-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcipher-map2.py
More file actions
31 lines (28 loc) · 820 Bytes
/
cipher-map2.py
File metadata and controls
31 lines (28 loc) · 820 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
27
28
29
30
31
def recall_password(cipher_grille, ciphered_password):
result = ''
cipher_list = [list(x) for x in cipher_grille]
for r in range(0, 4):
for k, row in enumerate(cipher_list):
for i in [i for i, x in enumerate(row) if x == 'X']:
result += ciphered_password[k][i]
cipher_list = list(zip(*cipher_list[::-1]))
return result
if __name__ == '__main__':
assert recall_password(
('X...',
'..X.',
'X..X',
'....'),
('itdf',
'gdce',
'aton',
'qrdi')) == 'icantforgetiddqd', 'First example'
assert recall_password(
('....',
'X..X',
'.X..',
'...X'),
('xhwc',
'rsqx',
'xqzz',
'fyzr')) == 'rxqrwsfzxqxzhczy', 'Second example'