def solution(progresses, speeds):
answer = []
# progresses가 남아있는 이상 계속 while
while progresses:
cnt=0
# progresses가 없는데 pop 할 수 없으므로 progresses가 True인지 확인 추가
while progresses and progresses[0] >=100:
cnt+=1
progresses.pop(0)
speeds.pop(0)
progresses = [(progresses[i] + speeds[i]) for i in range(len(progresses))]
# cnt는 계속 넣어주는데 0이 아니면 넣어주지 않음
if cnt != 0:
answer.append(cnt)
return answer
# progresses에 speeds를 게속 더하면서 100이 넘을 시 cnt를 세고 pop으로 빼줌
'코딩테스트 | python > 프로그래머스' 카테고리의 다른 글
| [프로그래머스 | python] 전화번호 목록 (2회차) (0) | 2024.02.15 |
|---|---|
| [프로그래머스 | python] 폰켓몬 (0) | 2024.02.06 |
| [프로그래머스 | python] 같은 숫자는 싫어 (0) | 2024.02.06 |
| [프로그래머스 | python] 전화번호 목록 (0) | 2024.02.06 |
| [프로그래머스 | python] 완주하지 못한 선수 (1) | 2024.02.06 |