33 lines
885 B
Python
33 lines
885 B
Python
def recall_password(cipher_grille, ciphered_password):
|
|
password = ""
|
|
for rotation in range(4):
|
|
for i, row in enumerate(cipher_grille):
|
|
for j, cell in enumerate(row):
|
|
if cell == "X":
|
|
password += ciphered_password[i][j]
|
|
cipher_grille = list(zip(*cipher_grille[::-1]))
|
|
return password
|
|
|
|
|
|
if __name__ == '__main__':
|
|
# These "asserts" using only for self-checking and not necessary for auto-testing
|
|
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'
|