The knight's tour: the method and the solution

By Arnaud, creator of procstd. Updated November 22, 2026.

Take the chess knight over every square, once each: the puzzle fascinated Euler, and it looks impossible as long as you move at random. Yet one very simple rule, found in 1823 by Warnsdorff, is almost always enough. Here it is, with a step-by-step example and two complete tours, on 5 × 5 and on the 8 × 8 chessboard.

Try it as you read: play Knight's Tour, free and ad-free.

The rules

The knight jumps in an "L": two squares in one direction, then one to the side. From its starting square, it must visit every square of the board, once each. It does not need to come back to the start: this is an "open" tour.

In the Knight's Tour game, each board is drawn from a real tour: it always has a solution. A button takes back one jump, and the leaderboard counts time.

Warnsdorff's rule

At each jump, look at the squares the knight can reach. For each one, count the jumps it would then have, to squares still free. Go to the one with the fewest.

The idea: hard-to-reach squares, the corners and edges, have only two or three neighbours. Leave them for later and you end up cutting them off. Warnsdorff takes them as soon as they are in reach, while there is still a way out. The knight thus runs along the edges first, and finishes in the centre, where choices stay plentiful.

133324231
Before
13245
After

After 4 jumps, the knight has five possible squares; the coloured number says how many jumps it would then have. The corner has only one: go there now, or it would soon be cut off.

A complete tour on 5 × 5

Following the rule from the top-left corner, you fill all 25 squares without ever getting stuck. Notice how the path turns along the edges before heading into the centre.

On 5 × 5, there are 13 squares of one colour and 12 of the other, as on a chequerboard. The knight changes colour at every jump: a 25-square tour therefore starts and ends on the corners' colour. From a square of the other colour, no tour exists. The game never gives you such a start.

11492032419215101382342118256111671217225

Warnsdorff's tour from the corner: the squares are numbered in the order of the jumps, from 1 to 25.

When two squares are tied

The rule says nothing when two squares have the same count. Most of the time, either one works. To give yourself every chance, take the one nearer an edge, or look one move further: which one then leaves a square with a single jump?

If you get stuck before the end, go back a few jumps, to the last tied choice, and take the other square.

The solution on the 8 × 8 chessboard

On the chessboard, the rule also works from the corner, from the first to the 64th jump. Here it is in full: start at 1 and follow the numbers.

Euler studied the problem in 1759, and we now know there are thousands of billions of different tours on 8 × 8. No need to learn them: with the rule, you can find one from any start.

11627223184752262321746514191528255021485356243530456255205291461344944575436313841606369134033641184358323712394259107

A complete knight's tour on 8 × 8, found with Warnsdorff's rule from the top-left corner.

The holes at the Easy level

At the Easy level, a few squares are holes: the knight cannot go there. The rule stays the same: count only the jumps to free squares that are not holes. A square next to a hole has fewer exits, so it comes earlier.

The game's levels

Easy: 5 × 5, with 5 holes. Hard, the leaderboard level: 6 × 6. Expert: 7 × 7. Hardcore: the 8 × 8 chessboard, with no hints.

Your turn

The rules, the levels and the frequently asked questions are on the Knight's Tour page. Each level has its own leaderboard.

Play Knight's Tour

Other guides