34 lines
669 B
Python
34 lines
669 B
Python
|
import re
|
||
|
|
||
|
file_name: str = "simple"
|
||
|
|
||
|
|
||
|
def find_maximum_digit_substrings(text):
|
||
|
pattern = re.compile(r"\d+")
|
||
|
|
||
|
matches = pattern.findall(text)
|
||
|
|
||
|
result = " ".join(matches)
|
||
|
return result
|
||
|
|
||
|
|
||
|
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_maximum_digit_substrings(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")
|