Programmers 기능개발
기능개발
https://school.programmers.co.kr/learn/courses/30/lessons/42586
Explanation
Well, technically it is a stack question but zipping through the list is
easier. We first set the first progress count with the first element in the
progress list. If we see a value less than this count, we just increment count
but when we have a greater value, then we set this original progress count
as this greater value and append our count
to our answer list. Lastly,
don’t forget to reset the count
to one.
Once we finished iterating, the last count
need to be appended.
import math
def solution(progresses, speeds):
count = 0
answer = []
for progress, speed in zip(progresses, speeds):
hola = 0
day = math.ceil((100 - progress) / speed)
if day <= count:
hola += 1
else:
count = day
if hola > 0:
answer.append(hola)
hola = 1
answer.append(hola) # Append the count of the last set
return answer