Queens
8×8
8
Statistics

More about the Eight Queens puzzle

Eight Queens

A queen attacks along its row, its column, and both diagonals. Can you place eight of them on a chessboard so that none attacks another? There are 92 ways, or 12 if rotations and mirror images count as one. Place the queens yourself, or watch backtracking find them one step at a time. Click a square to place a queen, and click it again to take it away. No two queens may share a row, column, or diagonal. Solve shows the backtracking search one step at a time and keeps your queens. Next solution goes through every solution in order.

How it works

  1. Click a square to place a queen. The squares it attacks get a dot, so the safe ones stand out.
  2. Place all eight with no two in the same row, column, or diagonal. Queens that attack each other turn red.
  3. Press Solve to watch backtracking, or Next solution to see all 92, then save a PNG.

The rules

A queen moves any distance along a row, a column, or a diagonal. Eight queens on eight rows means exactly one queen in every row and every column, so the real puzzle is the diagonals. Size changes the board from 4×4 to 12×12, always with as many queens as rows.

Backtracking, step by step

Solve fills the board one row at a time. In each row it puts a queen on the first safe square. When a row has no safe square left, it takes back the queen in the row above and moves it on. The blue band shows the row it is working on, and Steps counts every queen placed or taken back. On an empty 8×8 board the first solution takes 218 steps.

92 solutions in 12 families

Turn a solution a quarter turn or reflect it in a mirror and you get another solution, so the 92 solutions fall into families. There are 12 families: eleven with 8 members and one with only 4, a solution that looks the same after a half turn.

Frequently asked questions

How many solutions does the eight queens puzzle have?

92. If solutions that are rotations or reflections of each other count as one, there are 12.

Is there a solution for every board size?

Every board from 4×4 up has one; 2×2 and 3×3 have none. The 6×6 board is unusual: it has only 4 solutions, fewer than the 10 of the 5×5 board.

What do Steps count?

Every queen the search places and every queen it takes back. Your own queens stay where they are, and the search works around them.

Why does Solve say no solution keeps my queens?

Some placements cannot be completed even though no two queens attack each other yet. The search has tried every way to fill the remaining rows. Remove a queen and try again.

How do you solve the eight queens puzzle?

Put one queen in each row and backtrack: place it on the first safe square, and when a row has no safe square left, move the queen in the row above on to its next safe square. Press Solve to watch this. One solution to remember: a1, b5, c8, d6, e3, f7, g2, h4.

八皇后: how do I record a video?

Press the red Record button in the playback bar: it films what the stage shows. Press it again to stop, and the video is saved to your device.Recording is free; you only need to sign in. Without a subscription the video carries a small PictorX logo in a corner.The button beside Record opens the video options: the shape (as shown, square, story 9:16 or wide 16:9), the length (until you stop, or 5, 10, 15 or 30 seconds for social media) and the file: MP4, WebM or an animated GIF.For the sound, choose the app's own sounds or one of three music tracks: calm, bright or beat.

Ready to try it?

Open PictorX in your browser — no install, no credit card required to start.

前往編輯器