Toolstia / N-Queens puzzle
N-Queens puzzle
Place one queen in every row so that no two queens attack each other. Conflicts are highlighted in red as you play, and a button shows a full solution when you are stuck.
Place one queen in each row so that none attack another.
Place queens so that no two share a row, column or diagonal. Click a square to place a queen, and click again to remove it. Clicking another square in the same row moves that row queen.
How it works
- Choose a board size.
- Click squares to place queens. Click again to remove one.
- Fix the red queens until none attack another.
The goal
No two queens may share a row, column or diagonal. On an 8x8 board there are 92 different solutions.
Highlighting
Queens that are under attack turn red, so you can see at once which ones to move.
Solution counts
The tool shows how many solutions exist for the chosen size, from 2 on 4x4 to 14200 on 12x12.
Hint
Work row by row. If a row has no safe square, go back and move an earlier queen.
Questions
Is anything uploaded?
Everything happens in your browser, and nothing you enter is sent anywhere.
Does a solution exist for every size?
Yes for every size except 2x2 and 3x3, and all sizes here have at least one.
Can I move a queen?
Click a different square in the same row to move that queen, or click the queen to remove it.