The EIS reference is the best definition: "a rook must land on each square exactly once, but may start and end anywhere and may intersect it's own path". (For the non-chess players, the rook may move from a given square to any other square in the same row or the same column.)
The data structure I'm using takes advantage of the fact that any given position is equivalent to one in which rows and/or columns are arbitrarily reordered, in an attempt to maximise the benefits of memoizing calculated values; the rearrange() function under discussion is trying to do precisely that reordering.
I don't know enough graph theory to guess whether a graph-based approach would gain me anything; I think I'm happy with my data structure (though there may well be a better way), but I understand it rather better than I've been able to explain it so far.
Hugo
In reply to Re^4: better algorithm: bitwise reordering
by hv
in thread better algorithm: bitwise reordering
by hv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |