SHARE
TWEET

Untitled

a guest Jan 21st, 2020 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #новая версия num - функция, num1 - не может быть пробле на 1 месте
  2. s = str(input())
  3.  
  4. letters=[]
  5. for i in range(1,34):
  6.     letters.append(str(i))
  7.  
  8. def num(s):
  9.     if len(s)<=1:
  10.         return 1
  11.     else:
  12.         l = s[0:2]
  13.         if l in letters:
  14.             return num(s[1:])+num(s[2:])
  15.         l=l[0]
  16.         if l in letters:
  17.             return num(s[1:])
  18.         return num1(s[1:])
  19.    
  20. def num1(s):
  21.     if len(s)<=1:
  22.         if s=='0':
  23.             return 0
  24.         return 1
  25.     else:
  26.         l = s[0:2]
  27.         if l in letters:
  28.             return num(s[1:])+num(s[2:])
  29.         l=l[0]
  30.         if l in letters:
  31.             return num(s[1:])
  32.         return 0
  33.            
  34. print(num(s))
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