Greedy Coins
Greedy Coins
Write greedy_coins(amount: int, coins: list[int]) -> int that returns how many coins a greedy cashier uses: order the coin values from largest to smallest with sorted(coins)[::-1] and, for each coin, keep subtracting it from the amount still owed while it fits, counting one coin each time. The coins always include 1. Greedy is fast but not always optimal: with coins 25 10 1 and an amount of 30 it uses six coins (25 and five 1s) where three 10s would do; just report what greedy does. 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 count your function returns.
Expected Output:
6= newline. The output ends with a newline — print one after the last line.
Your Output
Run your code to see the output here...