Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Xs and Os Referee by walkingpendulum
# migrated from python 2.7
def checkio(game_result):
sample = "".join(game_result)
data = game_result + [sample[i:9:3] for i in range(3)] + [sample[0:9:4], sample[2:8:2]]
if "OOO" in data:
return "O"
elif "XXX" in data:
return "X"
else:
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"
March 25, 2015
Comments: