Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
build substring, check substring vs win condition solution in Clear category for Xs and Os Referee by UpwardTrajectory
def checkio(game):
for p in ('X', 'O'):
DRdiag = ''.join(game[j][j] for j in [0,1,2])
DLdiag = ''.join(game[j][2-j] for j in [0,1,2])
for n in [0,1,2]:
down = ''.join(game[j][n] for j in [0,1,2])
if down == 3*p: # Vert win
return p
if game[n] == 3*p: # Horiz win
return p
if DRdiag == 3*p: # \ win
return p
if DLdiag == 3*p: # / win
return p
return 'D'
March 26, 2019
Comments: