davegimo

matteo

Jun 17th, 2020
1,257
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def conta(A,min,max):
  2.     return matteo(A,min,max,0)
  3.  
  4. def matteo(A,min,max,livello):
  5.    
  6.     if A.left == null and A.right == null:
  7.         if livello%2 == 1 and A.val%2 == 0 and nonAppartiene(min,max,A.val):
  8.             return A.val
  9.     else:
  10.         return 0
  11.    
  12.     conta = 0
  13.    
  14.     if livello%2 == 1 and A.val%2 == 0 and nonAppartiene(min,max,A.val):
  15.             conta += A.val
  16.  
  17.     if A.left != null:
  18.         conta += matteo(A.left,min,max,livello+ 1)
  19.     if A.right != null:
  20.         conta += matteo(A.right,min,max,livello+ 1)
  21.  
  22.     return conta
RAW Paste Data