9io.ai / Blog

The eight queens puzzle explained: 92 solutions and n queens

The 8 queens problem has 92 solutions, 12 up to symmetry. Who posed it in 1848, n queens counts, a Python solver, and how crown puzzles change the rules.

Key takeaways

  • The eight queens puzzle has 92 solutions, or 12 if rotations and reflections count as one.
  • Max Bezzel posed it in 1848, and Franz Nauck published the first solutions in 1850.
  • Every board from 4×4 up has a solution, and exact counts are known up to 29×29.
  • A short backtracking solver in Python finds all 92 and sorts them by symmetry.
  • Crown puzzles add regions and ban only touching, so a well-made board has exactly one answer.

The eight queens puzzle asks you to put eight chess queens on an 8×8 board so that no two attack each other, which means no two share a row, a column or a diagonal. It has 92 solutions. If you count the rotations and mirror images of a solution as the same answer, 12 are left. The chess composer Max Bezzel posed it in 1848.12 Its general form, the n queens problem, puts n queens on an n×n board. It has solutions for every n except 2 and 3, and as of 27 November 2026 the exact counts are known up to n = 29.3

We make Crownfold at 9io, a daily logic puzzle for iPhone and iPad that’s free on the App Store as Crownfold: Queens Puzzle Game. Its rules are a variation on this puzzle, with one crown in every row, every column and every colour region, and no two crowns touching. This post covers the chess puzzle, where it came from, how the counts grow with the board, a short backtracking solver in Python with its output, and what changes when regions and a no-touch rule replace the queen’s diagonals. It ends with a checklist for checking any answer by hand.

What the eight queens puzzle asks

A queen moves any distance along its row, its column or either diagonal, so two queens attack each other if they share any of those lines. Eight queens on eight rows means exactly one queen in each row, and the same goes for columns. Every solution is therefore a permutation, a choice of column for each row with no column used twice. The diagonals do the rest. Two queens share a diagonal when the gap between their columns equals the gap between their rows.

Q . . . . . . .
. . . . Q . . .
. . . . . . . Q
. . . . . Q . .
. . Q . . . . .
. . . . . . Q .
. Q . . . . . .
. . . Q . . . .

Reading down the rows, these queens stand in columns 1, 5, 8, 6, 3, 7, 2 and 4. It’s the first solution a search finds if it tries the columns from left to right, row by row, and it’s the one the solver further down prints.

Each rule shrinks the field a lot. Niklaus Wirth used the puzzle in 1971 to teach program design. He put the ways to place eight queens on 64 squares at about 2³², and reckoned that a computer trying them at 100 microseconds each would need roughly 7 hours to find a solution. Allowing only one queen per column cut the field to 8⁸, which is 2²⁴, and the time to about 100 seconds.4

Rule applied Placements left
Any 8 of the 64 squares 4,426,165,368
One queen per column 16,777,216
One per row and one per column 40,320
No two on a diagonal 92

The first three rows are plain arithmetic, the number of ways to choose 8 squares from 64, then 8⁸ and 8!. The last is the puzzle’s answer.

Who posed it: Bezzel, Nauck and Gauss

The puzzle first appeared in 1848, when the chess composer Max Bezzel posed it in the Berliner Schachzeitung. Franz Nauck, writing from Schleusingen, published it in the Illustrirte Zeitung in 1850, possibly without knowing of Bezzel’s version, and printed the first solutions.12 Nauck also extended it to n queens on an n×n board. In the same year he set a version with some queens already on the board, the first known instance of what’s now called the n queens completion problem.1

Nauck’s article caught the attention of Carl Friedrich Gauss. Gauss reported 76 solutions, then found that four of them were wrong, which left him with 72, short of the true 92.1 The puzzle was long credited to him anyway. Paul J. Campbell untangled that error in a 1977 paper in Historia Mathematica,5 and older books show how far the credit wandered. The 1914 edition of W. W. Rouse Ball’s Mathematical Recreations and Essays says Nauck proposed it in 1850.6

Rouse Ball also describes two early methods. In 1874 S. Günther suggested finding solutions with determinants, and J. W. L. Glaisher showed the same year how the solutions for one board size lead to those for the next size up.6

92 solutions, and the 12 essentially different ones

