2001 LSU Computer Science High School Programming Contest

Sponsored by Texas Instruments

Novice - Problem 6

Colored Cube

Remeber Rubik's Cube? Dr. Brownian was fascinated with it. He kept trying to imagine a translucent version. Unfortunately, no one could ever visualize what he was describing. He could not build one either. He did manage to build a simplified version. A real simple version - a cube with six tinted sides. And of course this leads to a problem for you! Problem: A Cube has 6 sides, each of which may be 1 of 5 different tinted panes. Each tinted pane filters light differently. If the pane is tinted red, green, or blue it is translucent. The only completely opaque tint, through which light cannot pass, is black. Clear panes are not tinted at all (but described as a clear tint to make the wording of the rest of this problem easier).

Your task is to determine which color light is transmitted through the cube, given the tints of the panes on each side of the cube and the side through which you are looking. For our purposes, we only need to determine the transmitted color of light when the cube is oriented orthogonally to our viewing direction, hence only 2 tinted panes are effectively visible for any one of the desired viewpoints (the light you see passes through the pane you are looking in and the pane exactly opposite it in the cube). A black pane blocks light; a clear side does not tint the color of the light; red, green, and blue filter the red, green and blue tints respectively of the transmitted light. The table below summarizes the resulting colors, given two sides of arbitrary color:

Tint of Pane 1 Tint of Pane 2 Resulting Color
red red dark red
green green dark green
blue blue dark blue
red green brown
green blue aqua
blue red purple
clear any tint any tint
black any color black

Note that the order of the tints is irrelevant (red and blue are just as purple as blue and red).

Input: A number of cubes will be indicated by the first line of input. Following that will be 7 lines of data describing each cube. The first line will be which pane (side) to look through. The next 6 lines will indicate the colors of each of the sides (1 through 6 respectively). If the sides of the cube were unfolded and the sides were subsequently numbered, the cube would look like the following:

Exploded Cube      Tint Conversion Table
         ___
        |   |
        | 2 |
 ___ ___|___|___
|   |   |   |   |
| 6 | 3 | 1 | 4 |
|___|___|___|___|
        |   |
        | 5 |
        |___|
    
Tint Number
clear 0
black 3
red 7
blue 8
green 9

This is the order in which the input will be given for the sides. The 6 lines of data stating which tint is on each pane contain a single digit representing each tint.

Output: You will output (in text) the color as viewed though the slected panes.

Sample Input:

3		number of cubes
1		side to look through
7		side 1
3		side 2
9		side 3
8		side 4
3		side 5
0		side 6
2		side to look through
3		side 1
8		side 2
7		side 3
9		side 4
8		side 5
7		side 6
4		side to look through
7		side 1
3		side 2
8		side 3
9		side 4
3		side 5
0		side 6

Note: The items in italics are here to help you understand the data. Your real input will only have numbers.

Sample Output:

RED
DARK BLUE
AQUA



Return to Problem Index


 

The statements and opinions included in these pages are those of 2001 LSU Computer Science High School Programming Contest only. Any statements and opinions included in these pages are not those of Louisiana State University or the LSU Board of Supervisors.
© 2000,2001 Isaac Traxler
Last modified: Friday, 01 July, 2011 16:24:51