The first thing to realize is that since they all sum to 1, var3
is a function of var2 + var1
. So you really have two variables here.
You can brute force this by just looping var1
and var2
blindly and keeping the values:
List<int[]> sets = new ArrayList<>();
for(int var1 = 0; var1 <= 100; var1 += 5) {
for(int var2 = 0; var2 <= 100; var2 += 5) {
int var3 = 100 - (var1 + var2);
if(var1 + var2 + var3 == 100 && (var1 != var2) && (var1 != var3) && (var2 != var3)) {
int[] set = new int[] { var1, var2, var3 };
sets.add(set);
}
}
}
Now this is riddled with inefficiencies that hopefully you can spot and optimize, but this should be an effective way to do it. Note that I used integers so we didn't end up with weird floating point rounding errors. Modify your output accordingly.