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('А', 'З') + f('А', 'В'))
Advertisement
Add Comment
Please, Sign In to add comment