Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Commented solution in Clear category for Cipher Map by ludek.reif
def recall_password(cipher_grille, ciphered_password):
# comprehension to read all 'X' by lines and characters positions
xs = [(lino, chno) for lino, line in enumerate(cipher_grille) for chno, char in enumerate(line) if char == 'X']
# list for all positions
positions = []
# read all positions of characters
# unturned
positions += sorted((x[0], x[1]) for x in xs)
# 90 degrees turned
positions += sorted((x[1], abs(x[0] - 3)) for x in xs)
# 180 degrees turned
positions += sorted((abs(x[0] - 3), abs(x[1] - 3)) for x in xs)
# 270 degrees turned
positions += sorted((abs(x[1] - 3), x[0]) for x in xs)
# comprehension to read all letter in password by positions and join to finale message
return ''.join(ciphered_password[lino][chno] for lino, chno in positions)
Oct. 22, 2019