Tic-Tac-Toe Judge
Completed
Read a 3×3 board (three lines of X, O, .). Print X wins, O wins, draw (full board, no winner) or in progress.
Input
Three lines.
Output
One line.
Example
Input
XXX O.O ...
Output
X wins
Editor
Python
Hints
Collect all 8 lines: 3 rows, 3 columns, 2 diagonals.
A player wins if "XXX" or "OOO" is one of them.
Solution explanation
Turning the board into a list of lines makes the win check a single membership test.
Show solution
board = [input() for _ in range(3)]
lines = board + ["".join(col) for col in zip(*board)]
lines += ["".join(board[i][i] for i in range(3)), "".join(board[i][2 - i] for i in range(3))]
for player in "XO":
if player * 3 in lines:
print(f"{player} wins")
break
else:
print("in progress" if any("." in row for row in board) else "draw")