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 heigenbarth11
def checkio(game_result):
for i in game_result:
print (game_result)
if i == 'XXX': return 'X'
elif i == 'OOO': return 'O'
c1 = game_result[0]
c2 = game_result[1]
c3 = game_result[2]
for i in range(0,3):
if c1[i]==c2[i] and c2[i]==c3[i] and c1[i]!='.': return c1[i]
if c1[0]== c2[1] and c2[1] == c3[2] and c1[0] != '.': return c1[0]
if c1[2]== c2[1] and c2[1] == c3[0] and c1[2] != '.': return c1[2]
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!")
Dec. 4, 2017