Farz0l1x

Untitled

Apr 16th, 2023
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. s = 'ЛЗ ЗВБ ВЛБ ЖЛЗ АВ БАГЖ ГЖ'
  2. d = {c[0]:c[1:] for c in s.split()}
  3. def f(s, end):
  4.     if len(s) > 1 and s[-1] == end:
  5.         return 1
  6.     return sum(f(s + c, end) for c in d[s[-1]] if c not in s)
  7. print(f('Ж', 'Г'))
Advertisement
Add Comment
Please, Sign In to add comment