Advertisement
PnnK

Arseniy GameTheory

Nov 7th, 2021
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.38 KB | None | 0 0
  1. import math
  2.  
  3. def f(m, n = 20, turn = 0):
  4.     if n+m<=40 and (turn == 2 or turn == 4):  # Набрали меньше 40 ровно на 3
  5.         return True
  6.     elif n+m<=40 and turn < 4:  # Набрали меньше 40 до 3
  7.         return False
  8.     elif n+m>40 and turn == 4:  # Не набрали 40 на 3
  9.         return False
  10.     if turn%2 == 1:
  11.         return f(m-1, n, turn+1) or f(math.ceil(m/2), n, turn+1) \
  12.                or f(m, n-1, turn+1) or f(m, math.ceil(n/2), turn+1)
  13.     else:
  14.         return f(m-1, n, turn+1) and f(math.ceil(m/2), n, turn+1) \
  15.                and f(m, n-1, turn+1) and f(m, math.ceil(n/2), turn+1)
  16.  
  17. def Check2(m, n = 20, turn = 0):
  18.     if n+m <= 40 and turn == 2:  # Набрали меньше 40 ровно на 3
  19.         return True
  20.     elif n+m <= 40 and turn < 2:  # Набрали меньше 40 до 3
  21.         return False
  22.     elif n+m > 40 and turn == 2:  # Не набрали 40 на 3
  23.         return False
  24.     if turn % 2 == 1:
  25.         return Check2(m-1, n, turn+1) or Check2(math.ceil(m/2), n, turn+1) \
  26.                or Check2(m, n-1, turn+1) or Check2(m, math.ceil(n/2), turn+1)
  27.     else:
  28.         return Check2(m-1, n, turn+1) and Check2(math.ceil(m/2), n, turn+1) \
  29.                and Check2(m, n-1, turn+1) and Check2(m, math.ceil(n/2), turn+1)
  30.  
  31.  
  32. for s in range(20, 100):
  33.      if f(s) and not Check2(s):
  34.          print(s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement