#C348. Minimum Knight Moves on a Chessboard
Minimum Knight Moves on a Chessboard
Minimum Knight Moves on a Chessboard
Given the starting and ending positions of a knight on a standard chessboard, compute the minimum number of moves required for the knight to travel from the starting position to the destination. The knight moves in an L-shape: two steps in one direction (horizontal or vertical) and then one step perpendicular to that direction. It is guaranteed that both positions are valid on the chessboard.
inputFormat
The input consists of two lines:
- The first line contains two integers and , representing the starting coordinates of the knight.
- The second line contains two integers and , representing the destination coordinates. All coordinates satisfy .
outputFormat
Output a single integer representing the minimum number of moves required for the knight to reach the destination from the start.## sample
3 4
3 4
0