Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Solved with sets solution in Clear category for Xs and Os Referee by tomkun
def checkio(board, size=3):
check = lambda s: len(s)==1 and '.' not in s
#diagonals
diag1 = set(board[x][x] for x in range(size))
if check(diag1):
return diag1.pop()
diag2 = set(board[size-x-1][x] for x in range(size))
if check(diag2):
return diag2.pop()
#horizontal
for row in board:
s = set(row)
if check(s):
return s.pop()
#vertical
for col in range(size):
s = set(row[col] for row in board)
if check(s):
return s.pop()
return 'D'
Feb. 21, 2015
Comments: