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 ppitek40
def checkio(game_result):
for i in range(3):
if "XXX" in game_result[i]:
return "X"
elif "OOO" in game_result[i]:
return "O"
for i in range(3):
if "X" in game_result[0][i]:
print("something")
if "X" in game_result[1][i] and "X" in game_result[2][i]:
return "X"
for i in range(3):
if "O" in game_result[0][i]:
if "O" in game_result[1][i] and "O" in game_result[2][i]:
return "O"
if ("X" in game_result[0][0] and "X" in game_result[1][1] and "X" in game_result[2][2]) or ("X" in game_result[0][2] and "X" in game_result[1][1] and "X" in game_result[2][0]):
return "X"
if ("O" in game_result[0][0] and "O" in game_result[1][1] and "O" in game_result[2][2]) or ("O" in game_result[0][2] and "O" in game_result[1][1] and "O" in game_result[2][0]):
return "O"
return "D"
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert checkio([
"X.0",
"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. 12, 2017