All problems
Distance Between Points
Problem
Compute the Euclidean distance between points p and q:
sqrt(sum((p[i] - q[i])^2))
The two vectors must have the same length.
Hint
This is the L2 norm of the difference p - q.
Test cases
case 1
in: [[0,0],[3,4]]
expected: 5
case 2
in: [[1,1],[1,1]]
expected: 0
case 3
in: [[-1,-2],[2,2]]
expected: 5
case 4
in: [[0,0,0],[1,2,2]]
expected: 3
Starter codePython
def point_distance(p, q):
# Your code here
pass4 test cases · run your code against them in the editor