Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. # Node structure
  2.  
  3. class Node():
  4.     def __init__(self):
  5.         self.left
  6.         self.right
  7.         self.up
  8.         self.down
  9.  
  10. def find_path(start, end):
  11.     if start == end:
  12.         return 1
  13.     if node.left:
  14.         left = 1 + find_path(node.left)
  15.     if node.right:
  16.         right = 1 + find_path(node.right)
  17.     if node.up:
  18.         up = 1 + find_path(node.up)
  19.     if node.down:
  20.         down = 1 + find_path(node.down)
  21.  
  22.     return min(left, right, up, down)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement