static void FindPathToExit(Cell cell, char direction)
        {
            if (!InRange(cell))
            {
                // bottom
                return;
            }

            path.Add(cell);

            if (labirinth[cell.X, cell.Y] == 'e')
            {
                PrintPath(path);
            }

            if (labirinth[cell.X, cell.Y] == ' ')
            {
                labirinth[cell.X, cell.Y] = 's';

                FindPathToExit(new Cell(cell.X, cell.Y - 1), 'L'); // left
                FindPathToExit(new Cell(cell.X - 1, cell.Y), 'U'); // up
                FindPathToExit(new Cell(cell.X, cell.Y + 1), 'R'); // right
                FindPathToExit(new Cell(cell.X + 1, cell.Y), 'D'); // down

                labirinth[cell.X, cell.Y] = ' ';
            }

            path.RemoveAt(path.Count - 1);
        }
 public static bool InRange(Cell cell)
 {
     var rowInRange = cell.X >= 0 && cell.X < labirinth.GetLength(0);
     var colInRange = cell.Y >= 0 && cell.Y < labirinth.GetLength(1);
     return rowInRange && colInRange;
 }