题解 | #DNA序列#
DNA序列
http://www.nowcoder.com/practice/e8480ed7501640709354db1cc4ffd42a
def maxGCR(dna, n):
gcrs = [0.0] * (len(dna) - n + 1)
for i in range(len(dna) - n + 1):
gcrs[i] = (dna[i:i+n].count('G') + dna[i:i+n].count('C'))/n
maxIndex = gcrs.index(max(gcrs))
return dna[maxIndex: maxIndex + n]
while 1:
try:
dna, n = input().upper(), int(input())
print(maxGCR(dna, n))
except:
break