-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq4.py
More file actions
35 lines (34 loc) · 838 Bytes
/
q4.py
File metadata and controls
35 lines (34 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
f = open ('test1.txt','r')
string = f.read()
#print string;
lstring = string.splitlines()
string1 = lstring[0]
string2 = lstring[1]
vstring = string2.split(' ')
sequencesize = int(vstring[0])
Limit = int(vstring[1])
checker = int(vstring[2])
i = 0;
k = 0;
finallist=[];
while (i < len(string1) - Limit + 1):
stringofL = string1[i:i+Limit];
#print stringofL
d = {}
j = 0;
while (j < len(stringofL) - sequencesize + 1):
if stringofL[j:j+sequencesize] not in d:
d[stringofL[j:j+sequencesize]] = 0
d[stringofL[j:j+sequencesize]] = d[stringofL[j:j+sequencesize]] + 1;
#print stringofL[j:j+sequencesize]
j = j+1
for k,v in d.iteritems():
#print k,v;
if d[k] >= checker:
if k not in finallist:
finallist.append(k)
i = i + 1
outfinalstr = ''
for i in finallist:
outfinalstr = outfinalstr + i + ' '
print outfinalstr