Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Xs and Os Referee by bartosz_lyzwa
def checkRow(row):
if row.count('X')==3 or row.count('O')==3:
return row[0]
else:
return 'D'
def checkio(game_result):
for i in range(len(game_result)):
horizontalCheck = checkRow(game_result[i][0] + game_result[i][1] + game_result[i][2])
if horizontalCheck != 'D':
return horizontalCheck
verticalCheck = checkRow(game_result[0][i] + game_result[1][i] + game_result[2][i])
if verticalCheck != 'D':
return verticalCheck
diagonalCheck = checkRow(game_result[0][0] + game_result[1][1] + game_result[2][2])
if diagonalCheck != 'D':
return diagonalCheck
diagonalCheck = checkRow(game_result[2][0] + game_result[1][1] + game_result[0][2])
if diagonalCheck != 'D':
return diagonalCheck
return 'D'
Oct. 19, 2017