Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def f(x,y,k):
- bef = k - 1
- if max(x,y) >= 50:
- if bef == 3:
- return 1
- else: #bef < 3
- return 0
- elif bef == 3: #max(x,y) < 50
- return 0
- A = f(x + 3, y, k + 1)
- B = f(2 * x, y, k + 1)
- C = f(x, y + 3, k + 1)
- D = f(x, 2 * y, k + 1)
- if k % 2 == 1: #П
- return A or B or C or D
- else: #В
- return A and B and C and D
- def g(x,y,k):
- bef = k - 1
- if max(x, y) >= 50:
- if bef == 1 or bef == 3:
- return 1
- else:
- return 0
- A = g(x + 3, y, k + 1)
- B = g(x * 2, y, k + 1)
- C = g(x, y + 3, k + 1)
- D = g(x, y * 2, k + 1)
- if k % 2 == 1:
- return A or B or C or D
- else:
- return A and B and C and D
- for s in range(27, 0, -1):
- print("s ", s)
- ok = 1
- #1st moves Ivan
- if not f(22, s, 1):
- ok = 0
- #1st moves Peter
- #checking that Ivan cant win in 1 move
- v = [(22, s + 3), (22, s * 2)]
- for p in v:
- if p[1] * 2 >= 50:
- ok = 0
- #A = g(22 + 3, s, 1)
- #B = g(22 * 2, s, 1)
- C = g(22, s + 3, 1)
- D = g(22, s * 2, 1)
- E = C and D
- if not E:
- ok = 0
- if ok:
- print(s)
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement