Knight's Journey
On an N×N chessboard, print the minimum number of knight moves from square (r1, c1) to (r2, c2).
Input: one line with five integers: N r1 c1 r2 c2.
Output: the minimum number of knight moves (the board is large enough that it is always reachable for N ≥ 4).
Constraints:
- 4 ≤ N ≤ 500
- coordinates are within the board
Sample Tests
Input 1
8 1 1 8 8
Output 1
6
Input 2
5 3 3 3 3
Output 2
0
Discussion (opens after you solve — no spoilers before)
No comments yet.