DWITE Online Computer Programming Contest, February 2011, Problem 1
Colour has often been added to words to make them seem more attractive or distinct (take the Google logo for example). However, taking a look at coloured words under coloured light makes the letters in the word that has the same colour as the light seem invisible. For example, say I have the word DWITE
, and its letters are coloured blue, red, red, green and blue respectively. If you looked at the word under red light, you would only see D__TE
(note the underscores, representing positions, where the W
and I
have been). Given coloured words and the light they are observed under, determine what you would see.
The input will contain 5 test cases. The first line of each test case consists of two words (strings with no spaces) and , representing the word and the colour of each letter of the word respectively (so the letter of determines the colour of the letter of , where the possible colours are b
for blue, r
for red, and g
for green). The next line contains a string , representing the colour of the light. consists of either a b
, r
, or g
(representing blue, red and green), or any combination of these letters separated by +
s.
The output should consist of 5 lines, where each line contains the given word as it appears under the given light. Invisible letters are to be represented with _
underscores.
Note: There are 3 underscores after Compu
in the third line of output, and the last line of output contains 5 underscores. It is also assumed that combined colours remove letters of either individual component in the combination.
Sample Input
Sample rggbbr
b
DWITE brrgb
r
Computer bbbbbrrg
r+g
February brbrbrbr
g
Sweet brgbr
r+g+b
Sample Output
Sam__e
D__TE
Compu___
February
_____
Problem Resource: DWITE
Comments
If it helps anyone, I tested and found the maximum string length is 9.