I've got a problem with a solution for algorithmic problem as described below.
We have a set (e.g. array) of integers. Our task is to divide them into the groups (they don't have to have same amount of elements) that sum is equal to each other. I case that primal set cannot be divide we have to give answer "impossible to divide".
For example:
Set A
is given [-7 3 3 1 2 5 14]
. The answer is [-7 14], [3 3 1], [2 5]
.
It seems that it's easy to say when for sure it would be impossible. When sum of primal set isn't divisible by 3: sum(A) % 3 != 0
.
Do you have any idea how to solve that problem?