by JoeAltmaier · 1mo ago · 0 comments
As a kid, it seemed obvious to me that a good model was the digits 1 through 8, representing the row that a queen would be in. Doing a recursive backtracker on an ordering of the digits and testing each pair for diagonal (digit i minus digit j was equal to +/- i-j) and my BASIC program spit out the solutions in twenty minutes.
I didnt enter the contest because I figured everybody would do that. Turns out when the editor published the 'best' solutions, they all, every single one, modeled the board as an 8 by 8 array and ran around following diagonals iteratively. And took hours to complete.
Anyway, choosing a good solution model is most of the problem solved.
You still need to get the backtracking correct and there's some minor tricks to work out, but that'll get you up to n=8 working quite well.
The model (8 different digits representing row in that column) no queen was in the same row or column, by construction. So only the diagonal test remains.