[ 2023-05-29 ๐Ÿชข TIL ]

Burkeyยท2023๋…„ 5์›” 29์ผ
0

TIL

๋ชฉ๋ก ๋ณด๊ธฐ
88/157

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
profile
์Šคํƒฏ ์˜ฌ๋ฆฌ๋Š” ์ค‘

0๊ฐœ์˜ ๋Œ“๊ธ€