Skip to content

Commit

Permalink
Create 프린터.md
Browse files Browse the repository at this point in the history
  • Loading branch information
borricha authored Aug 17, 2022
1 parent dfbd207 commit bcb0ef5
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions programmers/고득점 kit_스택큐/프린터.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
https://school.programmers.co.kr/learn/courses/30/lessons/42587#
---

문제 자체는 어렵지 않았는데, 이해를 잘못해서 살짝 돌아갔다. "인쇄"하는 순서이다. 첫번째 인쇄하는 시점에 뒤에 남아있는 순번이 아니다.

```python
def solution(priorities, location):

location += 1
count = 0

while True:
flag = 0
current = priorities[0]
for i in range(1, len(priorities)):
if priorities[i] > current:
temp = priorities.pop(0)
priorities.append(temp)
flag = 1
location -= 1
if location == 0:
location = len(priorities)
break

#인쇄 하지 못하는 경우
if flag == 1:
continue

#내가 원하는 페이지를 인쇄하는 경우
elif location == 1:
return count + 1

#내가 원하지 않는 페이지를 인쇄하는 경우
else:
count += 1
priorities.pop(0)
location -= 1
continue
```

0 comments on commit bcb0ef5

Please sign in to comment.