DWITE Online Computer Programming Contest, January 2008, Problem 2
This one is a part of a classic game – given a board, check if X
, O
, or neither has won (winner being the one having 3 of their symbols in a row, column, or diagonal).
The input will contain 5 sets, 3 lines each. Each line has 3 characters, out of X
, O
, or .
.
The output will have 5 lines, a single character (X
, O
, or .
) – the winner of the game.
Note: you could assume that there is only one winner on each board.
Sample Input
XO.
.XO
O.X
...
.X.
...
XXO
OOX
XOO
OOO
...
...
O..
O..
O..
Sample Output
X
.
.
O
O
Problem Resource: DWITE
Comments