OVOXO - Tic-tac-toe 3
Bored to death working at the Byteland Office...your colleagues have resorted to game of crosses Xs and naughtd Os or Tic-tac-toe. One of them keeps on losing and is tired of the jokes. He plans to have an Android app in his phone to help him out. He is your good friend and seeks your assistance. "Treat at ANC is guaranteed", he says.
He also is very frugal when it comes to memory usage. So please don't write a long if else chain...cause you have to do the task within 999 bytes
An integer T - the number of test cases. (T<1000). T test cases follow.
Each test case comprises 3 strings each separated by newline and containing exactly 3 characters(either 'X','O' or '_') per line. An empty line follows each test case. Each input position is guaranteed to be a valid tic tac toe position such that the game is still not over.
For each test case print "WON" if it is a sure shot winning position. Else print "CONTINUE". Then output the game after having made your move. If more than one move are equally good try playing the move on the first empty spot.
2 OOX OX_ __X XX_ XOO _O_
WON OOX OXX __X WON XXX XOO _O_
Info1) iguaranteed always to be X's move (it is the standard) and whose move it currently is can be computed...
2) winning position is meant for the current player
3) winning in lesser number of moves is better and drawing is better than losing as in general AI
4) you need to print the board as it looks after making the best move
5) print WIN if the current player can win in the case when both players play optimally from here on...
Summary of rules confirmed by AC solution:
@mitch: my mistake forced win in 3 moves is possible...
Ok thanks for clarifying Robert and Aditya, but you gave slightly different rules, so it seems likely the test data is weak!
Description not really clear.
When should we print "WON"? I print when there is a winning move and after it the game is over. And in this case I choose the move that comes first. Is it a correct interpretation?