Hello! The second day I can not find a solution to this seemingly simple task. There is a number of cells f and a certain number of coins c . You can put only one coin in each cell, the task is to calculate the number of possible combinations (I coped with this quickly, there are formulas for this) and write all possible combinations into a text file. To make it clearer, this is how the file with combinations looks like (the case with 5 cells and 2 coins, the first line is the cell numbers):
- 1 2 3 4 5
- 1 1 0 0 0
- 1 0 1 0 0
- 1 0 0 1 0
- 1 0 0 0 1
- 0 1 1 0 0
- 0 1 0 1 0
- 0 1 0 0 1
- 0 0 1 1 0
- 0 0 1 0 1
- 0 0 0 1 1
To write the whole thing into a text file, you need to build some kind of array, here I have difficulties. Tell me, please, how can you solve this problem? I tend most to the solution with recursion, but I can not figure out how to do it.