Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Cipher Map by Krzysztof__wierblewski
def recall_password(cipher_grille, ciphered_password):
"""
Funkcja wykonujaca obrot planszy o 90 stopni
"""
def rotate (list):
x = 0
y = 0
new_grille = [[0 for col in range(5)] for row in range(5)]
while y <4 :
x = 0
while x <4:
if list[y][x] == 'X':
temp = y
newY = x
newX = 3 - temp
new_grille [newY][newX] = 'X'
x = x + 1
y = y + 1
return new_grille
print("x")
"""
Funkcja odczyujaca litery hasla
"""
def read (grille, password):
x = 0
y = 0
strPass = ""
while y <4 :
x = 0
while x <4:
if grille[y][x] == 'X':
zapX = x
zapY = y
print(zapX,zapY)
strPass = strPass + password[y][x]
x = x + 1
y = y + 1
return strPass
#========================main===================================================
password = read(cipher_grille, ciphered_password) #odczyt pierwszych 4 liter hasla bez obrotu siatki
nowe = rotate(cipher_grille) #wywolanie fukcji obrotu siatki
password = password + read(nowe,ciphered_password) #odczyt kolejnych 4 liter
for i in range(1,3): #obrot i odczyt reszty hasla
nowe = rotate(nowe)
password = password + read(nowe,ciphered_password)
return password
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'
Jan. 30, 2017