2026-rff_mp/NeklyudovMS/task2/strategyObjects/util.py
2026-09-05 10:15:13 +03:00

13 lines
373 B
Python

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