How to Solve the Eight Queens Puzzle

A complete beginner-friendly guide covering every strategy you need — from understanding the rules to finding all 92 solutions. No chess experience required.

Understanding the Rules

The Eight Queens Puzzle asks you to place eight chess queens on a standard 8×8 chessboard so that no two queens can attack each other. Before you can solve it, you need to understand exactly how a queen moves — and what "non-attacking" really means.

What Can a Queen Do?

In chess, a queen is the most powerful piece on the board. She can move any number of squares in eight directions:

  • Horizontally — left or right across an entire row
  • Vertically — up or down an entire column
  • Diagonally — in all four diagonal directions, for as many squares as the board allows

This makes the queen extremely powerful — and extremely dangerous to place near another queen. Two queens that share a row, column, or diagonal can attack each other.

What Does "Non-Attacking" Mean?

Two queens are "non-attacking" if they cannot reach each other in a single move. For the puzzle to be solved, every pair of queens must satisfy this condition simultaneously. With eight queens on the board, that means checking 28 pairs (8 choose 2 = 28 combinations) all at once.

The Three Conflict Types

When you place queens, watch out for three types of conflict:

  1. Row conflict: Two queens share the same row. Easy to spot — just scan the row horizontally.
  2. Column conflict: Two queens share the same column. Also easy — scan vertically.
  3. Diagonal conflict: Two queens share a diagonal line. This is the hardest conflict to detect by eye, and the most common source of errors for beginners.

A helpful rule: on an 8×8 board, two squares are on the same diagonal if the absolute difference between their row numbers equals the absolute difference between their column numbers. For example, a queen at row 2, column 3 is on the same diagonal as a queen at row 5, column 6 (both differ by 3).

The Scale of the Problem

There are 4,426,165,368 ways to place 8 queens on a 64-square board. Of those, only 92 are valid solutions where no queen attacks another. That sounds daunting, but with the right strategies you can find solutions quickly — often in under a minute. You can explore all all 92 solutions once you understand the methods.

Strategy 1: Start from the Edges

One of the most effective beginner strategies is to place your first queen on an edge square — preferably a corner or near a corner. This limits the number of squares that first queen threatens, giving you more room to work inward.

Why Edges Work Well

A queen placed in the center of the board attacks up to 27 other squares. A queen placed in a corner attacks only 21 squares. That difference of 6 squares might seem small, but when you are trying to find safe spots for 7 more queens, every free square counts.

The edge placement strategy works because:

  • Edge queens only have diagonals going inward, not in both directions along those diagonals
  • Corner queens threaten the fewest total squares
  • Starting at column 1 or column 8 gives your subsequent queens more freedom in the center

Step-by-Step Example

Let us try placing the first queen at row 1, column 1 (top-left corner). This queen now attacks:

  • All of row 1 (columns 2 through 8)
  • All of column 1 (rows 2 through 8)
  • The entire main diagonal (row 2 col 2, row 3 col 3, etc.)

Now move to row 2. Column 1 is blocked (same column). Column 2 is blocked (same diagonal). The first safe square in row 2 is column 3. Place the second queen there.

Continue this process: for each new row, scan from left to right and place the queen in the first column that is not under attack from any previously placed queen. When you cannot find a safe column, you have hit a dead end — which brings us to Strategy 4 (backtracking).

A Known Solution Using This Approach

Starting from edge placements, one well-known solution has queens at columns: [1, 5, 8, 6, 3, 7, 2, 4] for rows 1 through 8. This means: row 1 → column 1, row 2 → column 5, row 3 → column 8, and so on. Try verifying this yourself — no two queens share a row, column, or diagonal.

Strategy 2: One Row at a Time

The row-by-row strategy is the most systematic approach to solving the Eight Queens Puzzle. Since no two queens can share a row, and there are 8 rows for 8 queens, every valid solution has exactly one queen per row. This insight dramatically reduces the problem.

The Core Insight

Instead of thinking about 64 squares, think about 8 rows. In each row, you must place exactly one queen. Your task becomes: for each row (1 through 8), choose a column (1 through 8) such that no chosen column conflicts with any other.

This reduces the problem from 4 billion+ possibilities to at most 8^8 = 16,777,216 possibilities — still large, but much more tractable. With column and diagonal constraints applied, the real search space is far smaller.

