-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathluke11.py
More file actions
26 lines (22 loc) · 766 Bytes
/
luke11.py
File metadata and controls
26 lines (22 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import string
import numpy as np
alpha = string.ascii_lowercase
password = 'eamqia'
hints = [x.strip() for x in open('input/luke11.txt', 'r').readlines()]
def generate_passwords(hint: str):
words = []
while len(hint) > 0:
words.append(hint)
hint = hint[1:]
for i in range(0, len(hint)):
hint = hint[:i] + \
alpha[
(alpha.index(hint[i]) + 1 + alpha.index(words[-1][i])) %
len(alpha)] + \
hint[i+1:]
rectangle = [list(x) + ['']*(len(words[0])-len(x)) for x in words]
return ["".join(x) for x in np.rot90(rectangle)]
for hint in hints:
for candidate in generate_passwords(hint):
if password in candidate:
print(hint)