# Forming groups as nearly equal in sums as possible

#### treesloth

##### New member
Hello. I'm not sure what type of problem this is that I'm trying to solve. Any pointers would be greatly appreciated.

Suppose you have a list of numbers and you want to form them into, say, 4 groups such that the sum of each group is, as nearly as possible, equal to the sums of each of the other groups; basically, making groups with equal sums without regard to the number of elements in each. Is there a way to do that with certainty that the groups are as close as possible given the elements available? If not, is there a way to iteratively approach an optimal grouping? I'm just using a made-up dataset in R generated via:

Code:
x <- as.integer(runif(100, 250, 500))