Skip to content

Commit 46d65a6

Browse files
committed
Merge pull request kennyledet#357 from jcla1/master
Added missing tag files, manhattan distance and hamming distance in Python
2 parents 516c822 + 62539fc commit 46d65a6

17 files changed

Lines changed: 7 additions & 0 deletions

File tree

10_Harshad_Number/tags

Whitespace-only changes.

Ackermann/tags

Whitespace-only changes.

Average/tags

Whitespace-only changes.

Comb_Sort/tags

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def hamming_distance(p, 1):
2+
"""Return the Hamming distance between equal-length sequences"""
3+
if len(p) != len(q): raise ValueError("Undefined for sequences of unequal length")
4+
return sum(ch1 != ch2 for ch1, ch2 in zip(p, q))

Hamming_Distance/tags

Whitespace-only changes.

Happy_Number/tags

Whitespace-only changes.

Josephus_Problem/tags

Whitespace-only changes.
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))])

ROT47_Cipher/tags

Whitespace-only changes.

0 commit comments

Comments
 (0)