31 lines
720 B
Python
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))
|