Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Three pieces solution in Clear category for Xs and Os Referee by bryon.hance
from typing import List
def checkio(game_result: List[str]) -> str:
# Check rows
for row in game_result:
if row[0] == row[1] == row[2] != '.':
return row[0]
gr = game_result
# Check columns
for i in range(3):
if gr[0][i] == gr[1][i] == gr[2][i] != '.':
return gr[0][i]
# Check diagonals
if gr[0][0] == gr[1][1] == gr[2][2]:
return 'D' if gr[0][0] == '.' else gr[0][0]
if gr[2][0] == gr[1][1] == gr[0][2]:
return 'D' if gr[1][1] == '.' else gr[1][1]
return "D"
July 30, 2019