Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Xs and Os Referee by radekj
def checkio(game_result):
# determine all possible winning combinations: rows, columns and diagonals
rows = game_result
cols = list(zip(*rows))
diagonals = []
for _ in range(2):
diagonals.append([rows[i][i] for i in range(len(rows))])
rows.reverse()
# check if any of combinations contains the same set of chars
for line in rows + cols + diagonals:
if len(set(line)) == 1:
if line[0].isalpha():
return line[0]
# end game as a draw if no combination matches
return 'D'
March 11, 2015
Comments: