Thanks a lot to Mathias Kern aka gardengnome
for creating this puzzle!
Easter bunnies love Easter egg colouring. Given a sequence of eggs, each egg is initially coloured in either
blue (B
) or red (R
). The bunnies are very particular about their egg sequence; they do not like it when
there is a blue egg between any red eggs in the sequence. Helps the bunnies by recolouring the minimal number
of eggs so that they love the result. Both recolouring in blue and red is allowed.
Input: The first line of the problem will be a single integer t
denoting the number of test cases.
The next t
lines each contain a string that represents an egg sequence.
Output: For each test case, print the minimum number of recolouring steps required so that the bunnies love the resulting egg sequence. Print the answers on a single line separated by spaces.
Example:
Input:
3
RBR
RRBBR
RRBBRR
Answer:
1 1 2