Compare commits

..

No commits in common. "0188af8be3964bc50e7152f7c442cad201507b97" and "e4500a95f9bbdfb4c09bf9583041096442f1434f" have entirely different histories.

5 changed files with 5 additions and 144 deletions

View File

@ -4,11 +4,14 @@ file_name: str = "simple"
def find_hamlet_lines(text: str) -> list[str]:
pattern = re.compile(r"Hamlet", re.IGNORECASE)
# Define the regular expression pattern
pattern = re.compile(r".*Hamlet.*", re.IGNORECASE)
# Split the text into lines
lines = text.split("\n")
hamlet_lines = [line for line in lines if re.search(pattern, line)]
# Use the regular expression to find lines containing "Hamlet"
hamlet_lines = [line for line in lines if re.match(pattern, line)]
return hamlet_lines

View File

@ -1,34 +0,0 @@
import re
file_name: str = "simple"
def find_pies_lines(text: str) -> list[str]:
pattern = re.compile(r"\bpies\b", re.IGNORECASE)
lines = text.split("\n")
pies_lines = [line for line in lines if re.search(pattern, line)]
return pies_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_pies_lines(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")

View File

@ -1,34 +0,0 @@
import re
file_name: str = "simple"
def find_dates_1900_to_1999(text):
pattern = re.compile(r"19\d{2} r\.", re.IGNORECASE)
lines = text.split("\n")
date_lines = [line for line in lines if re.search(pattern, line)]
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")

View File

@ -1,33 +0,0 @@
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")

View File

@ -1,41 +0,0 @@
import re
FILE_NAME = "test"
MODE = "input"
def is_acronym(line):
acronym_pattern = re.compile(r"\b(?:PCMCIA|WYSIWYG|[A-Z]{2,5})\b")
if re.search(acronym_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_acronym(line))
for ind, found in enumerate(out):
if found == expected[ind]:
print(found)
else:
print("ERROR")
elif MODE == "input":
line = input("Enter a line: ")
# Check if the line is an acronym and print 'yes' or 'no'
if is_acronym(line) == "yes":
print("yes")
else:
print("no")