How to Solve the Knight's Tour Puzzle, Step by Step
This article was written with AI and may contain mistakes. Found one? Tell us.
To solve the knight's tour puzzle, move a single knight so that it lands on every square of the board exactly once, and at each step jump to the square that leaves the knight with the fewest moves still open. That simple habit, plus a quick colour check before you start, solves most small boards without guesswork.
This guide explains how the knight moves, the difference between open and closed tours, why colour matters, and how to use the fewest-onward-moves habit. It then walks through a full tour on a 5 by 5 board and shows a closed tour on a 6 by 6 board and on the full 8 by 8 board, each checked square by square.
What is the knight's tour puzzle?
You have an empty chessboard and one knight. Your task is to make a chain of knight moves that visits every square once and never lands on the same square twice.
A tour that ends anywhere is called an open tour. A tour whose last square is one knight's move away from the first is a closed tour, because the knight could jump straight back to where it began and go round again [1].
Mathematicians describe the puzzle with graphs. Each square is a point, and two points are joined by a line when a knight can jump between them. A closed tour is then a Hamiltonian cycle: a loop through the graph that passes every point exactly once [1]. Many other chessboard puzzles, such as placing queens that cannot attack each other, are studied in the same graph language [2].
How does a knight move?
A knight jumps two squares in a straight line and then one square to the side, making an L shape. It jumps over anything in the way, so on an empty board only the edges limit it.
On a flat board a knight has at most 8 possible moves [1]. That full set only appears near the middle. A knight in a corner has just two choices, and a knight on an edge has three or four. This is the key to the whole puzzle: corners and edges are the hard squares, because they are easy to cut off.
| Where the knight stands on an 8 by 8 board | Moves available |
|---|---|
| Corner square | 2 |
| Next to a corner, on the edge | 3 |
| Middle of the board | 8 |
What is the difference between an open and a closed tour?
An open tour only needs to cover every square. A closed tour has one extra demand: the last square must be a knight's move from the first [1].
Closed tours are harder to build, but they have a useful property. Because the tour is a loop, you can start it on any square and follow the same loop round. An open tour does not let you do that.
When you set yourself a puzzle, decide first which kind you want. If the board is small or odd-sized, an open tour is often the only possibility, as the sections below explain.
Why does the knight always change colour?
Look at any knight move on a chequered board. It always lands on a square of the other colour. Two squares along and one across adds up to three steps, an odd number, so the colour flips every time.
This colour-alternation rule has two quick consequences you can use before you even place the knight.
A closed tour needs equal numbers of light and dark squares. The colours alternate all the way round the loop, so the loop must have as many squares of one colour as of the other.
On a board with an odd number of squares in both directions, such as 5 by 5 or 7 by 7, one colour has an extra square, so no closed tour can exist. The same kind of two-colour counting argument is used to rule out closed tours inside odd-sized cubes [1].
On an odd board, an open tour must start and end on the majority colour. A 5 by 5 board has 13 squares of the corner colour and 12 of the other. In a 25-square tour, steps 1, 3, 5 and so on up to 25 share a colour, which makes 13 squares, so they must all be on the corner colour. Starting on the other colour is hopeless, however clever the moves.
What is the fewest-onward-moves rule?
Here is the rule of thumb that does most of the work. Whenever you have a choice, count how many unvisited squares the knight could reach from each candidate square. Then move to the candidate with the smallest count.
Why does this help? A square with only one or two ways in is in danger. If you leave it until later, its last remaining neighbours may get used up, and the square becomes an island the knight can never reach. By visiting the most cramped squares first, you keep the roomy squares, usually in the middle, for the end of the tour, when you need flexibility most.
Use it like this:
- List every unvisited square the knight can reach from where it stands.
- For each one, count its own onward moves to squares that are still unvisited.
- Move to the square with the lowest count.
- If two squares tie, pick either one. If you later get stuck, come back to the last tie and try the other choice.
- Write the step number on each square as you go, so you never land on one twice.
The rule is not a guarantee. On larger boards, and especially when you want a closed tour, you may still need to step back and try a different tie. But it removes most dead ends before they happen.
Worked example: how do you solve a 5 by 5 board?
Start in the top-left corner, which is the majority colour, so the colour check is passed. Number that square 1. Rows are counted from the top and columns from the left.
Step 1 to 2. From the corner the knight has only two moves, and both have five onward moves, so it is a tie. Take the square in row 2, column 3.
Step 2 to 3. From there the knight can reach five unvisited squares. The top-right corner, in row 1, column 5, has only one onward move left, while the other four have three each. The rule says take the corner, so it becomes square 3.
Step 4 to 5 and step 6 to 7. The same thing happens twice more. Each time a corner is the most cramped option, with just one onward move, so the knight takes the bottom-right corner as square 5 and the bottom-left corner as square 7.
Notice the pattern. After seven moves, all four corners have been visited. Those were the four squares most likely to strand the tour, and the rule cleared them first without any planning.
Step 10 to 11. The knight is in row 2, column 5. It can go to row 1, column 3, which has one onward move, or to the centre square, which has seven. The rule chooses the edge square and saves the roomy centre for later. In the end, the centre is not visited until step 23.
Keep going in the same way. Every step in the tour below follows the fewest-onward-moves rule, and the tour fills the board without a single dead end.
| Row | Col 1 | Col 2 | Col 3 | Col 4 | Col 5 |
|---|---|---|---|---|---|
| 1 | 1 | 22 | 11 | 16 | 3 |
| 2 | 12 | 17 | 2 | 21 | 10 |
| 3 | 25 | 8 | 23 | 4 | 15 |
| 4 | 18 | 13 | 6 | 9 | 20 |
| 5 | 7 | 24 | 19 | 14 | 5 |
Follow the numbers from 1 to 25 and you will see that every step is an L-shaped jump. Square 25 is not a knight's move from square 1, so this is an open tour, which is exactly what the colour rule predicted for an odd board.
What does a closed tour look like?
On a 6 by 6 board both colours have 18 squares, so a closed tour is possible. The tour below starts in the top-left corner. Square 36, in row 3 column 2, is a knight's move from square 1, so the knight can jump home and repeat the loop.
| Row | Col 1 | Col 2 | Col 3 | Col 4 | Col 5 | Col 6 |
|---|---|---|---|---|---|---|
| 1 | 1 | 28 | 21 | 12 | 3 | 34 |
| 2 | 20 | 11 | 2 | 35 | 22 | 13 |
| 3 | 27 | 36 | 29 | 14 | 33 | 4 |
| 4 | 10 | 19 | 8 | 23 | 30 | 15 |
| 5 | 7 | 26 | 17 | 32 | 5 | 24 |
| 6 | 18 | 9 | 6 | 25 | 16 | 31 |
When you hunt for a closed tour yourself, add one extra check to the fewest-onward-moves rule. Keep at least one free neighbour of your starting square until the very end. If all of them are used up early, the loop can never close, so step back at once.
The same method, with a little backtracking at ties, also produces a closed tour of the full 8 by 8 board. Square 64 sits in row 3, column 2, a knight's move from square 1 in the corner.
| Row | Col 1 | Col 2 | Col 3 | Col 4 | Col 5 | Col 6 | Col 7 | Col 8 |
|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 16 | 41 | 22 | 3 | 18 | 43 | 48 |
| 2 | 40 | 23 | 2 | 17 | 42 | 47 | 4 | 19 |
| 3 | 15 | 64 | 39 | 46 | 21 | 54 | 49 | 44 |
| 4 | 24 | 37 | 56 | 63 | 52 | 45 | 20 | 5 |
| 5 | 57 | 14 | 61 | 38 | 55 | 50 | 53 | 30 |
| 6 | 36 | 25 | 58 | 51 | 62 | 31 | 6 | 9 |
| 7 | 13 | 60 | 27 | 34 | 11 | 8 | 29 | 32 |
| 8 | 26 | 35 | 12 | 59 | 28 | 33 | 10 | 7 |
Which small boards have a closed tour?
You do not need to search every board yourself. Schwenk settled the question for every rectangle in 1991 [1]. Only three kinds of board are ruled out, and any rectangle that avoids all three has a closed tour [1].
| Ruled out by Schwenk's result [1] | Examples |
|---|---|
| Boards whose two sides are both odd | 5 by 5, 7 by 7 |
| Boards whose shorter side has 1, 2 or 4 squares | 2 by 8, 4 by 6 |
| Boards three squares wide and 4, 6 or 8 long | 3 by 4, 3 by 8 |
Small boards hold one surprise. The flat 4 by 4 board allows no knight's tour of any kind, yet the 4 by 4 by 4 cube allows a closed one [1]. In three dimensions a single cell can offer the knight as many as 24 jumps, three times the flat maximum of 8 [1].
How do you check a finished tour?
A tour is only solved when it passes three checks. Do them in this order, because each one is quick.
- Every number appears once. On a 5 by 5 board you need each number from 1 to 25, with no gaps and no repeats.
- Every step is a knight move. Find square 1, then square 2, and confirm the jump is two in one direction and one in the other. Repeat for every pair.
- For a closed tour, the ends meet. The last square must be a knight's move from square 1.
Every tour in this guide was checked this way by a short computer script, which tested every single step.
What mistakes trip people up?
- Starting on the wrong colour. On an odd board, a tour that starts on the minority colour cannot finish.
- Leaving corners for the end. A corner has only two neighbours, so if one of them is used by accident, the corner is lost.
- Chasing the centre. Save the middle, with its many exits, for late in the tour.
- Hoping for an impossible closed tour. Check the table above first.
How does the knight's tour connect to other chessboard puzzles?
The knight's tour is one of a group of puzzles about how pieces travel across a board.
In a paper published on 7 December 2021, the travel question was turned round: on an empty board a rook or a queen never needs more than two moves to get anywhere, so how few pawns does it take to force longer trips [2]? The paper answers this for rooks and queens at short distances, and it lists the same question for other pieces, the knight included, as still open [2].
Can a tour start next to the corner?
On a 5 by 5 board, can a knight's tour start on the square right next to the top-left corner, in row 1, column 2? Think about colour before you try.
Answer: No. That square has the minority colour, and on a 5 by 5 board every tour must start and end on the corner colour. You can, however, start an open tour from the very centre, because the centre has the corner colour. Try it with the fewest-onward-moves rule.
Then try this puzzle, which also asks you to visit points in the right order:
References
- DeMaio, J. (2007, May 9). Which Chessboards have a Closed Knight's Tour within the Cube?. The Electronic Journal of Combinatorics, 14(1), R32. DOI 10.37236/950
- Chatham, D. (2021, December 7). Diameter-Separation of Chessboard Graphs. Recreational Mathematics Magazine, 8(15), 13-26. DOI 10.2478/rmm-2021-0008