-
Notifications
You must be signed in to change notification settings - Fork 0
/
taskB.py
30 lines (25 loc) · 790 Bytes
/
taskB.py
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
def read_parameters(filename: str, rows: int) -> list:
tasks_parameters = []
with open("data/" + filename) as f:
f.readline()
params = []
for i, line in enumerate(f):
params.append(line.strip())
if (i+1) % rows == 0:
tasks_parameters.append(params)
params = []
return tasks_parameters
def taskB(params: list) -> str:
ans = []
s = params[0]
ss = params[1]
for i in range(len(s)):
if s[i:i+len(ss)] == ss:
ans.append(str(i+1))
return " ".join(ans)
answers = []
for params in read_parameters("prequal/inputB.txt", 2):
answers.append(taskB(params))
with open("results/prequal/outputB.txt", "w") as w:
for ans in answers:
w.write(ans + "\n")