daily pastebin goal
7%
SHARE
TWEET

Untitled

a guest Dec 15th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top