큐 = 선입 선출 구조의 정렬 알고리즘
enque : 데이터를 넣는 ↔ deque : 원소를 빼는
front : 큐에서 가장 첫번째 값 a[0] ↔ rear : 큐에서 가장 마지막 값 a[-1]
K번째를 계속해서 뽑아내는 요세푸스 문제를 해결해라
joseph = []
idx = 0
while lst:
idx = (idx+K-1) % len(lst)
num = lst.pop(idx)
joseph.append(num)
while True:
y_i += y[idx]
x_i += x[idx]
if y_i in range(1,N+1) and x_i in range(1,N+1) and (x_i,y_i) not in length:
time+=1
if length and apple[x_i][y_i]==0:
length.popleft()
else:
apple[x_i][y_i]=0
length.append((x_i,y_i))
if i < L and time == dir[i][0]:
if dir[i][1] == "D":
idx=(idx+1)%4
else:
idx=(idx-1)%4
i+=1
else:
break