make the solution a bit cleaner

This commit is contained in:
Andreas Zweili 2021-10-31 12:50:49 +01:00
parent 9853c0ead4
commit 294d39981b
1 changed files with 5 additions and 4 deletions

View File

@ -1,11 +1,12 @@
def distance(strand_a, strand_b):
length_sum = len(strand_a) - len(strand_b)
if (strand_a == strand_b):
return 0
if (length_sum != 0):
if (len(strand_a) != len(strand_b)):
raise ValueError("Not the same distance")
distance = 0
for i, letter in enumerate(strand_a):
if (letter != strand_b[i]):
zipped_strands = zip(strand_a, strand_b)
for a, b in zipped_strands:
if (a != b):
distance += 1
return distance