How to solve Finding a Closed Knight’s Tour Starting at Any Position?

Revision en1, by I_love_Computer_science, 2025-07-27 14:40:22

Hello, I want to solve this classic problem. Could you please help me by sharing the solution approach, some code ideas, and a link to the problem? I would be very happy if you could share these with me.

Thank you!


You have a standard 8×8 chessboard and a knight placed on a starting cell (x,y) — coordinates are 1-based (from 1 to 8). Your task is to find a sequence of knight moves such that: The knight visits every square on the board exactly once (i.e., it makes 64 moves in total, including the starting square). The sequence forms a closed tour, meaning that after the knight’s final move (the 64th move), the knight can move again by a single knight’s move to return to the starting cell (x,y). If such a closed knight’s tour exists from the given starting position, print the board with numbers 1 through 64, where the number at each cell represents the move number when the knight visits that cell. Otherwise print "No".

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English I_love_Computer_science 2025-07-27 14:40:38 0 (published)
en1 English I_love_Computer_science 2025-07-27 14:40:22 1045 Initial revision (saved to drafts)