Skip to content

Instantly share code, notes, and snippets.

@ricomoss
Last active January 24, 2017 20:07
Show Gist options
  • Save ricomoss/7614b9c9e3f949616f2e2af8d20114ee to your computer and use it in GitHub Desktop.
Save ricomoss/7614b9c9e3f949616f2e2af8d20114ee to your computer and use it in GitHub Desktop.
from itertools import product, compress
def combinations(items):
return (set(compress(items,mask)) for mask in product(*[[0,1]]*len(items)))
vals = [1, 2, 3, 4, 5, 6, 7, 8, 9]
combs = combinations(vals)
count = 0
for comb in combs:
count += 1
print(count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment