Write a rule coins to find all the combinations of U.S. coins,
except for pennies, whose value is a given amount. (I'm leaving out
pennies since otherwise there are too many combinations. Include 50 cent
and 1 dollar coins though.) For example:
coins(10,L)
should succeed with L=[10], i.e. one way of getting
10 cents is a single dime. On backtracking it should also succeed with
L=[5,5], i.e. two nickels.
It's OK to return the same answer a second time when you backtrack -- for
example, if you are finding combinations for 15 cents, you can return
[10,5] and also [5,10].
Using your coins rule:
- Find all the combinations of coins with value 35 cents.
- Find all the combinations of coins with value 12 cents. (Remember, no
pennies.)
- Find the value of two quarters and a dime.
- Find all the amounts of money that can be given using exactly two coins.
- Find all the amounts of money that can be given using 0 to 2 coins.