Untitled

mail@pastecode.io avatar
unknown
python
a year ago
480 B
2
Indexable
Never
def yieldAllCombos(items):
    N = len(items)
    for i in range(2**N):
        bag1 = []        
        for j in range(N):
            if (i >> j) % 2 == 1:
                bag1.append(items[j])
            for k in range(2**N):
                bag2 = []
                for l in range(N):
                    if (k >> l) % 2 == 1:
                        if not items[l] in bag1:
                            bag2.append(items[l])
                yield (bag1, bag2)