scripts/ege/Апробация 10.03.2023/13.py
2023-05-05 00:45:01 +03:00

26 lines
409 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

gr = {
"а": "бг",
"б": "д",
"в": "абгдж",
"г": "ж",
"д": "ие",
"е": "влк",
"ж": "е",
"и": "ел",
"к": "ж",
"л": "к",
}
def f(p, path):
if p == "е" and path:
return 1
s = []
for n in gr[p]:
if n not in path:
s.append(f(n, path + [n]))
return sum(s)
print(f("е", []))