CoCalc Public FilesMakeupWork / Done / 4-21Discussion.ipynbOpen with one click!
Author: Kaleb Cruz
Views : 52
Compute Environment: Ubuntu 20.04 (Default)

Suppose that a company sells computer chips in packages of size 1, 5, and 8. Find the least number of packages that can be used to order 20 chips.

In [11]:
def chips(n): L = [0 for i in range(n)] L[0] = 1 L[1] = 2 L[2] = 2 L[3] = 2 L[4] = 1 L[5] = 3 L[6] = 3 L[7] = 1 for i in range(8, n): L[i] = 1 + min(L[i - 1], L[i - 5], L[i - 8]) return L[n-1]
In [13]:
chips(20)
4
In [ ]:
In [ ]:
In [ ]:
In [ ]: