42 lines
1.0 KiB
Python
42 lines
1.0 KiB
Python
import re
|
|
|
|
FILE_NAME = "test"
|
|
|
|
MODE = "test"
|
|
|
|
|
|
def is_correct(line: str):
|
|
looking_pattern = re.compile(r"^\d{3}-\d{3}-\d{2}-\d{2}$|^\d{3}-\d{2}-\d{2}-\d{3}$")
|
|
|
|
if re.search(looking_pattern, line):
|
|
return "yes"
|
|
else:
|
|
return "no"
|
|
|
|
|
|
if MODE == "test":
|
|
with open(FILE_NAME + ".in", "r", newline="", encoding="utf8") as file:
|
|
text = [line.rstrip() for line in file.readlines()]
|
|
|
|
with open(FILE_NAME + ".exp", "r", newline="", encoding="utf8") as file:
|
|
expected = [line.rstrip() for line in file.readlines()]
|
|
|
|
out: list[str] = []
|
|
for line in text:
|
|
out.append(is_correct(line))
|
|
|
|
for ind, found in enumerate(out):
|
|
if found == expected[ind]:
|
|
print(found)
|
|
else:
|
|
print(f"ERROR: expected - {expected[ind]}, found - {found}")
|
|
|
|
elif MODE == "input":
|
|
line = input("Enter a line: ")
|
|
|
|
# Check if the line is an acronym and print 'yes' or 'no'
|
|
if is_correct(line) == "yes":
|
|
print("yes")
|
|
else:
|
|
print("no")
|