#list=[["0", "16"], ["0", "34"], ["10", "15"], ["10", "28"], ["20", "35"], ["20", "58"], ["34", "13"], ["34", "18"], ["34", "20"]]
#list=[["0", "16"], ["1", "13"], ["16", "34"], ["13", "15"], ["1", "28"],["34", "21"],["21", "46"]]
list=[[0, 16], [0, 34], [10, 15], [10, 28], [20, 35], [20, 58], [34, 13], [34, 18], [34, 20]]
while True:
l = []
i = j = 0
while i
#print(i)
flag = 0
j = 1
while j
#print(list[i][len(list[i])-1],list[j][0])
print(i, j, len(list) - i)
if list[i][len(list[i])-1] == list[j][0]:
print(list[i],list[j],j)
l += [list[i] + list[j][1:]]
del list[j]
print(l)
print(list)
flag = 1
else:
j += 1
#print(list, j)
print(j)
if flag == 0:
l += [list[i]]
i += 1
if list == l:
break
list = l
for i in list:
t = []
for j in i:
t += [int(j)]
l += [t]
#list=[["0", "16"], ["0", "34"], ["10", "15"], ["10", "28"], ["20", "35"], ["20", "58"], ["34", "13"], ["34", "18"], ["34", "20"]]
#list=[["0", "16"], ["1", "13"], ["16", "34"], ["13", "15"], ["1", "28"],["34", "21"],["21", "46"]]
list=[[0, 16], [0, 34], [10, 15], [10, 28], [20, 35], [20, 58], [34, 13], [34, 18], [34, 20]]
while True:
l = []
i = j = 0
while i
#print(i)
flag = 0
j = 1
while j
#print(list[i][len(list[i])-1],list[j][0])
print(i, j, len(list) - i)
if list[i][len(list[i])-1] == list[j][0]:
print(list[i],list[j],j)
l += [list[i] + list[j][1:]]
del list[j]
print(l)
print(list)
flag = 1
else:
j += 1
#print(list, j)
print(j)
if flag == 0:
l += [list[i]]
i += 1
if list == l:
break
list = l
l = []
for i in list:
t = []
for j in i:
t += [int(j)]
l += [t]
print(l)
最好自己多想多動手