Advertisement
mouradsme

Untitled

Mar 26th, 2022
1,134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. from itertools import combinations
  2. def filler(A, l):
  3.     n = len(l)
  4.     result = list()
  5.     for i in range(1, n+1):
  6.         for comb in combinations(l, i):
  7.             if (sum(comb) == A):
  8.                 result.append(comb)
  9.     return result if len(result) > 0 else "None"
  10.  
  11. # Example:
  12. print(filler(10, [1, 2, 3, 4]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement