Complete task 4

This commit is contained in:
s473573 2024-11-25 16:26:42 +01:00
parent 5417f67adf
commit 025bbead96
2 changed files with 19455 additions and 0 deletions

File diff suppressed because it is too large Load Diff

28
TaskB04/solution.py Normal file
View File

@ -0,0 +1,28 @@
import sys
import re
def solve(lines):
# filter all substrings that match
# print
# print(None, re.findall(r"\b\d+\b", lines[3]))
# return []
p = re.compile(r"\b\d+\b")
res = []
for l in lines:
m = re.findall(p, l)
if m:
res.append(' '.join(m) + '\n')
return res
if __name__ == "__main__":
lines = []
fp = sys.argv[1]
assert("polish_wiki_excerpt" in fp)
print(fp)
with open(fp, encoding="utf-8") as f:
lines = f.readlines()
sol = solve(lines)
with open("./polish_wiki_excerpt.out", 'w', encoding="utf-8") as f:
f.writelines(sol)