Skip to content

Instantly share code, notes, and snippets.

@alexozer
Last active July 1, 2018 03:18
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 alexozer/faccfb7e720d41de2e572baaa16661c3 to your computer and use it in GitHub Desktop.
Save alexozer/faccfb7e720d41de2e572baaa16661c3 to your computer and use it in GitHub Desktop.
def has_won(self, player):
mark = player.mark
size = len(self.board)
return (
any(all(slot == mark for slot in row) for row in self.board) or
any(all(row[col_idx] == mark for row in self.board) for col_idx in range(size)) or
all(self.board[i][i] == mark for i in range(size)) or
all(self.board[i][size - i - 1] for i in range(size))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment