Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
the most stupid solution of this task solution in Creative category for Xs and Os Referee by autotrap
from typing import List
def checkio(game_result: List[str]) -> str:
participants = ['O', 'X']
for p in participants:
for stroka in range(len(game_result)):
for object in range(len(game_result[stroka])):
if stroka == 0 and object == 0:
if game_result[stroka][object] == p:
if game_result[stroka].count(p) == 3:
return p
if game_result[stroka + 1][object] == p and game_result[stroka + 2][object] == p:
return p
if game_result[stroka + 1][object + 1] == p and game_result[stroka + 2][object + 2] == p:
return p
if stroka == 0 and object == 1:
if game_result[stroka][object] == p:
if game_result[stroka + 1][object] == p and game_result[stroka + 2][object] == p:
return p
if game_result[stroka][object + 1] == p and game_result[stroka][object - 1] == p:
return p
if stroka == 0 and object == 2:
if game_result[stroka][object] == p:
if game_result[stroka].count(p) == 3:
return p
if game_result[stroka + 1][object] == p and game_result[stroka + 2][object] == p:
return p
if game_result[stroka + 1][object - 1] == p and game_result[stroka + 2][object - 2] == p:
return p
if stroka == 1 and object == 0:
if game_result[stroka][object] == p:
if game_result[stroka].count(p) == 3:
return p
if game_result[stroka + 1][object] == p and game_result[stroka - 1][object] == p:
return p
if game_result[stroka][object + 1] == p and game_result[stroka][object + 2] == p:
return p
if stroka == 1 and object == 1:
if game_result[stroka][object] == p:
if game_result[stroka + 1][object] == p and game_result[stroka - 1][object] == p:
return p
if game_result[stroka][object + 1] == p and game_result[stroka][object - 1] == p:
return p
if stroka == 1 and object == 2:
if game_result[stroka][object] == p:
if game_result[stroka].count(p) == 3:
return p
if game_result[stroka + 1][object] == p and game_result[stroka - 1][object] == p:
return p
if game_result[stroka][object - 1] == p and game_result[stroka][object - 2] == p:
return p
if stroka == 2 and object == 0:
if game_result[stroka][object] == p:
if game_result[stroka].count(p) == 3:
return p
if game_result[stroka - 1][object] == p and game_result[stroka - 2][object] == p:
return p
if game_result[stroka][object + 1] == p and game_result[stroka][object + 2] == p:
return p
if stroka == 2 and object == 1:
if game_result[stroka][object] == p:
if game_result[stroka - 1][object] == p and game_result[stroka - 2][object] == p:
return p
if game_result[stroka][object + 1] == p and game_result[stroka][object - 1] == p:
return p
if stroka == 2 and object == 2:
if game_result[stroka][object] == p:
if game_result[stroka].count(p) == 3:
return p
if game_result[stroka - 1][object] == p and game_result[stroka - 2][object] == p:
return p
if game_result[stroka][object - 1] == p and game_result[stroka][object - 2] == p:
return p
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!")
March 6, 2020
Comments: