Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
X_O_D solution in Speedy category for Xs and Os Referee by spoty
# migrated from python 2.7
def checkio(l, m = ''.join):
c = lambda s: [x[0] for x in s if len(set(x)) == 1 and x[0] != '.'] or 'D'
return m(c(l+map(None, *l)+[m(l)[::4],m(l)[2:-1:2]]))[0]
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert checkio([
"X.O",
"XX.",
"XOO"]) == "X", "Xs wins"
assert checkio([
"OO.",
"XOX",
"XOX"]) == "O", "Os wins"
assert checkio([
"OOX",
"XXO",
"OXX"]) == "D", "Draw"
assert checkio([
"O.X",
"XX.",
"XOO"]) == "X", "Xs wins again"
July 6, 2014
Comments: