this time i remove redundant which not add full column sum already has beeb 27*2
but it always has syntax error, indentation error, where is wrong? def DFS(b, deep, maxx, sourceoperators, path): initlist = [] if deep > 0: print("deep=", deep) for aa,bb in itertools.combinations(sourceoperators, 2): print(aa,bb) if deep == maxx: finalresult = [] op1xy = [aa[b[i][0:1]+b[i][1:2]] for i in range(len(b))] op1yz = [aa[b[i][1:2]+b[i][2:3]] for i in range(len(b))] op1xz = [aa[b[i][0:1]+b[i][2:3]] for i in range(len(b))] op2xy = [bb[b[i][0:1]+b[i][1:2]] for i in range(len(b))] op2yz = [bb[b[i][1:2]+b[i][2:3]] for i in range(len(b))] op2xz = [bb[b[i][0:1]+b[i][2:3]] for i in range(len(b))] if sum(op1xy) == 54: path.append([(deep, aa, b, "xy")]) else: initlist.append(op1xy) if sum(op1yz) == 54: path.append([(deep, aa, b, "yz")]) else: initlist.append(op1yz) if sum(op1xz) == 54: path.append([(deep, aa, b, "xz")]) else: initlist.append(op1xz) if sum(op2xy) == 54: path.append([(deep, bb, b, "xy")]) else: initlist.append(op2xy) if sum(op2yz) == 54: path.append([(deep, bb, b, "yz")]) else: initlist.append(op2yz) if sum(op2xz) == 54: path.append([(deep, bb, b, "xz")]) else: initlist.append(op2xz) else: level = [] for j in range(len(b)): op1xy = [aa[b[j][i]] for i in range(len(b[j]))] op2xy = [bb[b[j][i]] for i in range(len(b[j]))] if sum(op1xy) == 54: path.append([(deep, aa, b[j], "xy")]) else: initlist.append(op1xy) if sum(op2xy) == 54: path.append([(deep, bb, b[j], "xy")]) else: initlist.append(op2xy) level.append(op1xy) level.append(op2xy) print("initlist=") print(len(initlist) if deep == maxx: if deep > 0: b = [] for aaa,bbb in itertools.combinations(initlist, 2): b.append([str(i)+str(j) for i,j in zip(aaa, bbb)]) print("deep=") print(deep) path2 = DFS(b, deep-1, maxx, sourceoperators, path) path.append(path2) else: print("") print("path=") print(len(path)) else: if deep > 0: for aaa,bbb in itertools.combinations(initlist, 2): b.append([str(i)+str(j) for i,j in zip(aaa, bbb)]) print("deep=") print(deep) path2 = DFS(b, deep-1, maxx, sourceoperators, path) path.append(path2) else: print("") print("path=") print(len(path)) return path On Saturday, June 11, 2016 at 8:34:16 AM UTC+8, MRAB wrote: > On 2016-06-11 00:31, meInvent bbird wrote: > > it is quite ridiculous, > > this time i am sure that i put correct indentation > > and add a else statement to make sure recursive call inside the > > if statement , it still memory error, > > > > where is the memory error? > > > > is itertools.combinations so big for the list? > > > [snip] > > How long is initlist? > > When I ran the code, it said over 100_000 items. > > How many combinations would there be? > > Over 10_000_000_000. > > That's how long the list 'b' would be. > > You'll need 10s of gigabytes of memory and a lot of patience! -- https://mail.python.org/mailman/listinfo/python-list