0
$\begingroup$

Given two squares on a chess board of 5x5 or under, how can we determine the minimum number of moves required by a knight to reach one square starting from the other, including a way to determine if it is impossible to reach the knight?

$\endgroup$
2
$\begingroup$

Model your knight's errand as a graph: the squares are vertices, edges connect squares if a knight can jump from one to the other. Finding the shortest sequence from one to the other can then be done using e.g. Dijkstra's algorithm.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.