Say we have an unordered array with 10 elements, like this: (in this case is ordered, but in fact, what is needed is the best solution)
- [6] => 19
- [5] => 18
- [8] => 18
- [1] => 18
- [2] => 16
- [4] => 15
- [9] => 11
- [0] => 10
- [3] => 8
- [7] => 6
Which is the best way, or how could I achieve divide it into 3 groups, so the sum of them are the most homogeneous manner. say for example 19+15+10=44, 18+18+8=44, 18+16+11+6=51 (note: i'm pretty sure this is not the best answer)
Is there a non-bruteforce way to achieve this partition? Could you lead me in the correct way to do it?