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 aquazul
def checkio(game_result):
xs, os = "XXX", "OOO"
if xs in game_result: return "X"
if os in game_result: return "O"
inversed = ["".join(l) for l in zip(*game_result)]
if xs in inversed: return "X"
if os in inversed: return "O"
if all(game_result[i][i] == "X" for i in range(3)): return "X"
if all(game_result[i][i] == "O" for i in range(3)): return "O"
if all(game_result[i][2-i] == "X" for i in range(3)): return "X"
if all(game_result[i][2-i] == "O" for i in range(3)): return "O"
return "D"
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert checkio([
"X.O",
"XX.",
"XOO"]) == "X", "Xs wins"
assert checkio([
"OO.",
"XOX",
"XOX"]) == "O", "Os wins"
assert checkio([
"OOX",
"XXO",
"OXX"]) == "D", "Draw"
assert checkio([
"O.X",
"XX.",
"XOO"]) == "X", "Xs wins again"
Jan. 14, 2016