Finding your destination in a big unknown city can be challenging, especially if you are a computer scientist like
Kirk, always trying to use the shortest possible path. Planning can help – given the map of the city Kirk wants to
find the shortest path between his current position and his destination.
The map of the city can be represented in the plane as an infinite grid composed of unit squares.
Kirk is currently located at the square (0, 0) and his destination is the square (X, Y).
There are N buildings in the city. Each building is a rectangle fully occupying a number of unit squares. No two
buildings touch or overlap, i.e. Kirk can walk freely around every building. A building is defined by specifying
the coordinates of two diagonally opposite squares occupied by the building.
In each step, Kirk can walk to one of the four neighboring squares, but he is not allowed to step onto a square
occupied by a building. His current position is at the west entrance to the city and the x coordinate of every
square occupied by a building is strictly greater than zero.
Write a program that, given the locations of the buildings, finds one shortest possible path from Kirk's current
position to his destination. A path should be reported as a sequence of vertical and horizontal segments, with no
two consecutive segments parallel. The length of a path is the number of squares contained in the path,
excluding the initial square.