Hi everyone, I have an interesting problem which I still can't find a solution to even in other forums. Hope someone can help. Anyway, I'd like to generate a list that exhausts all possible combinations for a given sum with a given number of columns. For example, I would like to know all the possible combinations by which I can arrive at 50 using 7 columns.
1st combination
Col 1: 49
Col 2: 1
2nd combination
Col 1: 49
Col 2: 0
Col 3: 1
3rd combination
Col 1: 49
Col 2: 0
Col 3: 0
Col 4: 1
(...until col 7)
I'd also like to have:
Col 1: 48
Col 2: 1
Col 3: 1
Col 4: 0
col 5: 0
col 6: 0
col 7: 0
Col 1: 48
Col 2: 2
Col 3: 0
Col 4: 0
col 5: 0
col 6: 0
col 7: 0
and so on.... (Hopefully my example is clear cause im having problems pasting a table here)
I do hope that if anyone comes up with a code, it will be generic (i.e. not just for sum of 50 or column of 7). I actually wish to use this even for sum of 100. Thanks for the help, it will be greatly appreciated![]()
Bookmarks