scripts/ege/28.03.2023 ПРОБНИК/Faily_IN11_28032023_/13.py
2023-05-05 00:45:01 +03:00

28 lines
443 B
Python
Vendored
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.

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