以下代码中的“如果c <=更改,coinValueList中的c对应c”是什么意思?

时间:2018-11-03 00:17:15

标签: python loops

以下代码来自interactivepython.org中的动态编程部分。我理解大多数代码,但是“如果c <=更改,c的coinValueList中的c为c”是什么?

def recDC(coinValueList,change,knownResults):
   minCoins = change
   if change in coinValueList:
      knownResults[change] = 1
      return 1
   elif knownResults[change] > 0:
      return knownResults[change]
   else:
       for i in [c for c in coinValueList if c <= change]:
         numCoins = 1 + recDC(coinValueList, change-i,
                              knownResults)
         if numCoins < minCoins:
            minCoins = numCoins
            knownResults[change] = minCoins
   return minCoins

print(recDC([1,5,10,25],63,[0]*64))

0 个答案:

没有答案