Nov-22-2023, 01:54 PM
Hi All,
I want to write a code for the following:
1. form clusters of adjacent digits whose sum is <= 8
2. The order of the numbers may not be changed
3. The clusters should be designed in such a way that the sum should be as close to 8 as possible
4. As few clusters as possible should be designed
An example of the input: 11111111113143111
An example of one of the possible outputs: (1+1+1+1+1+1+1+1)+(1+1+3+1)+(4+3)+(1+1+1) = 8+7+7+3
An other example of one of the possible outputs: (1+1+1+1+1)+(1+1+1+1+1)+(3+1+4)(3+1+1+1) = 5+5+8+6
As output I want all possibilities.
Thanks for the help!
I want to write a code for the following:
1. form clusters of adjacent digits whose sum is <= 8
2. The order of the numbers may not be changed
3. The clusters should be designed in such a way that the sum should be as close to 8 as possible
4. As few clusters as possible should be designed
An example of the input: 11111111113143111
An example of one of the possible outputs: (1+1+1+1+1+1+1+1)+(1+1+3+1)+(4+3)+(1+1+1) = 8+7+7+3
An other example of one of the possible outputs: (1+1+1+1+1)+(1+1+1+1+1)+(3+1+4)(3+1+1+1) = 5+5+8+6
As output I want all possibilities.
Thanks for the help!