automata-labs/TaskB02/solution.py

18 lines
473 B
Python
Raw Permalink Normal View History

2024-11-25 16:01:41 +01:00
import sys
import re
def solve(lines):
2024-11-26 17:38:06 +01:00
# return [l for l in lines if re.search(r"\bpies\b", l, re.I)]
return [l for l in lines if re.search(r"(^|\s)pies($|\s)", l, re.I)]
2024-11-25 16:01:41 +01:00
if __name__ == "__main__":
lines = []
fp = sys.argv[1]
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)