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 martin.pilka
from typing import List
def checkio(game_result: List[str]) -> str:
# Check rows
for i in range(0, 3):
if game_result[i][0] != '.' and game_result[i][0] == game_result[i][1] == game_result[i][2]:
return game_result[i][0]
# Check columns
for i in range(0, 3):
if game_result[0][i] != '.' and game_result[0][i] == game_result[1][i] == game_result[2][i]:
return game_result[0][i]
# Check diagonals
if game_result[0][0] != '.' and game_result[0][0] == game_result[1][1] == game_result[2][2]:
return game_result[0][0]
if game_result[0][2] != '.' and game_result[0][2] == game_result[1][1] == game_result[2][0]:
return game_result[0][2]
return 'D'
Jan. 17, 2019
Comments: