A warehouse robot has to move by the vector move (for example [3, -4]: 3 metres east and 4 metres south; in a tall warehouse there is a third number for up and down). How long the move is depends on how the robot travels:
- grid robots drive along one axis at a time, so they cover the sum of the absolute values of the components;
- drones fly in a straight line, so they cover the square root of the sum of the squares of the components;
- gantry robots run all their motors at once, each at 1 metre per second, so the move takes as many seconds as the largest absolute component.
Write move_lengths(move) that returns the tuple (grid, drone, gantry).
Examples
Input: move = [3, -4]
Output: (7, 5.0, 4)
Explanation: grid 3 + 4 = 7; drone the square root of 9 + 16 = 5.0; gantry max(3, 4) = 4.
Input: move = [0, 0, 0]
Output: (0, 0.0, 0)
Constraints
1 <= len(move) <= 1000; components are ints or floats with absolute value at most10**6- answers are compared with a tolerance of
1e-6, so ints and floats are both fine
Goals
- Compute the Manhattan (L1) and Euclidean (L2) length of a vector
- Compute the largest single component, the maximum norm
- Connect each length to a different way of moving