July 08, 2021
def solution(d, budget):
answer = 0
d.sort()
while budget > 0:
if (budget - d[0] >= 0):
budget -= d[0]
answer += 1
d.pop(0)
if len(d) == 0 or budget < min(d):
break
return answer
def solution(d, budget):
d.sort()
while budget < sum(d):
d.pop()
return len(d)