The streets in the central part of Manhattan are constructed in a way that resembles a grid. To get from one crossroad you need to go parallel in one direction and then vertical in another. So, if we imagine a virtual X and Y axis, in Manhattan, we always move either parallel to the OX axis or parallel to the OY axis.
This construction of streets has become so popular that people started using it as a distance metric. When it’s only allowed to move in the OX or the OY directions and one needs to get from
, they first move parallel to the OX axis to get from
and afterward from
. This changes the calculations of distance between points and is called Manhattan distance. The standard Euclidean distance is
Can you figure out the Manhattan distance between two points?
The input consists of 4 numbers:
coordinates of the first point followed by
coordinates of the second point. The program should output the Manhattan distance between those two points.
3 4 1 0.5