题解 | #DNA序列#

DNA序列

https://www.nowcoder.com/practice/e8480ed7501640709354db1cc4ffd42a?tpId=37&tqId=21286&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D2%26tpId%3D37%26type%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=

import sys

s = input()

length =int(input())

L=[]
#for i in range(len(s)):

#遍历所有的字串
i=0
while i+ length < len(s)+1:
    L.append(s[i:i+length])
    i+=1
#计算字串的GC_Ratio 
#保留最大值,并输出,如果小于等于当前最大值,不用更新
maxGC_Ratio =0
for x in L:
    current_Ratio=(x.count("G")+x.count("C"))/length
    if maxGC_Ratio < current_Ratio:
        maxGC_Ratio=current_Ratio
        maxGC_Ratio_string=x
    else:
        pass
print(maxGC_Ratio_string)

全部评论

相关推荐

野猪不是猪🐗:现在的环境就是这样,供远大于求。 以前卡学历,现在最高学历不够卡了,还要卡第一学历。 还是不够筛,于是还要求得有实习、不能有gap等等... 可能这个岗位总共就一个hc,筛到最后还是有十几个人满足这些要求。他们都非常优秀,各方面都很棒。 那没办法了,看那个顺眼选哪个呗。 很残酷,也很现实
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务