Skip to content

Instantly share code, notes, and snippets.

@ibebrett
Created October 11, 2023 00:08
Show Gist options
  • Save ibebrett/906e82a7d8c247a77d2cf1a00e5d512d to your computer and use it in GitHub Desktop.
Save ibebrett/906e82a7d8c247a77d2cf1a00e5d512d to your computer and use it in GitHub Desktop.
maze
visited = set([(0,0)])
# point = (3, 4)
# x, y = point
# x == 3
# y == 4
def visit(point):
#print('at ', point)
x, y = point
for d, next_point, back_d in [
("left", (x-1, y), "right"),
("right", (x+1, y), "left"),
("up", (x, y-1), "down"),
("down", (x, y+1), "up")]:
#print(visited)
if next_point in visited:
continue
print(d)
i = input()
if i == "solved":
return True
if i == "wall":
continue
visited.add(next_point)
res = visit(next_point)
if res != False:
return True
print(back_d)
_ = input()
return False
def main():
result = visit((0, 0))
if result == False:
print("not solvable")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment