Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Node structure
- class Node():
- def __init__(self):
- self.left
- self.right
- self.up
- self.down
- def find_path(start, end):
- if start == end:
- return 1
- if node.left:
- left = 1 + find_path(node.left)
- if node.right:
- right = 1 + find_path(node.right)
- if node.up:
- up = 1 + find_path(node.up)
- if node.down:
- down = 1 + find_path(node.down)
- return min(left, right, up, down)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement