배치하기1 정수를 나선형으로 배치하기 def solution(n): answer = [[0]*n for i in range(n)] x, y = 0, 0 move_state = 0#right==0, down = 1, left=2, up=3 for i in range(1,(n*n)+1): answer[y][x] = i if move_state == 0: x+=1 elif move_state == 1: y+=1 elif move_state == 2: x-=1 elif move_state == 3: y-=1 if (move_state==0 and (x+1 >= n or answer[y][x+1.. 2024. 5. 4. 이전 1 다음