GridPencil
10

Knight's Tour

Move a chess knight around a 5 by 5 board so that it lands on every square exactly once.

About Knight's Tour

The Knight's Tour is one of the oldest puzzles in chess, studied for well over a thousand years. The question is simple: can a knight visit every square of the board once, and only once? On this five by five board, starting from the corner, it can. Finding a route is another matter.

How it works

Each square you visit is numbered in order, so you can see the path you have taken. The squares available for your next move are highlighted. If the knight reaches a square with no moves left before the board is full, you are stuck, and the Undo button lets you step back as far as you need.

Solving tips

There is a famous rule of thumb, more than two hundred years old, which works remarkably well. At each step, move to the square from which the knight would have the fewest onward moves. In other words, visit the awkward squares first.

The reasoning is easy to see. Corners and edge squares can only be reached from a couple of places. If you leave them until late, the squares that lead to them will already be used, and they will be cut off. The centre, which has plenty of ways in, can wait.

So when two moves are on offer, count the exits from each and take the one with fewer. If there is a square with only one way in and one way out, plan to pass through it soon.

Watch the last few squares in particular. A tour that reaches twenty-two squares and then strands three is the most common ending, and it usually traces back to a corner left too long.

It is a short puzzle, but among HTML5 games it has one of the longest histories.