Please help me with 4.2 and 4.3, I get stuck in that. Below is the…
Question Please help me with 4.2 and 4.3, I get stuck in that. Below is the… Please help me with 4.2 and 4.3, I get stuck in that. Below is the instructions (in photos) and my code and test case. Thank youImage transcription text1 Overview In this program, you willsolve a maze. You will read the map upfrom a file, build a tree to … Show more… Show moreImage transcription text2 Map Format The maze will beencoded in a text file, which will looksomething like this: ####… Show more… Show moreImage transcription text2 .1 Coordinates When you read themap file, you need to record every “oell”that contains a path. Assi… Show more… Show moreImage transcription textYou can also assume that all of thepaths in the map are connected to eachother. Together, these two … Show more… Show moreImage transcription text4 Required Dump Points As notedabove, the “command” that the usertypes will tell you how far … Show more… Show moreImage transcription text5 Hints: Thee Building Probably the mostchallenging single part of this program isbuildling the tree. You won’… Show more… Show moreImage transcription text6 Hints: Tree Searching We already knowhow to search through an unorderedtree; we have to check eac… Show more… Show moremy code:def load_maze(line_lst): raw=[] maze=[] start_point=0 end_point=0 for line in line_lst: symbol=[] for char in line: symbol.append(char) raw.append(symbol) for row in range(len(raw)): for col in range(len(raw[row])): if raw[row][col]==’S’: start_point=(col,row) elif raw[row][col]==’E’: end_point=(col,row) if raw[row][col]!=’ ‘: maze.append((col,row)) return raw,maze,start_point,end_point def valid_char(line_lst): result=True for line in line_lst: for char in line: if char!=’#’ and char!=’ ‘ and char!=’S’ and char!=’E’: result=False if result==False: print(“ERROR: Invalid character in the map”) exit() def start_end_pos(line_lst): raw=[] maze=[] start_point=[] end_point=[] for line in line_lst: symbol=[] for char in line: symbol.append(char) raw.append(symbol) for row in range(len(raw)): for col in range(len(raw[row])): if raw[row][col]==’S’: start_point.append((col,row)) elif raw[row][col]==’E’: end_point.append((col,row)) return start_point,end_pointdef solve_maze(maze,path,end): row=path[0][0] col=path[0][1] if row<0 or col<0 or row>= len(maze) or col>=len(maze[0]): return False elif path[len(path)-1]==end: return True else: if not (row-1,col) in path: path.append((row-1,col)) if solve_maze(maze, path, end)==True: return True if not (row+1,col) in path: path.append((row+1,col)) if solve_maze(maze, path, end) == True: return True if not (row,col-1) in path: path.append((row,col-1)) if solve_maze(maze, path, end) == True: return True if not (row,col+1) in path: path.append((row,col+1)) if solve_maze(maze, path, end) == True: return True return Falsedef size(line_lst): return len(line_lst[0]),len(line_lst)def dump_cell(line_lst,maze,start,end): cell=[] height=len(line_lst[0]) count=0 while count


