I have an array from ten (or more) numbers, for example:
arr[1,2,3,4,5,6,7,8,9,10]
I want a method to check if three numbers from this arrays have the same sum to another three numbers (I want to get all the possibilities!), for example:
{1.8.10} {2.10.7} {3.7.9} {4.9.6} {5.6.8} {Sum of each set: 19}
{1.6.10} {3.10.4} {5.4.8} {7.8.2} {9.2.6} {Sum of each set: 17}
{6.3.5} {7.5.2} {8.2.4} {9.4.1} {10.1.3} {Sum of each set: 14}
Update:
That’s another example to what exactly I want to do:
alt text http://img208.imageshack.us/img208/1131/77603708.png
Create a map of sets. Setup a triple nested for loop and start adding numbers. Every sum becomes a key into the map. The set is the 3 numbers you used. Should only be a dozen or so lines of code.
and just iterate through the sums map and display your sets as you want. I’m not 100% sure on my continue logic here, but I think it’s correct. The idea will work, though it’s at least cubic in complexity.