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 tssrkt777
def checkio(a) -> str:
for x in range(3):
for w in ['O', 'X']:
if a[x].count(w) == 3 or a[0][x] == a[1][x] == a[2][x] == w or \
a[0][0] == a[1][1] == a[2][2] == w or a[0][2] == a[1][1] == a[2][0] == w:
return w
return "D"
if __name__ == "__main__":
print("Example:")
print(checkio(["X.O", "XX.", "XOO"]))
# These "asserts" using only for self-checking and not necessary for auto-testing
assert checkio(["X.O", "XX.", "XOO"]) == "X", "X wins"
assert checkio(["OO.", "XOX", "XOX"]) == "O", "O wins"
assert checkio(["OOX", "XXO", "OXX"]) == "D", "Draw"
assert checkio(["O.X", "XX.", "XOO"]) == "X", "X wins again"
print("Coding complete? Click 'Check' to review your tests and earn cool rewards!")
Nov. 1, 2021
Comments: