automata-labs/TaskB04/solution.py

23 lines
516 B
Python
Raw Normal View History

2024-11-25 16:26:42 +01:00
import sys
import re
def solve(lines):
2024-11-26 17:49:01 +01:00
p = re.compile(r"\d+")
return [
' '.join(re.findall(p, l)) + '\n'
for l in lines
if re.search(p, l)
]
2024-11-25 16:26:42 +01:00
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)