-
-
Save ericls/1bbc72f9501a18dc6177d25c3e09a15a to your computer and use it in GitHub Desktop.
foo.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import combinations, chain | |
l = [1, 2, 3, 4, 5] | |
s = 5 | |
[c for c in chain(*(combinations(l, i) for i in range(1, len(l) + 1))) if sum(c) == s] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment