Skip to content

Commit eeb099a

Browse files
author
Pablo Brasero
committed
Comprehension as a filter, removing need for 0s
1 parent e8fea47 commit eeb099a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

python/hamming/hamming.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def distance(s1, s2):
2-
return sum([n1 != n2 and 1 or 0 for n1, n2 in zip(s1, s2)])
2+
return sum(1 for n1, n2 in zip(s1, s2) if n1 != n2)

0 commit comments

Comments
 (0)