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 Pavellver
from typing import List
def checkio(game_result: List[str]) -> str:
for i in range(3):
if game_result[i] == 'XXX':
return 'X'
elif game_result[i] == 'OOO':
return 'O'
elif game_result[0][i] == game_result[1][i] == game_result[2][i] and game_result[0][i] != '.':
return game_result[0][i]
elif game_result[1][1] != '.' and (game_result[0][0] == game_result[1][1] == game_result[2][2] or game_result[0][2] == game_result[1][1] == game_result[2][0]):
return game_result[1][1]
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!")
Feb. 6, 2023
Comments: