Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Creative category for Cipher Map by lukasz.bogaczynski
def recall_password(pattern, letters):
deciphered_text = [{}, {}, {}, {}]
number_of_x = 0
for row in range(0, 4):
if number_of_x == 4:
break
for column in range(0, 4):
if number_of_x == 4:
break
if pattern[row][column] == 'X':
deciphered_text[0][(row * 4) + column] = letters[row][column]
deciphered_text[1][(column * 4) + 3 - row] = letters[column][3 - row]
deciphered_text[2][((3 - row) * 4) + 3 - column] = letters[3 - row][3 - column]
deciphered_text[3][((3 - column) * 4) + row] = letters[3 - column][row]
number_of_x = number_of_x + 1
result = []
for i in range(0, 4):
[result.append(deciphered_text[i][key]) for key in sorted(deciphered_text[i].keys())]
return ''.join([str(x) for x in 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'
Oct. 20, 2017