mikhail_dvorkin

Относительно универсальное решение задач 19—21

Jun 8th, 2022 (edited)
519
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. m = 170
  2. a = [[None] * m for _ in range(m)]  # +- выиграл/проиграл и за сколько ходов
  3. b = [[False] * m for _ in range(m)] # можно ли сейчас «подставиться»
  4. for i in range(m - 1, 0, -1):
  5.     for j in range(m - 1, 0, -1):
  6.         if i + j >= 79:
  7.             a[i][j] = 0
  8.             continue
  9.         moves = [a[i + 3][j], a[i * 2][j], a[i][j + 3], a[i][j * 2]]
  10.         b[i][j] = 1 in moves
  11.         if min(moves) <= 0:
  12.             a[i][j] = 1 - max([x for x in moves if x <= 0])
  13.             continue
  14.         a[i][j] = -1 - max(moves)
  15. for s in range(1, 69 + 1):
  16.     print(s, a[9][s], b[9][s])
Add Comment
Please, Sign In to add comment