Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Cipher Map by iwo.malyszka
# migrated from python 2.7
import itertools
def flatten(cipher_grille, ciphered_password):
new_grille = []
for i in cipher_grille:
for j in i:
if j == 'X':
new_grille.append(True)
else:
new_grille.append(False)
new_password = []
for m in ciphered_password:
for n in m:
new_password.append(n)
text = ''.join(itertools.compress(new_password, new_grille))
return text
def recall_password(cipher_grille, ciphered_password):
pss = ''
for i in range(4):
pss += flatten(cipher_grille, ciphered_password)
cipher_grille = [''.join(x) for x in zip(*cipher_grille[::-1])]
return pss
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'
Nov. 6, 2016
Comments: