Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Cipher Map by kamilinho20
def recall_password(cipher_grille, ciphered_password):
result = ""
map1 = [['.','.','.','.'],['.','.','.','.'],['.','.','.','.'],['.','.','.','.']]
map2 = [['.','.','.','.'],['.','.','.','.'],['.','.','.','.'],['.','.','.','.']]
map3 = [['.','.','.','.'],['.','.','.','.'],['.','.','.','.'],['.','.','.','.']]
map4 = [['.','.','.','.'],['.','.','.','.'],['.','.','.','.'],['.','.','.','.']]
for i in range(4):
for j in range(4):
if cipher_grille[i][j] == 'X':
map1[i][j] = ciphered_password[i][j]
map2[j][3-i] = ciphered_password[j][3-i]
map3[3-i][3-j] = ciphered_password[3-i][3-j]
map4[3-j][i] = ciphered_password[3-j][i]
if map1[i][j] != '.':
result = result + map1[i][j]
for i in range(4):
for j in range(4):
if map2[i][j] != '.':
result = result + map2[i][j]
for i in range(4):
for j in range(4):
if map3[i][j] != '.':
result = result + map3[i][j]
for i in range(4):
for j in range(4):
if map4[i][j] != '.':
result = result + map4[i][j]
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'
Dec. 13, 2016