A city is laid out on a grid of streets. A tourist at here is choosing between two cafés at a and b (all three are lists of coordinates, usually [x, y], but the same idea works in any number of dimensions). A bird flying straight measures the Euclidean distance; a taxi driving along the streets measures the Manhattan distance (the sum of the absolute differences of the coordinates).
Write closer_cafe(here, a, b) that returns a tuple (by_crow, by_taxi). Each entry is "a" if café a is closer under that distance, "b" if café b is closer, and "same" if both are equally far.
Examples
Input: here = [0, 0], a = [3, 3], b = [0, 5]
Output: ("a", "b")
Explanation: the crow flies about 4.24 to a and 5 to b; the taxi drives 6 to a and 5 to b.
Input: here = [2, 1], a = [5, 5], b = [-1, 5]
Output: ("same", "same")
Constraints
- all three vectors have the same length, between 1 and 10
- coordinates are whole numbers between
-10**6and10**6
Goals
- Compute Euclidean and Manhattan distances between two vectors
- Compare distances exactly by comparing squared Euclidean distances
- See that the two distances can disagree about which point is closer