1D Othello is a board game played with Othello tiles and a horizontal grid. The game is played as follows:
- The game pieces are tiles in which one side is black and the other side is white.
- There are two players. One player plays black tiles (the black side of the tiles), the other plays
white tiles (the white side of the tiles).
- The game begins with two tiles next to each other.The left tile is black and the right tile is white.
- The players take turns placing a tile on the board.A player cannot pass their turn
- Tiles can only be placed next to a tile that is already on the board. Therefore, there are only two positions in which a tile can be placed on each turn (to the left or right of the tiles already on the board).
- After placing a tile, the player flips all of the tiles between the new tile and the nearest same-color tile. If the tile next to the new tile is the same color or there are no same-color tiles, the player does not flip any tiles
- The player must place a tile even when he cannot flips any tiles.
A transcript of 1D Othello is written in a string consisting of L and R. If the i-th letter of the transcript is L, that means a tile (a black tile when i is an odd number and a white tile when i is an even number) was placed to the left of the tiles already on the board, and if it is R that means a tile was placed to the right of the tiles already on the board.
You are given a transcript S of the game. Please display the respective number of black and white tiles at the conclusion of the game.
Sample input 1
RRLL
Sample output 1
0 6
Explanation
The game proceeded as follows:
bw(initial)->bbb->bbbw->bbbbw->wwwwww
Hence, all six white tiles at the end of the game.
Sample input 2
LLRLRLR
Sample output 2
3 6
Please share approach to solve this.