Figure 2. The Hamming distance between these two strings is 7. Mismatched symbols are colored red.
Given two strings and of equal length, the Hamming distance between and , denoted , is the number of corresponding symbols that differ in and . See Figure 2.
Given: Two DNA strings and of equal length (not exceeding 1 kbp).
Return: The Hamming distance .
Sample Dataset
GAGCCTACTAACGGGAT
CATCGTAATGACGGCCT
Sample Output
7
字符比较,对于文件读取还是不是很熟
file=open('rosalind_hamm.txt','r')
line=list()
for lines in file.readlines():
line.append(lines.rstrip('\n'))
leng=len(line[0])
mutation=0;
for i in range(0,leng):
if(line[0][i]!=line[1][i]):
mutation+=1;
print(mutation)
ProblemFigure 2. The Hamming distance between these two strings is 7. Mismatched symbols are colored red.Given two strings and of equal length, the Hamming distance between and ,