Eight Queens on a Board
The puzzle
Place eight queens on a chessboard so that no two attack each other - no two sharing a row, a column or a diagonal.
Show that it is possible, and work out how many arrangements there are.
Stuck?
One at a time, smallest first. Open only as many as you need — the whole point of the puzzle is the part you work out yourself.
Hint 1
Eight queens on eight rows means exactly one per row, and exactly one per column. So an arrangement is a permutation of the columns.
Hint 2
That cuts the search from 4.4 billion placements to 40,320 permutations - then you only need to check the diagonals.
Show the answer Hide the answer
92 arrangements, which reduce to 12 genuinely different ones once rotations and reflections are counted as the same.
How to get there
One queen per row is forced, and one per column too, so write an arrangement as a list like 1-5-8-6-3-7-2-4, meaning the queen in row 1 is in column 1, the queen in row 2 in column 5, and so on. Every arrangement is a permutation of 1 to 8.
Rows and columns are now automatically safe. Two queens share a diagonal exactly when the difference in their rows equals the difference in their columns, so the only test left is that no two entries have |i - j| equal to |col(i) - col(j)|.
Checking all 8! = 40,320 permutations gives 92 that pass. The board has eight symmetries - four rotations, each with a mirror - so the 92 fall into 12 families. Eleven of those families have all eight symmetric copies distinct (88 arrangements) and one is symmetric under a half-turn, contributing only four: 88 + 4 = 92.
The technique worth keeping
Build the constraints into how you represent the problem rather than checking them afterwards. Representing the board as a permutation satisfies two of the three rules by construction and shrinks the search by five orders of magnitude.