From 1060b283bf4126afc1efd32cb41a8830cf185940 Mon Sep 17 00:00:00 2001 From: HOME-VM-TOSCHOOL Date: Tue, 17 Oct 2023 05:04:58 +0200 Subject: [PATCH] A03 --- TaskA03/run.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 TaskA03/run.py diff --git a/TaskA03/run.py b/TaskA03/run.py new file mode 100644 index 0000000..933b283 --- /dev/null +++ b/TaskA03/run.py @@ -0,0 +1,57 @@ +import os +from sre_parse import DIGITS + + +NUMBER_OF_INVOICES = 10 +DIR = os.path.dirname(__file__) +PHRASE = "19** r." +DIGITS = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] + + +def join_path(filename: str) -> str: + return os.path.join(DIR, filename) + + +with open(join_path("simple.in"), "r", newline="", encoding="utf8") as file: + text = file.readlines() + + +def in_set(letter, set): + for i in set: + if i == letter: + return True + return False + + +def find_me(): + for j in range(len(PHRASE)): + if PHRASE[j] == "*" and in_set(line[i + j], DIGITS): + continue + + if line[i + j] != PHRASE[j] and line[i + j] != PHRASE[j].capitalize(): + return False + + return True + + +found = True +phrase_array_slow = [] +for ind, line in enumerate(text): + for i in range(len(line)): + found = True + found = find_me() + + if found: + # print(ind + 1, ":", line[i:], end="") + phrase_array_slow.append(ind + 1) + break + + +# show numbers that are not in phrase_array and in rage of len(phrase_array_slow) +not_in_phrase_array = [ + num for num in range(1, len(phrase_array_slow) + 1) if num not in phrase_array_slow +] +print(*not_in_phrase_array, sep="\n") + + +# print(*phrase_array_slow, sep="\n")