1번
def solution(numbers):
return 45-sum(numbers)
2번
def solution(grid):
answer = []
cycle = 0
m = len(grid)
o = len(grid[0])
edges = [[[False for _ in range(4)] for _ in range(o)]for _ in range(m)]
dx = [0,0,1,-1]
dy = [1,-1,0,0]
for i in range(m):
for j in range(o):
for k in range(4):
x, y, kk = i, j, k
while True:
if edges[x][y][kk] == False:
edges[x][y][kk] = True
x, y = (x+dx[kk])%m, (y+dy[kk])%o
if grid[x][y]=='L':
if kk==0: kk = 3
elif kk==1: kk = 2
elif kk==2: kk = 0
else: kk = 1
elif grid[x][y]=='R':
if kk==0: kk = 2
elif kk==1: kk = 3
elif kk==2: kk = 1
else: kk = 0
cycle += 1
else:
if cycle != 0:
answer.append(cycle)
cycle = 0
break
answer.sort()
return answer