# Split a set of numbers into 2 sets, where the sum of each set is as close to one another as possible

Given a set of numbers, I’d like to split this set into 2 sets, where the sum of each set is as close to equal as possible. How would I go about doing this in a programmatic way?

Thanks in advance for any help!

EDIT: reworded for clarity perhaps?

“Given a set of integers, find a subset whose sum comes as close as possible to half the total of the entire set, without exceeding said total”

#### Solutions Collecting From Web of "Split a set of numbers into 2 sets, where the sum of each set is as close to one another as possible"

1. Sort your set DESC, like if you’ve [1,3,2,5,6], after DESC sort it will look like this: [6,5,3,2,1].
2. Now you’ll have ‘SET1’ and ‘SET2’ as your sub sets.
3. if (SET1<=SET2){The element in the given set should come into the ‘SET1’;}
else{The element in the given set should come into the ‘SET2’;}
4. And of-course you’ll eliminate the element you enter into the subsets ‘SET1’ OR ‘SET2’ from the given super set.