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
- Find minimum possible values of A, B and C when two of the (A + B), (A + C) and (B + C) are given
- Program to find the initials of a name.
- Find substrings that contain all vowels
- C++ Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +.......+ n/n!
- Find three element from given three arrays such that their sum is X | Set 2
- C++ Program to find whether a no is power of two
- How to find the sum of elements of an Array using STL in C++?
- Find N Geometric Means between A and B
- Find the Nth term of the series 14, 28, 20, 40,.....
- Find elements of an Array which are Odd and Even using STL in C++
- 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.