Skip to content

Instantly share code, notes, and snippets.

@beltiras
Created October 15, 2018 16:39
Show Gist options
  • Save beltiras/a71880eca858c4f2b710b32e435d27af to your computer and use it in GitHub Desktop.
Save beltiras/a71880eca858c4f2b710b32e435d27af to your computer and use it in GitHub Desktop.
def check_win(game_state, token):
all_rows = [[line[x] for line in game_state] for x in range(len(game_state))] + [game_state[len(game_state)-x-1][x] for x in range(len(game_state))] + [game_state[x][x] for x in range(len(game_state))]
for line in all_rows:
if sum([1 for t in line if t == token]) == len(game_state):
return token
return " "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment