Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
20 Lines, Nested if checks, Noob solution in Clear category for Xs and Os Referee by ccortello
def checkio(game_result):
#check 'crosses'
if game_result[0][0] == game_result[1][1] == game_result[2][2]:
if game_result[1][1] != '.':
return game_result[1][1]
elif game_result[0][2] == game_result[1][1] == game_result[2][0]:
if game_result[1][1] != '.':
return game_result[1][1]
#check each row and column
for i in range(3):
if game_result[i][0] == game_result[i][1] == game_result[i][2]:
if game_result[i][1] != '.':
return game_result[i][1]
elif game_result[0][i] == game_result[1][i] == game_result[2][i]:
if game_result[1][i] != '.':
return game_result[1][i]
#if no one won return D
return 'D'
June 4, 2015