this code works in the editor (assertions are ok) but it does not pass server validation;
not sure why...
rotated90 = lambda m : zip(*m[::-1])
def letter((grid, pasw)):
a=""
pairs=zip(grid, pasw)
for g,p in pairs:
if g is 'X':
a+=p
return a
def recall_password(cipher_grille, ciphered_password):
r=''
for i in [1]*4:
pairs=zip(cipher_grille, ciphered_password)
r += ''.join(map(letter, pairs))
cipher_grille=rotated90(cipher_grille)
return r
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'
Created at: 2016/05/26 13:42; Updated at: 2017/05/21 20:06
The question is resolved.