Guest User

Untitled

a guest
Dec 15th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. import itertools
  2.  
  3. packages = [6, 9, 20]
  4. smaller = min(packages)
  5. num = 1
  6.  
  7. count = 0
  8. while count < smaller:
  9.     n = 1
  10.     while n * smaller < num:
  11.         combinations = itertools.combinations_with_replacement(packages, n)
  12.         for x in combinations:
  13.             total = sum(x)
  14.             if total == num:
  15.                 count += 1
  16.                 break
  17.         else:
  18.             n += 1
  19.             continue
  20.         break
  21.     else:
  22.         count = 0
  23.     num += 1
  24. print(num - 1 - smaller)
Add Comment
Please, Sign In to add comment