title: Minimum number of coins to make up an amount using recursion
body: <p>The problem is the popular one to illustrate Dynamic Programming, which is as follows. We have unlimited coins of each of the denominations 1, 3, and 5. We want the minimum number of coins to get the amount N. </p>
  
  <p>I am aware of the Dynamic Programming method where we build up a solution from the base case(s). But I wanted to see how to write a purely recursive solution. I am able to work it out easily by hand for N = 11 and denominations = [1,3,5]. But for some reason I am unable to make the following work.</p>
  
  <pre><code>    def minNumberOfCoins(amount, denominations):
          if amount &lt;= 0:
              return(0)
          if amount in denominations:
              return(1)
          else:
              listToExamine = list(filter(lambda x: x &gt; 0, map(lambda x: amount - x, denominations)))
              print(listToExamine)
              minVal = min(listToExamine, key=lambda x: 1 + minNumberOfCoins(x, denominations))
              return(minVal)
  </code></pre>
  
  <p>As far as I can tell, the logic is identical to what I worked out on paper. Is there some nuance in Python's recursion I am not aware of, or is there something subtle I have been missing? Thank you!</p>