Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Speedy category for Xs and Os Referee by MichalBiderman127330
def checkio(G):
for i in [0,1,2]:
if G[i][2] == G[i][1] == G[i][0] != '.':
return G[i][0]
if G[2][i] == G[1][i] == G[0][i] != '.':
return G[1][i]
if G[1][1] != '.':
if G[0][0] == G[1][1] == G[2][2] or G[0][2] == G[1][1] == G[2][0]:
return G[1][1]
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"
Oct. 29, 2015
Comments: