Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Cipher Map by CyprianSzlachciak
def uzyjse(A,B):
s=""
for i in range(0,4):
for j in range(0,4):
if A[i][j]=='X':
s+=B[i][j]
return s
def trans(G):
A=[[],[],[],[]]
for i in range(0,4):
A[i]=G[i]
for i in range(0,4):
G[i]= " ".join(G[i])
G[i]=G[i].split()
"""A[i]= " ".join(A[i])
A[i]=A[i].split()"""
b = 0
for i in range(0, 4):
a = 3
for j in range(0, 4):
A[i][j] = G[a][b]
a -= 1
b += 1
return A
def recall_password(cipher_grille, ciphered_password):
P=[[],[],[],[]]
G=[[],[],[],[]]
for i in range(0,4):
G[i]+=cipher_grille[i]
P[i]+=ciphered_password[i]
word=""
for i in range(0,4):
G[i]= " ".join(G[i])
G[i]=G[i].split()
H =[G,G,G,G]
for i in range(1,4):
H[i]=trans(H[i-1])
for i in range(0,4):
word+=uzyjse(H[i],P)
print(word)
#print(trans(G))
#print(trans(G))
#print(trans(G))
return word
"""
for i in range(0,4):
G[i]= " ".join(G[i])
G[i]=G[i].split
P[i]= " ".join(P[i])
P[i]=P[i].split()"""
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. 24, 2016