DevYoon

[ν”„λ‘œκ·Έλž˜λ¨ΈμŠ€] κΈ°λŠ₯개발 (Python) λ³Έλ¬Έ

PS/Programmers

[ν”„λ‘œκ·Έλž˜λ¨ΈμŠ€] κΈ°λŠ₯개발 (Python)

gimewn 2022. 4. 26. 15:47

link πŸ”— https://programmers.co.kr/learn/courses/30/lessons/42586

 

μ½”λ”©ν…ŒμŠ€νŠΈ μ—°μŠ΅ - κΈ°λŠ₯개발

ν”„λ‘œκ·Έλž˜λ¨ΈμŠ€ νŒ€μ—μ„œλŠ” κΈ°λŠ₯ κ°œμ„  μž‘μ—…μ„ μˆ˜ν–‰ μ€‘μž…λ‹ˆλ‹€. 각 κΈ°λŠ₯은 진도가 100%일 λ•Œ μ„œλΉ„μŠ€μ— λ°˜μ˜ν•  수 μžˆμŠ΅λ‹ˆλ‹€. 또, 각 κΈ°λŠ₯의 κ°œλ°œμ†λ„λŠ” λͺ¨λ‘ λ‹€λ₯΄κΈ° λ•Œλ¬Έμ— 뒀에 μžˆλŠ” κΈ°λŠ₯이 μ•žμ— μžˆλŠ”

programmers.co.kr

 

import math
def solution(progresses, speeds):
    answer = []
    length = len(progresses)
    left = [0]*length
    for idx in range(length):
        left[idx] = math.ceil((100-progresses[idx])/speeds[idx])
    idx = 1
    temp = 0
    while True:
        if len(left) == 1:
            answer.append(temp+1)
            break
        if left[0] >= left[idx]:
            temp += 1
            left.pop(idx)
        elif left[0] < left[idx]:
            answer.append(temp+1)
            left.pop(0)
            idx = 1
            temp = 0
    return answer