How to Apply This Strategy

  1. Start at row 1. Pick any column. Mark that column and both diagonals as "used."
  2. Move to row 2. Try each column left to right. Skip any column that is already used or lies on a diagonal of a previously placed queen.
  3. Continue row by row. For each row, apply the same process: scan columns left to right and place in the first available safe square.
  4. If no safe column exists in a row, back up to the previous row (backtracking — see Strategy 4) and try the next column.
  5. When all 8 rows are filled, you have found a valid solution.

Tracking Conflicts Efficiently

A useful paper-and-pencil trick: use three separate checklists:

  • Columns used: Mark each column number (1–8) as you place a queen in it.
  • Diagonal 1 (row − column): Values range from −7 to +7. Mark each value as used.
  • Diagonal 2 (row + column): Values range from 2 to 16. Mark each value as used.

A square is safe if its column, row−column, and row+column values are all unmarked. This makes conflict checking instant — no need to scan the entire board.

The row-by-row approach is essentially the method that backtracking algorithms use when computers solve this puzzle. Understanding it deeply will help you appreciate why the history of this puzzle is so intertwined with the development of computer science.

Strategy 3: The Knight-Like Pattern

Once you have found a few solutions manually, you may notice something striking: some solutions follow movement patterns that look remarkably like chess knight moves. A knight moves in an "L" shape — two squares in one direction and one square perpendicular. Certain Eight Queens solutions jump between rows and columns in exactly this pattern.

Why Knight-Like Jumps Work

Knight moves by definition never share a row or column with the starting square. More importantly, a knight move of (2, 1) or (1, 2) almost never lands on the same diagonal as the origin — the diagonal difference would be |2-1| = 1 or |1-2| = 1, which means a (1,1) diagonal is shared, so straight knight jumps do not automatically avoid diagonals. However, alternating knight-like steps, combined with occasional adjustments, can generate valid queen placements.

The Pattern in Practice

Consider the solution: [2, 4, 6, 8, 3, 1, 7, 5]. The column differences between consecutive rows are: +2, +2, +2, −5, −2, +6, −2. This is not a pure knight pattern, but certain sub-sequences follow a +2 jump.

A cleaner knight-like solution is: [3, 6, 2, 7, 1, 4, 8, 5]. Notice how starting at column 3, jumping by +3, −4, +5, −6, +3, +4, −3 gives a mix of knight-sized moves.

The useful heuristic here: if you are stuck looking for the next safe placement, try jumping 2 rows and 1 column from your last queen, or 1 row and 2 columns (like a knight). These positions tend to avoid the diagonals of recently placed queens more reliably than adjacent placements.

Using This as a Starting Seed

Rather than treating knight moves as a complete algorithm, use them as a starting point:

  1. Place your first 3–4 queens using knight-like jumps
  2. Check for conflicts
  3. Fill in remaining rows using the row-by-row method
  4. Backtrack if needed

This hybrid approach often reaches a solution faster than pure left-to-right scanning because you start with a more spread-out initial configuration.

Strategy 4: Backtracking When Stuck

Backtracking is the most important concept in solving the Eight Queens Puzzle. It is what separates systematic problem-solving from random trial and error. Even computers use backtracking — it was famously used by Edsger Dijkstra in 1972 to demonstrate structured programming.

What is Backtracking?

Backtracking means recognizing when you are in a dead end and systematically undoing your most recent decision to try a different path. It is like navigating a maze: when you hit a wall, you do not start over from the entrance — you step back to the last intersection and try a different direction.

How to Recognize a Dead End

You are in a dead end when:

  • You reach a row where every column is under attack from at least one previously placed queen
  • There is simply no safe square available in the current row

This happens more often than you might expect. When placing queens in rows 6, 7, or 8, the board becomes increasingly crowded with attacked squares.

The Backtracking Steps

  1. Recognize the dead end: No safe column exists in the current row.
  2. Remove the last queen: Go back to the previous row and remove the queen you placed there.
  3. Try the next column: In that previous row, try placing the queen in the next available column to the right of where it was.
  4. Continue forward again: With the new placement in the previous row, resume placing queens in subsequent rows.
  5. Repeat as needed: You may need to backtrack multiple levels. If you exhaust all columns in row N, back up to row N−1 and repeat.

A Concrete Example

Suppose you have placed queens in rows 1–5 and find row 6 has no safe columns. Do not give up! Instead:

  1. Return to row 5 and move that queen to the next safe column in row 5
  2. Try row 6 again with this new row-5 queen position
  3. If row 6 now has safe options, continue to rows 7 and 8
  4. If row 5 has no more safe columns either, back up to row 4 and repeat

This systematic process guarantees you will find all solutions given enough time. The interactive solutions page can show you solutions found this way.

Mental Model: A Decision Tree

Think of each queen placement as a branch in a decision tree. When a branch leads to a dead end, you prune it and try the next branch at the same level. Backtracking is essentially a depth-first traversal of this decision tree with pruning.

Common Mistakes to Avoid

Even experienced puzzle solvers make these mistakes when working on the Eight Queens Puzzle. Being aware of them will save you a lot of time and frustration.

Mistake 1: Forgetting the Diagonals (The Hardest Mistake to Spot)

Row and column conflicts are easy to see — you can scan horizontally or vertically. But diagonal conflicts require you to mentally trace lines at 45-degree angles, which is much harder to do visually. This is by far the most common error.

How to avoid it: After placing each queen, explicitly check both diagonal directions. For a queen at (row r, column c), check if any other queen sits at (r+k, c+k), (r+k, c-k), (r-k, c+k), or (r-k, c-k) for any positive k. Better yet, use the diagonal checklist described in Strategy 2.

Mistake 2: Placing Two Queens in the Same Column

When you focus on rows, it is easy to accidentally place queens in the same column. Keep a simple list of used columns (1 through 8) and tick them off as you go.

Mistake 3: Not Backtracking Far Enough

When stuck, beginners often backtrack only one step when they need to backtrack two or three steps. If you back up to row N and all columns in row N are already exhausted, you must continue backtracking to row N-1. Do not give up after one backtrack step.

Mistake 4: Assuming Early Placements Are Fine

A placement that looks safe in row 1 or 2 may make rows 6, 7, or 8 impossible to fill. The puzzle often requires going back and reconsidering seemingly obvious early choices.

Mistake 5: Trying to Memorize Without Understanding

Some people memorize specific solutions (like [1,5,8,6,3,7,2,4]) without understanding why they work. This does not help you solve the puzzle from scratch. Focus on understanding the backtracking logic — then solutions become discoverable rather than memorizable.

Mistake 6: Confusing the 8-Queens Puzzle with Smaller Variants

If you practice on smaller boards first (like the 4 Queens Puzzle), be aware that strategies that work on 4×4 boards may give you false confidence. The 8×8 board has subtleties that 4×4 does not.

Advanced Techniques

Once you can reliably find solutions using backtracking, these advanced techniques will help you find solutions faster and understand the puzzle at a deeper level.

Technique 1: Symmetry Exploitation

The 8×8 board has 8 symmetry operations: 4 rotations (0°, 90°, 180°, 270°) and 4 reflections (horizontal, vertical, and two diagonals). If you find one solution, you can generate up to 7 more by applying these symmetry operations.

This is why there are 92 total solutions but only 12 "fundamental" solutions. Each fundamental solution generates a family of 4 or 8 related solutions through symmetry. See the complete list of all 92 solutions to explore these families.

Practical tip: When searching for solutions, only look at solutions where the first queen is in columns 1–4 (left half of the board). Solutions with the first queen in columns 5–8 are just reflections of solutions starting in columns 1–4.

Technique 2: Pattern Memorization of Fundamental Solutions

The 12 fundamental solutions are worth memorizing if you want to solve the puzzle very quickly. Here they are as column sequences (queen positions for rows 1–8):

  1. [1, 5, 8, 6, 3, 7, 2, 4]
  2. [1, 6, 8, 3, 7, 4, 2, 5]
  3. [1, 7, 4, 6, 8, 2, 5, 3]
  4. [2, 4, 6, 8, 3, 1, 7, 5]
  5. [2, 5, 7, 1, 3, 8, 6, 4]
  6. [2, 5, 7, 4, 1, 8, 6, 3]
  7. [3, 6, 2, 7, 1, 4, 8, 5]
  8. [3, 6, 4, 1, 8, 5, 7, 2]
  9. [4, 2, 7, 3, 6, 8, 5, 1]
  10. [4, 6, 8, 2, 7, 1, 3, 5]
  11. [5, 2, 4, 7, 3, 8, 6, 1]
  12. [5, 3, 8, 4, 7, 1, 6, 2]

Verify any of these by checking that no two numbers in the same position relative to each other differ by the same amount as their position difference.

