Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Straighforward backtracking solution. solution in Clear category for Open Labyrinth by dunpealer
MOVE = {"S": (1, 0), "N": (-1, 0), "W": (0, -1), "E": (0, 1)}
def checkio(maze_map):
visited = [[0] * 11 for i in range(11)]
def visit(r, c, path=''):
if r == c == 10:
return path
for grid in maze_map, visited:
if grid[r][c]:
return
visited[r][c] = 1
for l, (rd, cd) in MOVE.items():
result = visit(r+rd, c+cd, path+l)
if result:
return result
return visit(1, 1)
Sept. 6, 2015
Comments: