3 ms·
I think JulianWasTaken is hinting that your solution is exactly a recursive solution to generate all permutations (google "recursively generate permutations").
by arnarbi 14y ago
I think JulianWasTaken is hinting that your solution is exactly a recursive solution to generate all permutations (google "recursively generate permutations"). This is because any N-rook solution is just a reordering of the columns of the trivial solution.
It may be interesting for you to try to come up with a different solution, where the basic operation is to swap adjacent columns - and try to minimize the number of swaps.
- xiaoma 14y agoYes, the solution for any N is all permutations. I realized that the morning after writing the recursive algorithm I shared. It was pretty fun trying to come up with a recursive step to generate all queens for N, given all queens for N-1. Even now I can't say for sure that no such recursive step exists.