Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- packages = [6, 9, 20]
- smaller = min(packages)
- num = 1
- count = 0
- while count < smaller:
- n = 1
- while n * smaller < num:
- combinations = itertools.combinations_with_replacement(packages, n)
- for x in combinations:
- total = sum(x)
- if total == num:
- count += 1
- break
- else:
- n += 1
- continue
- break
- else:
- count = 0
- num += 1
- print(num - 1 - smaller)
Add Comment
Please, Sign In to add comment