-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |