배고픈 개발자 이야기

[2019 kakao blind] 실패율 본문

알고리즘 문제/PROGRAMMERS

[2019 kakao blind] 실패율

이융희 2021. 7. 31. 16:05
728x90

귀찮 나중에

 

 

def solution(N, stages):
    answer = []
    temp = dict()
    stage_len = len(stages)
    count_sum = 0
    
    for num in range(1, N + 1):    
        num_cnt = 0
        if stage_len - count_sum > 0:
            num_cnt = stages.count(num)
            failed = num_cnt / (stage_len - count_sum)
            #[stages.remove(num) for _ in range(num_cnt)]
        else:
            failed = .0
        temp[num] = failed
        count_sum += num_cnt
        
    #def f2(x):
    #    return x[1]    
    #sorted_failed = sorted(temp.items(), key=f2)
    sorted_failed = sorted(temp.items(), key=(lambda x: x[1]), reverse = True)

    return [stage[0] for stage in sorted_failed]
Comments