A Python solution for a classic chess puzzle

Knight's Tour

© Lead Image © Dima Sobko, 123RF.com

© Lead Image © Dima Sobko, 123RF.com

Author(s):

If you're looking for a head start on solving the classic Knight's Tour chess challenge, try this homegrown Python script.

A chess knight can travel around a chessboard using the knight's move and visit every square once, and only once. This is known as the Knight's Tour. The Knight's Tour is usually played with numbered counters on a conventional chessboard (Figure 1), but you can play it on any rectangular board with five or more rows and columns.

Figure 1: The Knight's Tour is usually played on a chessboard with counters to mark the progress. This tour starts on the square with the black knight and ends on the square with the white knight.

The Knight's Tour is an example of a classic mathematical problem that lends itself to easy and creative expression through computer programming. I created a Python program to help users practice solving the Knight's Tour. The Knight's Tour program is a good example of the simple yet powerful applications you can build with the Pygame Python library for computer gamers.

[...]