Skip to content

Commit fe8f3a4

Browse files
committed
Added manhattan distance in Python
1 parent 3b2392c commit fe8f3a4

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def manhattan_distance(p, q):
2+
if len(p) != len(q): return 0
3+
return sum([abs(p[i] - q[i]) for i in xrange(len(p))])

0 commit comments

Comments
 (0)