scripts/ege/СтатГрад № 5 Файлы/13.py
2023-05-05 00:45:01 +03:00

30 lines
483 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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("а", ["а"]))