Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Recursive search solution in Clear category for Open Labyrinth by michal_bien
maze = []
def checkWay(x,y, prway):
global maze
maze[x][y]=1
if x==10 and y==10:
return prway
res=-1
if maze[x+1][y]==0:
res=checkWay(x+1,y,prway+'S')
if res!=-1: return res
if maze[x][y+1]==0:
res=checkWay(x,y+1,prway+'E')
if res!=-1: return res
if maze[x-1][y]==0:
res=checkWay(x-1,y,prway+'N')
if res!=-1: return res
if maze[x][y-1]==0:
res=checkWay(x,y-1,prway+'W')
if res!=-1: return res
return res
def checkio(maze_map):
global maze
maze = maze_map
return checkWay(1,1, "")
Oct. 20, 2016