프린터
Updated:
- 프로그래머스 level_2
단순구현
def solution(priorities, location):
answer = 0
# 인덱스 배열을 따로만들어준다
index = []
for i in range(len(priorities)):
index.append(i)
while True:
max = 0
tmp_index = -1
for i in range(len(priorities)):
if max<priorities[i]:
max = priorities[i]
tmp_index = i
for i in range(tmp_index):
priorities.append(priorities[0])
del priorities[0]
index.append(index[0])
del index[0]
answer = answer+1
if index[0] == location:
break
del priorities[0]
del index[0]
return answer
Leave a comment