Solver

Place n queens, then undo the mistakes

No two queens may share a row, column or diagonal. The solver puts one queen per row and slides it right until it's safe. When a row has no safe square, it backtracks to the row above and tries that queen's next column.

New to this?Start with the 4×4 walkthrough →
  1. 1
    Pick a board size

    4 to 12 in the Board card. Start with 8, the classic puzzle.

  2. 2
    Press play

    Or press Space. Step with ← and → to see every check, placement and backtrack.

  3. 3
    Watch the stack

    Each row is one recursive call. A dead end pops back to the row above.

Empty 8×8 board. The solver fills one row at a time, trying columns left to right.

01234567
01234567
0/1088

Red line = the queen that attacks the square being checked · dots = squares already attacked · Space play · ←→ step

Things to try

Why 4×4 has only two answers

No. 1

Pick 4 and "All solutions". Watch row 0 try every column: corners lead to dead ends, the middle columns don't.

Count the pruning

No. 2

On 8×8 with All solutions, compare "Backtracking placed" (2,056) with "One per row & column" (8! = 40,320). Rejecting early skips almost everything.

Some sizes are easy

No. 3

Try first-solution on 5 and then 6. n = 5 finds an answer with zero backtracks; n = 6 needs many. Size isn't everything.

Find all 92

No. 4

Set 8 + All solutions and raise the speed. Solutions pile up in the gallery as mini boards.