2026-rff_mp/pomelovsd/ExitMaze/Strategies/path.py

14 lines
301 B
Python
Raw Normal View History

2026-05-25 13:45:18 +03:00
def restore(parent, start, exit):
2026-05-22 23:34:48 +03:00
if exit not in parent and start != exit:
2026-05-25 16:02:23 +03:00
return []
2026-05-22 23:34:48 +03:00
path = []
2026-05-25 16:02:23 +03:00
current = exit
2026-05-22 23:34:48 +03:00
2026-05-25 16:02:23 +03:00
while current != start:
2026-05-22 23:34:48 +03:00
path.append(current)
current = parent[current]
path.append(start)
path.reverse()
return path