Advertisement
GeorgiLukanov87

tic-tac-toe function #2 100/100

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