Lecture Notes on 28 Apr 2017 def dpMakeChange (coinList, change, minCoins, coinsUsed): for cents in range (change + 1): coinCount = cents newCoin = 1 for j in [c for c in coinList if c <= cents]: if minCoins[cents - j] + 1 < coinCount: coinCount = minCoins[cents - j] + 1 newCoin = j minCoins[cents] = coinCount coinsUsed[cents] = newCoin return minCoins[change] def printCoins (coinsUsed, change): coin = change while coin > 0: thisCoin = coinsUsed[coin] print (thisCoin) coin = coin - thisCoin def main(): coinList = [1, 3, 8, 12, 22] coinCount = [] coinsUsed = [] change = int (input ("Enter change: ")) for i in range (change + 1): coinCount.append (0) coinsUsed.append (0) numCoins = dpMakeChange (coinList, change, coinCount, coinsUsed) print ("Minimum number of coins needed is", numCoins, "to make change", change) print ('The coins are: ') printCoins (coinsUsed, change) main()