

나의 코드
def solution(d, budget):
answer = 0
total_budget = 0
while True:
if len(d) == 0 or (total_budget + min(d)) > budget:
break
elif total_budget + min(d) <= budget:
total_budget+=min(d)
answer += 1
d.remove(min(d))
print(answer)
return answer
solution([1,3,2,5,4],9)
'코딩테스트 파이썬 > 파이썬 프로그래머스 1단계' 카테고리의 다른 글
| 삼총사 (0) | 2023.05.15 |
|---|---|
| 시저 암호 (0) | 2023.05.15 |
| 이상한 문자 만들기 (0) | 2023.05.15 |
| 3진법 뒤집기 (0) | 2023.05.14 |
| 같은 숫자는 싫어 (0) | 2023.05.14 |