Skip to content

Instantly share code, notes, and snippets.

@clonex10100
Last active August 19, 2018 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clonex10100/dca06673ba90c9281f9989a7d179b143 to your computer and use it in GitHub Desktop.
Save clonex10100/dca06673ba90c9281f9989a7d179b143 to your computer and use it in GitHub Desktop.
def analyze(x):
board=[list(x[0:3]),list(x[3:6]),list(x[6:9])]
for i in range(3):
if all(j[i] == "X" for j in board) or all(board[i][j] == "X" for j in range(3)):
return "X"
if all(j[i] == "O" for j in board) or all(board[i][j] == "O" for j in range(3)):
return "O"
#Check diagnals
if board[0][0] == board[1][1] == board[2][2] or board[0][2] == board[1][1] == board[2][0]:
if board[1][1] != "#":
return board[1][1]
return "#"
print(analyze(input()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment