ArticleslgStudy

mathematics

Eight queens puzzle

Eight queens puzzle is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Eight queens puzzle rather than just read about it. In short: The eight queens puzzle is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other; thus, a solution requires that no two queens share the same row, column, or diagonal. There are 92 solutions.

Eight queens puzzle — main illustration
Eight queens puzzle — illustration

Key takeaways

  • Eight queens puzzle belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Eight queens puzzle to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Eight queens puzzle from memory before moving on to harder problems.

Reference excerpt

The eight queens puzzle is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other; thus, a solution requires that no two queens share the same row, column, or diagonal. There are 92 solutions. The problem was first posed in the mid-19th century. In the modern era, it is often used as an example problem for various computer programming techniques. The eight queens puzzle is a special case of the more general n queens problem of placing n non-attacking queens on an n×n chessboard. Solutions exist for all natural numbers n with the exception of n = 2 and n = 3. Although the exact number of solutions is only known for n ≤ 27, the asymptotic growth rate of the number of solutions is approximately (0.143n)n.

History Chess composer Max Bezzel published the eight queens puzzle in 1848. Franz Nauck published the first solutions in 1850. Nauck also extended the puzzle to the n queens problem, with n queens on a chessboard of n×n squares. Since then, many mathematicians, including Carl Friedrich Gauss, have worked on both the eight queens puzzle and its generalized n-queens version. In 1874, S. Günther proposed a method using determinants to find solutions. J.W.L. Glaisher refined Gunther's approach. In 1972, Edsger Dijkstra used this problem to illustrate the power of what he called structured programming. He published a highly detailed description of a depth-first backtracking algorithm.

Constructing and counting solutions when n = 8 The problem of finding all solutions to the 8-queens problem can be quite computationally expensive, as there are 4,426,165,368 possible arrangements of eight queens on an 8×8 board, but only 92 solutions. It is possible to use shortcuts that reduce computational requirements or rules of thumb that avoids brute-force computational techniques. For example, by applying a simple rule that chooses one queen from each column, it is possible to reduce the number of possibilities to 16,777,216 (that is, 88) possible combinations. Generating permutations further reduces the possibilities to just 40,320 (that is, 8!), which can then be checked for diagonal attacks. The eight queens puzzle has 92 distinct solutions. If solutions that differ only by the symmetry operations of rotation and reflection of the board are counted as one, the puzzle has 12 solutions. These are called fundamental solutions; representatives of each are shown below. A fundamental solution usually has eight variants (including its original form) obtained by rotating 90, 180, or 270° and then reflecting each of the four rotational variants in a mirror in a fixed position. However, one of the 12 fundamental solutions (solution 12 below) is identical to its own 180° rotation, so has only four variants (itself and its reflection, its 90° rotation and the reflection of that). Thus, the total number of distinct solutions is 11×8 + 1×4 = 92. All fundamental solutions are presented below:

Solution 10 has the additional property that no three queens are in a straight line.

Existence of solutions Brute-force algorithms to count the number of solutions are computationally manageable for n=8, but would be intractable for problems of n≥20, as 20! = 2.433 × 1018. If the goal is to find a single solution, one can show solutions exist for all n ≥ 4 with no search whatsoever. These solutions exhibit stair-stepped patterns, as in the following examples for n = 8, 9 and 10:

The examples above can be obtained with the following formulas. Let (i, j) be the square in column i and row j on the n × n chessboard, k an integer. One approach is

If the remainder from dividing n by 6 is not 2 or 3 then the list is simply all even numbers followed by all odd numbers not greater than n. Otherwise, write separate lists of even and odd numbers (2, 4, 6, 8 – 1, 3, 5, 7). If the remainder is 2, swap 1 and 3 in odd list and move 5 to the end (3, 1, 7, 5). If the remainder is 3, move 2 to the end of even list and 1,3 to the end of odd list (4, 6, 8, 2 – 5, 7, 9, 1, 3). Append odd list to the even list and place queens in the rows given by these numbers, from left to right (a2, b4, c6, d8, e3, f1, g7, h5). For n = 8 this results in fundamental solution 1 above. A few more examples follow.

14 queens (remainder 2): 2, 4, 6, 8, 10, 12, 14, 3, 1, 7, 9, 11, 13, 5. 15 queens (remainder 3): 4, 6, 8, 10, 12, 14, 2, 5, 7, 9, 11, 13, 15, 1, 3. 20 queens (remainder 2): 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 3, 1, 7, 9, 11, 13, 15, 17, 19, 5.

Counting solutions for other sizes n

Exact enumeration There is no known formula for the exact number of solutions for placing n queens on an n × n board i.e. the number of independent sets of size n in an n × n queen's graph. The 27×27 board is the highest-order board that has been completely enumerated. The following tables give the number of solutions to the n queens problem, both fundamental (sequence A002562 in the OEIS) and all (sequence A000170 in the OEIS), for all known cases.

The number of placements in which furthermore no three queens lie on any straight line is known for n≤25 (sequence A365437 in the OEIS).

Asymptotic enumeration In 2021, Michael Simkin proved that for large numbers n, the number of solutions of the n queens problem is approximately (0.143n)n. More precisely, the number 𝒬(n) of solutions has asymptotic growth 𝒬(n)=((1±o(1))ne−α)n where α is a constant that lies between 1.939 and 1.945. (Here o(1) represents little o notation.) If one instead considers a toroidal chessboard (where diagonals "wrap around" from the top edge to the bottom and from the left edge to the right), it is only possible to place n queens on an n×n board if n≡1,5mod6. In this case, the asymptotic number of solutions is T(n)=((1+o(1))ne−3)n.

Related problems

… excerpt ends here. Continue reading the full article.

Illustrations

Eight queens puzzle: This animation illustrates backtracking to solve the problem. The ith queen is placed in the ith row of the chessboard, in a column that is known not to cause conflict. If a column is not found the program returns to the last good state and then tries a different column.
This animation illustrates backtracking to solve the problem. The ith queen is placed in the ith row of the chessboard, in a column that is known not to cause conflict. If a column is not found the program returns to the last good state and then tries a different column.
Eight queens puzzle: min-conflicts solution to 8 queens
min-conflicts solution to 8 queens

Worked examples

Example 1 — a first encounter with Eight queens puzzle

Start with the simplest possible case. Write down what Eight queens puzzle claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Eight queens puzzle before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Eight queens puzzle ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Eight queens puzzle

In research
Eight queens puzzle appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Eight queens puzzle in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Eight queens puzzle is common in secondary-school and first-year university syllabi. It links to neighbouring topics 1848 in chess, Enumerative combinatorics, Mathematical chess problems, so understanding it makes those chapters shorter.
In everyday life
Look for Eight queens puzzle outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Eight queens puzzle” →

How to study Eight queens puzzle in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Eight queens puzzle means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Eight queens puzzle out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Eight queens puzzle in simple terms?

The eight queens puzzle is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other; thus, a solution requires that no two queens share the same row, column, or diagonal. There are 92 solutions.

Why does Eight queens puzzle matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Eight queens puzzle?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Eight queens puzzle.

Tags

  • 1848 in chess
  • Enumerative combinatorics
  • Mathematical chess problems
  • Mathematical problems

Keep exploring