Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- values = [6, 9, 20]
- results = range(50, 55 + 1)
- n = 1
- while results:
- combinations = itertools.combinations_with_replacement(values, n)
- for x in list(combinations):
- total = sum(x)
- if total in results:
- print(total, x)
- results.remove(total)
- n += 1
Add Comment
Please, Sign In to add comment