Loading environment...
Problem Description
Ngoc and Minh devised a creative way to eat candy that comes in three different colours: red, green, and blue. They begin by arranging some coloured candies into a line. Then, the candy at the front of Ngoc's line is compared to the candy at the front of Minh's line.
The winning rules are as follows:
R wins against green candy G.G wins against blue candy B.B wins against red candy R.This process of comparing and eating candy repeats until there is at least one empty line of candy. When that happens, if one person still has candy left in their line, then that person eats all of their leftover candy. Your job is to determine how much candy each person eats.
Input Specification
The first line of input contains a sequence of letters, representing Ngoc's line of candy. The second line contains a sequence of letters, representing Minh's line of candy. Each letter will be an uppercase R, G, or B representing the colours red, green, and blue, respectively. The first letter in each sequence represents the colour of the candy at the front of that person's line. There will always be at least one letter in each sequence.
| Marks | Description | Bounds |
|---|---|---|
| 2 | Ngoc and Minh each have one candy. | and |
| 4 | Ngoc's line will empty first, or both lines will empty at the same time. | and |
| 7 | Ngoc and Minh could have many candies. | and |
| 2 | Ngoc and Minh could have an absurd amount of candy. | and |
Output Specification
There will be two lines of output.
Sample Input
Sample Output
Explanation for Sample Output
RRR, Minh: RGBB. Both have red candy at the front. Both eat their red candy. (Ngoc: 1, Minh: 1).RR, Minh: GBB. Ngoc's red candy wins against Minh's green candy. Ngoc eats the green candy. (Ngoc: 2, Minh: 1).RR, Minh: BB. Minh's blue candy wins against Ngoc's red candy. Minh eats Ngoc's red candy. (Ngoc: 2, Minh: 2).R, Minh: BB. Minh's blue candy wins against Ngoc's red candy. Minh eats Ngoc's red candy. (Ngoc: 2, Minh: 3).No comments yet. Be the first to comment!