In the board shown, there are positions that are reachable by the knight and some that aren't.
From the positions that are reachable, considering that the knight always takes the shortest path to any position, what is the farthest position from the knight and how many moves does it take to reach it?
If is the row index as seen in the image, is the column index also as seen in the image, and is the number of moves it takes to reach the position, what is of this position?
Clarification:
The farthest distance is the one that takes the most moves to reach.
Try solving an easier version here .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
The board can be interpreted as a graph where positions are nodes and the movement from one position to the other is an edge. From that, we can use the Breadth-First search to find the distance to a position. We just need to choose then the position with the largest distance, which in this case is the position (13, 13) with a distance of 11 moves. As seen here:
Here is my implementation of the algorithm in c++