Skip to content

Commit 2f10f72

Browse files
committed
adds programming 1833
1 parent 3936693 commit 2f10f72

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

programming-py/1833.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def max_icecream(costs, coins):
2+
costs.sort()
3+
buyable = 0
4+
for each in costs:
5+
if each <= coins:
6+
buyable += 1
7+
coins -= each
8+
else:
9+
return buyable
10+
return buyable
11+
12+
13+
# test below
14+
print(max_icecream([1, 3, 2, 4, 1], 7))
15+
print(max_icecream([10, 6, 8, 7, 7, 8], 5))
16+
print(max_icecream([7, 3, 3, 6, 6, 6, 10, 5, 9, 2], 56))

0 commit comments

Comments
 (0)