Backtracking chopsticks in java

47 Views Asked by At

I have an exercise that is killing my brain; which is: I have x sticks, and I break them into x chunks which I measure, they are a vector of numbers, the solution to the problem is to find the minimum number to create sticks of the same size:

Sample input

9

5 2 1 5 2 1 5 2 1

4

1 2 3 4

0 (this is the end of the input it have to be there)

Sample output

6

5
0

There are 0 best solutions below