Using only pennies (1), nickels (5), dimes (10), quarters (25), half dollars (50), and dollars (100), how many different combinations can be made from a given amount in cents.
Example 1:
>>change(17)
%Output will be the the number of combinations of coins to make 17 cents.
c =
6
There are 6 combinations:
17 pennies
12 pennies and 1 nickel
7 pennies and 2 nickels
2 pennies and 3 nickels
7 pennies and 1 dime
2 pennies, 1 nickel, and 1 dime.
Example 2:
>>change(100)
c =
293
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers52
Suggested Problems
-
1471 Solvers
-
Project Euler: Problem 2, Sum of even Fibonacci
2835 Solvers
-
Calculate the Hamming distance between two strings
345 Solvers
-
Generate a vector like 1,2,2,3,3,3,4,4,4,4
13705 Solvers
-
Area of an equilateral triangle
6801 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
please Ken, could you add a few more test cases of change(x) using x values greater than 100 to remove my (lame) look-up table leading solution? sorry!