Advertisement
stupid_pro

Untitled

Jun 17th, 2023
875
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.36 KB | None | 0 0
  1. def moves(h):
  2.     return h + 3, h * 2
  3.  
  4.  
  5. def game(h):
  6.     if h >= 33:
  7.         return 'W'
  8.     if any(game(m) == 'W' for m in moves(h)):
  9.         return 'P1'
  10.     if all(game(m) == 'P1' for m in moves(h)):
  11.         return 'B1'
  12.     if any(game(m) == 'B1' for m in moves(h)):
  13.         return 'P2'
  14.     if all(game(m) == 'P1' or game(m) == 'P2' for m in moves(h)):
  15.         return 'B2'
  16.  
  17.  
  18. for i in range(1, 33):
  19.     if game(i) == 'P1':
  20.         print(i, game(i), end=' ')
  21.         print()
  22. # print('\n\\')
  23. #
  24. for i in range(1, 33):
  25.     if game(i) == 'B1':
  26.         print(i, game(i))
  27.  
  28. print()
  29.  
  30. for i in range(1, 33):
  31.     if game(i) == 'P2':
  32.         print(i, game(i))
  33.  
  34. print()
  35.  
  36. for i in range(1, 33):
  37.     if game(i) == 'B2':
  38.         print(i, game(i))
  39.  
  40. def moves(h):
  41.     return h + 4, h * 3
  42.  
  43. def game(h):
  44.     if h >= 70:
  45.         return 'W'
  46.     if any(game(m) == 'W' for m in moves(h)):
  47.         return 'P1'
  48.     if all(game(m) == 'P1' for m in moves(h)):
  49.         return 'B1'
  50.     if any(game(m) == 'B1' for m in moves(h)):
  51.         return 'P2'
  52.     if all(game(m) == 'P1' or game(m) == 'P2' for m in moves(h)):
  53.         return 'B2'
  54.  
  55. for i in range(1, 70):
  56.     if game(i) == 'B2':
  57.         print(i, game(i))
  58.  
  59. def moves(h):
  60.     return h + 4, h * 2
  61.  
  62.  
  63. def game(h):
  64.     if h >= 35:
  65.         return 'W'
  66.     if any(game(m) == 'W' for m in moves(h)):
  67.         return 'P1'
  68.     if all(game(m) == 'P1' for m in moves(h)):
  69.         return 'B1'
  70.     if any(game(m) == 'B1' for m in moves(h)):
  71.         return 'P2'
  72.     if all(game(m) == 'P2' or game(m) == 'P1' for m in moves(h)):
  73.         return 'B2'
  74.  
  75.  
  76. for i in range(1, 35):
  77.     if game(i) == 'B1':
  78.         print(i, game(i))
  79. from functools import lru_cache
  80.  
  81.  
  82. @lru_cache(None)
  83. def moves(h):
  84.     return h + 3, h * 3
  85.  
  86.  
  87. def game(h):
  88.     if h >= 60:
  89.         return 'W'
  90.     if any(game(m) == 'W' for m in moves(h)):
  91.         return 'P1'
  92.     if all(game(m) == 'P1' for m in moves(h)):
  93.         return 'B1'
  94.     if any(game(m) == 'B1' for m in moves(h)):
  95.         return 'P2'
  96.     if all(game(m) == 'P2' or game(m) == 'P1' for m in moves(h)):
  97.         return 'B2'
  98.  
  99.  
  100. for i in range(1, 60):
  101.     if game(i) == 'B2':
  102.         print(i, game(i))
  103. from functools import lru_cache
  104.  
  105.  
  106. def moves(h):
  107.     a, b = h
  108.     return (a + 2, b), (a, b + 2), (a * 2, b), (a, b * 2)
  109.  
  110.  
  111. @lru_cache(None)
  112. def game(h):
  113.     a, b = h
  114.     if a + b >= 75:
  115.         return 'W'
  116.     if any(game(m) == 'W' for m in moves(h)):
  117.         return 'P1'
  118.     if all(game(m) == 'P1' for m in moves(h)):
  119.         return 'B1'
  120.     if any(game(m) == 'B1' for m in moves(h)):
  121.         return 'P2'
  122.     if all(game(m) == 'P2' or game(m) == 'P1' for m in moves(h)):
  123.         return 'B2'
  124.  
  125.  
  126. for i in range(1, 66):
  127.     j = 9, i
  128.     if game(j) == 'B2':
  129.         print(i, game(j))
  130.  
  131.  
  132. from functools import lru_cache
  133.  
  134.  
  135. def moves(h):
  136.     a, b = h
  137.     return (a + 1, b), (a, b + 1), (a * 2, b), (a, b * 2)
  138.  
  139.  
  140. @lru_cache(None)
  141. def game(h):
  142.     a, b = h
  143.     if a + b >= 83:
  144.         return 'W'
  145.     if any(game(m) == 'W' for m in moves(h)):
  146.         return 'P1'
  147.     if all(game(m) == 'P1' for m in moves(h)):
  148.         return 'B1'
  149.     if any(game(m) == 'B1' for m in moves(h)):
  150.         return 'P2'
  151.     if all(game(m) == 'P2' or game(m) == 'P1' for m in moves(h)):
  152.         return 'B2'
  153.  
  154.  
  155. for i in range(1, 74):
  156.     j = 9, i
  157.     if game(j) == 'B2':
  158.         print(i, game(j))
  159.  
  160.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement