Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #https://kpolyakov.spb.ru/school/ege/gen.php?action=viewVar&answers=on&varId=10
- def step(x, f, path):
- global answ
- if x > 63:
- return
- if x == 62:
- if 32 in path:
- answ += 1
- return
- if ((x * 3) % 10 != 0) and ((x * 3) not in path):
- step(x * 3, False, path | {x * 3})
- if ((x + 2) % 10 != 0) and ((x + 2) not in path):
- step(x + 2, False, path | {x + 2})
- if (not f) and ((x - 1) % 10 != 0) and ((x - 1) not in path):
- step(x - 1, True, path | {x - 1})
- answ = 0
- step(5, False, {5})
- print(answ)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement