This commit is contained in:
HOME-VM-TOSCHOOL 2023-10-17 04:21:48 +02:00
parent e5e1e10494
commit 87f198acc2

View File

@ -10,18 +10,28 @@ def join_path(filename: str) -> str:
return os.path.join(DIR, filename) return os.path.join(DIR, filename)
with open(join_path("simple.in"), "r", newline="", encoding="utf8") as file: with open(
join_path("polish_wiki_excerpt.in"), "r", newline="", encoding="utf8"
) as file:
text = file.readlines() text = file.readlines()
def not_in(letter, set):
for i in set:
if i == letter:
return False
return True
def find_me(): def find_me():
for j in range(len(PHRASE)): for j in range(len(PHRASE)):
if line[i + j] != PHRASE[j] and line[i + j] != PHRASE[j].capitalize(): if line[i + j] != PHRASE[j] and line[i + j] != PHRASE[j].capitalize():
return False return False
if line[i - 1] not in [" ", "\t", "\n"]: if not_in(line[i - 1], [" ", "\n"]):
return False return False
if line[i + len(PHRASE)] not in [" ", "\t", "\n", "\r"]:
if not_in(line[i + len(PHRASE)], [" ", "\n", "\r"]):
return False return False
return True return True