forked from miczar1/djfz-24_25
Complete task 4
This commit is contained in:
parent
5417f67adf
commit
025bbead96
19427
TaskB04/polish_wiki_excerpt.out
Normal file
19427
TaskB04/polish_wiki_excerpt.out
Normal file
File diff suppressed because it is too large
Load Diff
28
TaskB04/solution.py
Normal file
28
TaskB04/solution.py
Normal 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)
|
Loading…
Reference in New Issue
Block a user