diff --git a/TaskA02/run.py b/TaskA02/run.py index 4e63a09..6b5eac5 100644 --- a/TaskA02/run.py +++ b/TaskA02/run.py @@ -10,18 +10,28 @@ def join_path(filename: str) -> str: 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() +def not_in(letter, set): + for i in set: + if i == letter: + return False + return True + + def find_me(): for j in range(len(PHRASE)): if line[i + j] != PHRASE[j] and line[i + j] != PHRASE[j].capitalize(): return False - if line[i - 1] not in [" ", "\t", "\n"]: + if not_in(line[i - 1], [" ", "\n"]): return False - if line[i + len(PHRASE)] not in [" ", "\t", "\n", "\r"]: + + if not_in(line[i + len(PHRASE)], [" ", "\n", "\r"]): return False return True