|
Cars & Coffee Killer
Join Date: Sep 2004
Location: State of Failure
Posts: 32,246
|
Yep, the tricky thing here is there could be multiple solutions. Solving this programatically would generally yield the first solution encountered.
I would probably create an array for each number and assign a number to that array for each iteration through the set. I would also store a sum for each iteration. This would allow me to keep track of what I've already added (to avoid duplication) and to see if there are multiple solutions.
The next trick is writing an algorithm that could successfully add each permutation of the numbers in the set. I'd have it start buy just "summing" each individual number, then every unique pair of numbers, then every unique set of three numbers, and so on up to the size of the set.
__________________
Some Porsches long ago...then a wankle...
5 liters of VVT fury now
-Chris
"There is freedom in risk, just as there is oppression in security."
|