Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Xs and Os Referee by Moonra
def checkio(g):
grid = g + list(map("".join, zip(*g))) + [g[0][0]+g[1][1]+g[2][2], g[0][2]+g[1][1]+g[2][0]]
if "XXX" in grid:
return "X"
elif "OOO" in grid:
return "O"
else:
return "D"
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio([
"X.O",
"XX.",
"XOO"]) == "X", "Xs wins"
assert checkio([
"OO.",
"XOX",
"XOX"]) == "O", "Os wins"
assert checkio([
"OOX",
"XXO",
"OXX"]) == "D", "Draw"
Sept. 12, 2013
Comments: