Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in 3rd party category for Cipher Map by akisame338
import numpy
ROTATE_TIME = 4
ROWS = 4
COLS = 4
def recall_password(cipher_grille, ciphered_password):
password = ''
for n in range(ROTATE_TIME):
rotated_grille = rotate(cipher_grille, n)
password += ''.join([ciphered_password[i][j] for i in range(ROWS) for j in range(COLS) if rotated_grille[i][j] == 'X'])
return password
def rotate(cipher_grille, n):
rotated = list(map(list, cipher_grille))
for i in range(n):
rotated = [ary.tolist()[::-1] for ary in numpy.array(rotated).T]
return rotated
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'
Feb. 28, 2017
Comments: