14 lines
301 B
Python
14 lines
301 B
Python
def restore(parent, start, exit):
|
|
if exit not in parent and start != exit:
|
|
return []
|
|
|
|
path = []
|
|
current = exit
|
|
|
|
while current != start:
|
|
path.append(current)
|
|
current = parent[current]
|
|
|
|
path.append(start)
|
|
path.reverse()
|
|
return path |