Manhattan Meeting Time


Collapse Content

You're working on an app that calculates driving time in a city from point A to point B. People drive at 24mph on avenues (along the Y-axis) and 20mph on streets (along the x-axis).

You will be given four integer co-ordinates {x1, y1, x2, y2} in an array, where (x1,y1) and (x2,y2) are points A and B on a 2D grid. Calculate and print the time in minutes it will take to drive from point A to point B.

For example, if A is (0,0) and B is at (10,6), then the user will need to drive 6 miles at 24mph and 10 miles at 20mph, so it will take 15+30= 45 minutes in total.

manhattan-grid-example

Challenge

Print how many minutes it will take to drive from A to B.

Please sign in or sign up to submit answers.

Alternatively, you can try out Learneroo before signing up.

Comments

Contact Us
Sign in or email us at [email protected]