There are x digits and y boxes where y is between 1 and x inclusive. I have to print all the possible digits in boxes (combinations) in any order.
For examples, if x = 5 and y = 2 we can have the following 4 combinations:
1234 5
123 45
12 345
1 2345
Similarly if x = 5 and y = 3
123 4 5
12 34 5
12 3 45
1 234 5
1 23 45
1 2 345
if x = 5 and y = 5 then there is only 1 combination
1 2 3 4 5
Both x and y are variable and I can't figure out even a brute force way of doing this. I have tried using three nested for
loops but have no luck.