Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Rude solution in Clear category for Xs and Os Referee by melodyHH
# migrated from python 2.7
def win(list, c):
if list[0][0] == list[0][1] == list[0][2] == c : return True
if list[1][0] == list[1][1] == list[1][2] == c : return True
if list[2][0] == list[2][1] == list[2][2] == c : return True
if list[0][0] == list[1][0] == list[2][0] == c : return True
if list[0][1] == list[1][1] == list[2][1] == c : return True
if list[0][2] == list[1][2] == list[2][2] == c : return True
if list[0][0] == list[1][1] == list[2][2] == c : return True
if list[0][2] == list[1][1] == list[2][0] == c : return True
return False
def checkio(game_result):
if win(game_result, 'X'): return "X"
if win(game_result, 'O'): return "O"
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"
Sept. 18, 2015