def getCombinations(arr, exp, somepart=[]):
total = sum(somepart)
if total == exp:
print(somepart)
if total >= exp:
return
for i in range(0, len(arr)):
getCombinations(arr[i + 1:], exp, somepart + [arr[i]])
getCombinations([2, 4, 5, 8, 12, 17, 21, 3], 20)
No comments :
Post a Comment