Guest User

Untitled

a guest
Dec 14th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. import itertools
  2.  
  3. values = [6, 9, 20]
  4. results = range(50, 55 + 1)
  5.  
  6. n = 1
  7. while results:
  8.     combinations = itertools.combinations_with_replacement(values, n)
  9.     for x in list(combinations):
  10.         total = sum(x)
  11.         if total in results:
  12.             print(total, x)
  13.             results.remove(total)
  14.     n += 1
Add Comment
Please, Sign In to add comment