scripts/ege/СтатГрад № 5 Файлы/13.py

30 lines
483 B
Python
Raw Normal View History

2023-05-05 00:45:01 +03:00
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("а", ["а"]))