Question: In city street grids, intersections are often defined by two integers, counting the position of horizontal and vertical streets ( sometimes called streets and avenues

In city street grids, intersections are often defined by two integers, counting the position of horizontal and vertical streets (sometimes called streets and avenues). Imagine traveling from position
to
. How many blocks do you traverse?
An image of a street grid with different paths from point h1, v1 to point h2, v2
Even though there are many possible routes, the distance only depends on the differences
and
. However, you need to take the absolute value because the differences might be negative.
Complete the following program that prints the number of blocks traveled, given the origin and destination of the trip (which will change as your code is tested).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!