#K65972. Tic-Tac-Toe Game Winner Determination

    ID: 32316 Type: Default 1000ms 256MiB

Tic-Tac-Toe Game Winner Determination

Tic-Tac-Toe Game Winner Determination

You are given a 3x3 tic-tac-toe board. Each cell of the board is filled with either X, O, or an underscore _ representing an empty cell.

Your task is to determine the current status of the game. The game status is determined as follows:

  • If any row, column, or diagonal has the same symbol (either X or O) and is not an empty cell (_), that symbol wins and the output should be either "X wins" or "O wins".
  • If all cells are filled and there is no winner, the output should be "Draw".
  • If there are still empty cells and no side has won, the game is "Incomplete".

Input is provided via standard input (stdin) and output should be written to standard output (stdout). Use the given input format for the board.

Note: The board will always contain three lines, each line has three characters separated by spaces.

inputFormat

The input consists of exactly 3 lines. Each line contains 3 characters separated by a space. Each character is either X, O, or _ (underscore) which denotes an empty cell.

For example:

X X X
O _ _
O _ _

outputFormat

Output a single line representing the game status. The possible outputs are:

  • X wins
  • O wins
  • Draw
  • Incomplete
## sample
X X X
O _ _
O _ _
X wins