Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Cipher Map by welv
import itertools
def password(cipher_grille, ciphered_password):
g = [True if j == "X" else False for i in cipher_grille for j in i]
p = [j for i in ciphered_password for j in i]
return "".join(itertools.compress(p, g))
def recall_password(cipher_grille, ciphered_password):
result = ""
for i in range(4):
result += password(cipher_grille, ciphered_password)
cipher_grille = list(map(lambda x: "".join(x), zip(*cipher_grille[::-1])))
return result
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'
Jan. 20, 2017