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 radek120299
from typing import List
def checkio(game_result: List[str]) -> str:
odp=""
for i in range(3):
if game_result[0][i]==game_result[1][i] and game_result[1][i]==game_result[2][i]:
odp=game_result[0][i]
if game_result[i][0]==game_result[i][1] and game_result[i][1]==game_result[i][2]:
odp=game_result[i][0]
if game_result[0][0]==game_result[1][1]==game_result[2][2]:
odp=game_result[0][0]
if game_result[0][2]==game_result[1][1]==game_result[2][0]:
odp=game_result[0][2]
if odp=="" or odp==".":
odp="D"
return odp
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", "Xs wins"
assert checkio([
"OO.",
"XOX",
"XOX"]) == "O", "Os wins"
assert checkio([
"OOX",
"XXO",
"OXX"]) == "D", "Draw"
print("Coding complete? Click 'Check' to review your tests and earn cool rewards!")
Nov. 6, 2018