Skip to content

Instantly share code, notes, and snippets.

@bentrevett
Created January 17, 2017 03:35
Show Gist options
  • Save bentrevett/b5b2372b2604814f881dc99bc18ba99e to your computer and use it in GitHub Desktop.
Save bentrevett/b5b2372b2604814f881dc99bc18ba99e to your computer and use it in GitHub Desktop.
Find Euclidean distance in one line in Python.
euclidian = lambda v1,v2: (sum([(a-b)**2 for a,b in zip(v1,v2)])**0.5)
print(euclidian([0.4,0.2,0.3],[0.5,0.6,0.7])) #0.574456264654
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment