Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Open Labyrinth by testarossa
def checkio(maze_map):
visited=[[0 for col in range(12)] for row in range(12)]
def route(maze_map,x,y,path):
visited[x][y]=1
if x==10 and y==10:
return path
if maze_map[x][y+1]==0 and visited[x][y+1]==0:
result=route(maze_map,x,y+1,path + 'E')
if result:
return result
if maze_map[x+1][y]==0 and visited[x+1][y]==0:
result=route(maze_map,x+1,y,path + 'S')
if result:
return result
if maze_map[x][y-1]==0 and visited[x][y-1]==0:
result=route(maze_map,x,y-1,path + 'W')
if result:
return result
if maze_map[x-1][y]==0 and visited[x-1][y]==0:
result=route(maze_map,x-1,y,path + 'N')
if result:
return result
return ''
path=route(maze_map,1,1,'')
return path
Nov. 19, 2016
Comments: