Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You may use generators instead of lists. See: https://wiki.python.org/moin/Generators

For example:

def test_generator(n1,n2,n3,n4):
    for a in range(n1):
        for b in range(n2):
            for c in range(n3):
                for d in range(n4):
                    yield (a,b,c,d)

G = test_generator(100,100,100,100)

for k in range(100^4):
    if sum(G.next()) == 10: print k