Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Cipher Map by kxy_2333
from typing import List
def recall_password(grille: List[str], password: List[str]) -> str:
ind1,ind2,ind3,ind4 = [],[],[],[]
ans = ''
for i,j in enumerate(grille):
for k,l in enumerate(j):
if l == 'X':
ind1.append([i,k])
for i in ind1:
ind2.append([i[1],3-i[0]])
for i in ind2:
ind3.append([i[1],3-i[0]])
for i in ind3:
ind4.append([i[1],3-i[0]])
ind1,ind2,ind3,ind4 = sorted(ind1),sorted(ind2),sorted(ind3),sorted(ind4)
ind = ind1 + ind2 + ind3 + ind4
for i in ind:
ans += password[i[0]][i[1]]
return ans
if __name__ == '__main__':
print("Example:")
print(recall_password(['X...', '..X.', 'X..X', '....'],
['itdf', 'gdce', 'aton', 'qrdi']))
# These "asserts" are used for self-checking and not for an auto-testing
assert recall_password(['X...', '..X.', 'X..X', '....'],
['itdf', 'gdce', 'aton', 'qrdi']) == 'icantforgetiddqd'
assert recall_password(['....', 'X..X', '.X..', '...X'],
['xhwc', 'rsqx', 'xqzz', 'fyzr']) == 'rxqrwsfzxqxzhczy'
print("Coding complete? Click 'Check' to earn cool rewards!")
April 27, 2022
Comments: