Microsoft SWE1/2 Onsite
Anonymous User
273
May 21, 2022
May 21, 2022

Given a class Maze and some functions, return True if you are able to exit the maze else return False.
Could anyone provide a solution for this? I used recursion to check in all directions and after calling moveForward, I checked for the base case using isExitCell function.

class Maze:
	def moveForward(): #Move one step forward in any direction
	def isExitCell(): #Return True if you can exit the cell from here
	def turnLeft(): #Change your direction to left
	def turnRight(): #Change your direction to right
	def isVisited(): #If the cell / location has already been visited then return True else False
	def SetVisited(): # Sets the cell / location to visited after visiting it.
	
	```
	You can move in 4 different directions using the turnLeft and turnRight function. The maze is not  2x2 dimensional. Consider it as a real life maze without any definite coordinates such as (row,col). You can only use these functions to return whether you can exit the maze or not.
Comments (0)