Technique 3: Constraint Propagation

Before placing each queen, mark off all squares that would be attacked by it. Then, before placing the next queen, look for rows that have only one or two remaining safe columns. These "forced" placements can guide your choices and quickly reveal dead ends before you waste time going down them.

Technique 4: Starting Mid-Board

For experienced solvers, starting in the middle columns (4 or 5) rather than edges can lead to solutions faster in some configurations because central queens constrain more squares initially, which makes dead ends apparent earlier — saving backtracking time later.

For the mathematical underpinnings of these techniques, see Queens Puzzle Mathematics.

Practice Makes Perfect

Reading about strategies is helpful, but the only way to truly internalize them is to practice. Here is a structured practice plan to take you from beginner to confident solver:

Step 1: Start on a 4×4 Board

The 4 Queens Puzzle on a 4×4 board has only 2 solutions. It is a great place to practice the row-by-row method and get comfortable with diagonal checking. You can do it in your head or on paper in just a few minutes. Visit the 4 Queens Puzzle page to try it.

Step 2: Try the 6×6 Board

The 6 Queens Puzzle has 4 solutions and introduces more complexity. Practicing on a 6×6 board forces you to use backtracking meaningfully, since dead ends appear more frequently. See the 6 Queens Puzzle for details.

Step 3: Tackle the 8×8 Board

Once you are comfortable on smaller boards, move to the full 8×8 challenge. Try to find at least 3 distinct solutions without looking anything up. This typically takes 15–30 minutes for a first-time solver using the systematic row-by-row approach.

Step 4: Use the Interactive Puzzle

The best way to practice is with real-time feedback. The interactive puzzle at /play lets you place queens on a live board and immediately see conflicts highlighted. It will tell you when you have found a valid solution, letting you build confidence quickly.

Step 5: Challenge Yourself with Larger Boards

Once you master 8×8, try larger boards. The 9 Queens Puzzle has 352 solutions. The strategy guide covers advanced approaches for larger boards.

Quick Reference: Steps to Solve

  1. Place the first queen in row 1, column 1
  2. In each subsequent row, find the leftmost safe column
  3. If no safe column exists, backtrack to the previous row and advance its queen to the next safe column
  4. Continue until all 8 rows are filled
  5. When you find a solution, record it and continue to find more (or stop if one solution is enough)

Play Interactively

Practice placing queens on a live board with instant conflict detection and validation.

8 Queen Puzzle

Deep dive into the classic 8×8 challenge with strategies, tips, and all 92 solutions.

All 92 Solutions

View every valid solution to the Eight Queens Puzzle in an organized, explorable format.

Frequently Asked Questions

How do you solve the 8 Queens Puzzle?

The most reliable method is the row-by-row backtracking approach: place one queen per row, choosing the leftmost column not under attack by any previously placed queen. When no safe column exists in a row, back up to the previous row and try the next column. Repeat until all 8 rows are filled. This systematic method guarantees finding a solution.

What is the easiest way to solve the Eight Queens Puzzle?

The easiest approach for beginners is the row-by-row method combined with the edge-start strategy. Place your first queen in row 1, column 1. Then work through rows 2–8, always picking the leftmost safe column. When stuck, backtrack one row. This usually leads to the solution [1, 5, 8, 6, 3, 7, 2, 4] relatively quickly without requiring advanced insight.

How many solutions does the 8 Queens Puzzle have?

The 8 Queens Puzzle has exactly 92 unique solutions. Of these, 12 are considered "fundamental" — all others can be derived from the 12 fundamentals by rotating or reflecting the board. You can see all 92 solutions on the complete solutions page.

Can you solve the 8 Queens Puzzle without a computer?

Yes, absolutely! The puzzle was first solved by hand in 1850 by Franz Nauck, long before computers existed. Using the systematic row-by-row backtracking method with a pencil and grid paper, most people can find at least one solution within 10–30 minutes. Finding all 92 solutions by hand takes several hours.

What is the trick to solving the 8 Queens Puzzle?

The key insight is that exactly one queen must go in each row and each column. This reduces the problem from placing queens on any of 64 squares to choosing a permutation of columns [1,2,3,4,5,6,7,8] for rows [1,2,3,4,5,6,7,8] such that no two positions are on the same diagonal. The "trick" is using backtracking to efficiently explore this permutation space rather than checking all 40,320 possible permutations.