#K70387. Minimum Knight Moves
Minimum Knight Moves
Minimum Knight Moves
You are given an 8×8 chessboard and two positions on the board: a starting position and a target position. A knight on a chessboard moves in an L-shape: it can move two squares in one direction and then one square perpendicular to that. In other words, in one move the knight can move from position \((x, y)\) to \((x+\Delta x, y+\Delta y)\) where \((\Delta x, \Delta y)\) is one of \((2,1), (2,-1), (-2,1), (-2,-1), (1,2), (1,-2), (-1,2), (-1,-2)\).
Your task is to compute the minimum number of moves required for the knight to move from the starting position to the target position using valid moves on this chessboard.
The solution typically involves a breadth-first search (BFS) algorithm to explore all possible moves until the target is reached.
inputFormat
The input is read from standard input (stdin) and consists of four space-separated integers: xstart ystart xend yend. All coordinates are zero-indexed and lie in the range [0, 7].
outputFormat
Print a single integer to standard output (stdout) representing the minimum number of moves required for the knight to reach the target position from the starting position.
## sample0 0 0 0
0