mirror of
https://github.com/Alexander-D-Karpov/scripts.git
synced 2024-11-14 17:06:34 +03:00
30 lines
483 B
Python
Vendored
30 lines
483 B
Python
Vendored
gr = {
|
||
"а": "б",
|
||
"б": "ве",
|
||
"в": "гиж",
|
||
"г": "и",
|
||
"д": "аб",
|
||
"е": "вдл",
|
||
"ж": "ем",
|
||
"и": "н",
|
||
"к": "д",
|
||
"л": "дк",
|
||
"м": "ели",
|
||
"н": "м",
|
||
}
|
||
|
||
|
||
def f(p, path):
|
||
if p == "н" and path:
|
||
print(path)
|
||
return 1
|
||
res = []
|
||
for g in gr[p]:
|
||
if path.count(g) <= 0:
|
||
res.append(f(g, path + [g]))
|
||
|
||
return sum(res)
|
||
|
||
|
||
print(f("а", ["а"]))
|