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

31 lines
720 B
Python

import os
NUMBER_OF_INVOICES = 10
DIR = os.path.dirname(__file__)
HAMLET = "Hamlet"
def join_path(filename: str) -> str:
return os.path.join(DIR, filename)
with open(join_path("shakespeare.in"), "r", newline="", encoding="utf8") as file:
text = file.readlines()
found = True
hamlet_array_slow = []
for ind, line in enumerate(text):
for i in range(len(line)):
found = True
for j in range(len(HAMLET)):
if line[i + j] != HAMLET[j]:
found = False
break
if found:
print(ind + 1, ":", line, end="")
hamlet_array_slow.append(ind + 1)
break
# print(len(phrase_array_slow))