Advertisement
davegimo

Untitled

Jun 28th, 2020
1,382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. def verifica(a,b):
  2.     sx = verificaComodo(left(a),b,1)
  3.     dx = verificaComodo(right(a),b,1)
  4.     return sx or dx
  5.  
  6. def verificaComodo(a,b,livello):
  7.    
  8.     t = trova(info(a),b,livello,0)
  9.     if t == True:
  10.         return True
  11.     else:
  12.         t_sx = False
  13.         t_dx = False
  14.  
  15.         if not isNull(left(A)):
  16.             t_sx = verificaComodo(left(a),b, livello+1)
  17.        
  18.         if not isNull(right(A)):
  19.             t_dx = verificaComodo(right(a),b,livello+1)
  20.        
  21.         return t_sx or t_dx
  22.  
  23. def trova(infoA,b,livello,current):
  24.     if isNull(b) or livello <= current:
  25.         return False
  26.  
  27.     if info(b) == infoA:
  28.         return True
  29.    
  30.     return trova(infoA,left(b),livello, current + 1) or trova(infoA,right(b),livello, current + 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement