CodyKochmann
10/2/2016 - 8:15 PM

calculate the distance between two points with unlimited dimensions in python

calculate the distance between two points with unlimited dimensions in python

from math import sqrt
def distance(p1, p2):
    # calculates the distance between two points with unlimited dimensions
    # by: Cody Kochmann
    return sqrt(sum( (a-b)**2 for a,b in zip(p1,p2) ))