Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from functools import lru_cache
- con = 41
- def moves(h):
- return h + 1, h + 5, h * 3
- @lru_cache(None)
- def ans(h):
- if h >= con:
- return "end"
- elif any(ans(x) == "end" for x in moves(h)):
- return 'П1'
- elif all(ans(x) == 'П1' for x in moves(h)):
- return "В1"
- elif any(ans(x) == 'В1' for x in moves(h)):
- return 'П2'
- elif all(ans(x) == 'П2' or ans(x) == 'П1' for x in moves(h)):
- return "В2"
- print('Задача 19')
- for s in range(1, 41):
- if ans(s) == 'В1':
- print(s, ans(s))
- print('Задача 20')
- for s in range(1, 41):
- if ans(s) == 'П2':
- print(s, ans(s))
- print('Задача 21')
- for s in range(1, 41):
- if ans(s) == 'В2':
- print(s, ans(s))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement