2026-rff_mp/MusinAA/task2/strategyObjects/util.py

12 lines
353 B
Python

from task2.mazeObjects.maze import Maze
from task2.mazeObjects.cell import Cell
def restorePath(parents: dict, start: Cell, exit: Cell) -> list[Cell]|None:
path = []
current = exit
while current:
path.append(current)
if current not in parents:
return None
current = parents[current]
return path[::-1]