Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
lines generator solution in Clear category for Xs and Os Referee by Phil15
def lines(grid):
# rows
yield from grid
# columns
yield from zip(*grid)
# diagonals
yield grid[0][0], grid[1][1], grid[2][2]
yield grid[0][2], grid[1][1], grid[2][0]
def checkio(game_result):
return next((a for a, b, c in lines(game_result) if a == b == c != '.'), 'D')
# Which is equivalent to:
# for a, b, c in lines(game_result):
# if a == b == c != '.':
# return a
# return 'D'
Feb. 27, 2020
Comments: