3 ms·
There is no search solution to N-queens, so any code doing search is poor and wasteful. I am not going to spoil the fun by giving you the details here, just th
by SagelyGuru 11y ago
There is no search solution to N-queens, so any code doing search is poor and wasteful.
I am not going to spoil the fun by giving you the details here, just the hint: start on the right square, depending on whether N is even or odd. Then place successive queens in a knight jump pattern.
It is fascinating to me that whoever invented chess a long time ago may have been aware of these subtle complementary relationships between the different types of moves?
- JoeAltmaier 11y agoThat may find some solutions, but does it find them all?
- tromp 11y agoobviously not
- SagelyGuru 11y agoYou can probably find them all by considering all the valid starting (boundary) positions, mostly obtainable by symmetry.
- chongli 11y agoYes, the knight is to the queen as the bishop is to the rook.