From 87f198acc206117f82a29c6c3da52178e78363e7 Mon Sep 17 00:00:00 2001 From: HOME-VM-TOSCHOOL Date: Tue, 17 Oct 2023 04:21:48 +0200 Subject: [PATCH] A02 --- TaskA02/run.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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