I'm working on a multi-dimensional integer optimization problem, and at one step I have to run a function on all matrices of dim = r x i such that there is only one 1 per row and all the rest of the row is zeros.
I'm having a hard time writing the recursion code or loop for this, mainly because I need r to be a variable (i can be fixed no problem).
The main problem arising is that I would need r amount of for loops to execute this, so I believe a recursion function might be the way to go.
I know this code will execute in exponential time, but the size of the matrix won't be that large so it should be able to handle this brute-force solution. (Usually r < 15, i < 5)
So, my question is how do I write an algorithm to generate all these matrices given the constraint?