Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. def is_fibonacci(t):
  2.     if t==None:
  3.         return True
  4.     return (is_foglia(t) or abs(altezza(t.sx)-altezza(t.dx))==1) and is_fibonacci(t.sx) and is_fibonacci(t.dx)
  5.  
  6. def is_foglia(t):
  7.     return t.sx==None and t.dx==None
  8.  
  9. def altezza(t):
  10.     if t==None:
  11.         return -1
  12.     return max(altezza(t.sx),altezza(t.dx))+1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement