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 Anna_Barys
def checkio(game_result):
GR = []
for x in range(0,3):
b = list(game_result[x])
GR.append(b)
print(GR)
for y in range(0,3):
if (GR[y][0] == GR[y][1] == GR[y][2]) and GR[y][0] != ".":
wynik = GR[y][0]
print(y, wynik)
break
elif (GR[0][y] == GR[1][y] == GR[2][y]) and GR[0][y] != ".":
wynik = GR[0][y]
print(y, wynik)
break
elif (GR[0][0] == GR[1][1] == GR[2][2]) and GR[0][0] != ".":
wynik = GR[0][0]
print(y, wynik)
break
elif (GR[0][2] == GR[1][1] == GR[2][0])and GR[0][2] != ".":
wynik = GR[0][2]
print(y, wynik)
break
else:
wynik = "D"
print(wynik)
return wynik
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"
Jan. 1, 2016