1 回答
TA贡献1921条经验 获得超9个赞
女士们先生们,我们得到了他。
coordinates = [['X',0,20],['B',15,20],['G',20,45],['Y',20,55],['H',15,45]]
dir = dijsktra(graph,'B','X')
indexes = []
for i in range(len(dir)):
for j in range(len(coordinates)):
if dir[i] == coordinates[j][0]:
indexes.append(j)
turnons = []
newdir = []
for i in range(len(dir)-1):
if coordinates[indexes[i]][1] == coordinates[indexes[i+1]][1]:
turnons.append(['R',i+1])
elif coordinates[indexes[i]][2] == coordinates[indexes[i+1]][2]:
turnons.append(['L',i+1])
uzunluk = len(dir) + len(turnons)
turnsyc = 0
dirsyc = 0
print(dir,turnons)
for i in range(uzunluk):
if i % 2 == 0 or i == 0:
newdir.append(dir[dirsyc])
dirsyc += 1
else:
newdir.append(turnons[turnsyc][0])
turnsyc += 1
添加回答
举报