-
Notifications
You must be signed in to change notification settings - Fork 0
/
Frequent words problem.py
16 lines (15 loc) · 1.28 KB
/
Frequent words problem.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def freqw( str, int ):
numb = {}
for i in range(len(str)-int+1):
if str[i:i+int] not in numb:
numb[str[i:i+int]] = 0
numb[str[i:i+int]] += 1
maxim = max(numb.values())
res = []
for kmers in numb:
if numb[kmers] == maxim:
res.append(kmers)
return res
str = 'AATGATCCGTTATGCCCGTGCCGCACAGAATGATCCGGTATTTTGAATGATCCGTTATGCCCGTGTATTTTGGTATTTTGGCCGCACAGGCCGCACAGAAATGAGTAGAATGATCCGTTATGCCCGTAATGATCCGGTATTTTGTTATGCCCGTAAATGAGTAGGCCGCACAGGCCGCACAGGTATTTTGGTATTTTGAAATGAGTAGGCCGCACAGGTATTTTGGCCGCACAGTTATGCCCGTTTATGCCCGTGTATTTTGAATGATCCGAAATGAGTAGGTATTTTGAATGATCCGTTATGCCCGTTTATGCCCGTGTATTTTGAAATGAGTAGGCCGCACAGAAATGAGTAGTTATGCCCGTTTATGCCCGTAATGATCCGAAATGAGTAGAATGATCCGAATGATCCGTTATGCCCGTGTATTTTGGCCGCACAGGCCGCACAGAATGATCCGAAATGAGTAGGCCGCACAGGTATTTTGGTATTTTGGCCGCACAGGTATTTTGTTATGCCCGTGTATTTTGAAATGAGTAGGTATTTTGAATGATCCGAAATGAGTAGGTATTTTGAAATGAGTAGAATGATCCGTTATGCCCGTTTATGCCCGTTTATGCCCGTGTATTTTGGCCGCACAGAAATGAGTAGGCCGCACAGGTATTTTGGTATTTTGAAATGAGTAGAATGATCCGGTATTTTGAATGATCCGTTATGCCCGTGCCGCACAGAATGATCCGGCCGCACAGGCCGCACAGGCCGCACAGGCCGCACAGGCCGCACAGAATGATCCGGCCGCACAGGCCGCACAGAATGATCCGAAATGAGTAGTTATGCCCGTAATGATCCGAAATGAGTAGGCCGCACAGGTATTTTGTTATGCCCGTGTATTTTGTTATGCCCGTAAATGAGTAGTTATGCCCGTTTATGCCCGTT'
int = 12
print (' '.join(freqw(str,int)))