4 ms·
Nice reference. 1.29 happened to be exactly what I was looking for: for subset in itertools.chain(*(itertools.combinations(a, n) for n in range(len(a) + 1))
by RK 13y ago
Nice reference.
1.29 happened to be exactly what I was looking for:
for subset in itertools.chain(*(itertools.combinations(a, n) for n in range(len(a) + 1)))
I spent way too much time writing a function to come up with these combinations.
- rockymeza 13y agoYou can also do itertools.chain.from_iterable(itertools.combinations(a, n) for n in range(len(a) + 1))