Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- s = 'ЛЗ ЗВБ ВЛБ ЖЛЗ АВ БАГЖ ГЖ'
- d = {c[0]:c[1:] for c in s.split()}
- def f(s, end):
- if len(s) > 1 and s[-1] == end:
- return 1
- return sum(f(s + c, end) for c in d[s[-1]] if c not in s)
- print(f('Ж', 'Г'))
Advertisement
Add Comment
Please, Sign In to add comment