Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Recursion with rotation solution in Creative category for Xs and Os Referee by Baxter
# migrated from python 2.7
def checkio(game_result):
def check_lines(game_result, last=False):
diag1 = diag2 = ''
for i, r in enumerate(game_result):
diag1 += r[i]
diag2 += r[2-i]
if r == "XXX" or diag1 == "XXX" or diag2 == "XXX":
return "X"
elif r == "OOO" or diag1 == "OOO" or diag2 == "OOO":
return "O"
if last:
return "D"
game_result= list(map(lambda x, y, z: x+y+z, game_result[0], game_result[1], game_result[2]))
return check_lines(game_result, last=True)
return check_lines(game_result)
Jan. 29, 2015
Comments: