2023-12-10 17:32:32 +01:00
|
|
|
import re
|
|
|
|
|
|
|
|
file_name: str = "simple"
|
|
|
|
|
|
|
|
|
|
|
|
def find_dates_1900_to_1999(text):
|
|
|
|
# Define the regular expression pattern
|
2023-12-10 17:44:59 +01:00
|
|
|
pattern = re.compile(r"19\d{2} r\.", re.IGNORECASE)
|
2023-12-10 17:32:32 +01:00
|
|
|
|
|
|
|
# Split the text into lines
|
|
|
|
lines = text.split("\n")
|
|
|
|
|
|
|
|
# Use the regular expression to find lines containing dates from 1900 to 1999
|
2023-12-10 17:44:59 +01:00
|
|
|
date_lines = [line for line in lines if re.search(pattern, line)]
|
2023-12-10 17:32:32 +01:00
|
|
|
|
|
|
|
return date_lines
|
|
|
|
|
|
|
|
|
|
|
|
with open(file_name + ".in", "r", newline="", encoding="utf8") as file:
|
|
|
|
text = file.read()
|
|
|
|
|
|
|
|
with open(file_name + ".exp", "r", newline="", encoding="utf8") as file:
|
|
|
|
expected = [line.rstrip() for line in file.readlines()]
|
|
|
|
|
|
|
|
|
|
|
|
found_lines = find_dates_1900_to_1999(text)
|
|
|
|
|
|
|
|
mistake = False
|
|
|
|
for line in expected:
|
|
|
|
if line in found_lines:
|
|
|
|
print(f"{line}")
|
|
|
|
else:
|
|
|
|
print(f"NO: {line}")
|
|
|
|
mistake = True
|
|
|
|
|
|
|
|
if mistake:
|
|
|
|
print("ERROR")
|