#K61232. Mixing Colors
Mixing Colors
Mixing Colors
You are given a list of base colors along with a series of mixing instructions. Each mixing instruction is in the format \(a+b=c\), where \(a\) and \(b\) are the colors to be mixed, and \(c\) is the resulting color.
The first line of the input contains the base colors (which may not be used in the mixing process). Each subsequent line contains a mixing instruction and the list terminates when a line containing a single asterisk (*
) is encountered.
Your task is to simulate the mixing process by processing each instruction in order and appending the resulting color \(c\) to your output list if it has not been produced before. Finally, print the list of resulting colors separated by a space.
inputFormat
The input is read from stdin and consists of multiple lines:
- The first line contains the base colors separated by spaces.
- Each of the following lines contains a mixing instruction in the format
color1+color2=result
. - The instruction list is terminated by a line that contains a single asterisk (
*
).
outputFormat
Output a single line to stdout containing the resulting mixed colors, separated by a single space. If no instructions are provided, output an empty line.
## samplered blue yellow
red+blue=purple
blue+yellow=green
red+yellow=orange
*
purple green orange
</p>