I have a set of 18 values (it will always be 18), which I need to distribute into two sets, one of 10 elements and one of 8 elements.
The distribution rule is that the values of each set should be equal (or as close as possible) to a certain known value - therefore, in the first set, the sum of the values should be as close as possible to 1500000 and in the second set of the sum iof the values should be as close as possible to 1,000,000.
What is the best (and this may mean the simplest) algorithm for this?
For further clarification, values range from 110,000 to 200,000. Values are always a multiple of 100 and are positive integer targets, and there may be duplicates.
source
share