Last active
July 1, 2018 03:18
-
-
Save alexozer/faccfb7e720d41de2e572baaa16661c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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