-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path24tht_rote.py
More file actions
executable file
·51 lines (49 loc) · 1.46 KB
/
Copy path24tht_rote.py
File metadata and controls
executable file
·51 lines (49 loc) · 1.46 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def rotate_matrix(matrix):
matrix1 = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
matrix1[0][0] = matrix[1][0]
matrix1[0][1] = matrix[0][0]
matrix1[0][2] = matrix[0][1]
matrix1[1][0] = matrix[2][0]
matrix1[1][1] = matrix[1][1]
matrix1[1][2] = matrix[0][2]
matrix1[2][0] = matrix[2][1]
matrix1[2][1] = matrix[2][2]
matrix1[2][2] = matrix[1][2]
return matrix1
def reverse_rotate_matrix(matrix):
matrix1 = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
matrix1[0][0] = matrix[0][1]
matrix1[0][1] = matrix[0][2]
matrix1[0][2] = matrix[1][2]
matrix1[1][0] = matrix[0][0]
matrix1[1][1] = matrix[1][1]
matrix1[1][2] = matrix[2][2]
matrix1[2][0] = matrix[1][0]
matrix1[2][1] = matrix[2][0]
matrix1[2][2] = matrix[2][1]
return matrix1
mat = [[int(i) for i in input().split()] for _ in range(0, 3)]
int(input())
for i in (int(i) for i in input().split()):
if i == 1:
submat = []
for i in mat:
submat.append(i[:3])
#print(submat)
submat = rotate_matrix(submat)
for i in range(0, 3):
for j in range(0, 3):
mat[i][j] = submat[i][j]
else:
submat = []
for i in mat:
submat.append(i[1:4])
#print(submat)
submat = reverse_rotate_matrix(submat)
for i in range(0, 3):
for j in range(1, 4):
mat[i][j] = submat[i][j - 1]
#print(submat)
#print(mat)
for i in mat:
print(*i)