Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Cipher Map by Lachesis_132296
def make_empty():
new = []
for i in range(4):
new.insert(i, [])
for i in new:
for j in range(4):
i.insert(j, 0)
return new
def turn(matrix):
new = make_empty()
for i in range(4):
for j in range(4):
new[j][3-i] = matrix[i][j]
return new
def grille2matrix(g):
m = make_empty()
for i in range(4):
for j in range(4):
m[i][j] = g[i][j]
return m
def reading(grille, password):
pas = ""
for i in range(4):
for j in range(4):
if grille[i][j] == 'X':
pas += password[i][j]
return pas
def recall_password(cipher_grille, ciphered_password):
grille = grille2matrix(cipher_grille)
result = ""
for i in range(4):
result += reading(grille, ciphered_password)
grille = turn(grille)
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. 2, 2016