On this page
A knight's tour is a sequence of knight moves that lands on every square of a board exactly once (Wikipedia: Knight's tour). If the last square is one knight move from the first, the tour is closed. Otherwise it is open. The same article notes that Rudrata's 9th-century Kavyalankara, a Sanskrit work on poetics, presents a knight's tour on a half-board as a poetic figure.
In graph terms a tour is a Hamiltonian path, which our post on Hamiltonian cycles, Dirac's test and the knight's tour covers.
What is Warnsdorff's rule?
In 1823 H. C. von Warnsdorff proposed a simple rule that he suggested gave a tour on the 8×8 board (Squirrel and Cull, 1996). Look at every unvisited square the knight can jump to. For each, count the unvisited squares it could jump to next, its onward moves. Go to the square with the fewest.
The rule says nothing about ties. Warnsdorff claimed any tie-break gives a tour; Squirrel and Cull showed it does not.
Why should a greedy rule work? Corners and edges have few exits, and if you leave them for later they get stranded. The rule visits awkward squares while they can still be reached and saves the well-connected centre for the end. It is the same instinct as handling the most constrained vertex first in greedy graph colouring.
How does Warnsdorff's rule work on a 5×5 board?
Label columns a to e and rows 1 to 5, and start at a1. Brackets give each candidate's onward moves.
From a1 you can reach b3 (5) or c2 (5). This tie is harmless because the two squares are mirror images. Take c2.
From c2: a3 (3), e1 (1), e3 (3), b4 (3), d4 (3). Go to e1.
e1's only exit is d3. From d3, e5 scores 1 and the rest score 2 or 3, so go to e5, then c4, its only exit.
From c4, a5 scores 1. Go to a5, then b3, its only exit.
From b3, c5, d4, d2 and c1 all score 2: the first real choice. We took d2.
From d2, e4 and b1 tie on 2. We took e4. From e4, c5 scores 1 and the centre c3 scores 7, so go to c5.
From c5 to b5, every move is forced or scores 1.
With a3, b1 and c3 left, either order finishes.
The full tour is a1, c2, e1, d3, e5, c4, a5, b3, d2, e4, c5, a4, b2, d1, e3, d5, b4, a2, c1, e2, d4, b5, a3, b1, c3. All four corners are done by move 7, and the centre is the last square.
The tour is open, and it has to be. A knight always changes colour, so a closed tour needs equal numbers of light and dark squares. A 5×5 board has 13 of one colour and 12 of the other.
How reliable is Warnsdorff's rule?
Squirrel and Cull's experiments confirmed that arbitrary tie-breaking is likely to produce a tour on square boards smaller than 50×50 (Squirrel and Cull, 1996). On larger boards, their results suggest the chance of success with random tie-breaks falls rapidly towards zero. Small boards can still punish several bad choices: the paper prints a 5×5 path that gets stuck after 17 squares.
They also tried each of the 8! = 40,320 fixed move orders as a tie-breaker, and every one failed on some board. Combining orders in different regions of the board gave a rule they partly prove works on all square boards larger than 112×112.
Tours are also plentiful on 8×8. Brendan McKay counted 13,267,364,410,532 undirected closed tours on the standard board (OEIS A001230).
Which board sizes have a knight's tour?
For an m×n board with m ≤ n, Allen Schwenk proved that a closed tour exists unless m and n are both odd, m is 1, 2 or 4, or m is 3 and n is 4, 6 or 8 (Schwenk, 1991; summarised in Wikipedia). An open tour exists unless m is 1 or 2, m is 3 and n is 3, 5 or 6, or the board is 4×4; the same article credits Conrad and colleagues (1994)00170-Q) and Cull and colleagues for boards whose shorter side is at least 5.
8×8: closed tours exist.
6×6: closed, with 9,862 undirected closed tours (OEIS A001230).
5×5: open only, because both sides are odd.
4×4: no tour at all.
3×4: open, never closed.
3×3: none, because the centre square has no knight moves.
How can you practise this yourself?
On a 5×5 grid, rerun the tour from a1 but pick c1 or c5 at the four-way tie. Do you finish?
Write out the colouring proof that no odd-by-odd board has a closed tour, a classic olympiad-style parity argument.
Set it beside the travelling salesman problem with a 5-city worked example and ask what a quick rule of thumb gives up.
If Hamiltonian paths or vertex degree are new to you, the Fermi Concept Library has a lesson for every concept in mathematics and computing. For practice, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning.



