-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathencrypt.py
25 lines (21 loc) · 1.06 KB
/
encrypt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import move
def encrypt(cube, moves):
for rotation in moves:
if rotation.type == move.Move.rotation_row:
cube.rotate_row(rotation.row_or_column, rotation.times)
elif rotation.type == move.Move.rotation_column:
cube.rotate_column(rotation.row_or_column, rotation.times)
elif rotation.type == move.Move.rotation_clockwise:
cube.rotate_clockwise()
elif rotation.type == move.Move.rotation_anti_clockwise:
cube.rotate_anti_clockwise()
def decrypt(cube, moves):
for rotation in reversed(moves):
if rotation.type == move.Move.rotation_row:
cube.rotate_row(rotation.row_or_column, cube.matrix.__len__() - rotation.times)
elif rotation.type == move.Move.rotation_column:
cube.rotate_column(rotation.row_or_column, cube.matrix[0].__len__() - rotation.times)
elif rotation.type == move.Move.rotation_clockwise:
cube.rotate_anti_clockwise()
elif rotation.type == move.Move.rotation_anti_clockwise:
cube.rotate_clockwise()