Question: class MazeSolver: def __init__(self, maze_str: str, configuration: dict=None): IIIIII Initialize the solver with map string and configuration. Map string can consist of several lines,



class MazeSolver: def __init__(self, maze_str: str, configuration: dict=None): IIIIII Initialize the solver with map string and configuration. Map string can consist of several lines, line break separates the lines. Empty lines in the beginning and in the end should be ignored. Line can also consist of spaces, so the lines cannot be stripped. On the left and right sides there can be several doors (marked with "|"). Solving the maze starts from a door from the left side and ends at the door on the right side. See more @solve(). Configuration is a dict which indicates which symbols in the map string have what cost. Doors are not shown in the configuration and are not used inside the maze. Door cell cost is 0. When a symbol on the map string is not in configuration, its cost is 0. Cells with negative cost cannot be moved on/through. Default configuration: configuration = { ': 1, '#': -1, .: 2, : 5, 'W': 10 :param maze_str: Map string :param configuration: Optional dictionary of symbol costs. if configuration is None: configuration = { ': 1, '%23': -1, .: 2, -: 5, } pass 'W': 10 def get_shortest_path(self, start: tuple, goal: tuple) -> tuple: Return shortest path and the total cost of it. The shortest path is the path which has the lowest cost. Start and end are tuples of (y, x) where the first (upper) line is y = 0. The path should include both the start and the end. If there is no path from the start to goal, the path is None and cost is -1.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
