1

Manhattan Distance

Unsolved
Fundamentals

Difficulty: 1 | Problem written by hemdan219@gmail.com
Problem reported in interviews at

Amazon
Apple
Facebook

Given two tuples for two coordinates on a map, your task is to calulate the Manhattan Distance between two cities:

\(D(a,b) = { \sum_{n=1}^{\ N}| a_i-b_i\ |}\)

 

Sample Input:
<class 'tuple'>
city1: (1, 1)
<class 'tuple'>
city2: (2, 2)

Expected Output:
<class 'int'>
2

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Temporibus ipsa quas sint unde labore impedit at? Fugiat iure recusandae sed id aspernatur?

Laudantium ad quam nulla veritatis soluta dolores. Est excepturi aliquid quasi assumenda mollitia ipsa dicta accusantium delectus, velit labore neque, cum voluptates recusandae vitae, unde in dolorum expedita, nemo pariatur perspiciatis. Minus accusantium voluptates quae ullam, sequi inventore consequatur deserunt a numquam est at ea amet perspiciatis doloribus, laudantium ipsum aut unde voluptatum eveniet cum aperiam, inventore voluptatum suscipit?

Quae eum voluptates suscipit accusantium beatae excepturi, architecto sit officia vel voluptas, corrupti odio enim assumenda recusandae iste facilis fugiat harum repudiandae commodi culpa, voluptas amet voluptates perferendis aliquam perspiciatis nostrum iste tempore.

This is a premium feature.
To access this and other such features, click on upgrade below.

Ready.

Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)