N-Queens Visualizer illustration

N-Queens Visualizer

Place N queens on an N×N board so that none attacks another — the classic testbed for backtracking search. Watch the algorithm work row by row: it places a queen, greys out every square she attacks, and when a row has no safe square left it backtracks, undoing earlier choices. Choose the board size, slow the animation down, and count the dead ends — the 8×8 board has 92 solutions hiding among 4.4 billion arrangements.

Runs 100% in your browser — simulations are computed locally on your device.

Notes

  • Backtracking prunes entire subtrees the moment a partial placement fails — that is its whole power.
  • Solutions exist for every N except 2 and 3.
  • The 8-queens puzzle has 92 solutions, 12 up to rotation and reflection.
  • Runs 100% in your browser — simulations are computed locally on your device.