1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def rotate_matrix_90(a):
'''
시계 방향으로 회전
'''
n = len(a)
m = len(a[0])
result = [[0] * n for _ in range(m)]
for i in range(n):
for j in range(m):
result[j][n-i-1] = a[i][j]
return result

def rotate_matrix_90_r(a):
'''
반시계 방향으로 회전
'''
n = len(a)
m = len(a[0])
result = [[0] * n for _ in range(m)]
for i in range(n):
for j in range(m):
result[n-j-1][i] = a[i][j]
return result