Advertisement
GeorgiLukanov87

tic_tac_toe_function

Jun 21st, 2022
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. def winner_check(l1, l2, l3, pl):
  2.     if      (l1[0] == pl and l1[1] == pl and l1[2] == pl) or \
  3.             (l2[0] == pl and l2[1] == pl and l2[2] == pl) or \
  4.             (l3[0] == pl and l3[1] == pl and l3[2] == pl) or \
  5.             (l1[0] == pl and l2[1] == pl and l3[2] == pl) or \
  6.             (l1[2] == pl and l2[1] == pl and l3[0] == pl) or \
  7.             (l1[0] == pl and l2[0] == pl and l3[0] == pl) or \
  8.             (l1[1] == pl and l2[1] == pl and l3[1] == pl) or \
  9.             (l1[2] == pl and l2[2] == pl and l3[2] == pl):
  10.         return True
  11.     return False
  12.  
  13.  
  14. p1 = 1
  15. p2 = 2
  16.  
  17. l1 = list(map(int, input().split()))
  18. l2 = list(map(int, input().split()))
  19. l3 = list(map(int, input().split()))
  20.  
  21. if winner_check(l1, l2, l3, p1):
  22.     print('First player won')
  23.  
  24. elif winner_check(l1, l2, l3, p2):
  25.     print('Second player won')
  26.  
  27. else:
  28.     print('Draw!')
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement