I am trying to figure out how to solve this problem in computer science. I won't go into the programming side of things, but basically what I need is this:
I have a list of integers ranging from about 50 to 500 (these represent the height of elements on a web page I am building).
With these integers, I need to sort them into either 2, 3, 4, or 5 different lists (depending on the size of the users computer screen), but the problem is I need the sum of each list to match the sum of the other lists as closely as possible. So what I need is some way, mathematically, of working out which integers to add to each list, so that the sum of the integers in each list after all the integers have been added is as close as possible to every other list.
If someone could please tell me if this is possible, and if so, how I would go about it, I would be immensely grateful.
Thanks in advance
Cheers Corey
Here are just a few of my thoughts on a possible algorithm:
The subset sum and partition problems' programming solutions wouldn't really work here IMO since the chances of finding 2 - 5 sets, all mutually exclusive, totaling to the same number you found in 2. is minuscule.
I'm sorry for any possible confusion, this was a first thought and it includes a lot of referencing other steps which was unavoidable. This algorithm however should give you the closest approximation you can get to having all sums equal. In fact, if you want to see just how much of an error you obtained, subtract the sum of all the numbers in the original list from each of the sub-lists and average these numbers. This mean represents the average amount your lists are away from all having an equal sum. Depending on the distribution of values in your original list, the number might turn out to be relatively large (or small!). Hope for the latter.