#27 · Greedy · Beginner · 30 XP · about 6 min
A cashier pays out change with coins worth 25, 10, 5 and 1 cents and always wants to hand over as few coins as possible. Write make_change(cents) that returns a list of four whole numbers: how many 25-cent, 10-cent, 5-cent and 1-cent coins to give, in that order.
make_change(41) # returns [1, 1, 1, 1] make_change(30) # returns [1, 0, 1, 0] make_change(99) # returns [3, 2, 0, 4]
41 cents is one coin of each kind: 25 + 10 + 5 + 1.
0 <= cents <= 10000Ready?
Accept the challenge to start writing. A small timer counts the time this page is in view.
Output appears here.