I'm currently looking for ideas on how to find all the possible sums of a set of numbers with these rules. I have these numbers for work, and I want to find all possible amounts so that you can use only one number a maximum of 4 times and every time you select 7 of these numbers.
{0, 1, 5, 22, 98, 453, 2031, 8698, 22854, 83661, 262349, 636345 and 1479181}
Valid examples are
0 + 0 + 0 + 0 + 83 661 + 83 661 + 2031
An unacceptable example would be
0 + 0 + 0 + 0 + 0 + 83 661 + 2031
The only way I can think of is through a series of nested loops, but I also have problems with this. Will there be other options for this. I use Java, but I really don't think it matters.
source
share