in reply to Re^3: better algorithm: bitwise reordering
in thread better algorithm: bitwise reordering

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

Replies are listed 'Best First'.
Re^5: better algorithm: bitwise reordering
by dragonchild (Archbishop) on Aug 25, 2004 at 18:03 UTC
    Ok. This sounds interesting. And, yes, you could use graph theory to solve this, but you get a lot more edges. *ponders* Now I want to take a look at this problem. :-) Thanks!

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

    I shouldn't have to say this, but any code, unless otherwise stated, is untested