题解 | #DNA序列#

DNA序列

https://www.nowcoder.com/practice/e8480ed7501640709354db1cc4ffd42a

DNA = input()       # 输入DNA序列
N = int(input())            # 输入子串的长度

str = []        # 存储切片后的子串
GC_Ratio = []       # 存储GC的占比,即GC-Ratio

#遍历位置
for i in range(len(DNA)):
    str.append(DNA[i:i+N])      # 切片
    sum = DNA[i:i+N].count('G') + DNA[i:i+N].count('C')     # G和C出现的次数总和
    GC_Ratio.append(sum / N)        # GC-Ratio

x = max(GC_Ratio)       # 最大占比

# 打印最大占比所在的子串
print(str[GC_Ratio.index(x)])

全部评论

相关推荐

码农索隆:有点耳熟,你们是我教过最差的一届
点赞 评论 收藏
分享
点赞 评论 收藏
分享
深夜书店vv:腾讯是这样的,去年很多走廊都加桌子当工区
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务