Skip to main content
2 of 3
Code bug, numbers were wrong
Cruncher
  • 217
  • 1
  • 5

I know this is a super old question. I made a program that outputs all the positions a knight can be relative to starting position within five moves.

0: (0 0)
1: (2 1) 
2: (2 0) (3 3) (4 2) (3 1) (1 1) (4 0)
3: (3 2) (5 4) (4 1) (3 0) (6 1) (6 3) (4 3) (5 0) (1 0) (5 2)
4: (7 3) (6 4) (8 2) (5 5) (6 6) (7 1) (4 4) (8 0) (6 0) (8 4) (6 2) (7 5) (2 2) (5 1) (5 3)
5: (9 4) (10 1) (8 7) (10 3) (9 6) (6 5) (8 5) (7 2) (8 3) (9 0) (7 0) (10 5) (8 1) (9 2) (7 6) (7 4)

Number on the left is turn number, and the list on the right corresponds to all the positions the knight can be in with duplicate positions removed (we don't care that you can go back to your starting position for example, these are the shortest paths to each of these positions). Also, no negative numbers are represented. For example 2,1 -2,1, 2,-1 and -2,-1 are all considered the same position. Also the biggest number is always shown first. For example (4,2) means the night can move 4 spaces in some direction, and then 2 in an orthogonal direction.

One more caveat is that these numbers are the theoretical minimum with no pieces in the way, and a theoretical infinite plane to work with. That is, to achieve this could potentially require moves that exit the game board and come back.

Memorizing this is probably not that useful, but there's some interesting takeaways that may be worth noting.

For example, it takes a whole 3 moves to move a knight 1 square forward.

Cruncher
  • 217
  • 1
  • 5