add a solution for the hamming problem

This commit is contained in:
Andreas Zweili 2021-10-31 12:43:14 +01:00
parent 7967af4eb5
commit 9853c0ead4
4 changed files with 16 additions and 7 deletions

View File

@ -1,8 +1,8 @@
{
"python.pythonPath": "python/venv/bin/python3",
"python.terminal.activateEnvInCurrentTerminal": true,
"python.testing.pytestArgs": ["python"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.linting.enabled": true
"python.linting.enabled": true,
"python.testing.pytestArgs": ["python"]
}

View File

@ -1,6 +1,11 @@
def distance(strand_a, strand_b):
strand_a_length = strand_a.length()
strand_b_length = strand_b.length()
print(strand_a_length)
pass
length_sum = len(strand_a) - len(strand_b)
if (strand_a == strand_b):
return 0
if (length_sum != 0):
raise ValueError("Not the same distance")
distance = 0
for i, letter in enumerate(strand_a):
if (letter != strand_b[i]):
distance += 1
return distance

View File

@ -1,4 +1,5 @@
import unittest
import pytest
from hamming import (
distance,

3
python/requirements.txt Normal file
View File

@ -0,0 +1,3 @@
pytest
pep8
pylint