I tried to find a solution to this for several months. This is for my art project. so far I could find partial python and c solutions, but they are useless for my case ... I need a working solution in either PHP or Javascript.
that is the question:
- to find all possible combinations of N numbers, the following should be done:
- numbers are not repeated in combination
- numbers do not repeat in other decisions in a different order
- only integers are used
- within a certain range of integers
- which add to X
eg:
- find all combinations of 3 numbers
- in all rooms from 1 to 12
- which make up to 15
the calculated solution should spit out:
[1,2,12]
[1,3,11]
[1,4,10]
[1,5,9]
[1,6,8]
[1,7,7] = EXAMPLE OF WRONG OUTPUT, NO REPEATING NUMBERS WITHIN COMBINATION
[1,8,6] = EXAMPLE OF WRONG OUTPUT, NO REPEATING NUMBERS IN OTHER SOLUTIONS (see [1,6,8])
[2,3,10]
[2,4,9]
[2,5,8]
[2,6,7]
[3,4,8]
[3,5,7]
[4,5,6]
, , , script ...
!