Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Using numpy matrix solution in Clear category for Cipher Map by michal_bien
import numpy as np
def part_decode(transp_grille, ciphered_password):
i=0
res=''
while i<4:
j=0
while j<4:
if transp_grille[i][j]=='X':
res+=ciphered_password[i][j]
j+=1
i+=1
return res
def turn(matrix):
matrix = np.matrix(matrix).transpose()
newm = []
for line in matrix.tolist():
newm.append(line[::-1])
return(newm)
def recall_password(cipher_grille, ciphered_password):
matrix = []
res=''
for line in cipher_grille:
matrix.append(list(line))
res+=part_decode(cipher_grille, ciphered_password)
for x in range(0,3):
matrix = turn(matrix)
res+=part_decode(matrix, ciphered_password)
return res
Oct. 9, 2016