R=[(1,10,14,34),(2,5,19,21),(3,7,31,32),(1,9,12,31),(2,10,11,22),(4,8,14,32),(13,15,19,34),(1,5,15,20),(3,26,19,25),(4,17,19,21),(4,17,20,21)]
对于R中的每个元组,找到具有相同元素位置的每个元素的下一个索引,其中两个元组中不应存在其他元素。
FOR索引0和1这里是预期的样本结果
0: 4,5,6,7
1: 2,5,6,8
.
.
.
.
.
so on
这是我的代码太详细,太冗长,需要太长时间才能运行我的实际项目。所以我给了一个上面的样本请帮助我以乐观的方式驾驶它......,以达到速度。
for j in range(i+1,i+10):
b=set(Results[j])
if (len(a&b)==0):
for k in range(i+10, i+200):
c=set(Results[k])
if ( (len(a&c)==0) and (len(b&c)==0) ):
for l in range(i+200, i+600):
d=set(Results[l])
if ( (len(a&d)==0) and (len(b&d)==0) and (len(c&d)==0) ):
for m in range(i+500, i+1000):
e=set(Results[m])
if ( (len(a&e)==0) and (len(b&e)==0) and (len(c&e)==0) and (len(d&e)==0) ):
for n in range(i+1000, i+2000):
f=set(Results[n])
if ( (len(a&f)==0) and (len(b&f)==0) and (len(c&f)==0) and (len(d&f)==0) and (len(e&f)==0) ):
for o in range(i+2000, i+3000):
g=set(Results[o])
if ( (len(a&g)==0) and (len(b&g)==0) and (len(c&g)==0) and (len(d&g)==0) and (len(e&g)==0) and (len(f&g)==0) ):
for p in range(i+3000, XRUN):
h=set(Results[p])
if ( (len(a&h)==0) and (len(b&h)==0) and (len(c&h)==0) and (len(d&h)==0) and (len(e&h)==0) and (len(f&h)==0) and (len(g&h)==0)):
CN=CN+1
提前致谢。