Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Xs and Os Referee by danilovmy
def checkio(game_result):
game_result += (map(''.join,zip(*game_result)))
game_result.append(''.join(game_result[i][-i-1] for i in range(0,len(game_result[0]))))
game_result.append(''.join(game_result[i][i] for i in range(0,len(game_result[0]))))
return "X" if game_result.count("XXX") else "O" if game_result.count("OOO") else "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"
Aug. 17, 2015