mirror of
https://github.com/Alexander-D-Karpov/scripts.git
synced 2024-11-22 20:06:33 +03:00
30 lines
483 B
Python
30 lines
483 B
Python
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("а", ["а"]))
|