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 count1:       print(“ERROR: The map has more than one START position”)       exit()   elif len(end_lst)>1:       print(“ERROR: The map has more than one END position”)       exit()   valid_char(line_lst)   choice=input()   path=[start]   solution=solve_maze(raw_maze,path,end)   if choice == “NOT_A_VALID_COMMAND”:       print(“ERROR: Unrecognized command NOT_A_VALID_COMMAND”)       exit()   elif choice == ‘dumpSize’:       wid,hei=size(line_lst)       print(“MAP SIZE:”)       print(”  wid: “,wid)       print(”  hei: “,hei)   elif choice==’dumpCells’:       print(‘DUMPING OUT ALL CELLS FROM THE MAZE:’)       dump_cell(line_lst,maze,start,end)   elif choice ==’dumpSolution’:       print(“PATH OF THE SOLUTION:”)       for pos in path:           print(pos)Main()Test case:maze.txt:Input:maze2.txtdumpSolutionOutput:Input:maze2.txtdumpTreeOutput:Image transcription textDUMPING OUT THE TREE THATREPRESENTS THE MAZE: (2, 6) (1, 6)(0, 6) (3, 6) 6 ) (5 , 6 ) (6, 6… Show more… Show moreImage transcription text(5, 4) 1 (4, 4) 7, 6) (8, 6) (8, 5) (8, 4) 3 ) 2) (8, 1 ) 0 ) (9, 0) (10, 0) (11, 0 ) 1 1 (12, 0 )(9, 2) 1 (10, 2) 9, 4) 4) (10, … Show more… Show more  Computer Science Engineering & Technology Python Programming COMP 120 Share QuestionEmailCopy link Comments (0)