Make it Colorful
Submissions: 143   Accuracy:

18.89%

  Difficulty: Easy   Marks: 2

In a party, there are 4 dress codes i.e. one can either wear Red(R) or Blue(B) or Green(G) or Yellow(Y). Photographer needs the most colorful pic he can, so he arranges people in a specific order like RGBYRGBY, RYBGRY, RYBGR, RGBYRGB but no order like GGBRGBR, BGYBGY, GBGGBYR. Using the given information you have tell the no. of persons of a particular color required in the order if there is a place for a particular color to have the colorful pic.

Input :
The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. First line contains a string representing the 'order' where an '!' denotes a missing character. You may assume that no Input like GBYR!Y!!!! or YG!!RB!G will be given.

Output :
For each test case in a new line print the string RxByYmGn where x, y, m, n represent the count of the missing colors ie red, blue, yellow, green in the string which satisfies the order.

Constraints:
1<=T<=17
1<=Length of string<=1000

 

Example :
Input:

3
YRGBYRGB
!!!!RYGB
!!!!!BGYR

Output:
R0B0Y0G0
R1B1Y1G1
R2B1Y1G1

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Mohit Gupta
Author: Shubham Joshi 1


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.