Advertisement
stupid_pro

Stones_count_intuitive

Jan 28th, 2023 (edited)
950
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.22 KB | None | 0 0
  1. # or - умный, and - бот
  2.  
  3. def win(s1,s):
  4.     return s1+s>=75
  5.  
  6. def first(s1,s):
  7.     return (win(s1+1,s) or win(s1,s+1) or win(s1*2,s) or win(s1,s*2)) and not win(s1,s)
  8.  
  9. def second(s1,s):
  10.     return first(s1+1,s) and first(s1,s+1) and first(s1*2,s) and first(s1,s*2) and not win(s1,s)
  11.  
  12. def third(s1,s):
  13.     return (second(s1+1,s) or second(s1,s+1) or second(s1*2,s) or second(s1,s*2)) and not win(s1,s)
  14.  
  15. def fourth (s1,s):
  16.     return (third(s1+1,s) or first(s1+1,s)) and (third(s1,s+1) or first(s1,s+1)) and (third(s1*2,s) or first(s1*2,s)) and (third(s1,s*2) or first(s1,s*2)) and not win(s1,s)
  17. '''
  18. print('Выигрыш первым ходом:')
  19. for i in range(1, 67):
  20.    if first(8,i):
  21.        print(i, end = ' ')
  22.  
  23. print('\n\nВыигрыш вторым ходом:')
  24. for i in range(1, 67):
  25.    if second(8,i):
  26.        print(i, end = ' ')
  27. '''
  28.  
  29. print('\n\nВыигрыш третьим ходом (ответ на КИМ 20):')
  30. for i in range(1, 67):
  31.     if third(8,i):
  32.         print(i, end = ' ')
  33.  
  34. print('\n\nВыигрыш четвёртым, но не вторым ходом (ответ на КИМ 21):')
  35. for i in range(1, 67):
  36.     if fourth(8,i) and not second(8,i):
  37.         print(i, end = ' ')
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement