No.88 Whose Turn Is Next?
Problem Statement
There is a board game called Reversi (also known as Shirokuro or Othello), played with an 8×8 board and 64 stones that are white on one side and black on the other.
Oda-kun and Yukiko-chan are now playing this Reversi.
However, they got a little tired, so they decided to take a break in the middle of the game.
When they tried to resume the game after the break, they found that they had both forgotten whose turn was next.
They remember only who moved first (playing black), and that neither of them passed even once.
From the current state of the board, tell them which of them should place a stone next.
Note that the player whose turn is next will not pass.
If you cannot place a stone in a way that sandwiches the opponent's stones, you pass and it becomes the opponent's turn.
Two black stones and two white stones are placed diagonally on the central 4 squares of the board, and black always moves first.
The game ends when neither player can sandwich the opponent's stones or when all 64 squares are filled. The player with more stones of their color wins.
Reference: Wikipedia
http://ja.wikipedia.org/wiki/%E3%82%AA%E3%82%BB%E3%83%AD_%28%E9%81%8A%E6%88%AF%29#.E5.9F.BA.E6.9C.AC.E7.9A.84.E3.81.AA.E3.83.AB.E3.83.BC.E3.83.AB
Input
$S$ $B_1$ $B_2$ $\vdots$ $B_8$
Line $1$ contains a string $S$ (either "oda" or "yukiko") indicating who moved first.
The next $8$ lines contain strings $B_i$ representing the state of the board.
The $j$-th character of $B_i$ represents the state of the square that is $i$-th from the top and $j$-th from the left. $(1\leq j\leq8)$
The strings consist of three kinds of characters, ".", "b" and "w": "." means the square is empty, "b" means a black stone is placed on it, and "w" means a white stone is placed on it.
It is guaranteed that the answer is uniquely determined.
It is guaranteed that the board is not invalid as a game position.
Output
Output "oda" if the next turn is Oda-kun's, or "yukiko" if it is Yukiko-chan's.
Print a newline at the end.
Sample
Sample 1
Input
oda ........ ........ ........ ...wb... ...bw... ........ ........ ........
Output
oda
This is the standard initial arrangement. Note that black moves first.
Sample 2
Input
yukiko ........ ........ ........ ..bbb... ...bw... ........ ........ ........
Output
oda
This arrangement cannot occur in any state other than the one where one stone has been placed from the initial arrangement.
Sample 3
Input
yukiko ........ ....w... ..wwww.. ..wbww.. ..bbbwb. .b.bb.w. ........ ........
Output
yukiko
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。