mirror of
https://github.com/Alexander-D-Karpov/scripts.git
synced 2024-12-01 07:13:44 +03:00
26 lines
409 B
Python
26 lines
409 B
Python
|
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("е", []))
|