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 15510087266
from typing import List
def checkio(game_result: List[str]) -> str:
aList = []
answer = []
for word in game_result:
for w in word:
aList.append(w)
if (aList[0]==aList[4] and aList[8]==aList[4]) or (aList[2]==aList[4] and aList[6]==aList[4]):
answer.append(aList[4])
for i in range(0,3):
if aList[3*i] == aList[3*i+1] and aList[3*i] == aList[3*i+2]:
answer.append(aList[3*i])
if aList[i+3] == aList[i] and aList[i+6] == aList[i]:
answer.append(aList[i])
for ans in answer:
if ans.isalpha():
return ans
else:
continue
return 'D'
if __name__ == '__main__':
print("Example:")
print(checkio(["X.O",
"XX.",
"XOO"]))
#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"
print("Coding complete? Click 'Check' to review your tests and earn cool rewards!")
June 17, 2019