LV. 1 ์์ฐ
def solution(d, budget):
answer = 0
d.sort() # ๊ฐ๊ฒฉ ์ค๋ฆ์ฐจ์์ผ๋ก ์ ๋ ฌ
for p in d:
if budget - p >= 0:
budget -= p # ์์ ๊ฐ๊ฒฉ๋ถํฐ ์ง์ ๋ ์์ฐ์์ ๋นผ์ค๋ค.
answer += 1
return answer
LV. 1 ๋ถ์กฑํ ๊ธ์ก ๊ณ์ฐํ๊ธฐ
def solution(price, money, count):
total_price = 0
for m in range(1, count+1):
total_price += price * m
if (total_price - money) >= 0:
return (total_price - money)
else:
return 0