Skip to content

Instantly share code, notes, and snippets.

@nikhilc2710
Created January 19, 2021 03:00
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 nikhilc2710/9c4db6125417061fabdfa23e82c4eecf to your computer and use it in GitHub Desktop.
Save nikhilc2710/9c4db6125417061fabdfa23e82c4eecf to your computer and use it in GitHub Desktop.
for x2, y2 in ((x+1,y), (x-1,y), (x,y+1), (x,y-1)):
if ( 0 <= x2 < width and #X-axis in range
0 <= y2 < height and #y-axis in range
grid[y2][x2] != wall and #not a wall
(x2, y2) not in seen): #not visited
queue.append( (x2, y2))
seen.add((x2, y2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment