Your question is Knight Minimum Moves. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
In a Citadel trading-grid simulation, a knight moves across an n x n board using standard chess moves: two squares in one direction and one square perpendicular to it. Given the board size, starting square, and target square, return the minimum number of moves needed to reach the target.
Every square is traversable. Return 0 when the starting and target squares are identical.
Implement min_knight_moves(n, start, target).
n is an integer board size.start and target are two-element lists [row, column], using zero-based coordinates.Use breadth-first search because every move has equal cost, so the first time a square is visited is through a shortest path.
def min_knight_moves(n, start, target):