2019-8: Going the Distance
Given a vector of (X Y) points, or a single X Y point, determine the total distance covered when travelling in a straight line from the first point to the next one, and so on until the last point, then returning directly back to the start.
For example, given the points (A B C) ← (¯1.5 ¯1.5)(1.5 2.5)(1.5 ¯1.5), the distance A to B is 5, B to C is 4 and C back to A is 3, for a total of 12.
Examples
Implementation
You can also run the tests via ⌘/shift + enter