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 MadHatter
def checkio(r):
l = [[r[0][0], r[1][1], r[2][2]], [r[2][0], r[1][1], r[0][2]]]
for i in range(3):
l.append([x for x in r[i]])
l.append([x[i] for x in r])
if ['X', 'X', 'X'] in l: return 'X'
if ['O', 'O', 'O'] in l: return 'O'
return "D"
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio([
"X.O",
"XX.",
"XOO"]) == "X", "Xs wins"
assert checkio([
"OO.",
"XOX",
"XOX"]) == "O", "Os wins"
assert checkio([
"OOX",
"XXO",
"OXX"]) == "D", "Draw"
Sept. 17, 2013
Comments: