Canadian Computing Competition: 2010 Stage 1, Junior #5
Below is an chessboard on which we will designate square locations using the ordered pairs as indicated. For example, notice that piece is at position and piece is at position .
A knight is a special game piece that can leap over other pieces, moving in the "L" pattern. Specifically, in the diagram below, represents the knight's starting position and the numbers 1 through 8 represent possible places the knight may move to.
Your program will read the starting location of the knight and output the smallest number of jumps or moves needed to arrive at a location specified in the second input.
Your program will read four integers, where each integer is in the range . The first two integers represent the starting position of the knight. The second two integers represent the final position of the knight.
Your program should output the minimum (non-negative integer) number of moves required to move the knight from the starting position to the final position. Note that the knight is not allowed to move off the board during the sequence of moves.
Sample Input 1
2 1 3 3
Output for Sample Input 1
Sample Input 2
4 2 7 5
Output for Sample Input 2