Last active
August 19, 2018 23:38
-
-
Save clonex10100/dca06673ba90c9281f9989a7d179b143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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