CJCoding With Joseph
15free / daySign inCreate account

Greedy Coins Used

Write greedy_coins_used(amount: int, coins: list[int]) -> list[int] that returns the list of coins a greedy cashier hands out: go through the coin values from largest to smallest (the starter orders them with sorted(coins)[::-1]) and, while the current coin still fits in remaining, append it to used and subtract it. The coins always include 1, so the amount is always reached. Do NOT write a main block or any top-level test code; the tests construct the calls. Input: two lines, the amount and then the space-separated coin values; the tests print the list your function returns.

Expected Output:

[25, 25, 10, 5, 1, 1]

= newline. The output ends with a newline — print one after the last line.

Hints3 available
Topics:
Data Structures & Algorithms
📥 Auto-Input:
67\n25 10 5 1\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.