Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
using another function and a clever way of rotating through zip() solution in Clear category for Cipher Map by marcel.sliwinski
def read(cipher_grille, ciphered_password):
ans=''
for i in range (4):
for j in range(4):
if (cipher_grille[i][j]=='X'):
ans=ans+ciphered_password[i][j]
return ans
def recall_password(cipher_grille, ciphered_password):
ans=''
ans=ans+read(cipher_grille, ciphered_password)
cipher_grille=zip(*cipher_grille[::-1])
cipher_grille=list(cipher_grille)
ans=ans+read(cipher_grille, ciphered_password)
cipher_grille=zip(*cipher_grille[::-1])
cipher_grille=list(cipher_grille)
ans=ans+read(cipher_grille, ciphered_password)
cipher_grille=zip(*cipher_grille[::-1])
cipher_grille=list(cipher_grille)
ans=ans+read(cipher_grille, ciphered_password)
return ans
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. 23, 2017