Coding Test/Programmers

프로그래머스 - Level.1 실패율(Python)

JUNG씨 2023. 1. 9. 16:41

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

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

 

 

이게 무슨말인지....^_^;;;

def solution(N, stages):
    answer = []
    total = len(stages)
    
    stage_ppl = []
    for i in range(1, N+1):
        num = stages.count(i)
        if num == 0:
            stage_ppl.append(0)
        else:
            stage_ppl.append(num/total)
        total -= stages.count(i)
        
    for i in range(N):
        pop_idx = stage_ppl.index(max(stage_ppl))
        answer.append(pop_idx + 1)
        stage_ppl[pop_idx] = -1
        
    return answer