Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Xs and Os Referee solution in Clear category for Xs and Os Referee by Seaclaid
def checkio(gres):
print(gres)
w1,w2,w3=gres
for gracz in ['X','O']:
for i in range(3):
temp=gres[i]
if temp.count(gracz)==3:
print('wynik 1',gracz)
return gracz
if w1[i]==w2[i]==gracz and w2[i]==w3[i]==gracz:
print('wynik 2',w1[i])
return w1[i]
if w1[0]==w2[1]==w3[2]==gracz or w1[2]==w2[1]==w3[0]==gracz:
print('wynik 3',w2[1])
return w2[1]
print('wynik 4','D')
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"
assert checkio([".OX",".XX",".OO"]) == 'D'
Jan. 15, 2017