mirror of
https://github.com/Alexander-D-Karpov/scripts.git
synced 2024-11-15 01:16:36 +03:00
28 lines
443 B
Python
28 lines
443 B
Python
g = {
|
||
"а": "б",
|
||
"б": "ве",
|
||
"в": "ги",
|
||
"г": "и",
|
||
"д": "абе",
|
||
"е": "вжл",
|
||
"ж": "вл",
|
||
"и": "нм",
|
||
"к": "д",
|
||
"л": "дк",
|
||
"м": "жл",
|
||
"н": "м",
|
||
}
|
||
|
||
|
||
def f(n, path):
|
||
if n == "е":
|
||
return 1
|
||
s = []
|
||
for nd in g[n]:
|
||
if path.count(nd) != 1:
|
||
s.append(f(nd, path + [nd]))
|
||
return sum(s)
|
||
|
||
|
||
print(f("ж", []))
|