Given a String of three Colours(G, B, Y) as input, the task is to print the resultant combined colour formed according to the rule given below:
// Rules for colour combination Blue(B) * Green(G) = Yellow(Y) Yellow(Y) * Blue(B) = Green(G) Green(G) * Yellow(Y) = Blue(B)
Input: str = "GBYGB" Output B Input: str = "BYB" Output Y
Approach: This problem can be solved as follows:
- Get the input string.
- Compare each alphabet with its adjacent characters.
- Use the above condition to determine the combination.
- print the output combination.
Below is the implementation of the above approach:
- Shortest possible combination of two strings
- Python | Print all string combination from given numbers
- Count number of strings (made of R, G and B) using given combination
- Find the value of N when F(N) = f(a)+f(b) where a+b is the minimum possible and a*b = N
- C++ Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +.......+ n/n!
- Find the missing value from the given equation a + b = c
- Program to find the value of sin(nΘ)
- C++ Program to find whether a no is power of two
- Program to find the value of tan(nΘ)
- Program to find the initials of a name.
- Find the direction from given string
- Find substrings that contain all vowels
- Find the Nth term of the series 14, 28, 20, 40,.....
- Find sub-string with given power
- Program to find greater value between a^n and b^n
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.