Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from functools import lru_cache
- def summa(x):
- d = set()
- for i in range(1, int(x ** 0.5) + 1):
- if x % i == 0:
- d.add(i)
- d.add(x // i)
- if 1 in d:
- d.remove(1)
- if x in d:
- d.remove(x)
- return sum(list(d))
- def m(h, super):
- if super == 0:
- return (h + 1, False), (h + 4, False), (h + summa(h), True)
- return (h + 1, False), (h + 4, False)
- @lru_cache(None)
- def f(h, super):
- if h >= 43: return 'END'
- if any(f(x[0], 1 if x[1] else super) == 'END' for x in m(h, super)):
- return 'P1'
- elif all(f(x[0], 1 if x[1] else super) == 'P1' for x in m(h, super)):
- return 'V1'
- elif any(f(x[0], 1 if x[1] else super) == 'V1' for x in m(h, super)):
- return 'P2'
- elif all(f(x[0], 1 if x[1] else super) in ['P1', 'P2'] for x in m(h, super)):
- return 'V2'
- for s in range(1, 42 + 1):
- res = f(s, 0)
- if res and res == 'V1':
- print(res, s)
- # 19 - 20
- # 20 - 18
- # 21 - 13
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement