본문 바로가기
파이썬 코딩테스트/프로그래머스

프로그래머스 / 실패율 / 파이썬

by S.T.Lee 2022. 2. 27.

https://programmers.co.kr/learn/courses/30/lessons/42889

def solution(N, stages):
    clear = {}
    stage_num = len(stages)
    for n in range(1, N+1):
        try:
            if n != N:
                clear[n] = stages.count(n) / stage_num
                stage_num -= stages.count(n)
            else:
                clear[n] = stages.count(n) / stage_num
        except:
            clear[n] = 0
    return sorted(clear, key=lambda x:clear[x], reverse=True)