SHARE
TWEET

Untitled

a guest Feb 19th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def f(n,k=0):
  2.     if n=="" : return 0
  3.     t = ((-1)**(len(n)-1))*int(n[len(n)-1]) + f(n[:-1],k+1)
  4.     if k == 0:
  5.         return f(str(abs(t)),k+1) == 0
  6.     return t
  7.  
  8. print(f("11"))
  9. print(f("12"))
  10. print(f("22"))
  11. print(f("0"))
  12. print(f("121"))
  13. print(f("110"))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top