Problem 138823 · easy · Phase 01 Prerequisites & Setup

Fewest Coins

functions · integer division · modulo

A vending machine gives change using quarters (25c), dimes (10c), nickels (5c) and pennies (1c). Write make_change(cents) that returns the smallest number of coins that adds up to cents.

Examples

Input:  cents = 41
Output: 4
Explanation: 25 + 10 + 5 + 1.

Input:  cents = 99
Output: 9

Input:  cents = 0
Output: 0

Constraints

  • 0 <= cents <= 10**6

Goals

  • Use `//` and `%` to take as many large coins as possible
  • Chain the same idea across several denominations
Starting Python…