Skip to content

Instantly share code, notes, and snippets.

@5hirish
Last active July 26, 2016 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 5hirish/35a16ccd835ee33d381ebcf9d3c69ae9 to your computer and use it in GitHub Desktop.
Save 5hirish/35a16ccd835ee33d381ebcf9d3c69ae9 to your computer and use it in GitHub Desktop.
#! /usr/bin/python3
def explore(i, j, grid_map_exp, grid_map):
if i <= 3 and j <= 3:
current = grid_map[i][j]
if current == 's' or current == '-':
explore(i, j+1, grid_map_exp, grid_map)
explore(i, j-1, grid_map_exp, grid_map)
explore(i+1, j, grid_map_exp, grid_map)
explore(i-1, j, grid_map_exp, grid_map)
if grid_map[i][j]=='-':
parent = (i,j)
grid_map_exp[parent] = grid_map[i][j]
grid_map_exp = {}
grid_map = [['w','-','d','-'],
['w','-','w','-'],
['w','-','-','-'],
['-','-','w','s']]
root = (3,3)
grid_map_exp[root] = None
i , j = root
explore(i, j, grid_map_exp, grid_map)
print(grid_map_exp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment