Algorithms β˜…β˜…β˜† Moderate

β™› N-Queens Problem

Watch backtracking place and retract queens on an NΓ—N board β€” see every clash and every solution found in real time.

Active queen Placed (safe) Conflict Solution flash
Solutions found: 0 Backtracks: 0 Steps: 0 Status: Ready

How it works

The algorithm places queens column by column. For each column it tries every row from top to bottom. If a placement conflicts (same row, or same diagonal as any earlier queen), it backtracks immediately. When all N columns have a queen without conflict, a solution is recorded.

For N = 8 there are 92 solutions. Increase N to see how the search space explodes β€” N = 12 has 14,200 solutions but requires millions of steps.