[SciPy-user] Finding all combinations of numbers

Andrew Straw strawman@astraw....
Sun Jan 13 00:34:38 CST 2008

In addition to what David Warde-Farley said, I also have this lurking in
my code base:

def setOfSubsets(L):
    """find all subsets of L

    from Alex Martelli:
    N = len(L)
    return [ [ L[i] for i in range(N)
                if X & (1L<<i) ]
        for X in range(2**N) ]

More information about the SciPy-user mailing list