Turn a solution a quarter, a half or three quarters of the way round, or reflect it in a mirror, and you get another solution. Rows, columns and diagonals all land on rows, columns and diagonals. A square has eight such symmetries, counting the one that leaves it alone, so most solutions come in families of eight. Of the 92, 88 fall into 11 families of eight. The remaining four form a family of their own, because that solution looks the same after a half turn, so turning and reflecting it only gives four different boards. That makes 12 essentially different solutions.7

The half-turn solution has its queens in columns 3, 5, 2, 8, 1, 7, 4 and 6, reading down the rows. Turn the board upside down and every queen lands on a square that another queen just left.

The n queens problem: counts for every board size

The same question works on any square board. The table gives both counts for boards up to 14×14, from the OEIS, the Online Encyclopedia of Integer Sequences.37

Board Solutions Up to symmetry
1×1 1 1
2×2 0 0
3×3 0 0
4×4 2 1
5×5 10 2
6×6 4 1
7×7 40 6
8×8 92 12
9×9 352 46
10×10 724 92
11×11 2,680 341
12×12 14,200 1,787
13×13 73,712 9,233
14×14 365,596 45,752

Boards of 2×2 and 3×3 have no solution, and the 6×6 board has fewer than the 5×5, 4 against 10. After that the count climbs fast. The 10×10 board has 92 essentially different solutions, the same number as the 8×8 board’s total.

Every board from 4×4 up has at least one solution, and one can be written down by formula, with no search at all.12 Counting all of them is far harder. The 27×27 count, 234,907,967,154,122,528, came from the Q27 project in 2016, which ran a massively parallel search on programmable chips (FPGAs).13 As of 27 November 2026, the OEIS also lists counts for 28×28 and 29×29, added that month from work by Sergii Cherepanov and Peter Allen Webb. For large boards, Michael Simkin showed in 2021 that the count grows roughly like (0.143n)ⁿ.3

A backtracking solver in Python

Backtracking places one queen per row, top to bottom. In each row it tries the columns from left to right and skips any that clash with a queen above. When it finds a safe column it moves down a row, and when a row has no safe column left, it goes back up and moves the queen there along. The first published description of backtracking search on a computer, presented in 1958, used the n queens problem.1

This version, written for this post, finds every solution on boards up to 10×10 and sorts them into symmetry families. It also counts placements under the crown rule from later in this post, one piece per row and column with no two touching.

from collections import Counter


def solve(n, rule="queens"):
    """Every way to put n pieces on an n x n board, one per row and column.
    A solution is a tuple: entry r is the column of the piece in row r."""
    found, path = [], []

    def safe(r, c):
        if c in path:
            return False  # that column is taken
        if rule == "crowns":
            return not path or abs(path[-1] - c) > 1  # mustn't touch the piece in the row above
        return all(abs(c - pc) != r - pr for pr, pc in enumerate(path))  # no shared diagonal

    def place(r):
        if r == n:
            found.append(tuple(path))
            return
        for c in range(n):
            if safe(r, c):
                path.append(c)
                place(r + 1)
                path.pop()  # backtrack: lift the piece and try the next column

    place(0)
    return found


def variants(sol):
    """The solution under the board's 8 rotations and reflections."""
    n = len(sol)
    cells = list(enumerate(sol))
    out = set()
    for _ in range(4):
        cells = [(c, n - 1 - r) for r, c in cells]  # turn the board a quarter
        for board in (cells, [(r, n - 1 - c) for r, c in cells]):  # and its mirror image
            out.add(tuple(c for r, c in sorted(board)))
    return out


def classes(solutions):
    """How many solutions each symmetry class holds."""
    seen, sizes = set(), []
    for s in solutions:
        if s not in seen:
            group = variants(s)
            seen |= group
            sizes.append(len(group))
    return sizes


print(" n  queens  distinct   crowns")
for n in range(1, 11):
    queens = solve(n)
    print(f"{n:2}  {len(queens):6}  {len(classes(queens)):8}  {len(solve(n, 'crowns')):7}")

eight = solve(8)
print("first solution for n = 8, column of the queen in each row:", *(c + 1 for c in eight[0]))
print("n = 8 symmetry classes by size:", sorted(Counter(classes(eight)).items()))

Run with Python 3.9, it prints this.

 n  queens  distinct   crowns
 1       1         1        1
 2       0         0        0
 3       0         0        0
 4       2         1        2
 5      10         2       14
 6       4         1       90
 7      40         6      646
 8      92        12     5242
 9     352        46    47622
10     724        92   479306
first solution for n = 8, column of the queen in each row: 1 5 8 6 3 7 2 4
n = 8 symmetry classes by size: [(4, 1), (8, 11)]

The queens and distinct columns match the OEIS counts for every board here, and the last line is the 11 families of eight and the one family of four. The crowns column matches OEIS A002464, Hertzsprung’s problem, which counts kings placed one per row and column with no two touching.8 Checking diagonals by comparing gaps keeps the code short. Faster solvers keep the diagonals in use as sets or bitmasks, indexed by row minus column for one direction and row plus column for the other, so each check is a single lookup.

How region crown puzzles change the rules

A region crown puzzle, the kind Crownfold sets every day, keeps one piece per row and per column and changes two things. It cuts the board into n colour regions and asks for one crown in each. It also swaps the queen’s long diagonals for a no-touch rule, so no crown may sit in any of the eight cells around another, while two crowns may share a long diagonal if they don’t touch.

The no-touch rule on its own is looser than the queen’s. Every one of the 92 eight queens solutions is also a valid crown placement, since queens can’t touch either, and the crowns column above shows 5,242 placements on an empty 8×8 board. The regions are what bring that down to one. On this 8×8 board, exactly one of the 5,242 placements puts a crown in each of the eight regions, and none of the 92 queens solutions does.

Regions            The one solution
a a a a b b b b    . . . * . . . .
c c d e b b f f    * . . . . . . .
c d d e b f f f    . . * . . . . .
d d e e b b b f    . . . . . . * .
d d e e e b b f    . . . . * . . .
d d e g g g g f    . . . . . . . *
h h e e e g g g    . * . . . . . .
h g g g g g g g    . . . . . * . .

Three pairs of its crowns share a diagonal, such as the ones in row 3, column 3 and row 5, column 5, which no pair of queens could do. The answer is unique, and on this board you can reach it by deduction from the start. Region a fits only in row 1, so nothing else in row 1 can hold a crown. Regions c and h both fit inside columns 1 and 2, so those two columns’ crowns are theirs, and nothing else in them can hold one either. Steps like these, with a few blocked cells along the way, finish the board with no trial and error, and our guide to solving crown puzzles walks through each technique on a 6×6 board.

Eight queens puzzle Region crown puzzle
Board 8×8 with no regions (n×n in the general problem) n×n, cut into n colour regions
One per row and column Yes Yes
One per region No Yes
Diagonals No two pieces on any diagonal, at any distance Only touching is banned, corners included
Answers on an 8×8 board 92, or 12 up to symmetry 5,242 placements before regions, exactly one in a well-made puzzle
How you find them Search, usually backtracking Logic, one deduction at a time

Puzzle setters call this family Star Battle. Hans Eendebak created the style for the 2003 World Puzzle Championship in Arnhem, and in its general form every row, column and region holds the same set number of stars, with no two touching, corners included.9 Crownfold plays the one-star form.

Crownfold, a region crown puzzle every day

Crownfold puts out a new puzzle at midnight, numbered and the same for everyone. Mondays are gentle and Sundays are the toughest, with boards from 7×7 or 8×8 on a Monday to 10×10 or 11×11 on a Sunday. Every puzzle has exactly one solution, and you can always reach it by reasoning. Hints find the next logical step from your board and explain it, and automatic X marks cross out every cell a crown rules out. Beyond the daily there are six packs of 100 levels, from 6×6 boards in Gentle to 11×11 in Master, an endless mode and an archive of every past daily. The Crownfold guide covers the controls and modes.

Crownfold has two sister puzzles from 9io with guides of their own, how to solve binary puzzles for Evenfold and how to solve number path puzzles for Pathfold.

How to check an eight queens answer by hand

Write the answer as one column number per row, top to bottom, then run through these checks. The first four work for any n queens answer, and the last two turn it into a crown puzzle check.

  1. Count the numbers. There should be n of them, one per row.
  2. Make sure no column number appears twice, which settles rows and columns.
  3. Work out row minus column for each queen. Two equal values mean two queens on the same diagonal running down to the right.
  4. Work out row plus column for each queen. A repeat means a shared diagonal running down to the left.
  5. For a crown puzzle, replace checks 3 and 4 with a touching check, where the columns in neighbouring rows must differ by at least 2.
  6. Then check that every colour region holds exactly one crown.

Take the solution drawn at the top, 1 5 8 6 3 7 2 4. Row minus column gives 0, −3, −5, −2, 2, −1, 5 and 4, and row plus column gives 2, 7, 11, 10, 8, 13, 9 and 12. No value repeats in either list, so no two queens share a diagonal.


  1. Ian P. Gent, Christopher Jefferson and Peter Nightingale, “Complexity of n-Queens Completion”, Journal of Artificial Intelligence Research 59 (2017), https://doi.org/10.1613/jair.5512 ↩↩↩↩↩↩↩

  2. Wikipedia, “Eight queens puzzle”, https://en.wikipedia.org/wiki/Eight_queens_puzzle ↩↩↩

  3. OEIS, “A000170: Number of ways of placing n nonattacking queens on an n X n board”, https://oeis.org/A000170 ↩↩↩↩

  4. Niklaus Wirth, “Program Development by Stepwise Refinement”, Communications of the ACM 14, no. 4 (April 1971), 221–227, https://people.inf.ethz.ch/wirth/Articles/StepwiseRefinement.pdf ↩

  5. Paul J. Campbell, “Gauss and the eight queens problem: A study in miniature of the propagation of historical error”, Historia Mathematica 4 (1977), 397–404, https://doi.org/10.1016/0315-0860%2877%2990076-3 ↩

  6. W. W. Rouse Ball, Mathematical Recreations and Essays, sixth edition (Macmillan, 1914), chapter VI, https://archive.org/details/mathematicalrecr00ball ↩↩

  7. OEIS, “A002562: Number of ways of placing n nonattacking queens on n X n board (symmetric solutions count only once)”, https://oeis.org/A002562 ↩↩

  8. OEIS, “A002464: Hertzsprung’s problem”, https://oeis.org/A002464 ↩

  9. The Art of Puzzles (GMPuzzles), “Star Battle Rules and Info”, https://www.gmpuzzles.com/blog/star-battle-rules-and-info/ ↩

Frequently asked questions

How many solutions does the 8 queens puzzle have?

92. If rotations and reflections of the board count as the same answer, 12 are different. Eleven of those come in families of eight, and one looks the same after a half turn, so its family has four.

Who invented the eight queens puzzle?

The chess composer Max Bezzel posed it in the Berliner Schachzeitung in 1848. Franz Nauck published it in 1850, possibly independently, with the first solutions, and extended it to n queens on an n×n board. It was long credited to Carl Friedrich Gauss, who took it up after Nauck’s article.

Does the n queens problem have a solution for every n?

For every n except 2 and 3. A 1×1 board takes its single queen trivially, and every board from 4×4 up has at least one solution, which can be written down by formula without any search.

How do you solve the 8 queens problem with backtracking?

Place one queen per row, starting at the top. In each row, try the columns in order, skip any that share a column or diagonal with a queen above, and move down a row. When a row has no safe column, go back up a row and move that queen along. Carried through to the end, this finds all 92 solutions.

How many solutions does the n queens problem have on bigger boards?

The count grows fast: 724 on 10×10, 14,200 on 12×12 and 365,596 on 14×14. As of 27 November 2026 the OEIS lists exact counts up to 29×29, and the 27×27 board alone has 234,907,967,154,122,528 solutions.

How is Crownfold: Queens Puzzle Game different from the eight queens puzzle?

Crownfold adds colour regions, with one crown in every row, column and region, and swaps the queen’s long diagonals for a rule that no two crowns may touch. On an empty 8×8 board that rule allows 5,242 placements, and the regions narrow them to exactly one, which you can reach by logic.

Work with us

Building something like this?

9io is a small team of senior engineers with a fractional CTO. We work by the hour, and plans start at $5,000. Send us a note about your product. The reply comes from the person who'd do the work.