Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from functools import lru_cache
- def moves(heap):
- a,b= heap
- return (a+1,b),(a*3,b),(a,b+1),(a,b*3)
- @lru_cache(None)
- def game(heap):
- if sum(heap)>=75:
- return 'WIN'
- if any(game(m)=='WIN' for m in moves(heap)):
- return 'S1'
- if all(game(m) == 'S1' for m in moves(heap)):
- return 'P1'
- if any(game(m) == 'P1' for m in moves(heap)):
- return 'S2'
- if all(game(m) == 'S2' or game(m)=='S1' for m in moves(heap)):
- return 'p2'
- for s in range(1,67):
- print(s,game((7,s)))
- '''f = open('24_3.txt')
- s = f.readline()
- max = 0
- flag = 0
- global_count = 0
- for i in range(len(s)):
- if s[i]=='(':
- global_count=1
- flag = 1
- elif flag and (s[i]=='+' or s[i]=='*'):
- global_count+=1
- elif flag and s[i]=='(':
- global_count=1
- flag=1
- elif flag and s[i]==')':
- global_count+=1
- flag = 0
- if global_count>max:
- max = global_count
- global_count=0
- print(max)'''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement