Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Short with using chain solution in Clear category for Xs and Os Referee by Marcin_Ramotowski
from typing import List
from itertools import chain
def checkio(grid: List[str]) -> str:
chars = ('O', 'X')
columns = [[row[i] for row in grid] for i in range(3)]
diagonals = [[grid[i][i] for i in range(3)], [grid[i][2-i] for i in range(3)]]
def result(part):
for char in chars:
if part.count(char) == 3:
return char
for row in chain(grid, columns, diagonals):
score = result(row)
if score:
return score
return 'D'
Aug. 26, 2021
Comments: