jfz-2023-s473555/TaskA03/run.py
2023-10-21 02:07:06 +02:00

50 lines
1.0 KiB
Python

import os
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("polish_wiki_excerpt.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, end="")
phrase_array_slow.append(ind + 1)
break
# print(len(phrase_array_slow))