about | help | code help+videos | done | prefs |
change
Change we can believe in! Given an amount of money (in cents), return the number of ways to use change (coins) that total to that amount. The denominations of coins are 1, 5, 10, 25, 50, and 100; you may use any number of any of these coins. For example change(10) should return 4; the 4 ways are: a dime (10), two nickels (5, 5), a nickel and 5 pennies (5, 1, 1, 1, 1, 1), or 10 pennies (1, 1, 1, 1, 1, 1, 1, 1, 1, 1). (You don't have to list these, just return the total number of different ways. Note that "a nickel and 5 pennies" is one way; we don't care about the order of the nickel with respect to the pennies, so "5 pennies and a nickel" would not count as a different way, nor would "2 pennies, a nickel, and 3 more pennies".) change(10) → 4 change(14) → 4 change(25) → 13 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 500 Post-solution available
Copyright Nick Parlante 2017 - privacy