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 MKaa01
def checkio(game_result):
w = game_result
for i in range(3):
w += [w[0][i]+w[1][i]+w[2][i]]
w += [w[0][0] + w[1][1] + w[2][2], w[0][2] + w[1][1] + w[2][0]]
o = w.count('OOO')
x = w.count('XXX')
if o and x:
return 'D'
elif o:
return 'O'
elif x:
return 'X'
else:
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"
print("Coding complete? Click 'Check' to review your tests and earn cool rewards!")
Jan. 17, 2018