#K90462. Minimum Moves on an Infinite Chessboard
Minimum Moves on an Infinite Chessboard
Minimum Moves on an Infinite Chessboard
You are given coordinates of two positions on an infinite chessboard: \( (x_1, y_1) \) and \( (x_2, y_2) \). A piece on the chessboard can move one step in any of the 8 possible directions (horizontal, vertical, and diagonal) in each move.
Your task is to compute the minimum number of moves required to shift the piece from the starting position to the target position. It can be proved that the minimum number of moves is given by the formula:
[ \text{moves} = \max\big(|x_2 - x_1|, ; |y_2 - y_1|\big) ]
For example, moving from (1, 1) to (2, 2) requires 1 move, while moving from (5, 5) to (5, 10) requires 5 moves.
inputFormat
The input consists of a single line containing four space-separated integers: x1
, y1
, x2
, and y2
, representing the starting and target coordinates, respectively.
outputFormat
Output a single integer, which is the minimum number of moves required to reach from the start to the target position on the infinite chessboard.
## sample1 1 1 1
0