views:

33

answers:

1

say i have a list of 100 numbers, i want to split them into 5 groups which have the sum within each group closest to the mean of the numbers.

the simplest solution is to sort the hundred numbers and take the max number and keep adding the smallest numbers until the sum goes beyond the avg.

obviously that is not going to bring the best results. i guess we could use BFS or DFS or some other search algo. like A* to get the best result.

does anyone have a simple solution out there? pseudo code is good enough. thanks!

A: 

This sounds like a variation on the knapsack problem and if I'm interpreting you correctly, it may be the multiple knapsack problem. Can't you come up with an easy problem? :)

Arnold Spence