Strand Difference
Hamming distance helps compare two strings of the same length, such as short DNA strands or codes. The function distance receives strand_a and strand_b and counts how many positions contain different characters. If the strings have different lengths, raise ValueError.
Примеры
Ввод
("", "")Вывод
0Ввод
("A", "A")Вывод
0Ввод
("A", "G")Вывод
1Нужно реализовать
def distance(strand_a: str, strand_b: str) -> int:
Теги
strings
Prisijunkite, kad matytumėte pateikimų istoriją
PrisijungtiPrisijunkite, kad naudotumėte DI mentorių
PrisijungtiVisible tests
1
Input
"", ""Expected
02
Input
"A", "A"Expected
03
Input
"A", "G"Expected
14
Input
"GGACGGATTCTG", "AGGACGGATTCT"Expected
95
Input
"GGACG", "GGTCG"Expected
16
Input
"GCAGG", "GGTCG"Expected
3Focus radio
Paused · SomaFM · Fluid