gekro
GitHub LinkedIn

Eight Queens

Play the Eight Queens puzzle on boards from 4 by 4 to 12 by 12, with live conflicts, a count of the solutions still possible, hints and every solution behind it.

Queens 0 of 8

Attacking pairs 0

Solutions possible 92

Click a square to place a queen

Basic solutions found 0 of 12

Solved at this size 0

All solutions 92

Place one queen on every row so that no two queens share a row, a column or a diagonal. Click or tap a square to put a queen on it, and click it again to take it off. A queen that is attacked by another queen gets a rose ring and an exclamation mark, so you never have to tell colours apart. Turn on the shading to see which squares the queens attack: they are hatched. "Solutions possible" counts the solutions that still contain every queen you have placed, found by checking the full list. A hint points at a square that keeps at least one solution possible. Hints and shown solutions mean the board does not count toward your basic solutions. Arrow keys move around the board, Enter or Space places or removes a queen.

How it works

The page holds the complete list of solutions for each size, found by a search that places queens one row at a time and never extends a position in which two queens attack. The counts are 2, 10, 4, 40, 92, 352, 724, 2680 and 14200 for 4 to 12 queens. "Solutions possible" filters that list by your queens, a hint is a queen of the first solution in that filter, and "Basic solutions" are solutions that cannot be turned into each other by rotating or flipping the board: there are 1, 2, 1, 6, 12, 46, 92, 341 and 1787 of them. Nothing is guessed and nothing is uploaded. A board with too few squares to read on a narrow screen offers fewer sizes.

As-is, no warranty. These apps are free under their listed license and run entirely in your browser. Use at your own risk — don't blame me if your PC catches fire, your dog runs away, or the math turns out wrong. Verify anything that actually matters. None of this is professional financial, medical, legal, or engineering advice.

© 2026 Rohit Burani · MIT · Built at gekro.com · View source ↗

Guide

How to play

Put one queen on each row of the board so that no two queens attack each other. A queen attacks every square in its row, in its column and along both diagonals, as far as the board goes. The board can be any size from 4 by 4 to 12 by 12, and you need as many queens as the board is wide. The default is the classic 8 by 8 board with 8 queens.

  • Click or tap a square to put a queen on it. Click it again to take the queen off.
  • A queen that is attacked by another queen gets a rose ring and a small exclamation mark in its corner. The mark is the cue, so you never have to tell two colours apart.
  • Tick Show squares the queens attack to hatch every empty square that some queen attacks. A queen can safely go on any square that is not hatched.
  • The three boxes above the board show how many queens you have placed, how many pairs of queens attack each other, and how many solutions are still possible.
  • Hint points at a square, with a dashed green ring, where a queen can go and still leave a solution possible. Show a solution fills the board with a complete solution, one that keeps your queens if any solution does.
  • Undo takes back your last change, one step at a time. Clear board starts again at the same size.

When all queens are placed and none attack another, the board is solved. A solved board, or a shown solution, locks until you press Clear board. A hint or a shown solution means the board is not counted toward your finds.

On the keyboard, the arrow keys move around the board, Home and End jump to the ends of a row, and Enter or Space places or removes a queen. Every square is announced with its row, its column and what is on it, and the status line says what each move did and how many pairs attack. On a narrow screen the size menu greys out sizes whose squares would be under 28 pixels wide, so 11 and 12 are greyed out on the narrowest phones; a size that arrives in a shared link stays available.

Basic solutions

Turn a solution a quarter turn, or flip it, and you get another solution. The 92 solutions of the 8 by 8 board are really 12 different boards, each seen from up to 8 angles. The page counts those 12 as you find them, for the size you are on: Basic solutions found goes up when you solve the board without a hint and the pattern is new, and the message tells you if you had already found it. The count of finds lasts for the visit. How many times you solved each size is kept on your device.

How it works

The engine searches for solutions one row at a time. It keeps three sets of taken lines, columns and the two kinds of diagonal, as bits of a number, so the free squares in the next row come from one operation. A branch that has no free square is dropped at once. It runs the first time a size is used and the list is kept, in dictionary order, one column per row.

Everything on the page comes from that list:

  • Solutions possible counts the solutions that put a queen on every square you have occupied.
  • Hint takes the first of those solutions and points at its first square you have not filled.
  • Show a solution picks one of those solutions at random, or any solution if yours cannot be finished.
  • Basic solutions are found by turning and flipping a placement the eight ways a square can be, and keeping the smallest result as its name.

The test suite checks the engine rather than trusting it:

QueensSolutionsBasic solutions
421
5102
641
7406
89212
935246
1072492
112680341
12142001787
  • Three ways to count: the solution lists for 4 to 8 queens match a brute force over every ordering of the columns, solution by solution. The counts for 4 to 10 match a plain row-by-row search that checks each new queen against the earlier ones one at a time. For 5 and 6 queens the suite also tries every way of choosing that many squares, 53,130 and 1,947,792 sets, and counts the ones that pass the conflict check.
  • No solution below 4: the plain search finds none for 2 by 2 and 3 by 3, which is why the page starts at 4.
  • Basic solutions: turning and flipping gives 1, 2, 1, 6, 12, 46, 92, 341 and 1787 different boards. On 8 by 8, 11 of the 12 boards have 8 turned copies and one has only 4, because it looks the same turned half a circle. That makes 11 times 8 plus 4, which is 92.
  • Conflicts: the pairs of attacking queens, the queens marked, and the attacked squares match a second implementation that groups queens by row, column and the two diagonal sums in 3,000 random boards.
  • Solutions possible: matches a filter over the brute-force list in 400 random boards. A single queen in a corner of the 8 by 8 board leaves exactly 4 of the 92 solutions.
  • Hints: a hint is never on a taken square and always keeps a solution possible. Following hints one at a time finishes the board in 60 random runs, at sizes 4 to 10.

Privacy and storage

Nothing is uploaded and there is no account. The only thing kept is how many times you solved each size without help, as small whole numbers in a small JSON object in your browser’s local storage. Clearing site data removes it. The page address carries the size and the shading switch.

Limits

  • The hint and the shown solution come from a list found by search. That list is the whole answer for these sizes, so there is no learning in them and no chance of a wrong one, but also no explanation of why a square works.
  • Basic solutions found are not remembered between visits.
  • Sizes above 12 are not offered: the board stops fitting a phone.
  • A board is a plain square grid with no wrap-around.
All puzzles →

Free to play, no ads, nothing uploaded. These games are original and are not affiliated with any other game or brand.