# Longest path for knight

Suppose the knight is on square X and he wants to get to square Y, and in order to do that he has to move N moves. how big could N be?

Could that be solved using a mathematical equation? Say Nf3 should capture Bg8, could that be solved mathematically without having to take a look and analyze it step by step? is there an equation?

• Seems to be related to another question (stackoverflow.com/questions/2339101/…) posted on StackOverflow. Also, a quick googling found a possibly interesting link (behnel.de/knight.html). – Rauan Sagit Jan 13 '14 at 14:30
• This question doesn't seem quite complete. Do you mean the largest number of moves without ever occupying the same space? or without making the same exact move (between two spaces) twice? Otherwise Tony's right. – user3204646 Jan 16 '14 at 23:44
• No without making the same move twice, shortest path. Otherwise the number is obviously infinite and my question is nonsense – Lynob Jan 17 '14 at 0:07
• This is most probably solvable with an algorithm. But I don't see the practical application of this for a human player...? – Rauan Sagit Jan 17 '14 at 16:49
• @RauanSagit I want to see if chess could be solved mathematically, using equations – Lynob Jan 17 '14 at 17:22

The furthest distance is from one corner to the opposite one. You can get from a1 to h8 in six moves, for example a1,c2,d4,f3,e5,g6,h8. There are few pairs of squares that take more than four moves.

N can be infinite. I can always make a zillion knight moves. So I expect you really want to know the smallest number of moves a Knight needs to get from square A to square B.

Some N's won't work. A Knight on a1 can't get to b3 in any even number of moves.

One thing we know - if the start and end squares are the same color, it will take an even number of moves. If they are different colors, it will take an odd number of moves.

It doesn't take long to figure out the longest path on the board (a8 to h1 for example) requires six moves. Note the start and end squares are the same color. For alternating colors, the requirement is 5 moves, max.

I don't think there will be an equation where one enters the square locations and a single number comes out.

• I think "he has to move N moves. how big could N be?" means that the question is about the smallest number. – JiK Jan 13 '14 at 9:21
• The question is indeed about the smallest number – Lynob Jan 13 '14 at 9:58

If the knight cannot touch the same square twice then the answer is 63. See Knight's tour

A coworker of mine wrote the software to determine the route a long time ago.

• may i take a look at the software source code? or is it not open source? – Lynob Sep 2 '14 at 12:49
• Sadly, it is not. – ZL1Corvette Sep 2 '14 at 13:15

I think the options are finites (not infinite) is possible calculate all the possible moves from f3 to g8 so the Knight can take the Bishop but its a longest number.

Since the chess board is finite in dimensions (8x8) all the possible moves can be calculated, but off course it will be again a very longest number.