728x90
반응형
SMALL
프로그래머스 Level 1 실패율을 파이썬을 통해 풀어보았다.
programmers.co.kr/learn/courses/30/lessons/42889
Level 1 - 실패율
#Level 1 실패율.py
def solution(N, stages):
answer = []
fail = [0]*N
fail_percent = []
for i in stages :
if i > N :
continue
fail[i-1] += 1
sum = len(stages)
for i in fail :
if sum == 0 :
fail_percent.append(0)
else :
fail_percent.append(i/sum)
sum -= i
for i in range(len(fail_percent)) :
answer.append(fail_percent.index(max(fail_percent))+1)
fail_percent[fail_percent.index(max(fail_percent))]=-1
return answer
728x90
반응형
SMALL
'Problem Solving > programmers' 카테고리의 다른 글
[programmers] Level 1 두 개 뽑아서 더하기.py (0) | 2021.05.14 |
---|---|
[programmers] Level 1 3진법 뒤집기.java (0) | 2021.05.14 |
[programmers] Level 1 예산.py (0) | 2021.05.09 |
[programmers] Level 1 폰켓몬.java (0) | 2021.05.09 |
[programmers] Level 1 키패드 누르기.py (0) | 2021.05.07 |