Advertisement
TornioSubito

Ricorsione_mirrorSum

Jun 17th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. def mirrorSum(lis,x,cont=0):
  2. #@param lis : list
  3. #@param x : int
  4. #@return bool
  5. if len(lis)<=1:
  6. if cont>0:
  7. return True
  8. else:
  9. if x==0:
  10. return True
  11. else:
  12. return False
  13. else:
  14. if x-lis[0]==lis[len(lis)-1]:
  15. lis=lis[1:-1]
  16. return mirrorSum(lis,x,cont+1)
  17. else:
  18. return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement