Skip to content

Instantly share code, notes, and snippets.

@8Observer8
Created March 30, 2020 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 8Observer8/20420333e47ea4781d829ac7c0967d3e to your computer and use it in GitHub Desktop.
Save 8Observer8/20420333e47ea4781d829ac7c0967d3e to your computer and use it in GitHub Desktop.
grid = [
[" ", " ", " "],
[" ", " ", " "],
[" ", " ", " "]]
def is_winner(player):
return (
# Rows
grid[0][0] == player and grid[0][1] == player and grid[0][2] == player or
grid[1][0] == player and grid[1][1] == player and grid[1][2] == player or
grid[1][0] == player and grid[1][1] == player and grid[1][2] == player or
# Columns
grid[0][0] == player and grid[1][0] == player and grid[2][0] == player or
grid[0][1] == player and grid[1][1] == player and grid[2][1] == player or
grid[0][2] == player and grid[1][2] == player and grid[2][2] == player or
# Diagonals
grid[0][0] == player and grid[1][1] == player and grid[2][2] == player or
grid[0][2] == player and grid[1][1] == player and grid[2][0] == player)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment