← Back to challenges

Coins Combinations

PythonHardarraysnumberslogic

Instructions

Given an amount of money and a list of coins denominations, create a function that counts how many different ways you can make change with the given money.

Examples

coins_combinations(4, [1, 2]) ➞ 3
# 1+1+1+1 = 4
# 1+1+2 = 4
# 2+2 = 4

coins_combinations(10, [5, 2, 3]) ➞ 4

coins_combinations(11, [5, 7]) ➞ 0

Notes

  • Order of coins does not matter (i.e. 1+1+2 == 2+1+1).
  • You have an infinite amount of coins.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.