# Untitled

May 27th, 2021
785
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. str = input("Enter cells: ")
2.
3. print(f"""{"-" * 9}
4. | {str[0]} {str[1]} {str[2]} |
5. | {str[3]} {str[4]} {str[5]} |
6. | {str[6]} {str[7]} {str[8]} |
7. {"-" * 9}""")
8.
9. if abs(str.count("X") - str.count("O")) > 1:
10.     print("Impossible")
11.     exit()
12.
13. win = ""
14.
15. for b, s in [[0, 1], [3, 1], [6, 1], [0, 3], [1, 3], [2, 3], [0, 4], [2, 2]]:
16.     h = "".join([str[i] for i in range(b, b + s * 3, s)])
17.     if "XXX" in h:
18.         if win == "O":
19.             print("Impossible")
20.             exit()
21.         win = "X"
22.     elif "OOO" in h:
23.         if win == "X":
24.             print("Impossible")
25.             exit()
26.         win = "O"
27.
28. if win == "X":
29.     print("X wins")
30. elif win == "O":
31.     print("O wins")
32. elif str.count("_"):
33.     print("Game not finished")
34. else:
35.     print("Draw")
RAW Paste Data