2002 LSU Computer Science High School Programming Contest

Sponsored by Microsoft

Veteran - Problem 4

 MAIN
  Home
  Schedule
  Registration
  Rules
  About
  Language
  Prizes
  
 RESULTS
  Problem Set
  Judge Data
  Solutions
  
 LINKS
  LSU
  Computer Science
  Contest Index
  HS 2001
  HS 2000
  ACM Intl PC
  PC2
 

Colour Is The Key

If there's one thing that can shake Sam from his almost permanent state of slack, it's a good mental challenge. Which is quite fortuitous, considering the sort of pranks that his landlady plays on him. As a professional recreational mathematician, she loves to stump Sam with a good puzzle now and then.

Imagine his surprise when he came home and the lock on his door had been replaced by two interlocking circles, inset with gems.

Description:

The door is locked by a set of two rings inset with gemstones. Each ring has eight gems, and they interlock as shown:

      03      10 
  02      04      11

01     09    05     12

  08      06      13
      07      14

Positions 4 and 6 are shared between the two rings. Given both a starting set of coloured gems in the various positions and directions for turning the two rings, you are to print out what colour gems are in each position at the end. When a ring turns, all of the gems in it move by one position. Note that either ring turning moves the stones in positions 4 and 6. The rings may either turn widdershins (represented by an uppercase W)--the top of the ring towards the left--or deosil (represented by an uppercase D)--the top of the ring towards the right. The rings themselves are represented by a uppercase L for the left ring and an uppercase R for the right ring.

The possible colours for the gems are red, green, blue, yellow, and purple.

Input:

The first piece of data in the file is the number of simulations to run. For each simulation, the first 14 lines contain the colours of the fourteen gems, in the order shown above, represented by strings from the set {red, green, blue, yellow, purple}. The next piece of data is t, the number of turns to execute in the simulation, represented by a non-negative integer. The next t lines each contain two pieces of data, separated by a space and represented by single characters. The first is the ring to turn, taken from the set {L, R}; the second is the direction in which to turn it, taken from the set {W, D}.

Output:

For each simulation, print

	Simulation x:
	g1
	g2
	g3
	g4
	g5
	g6
	g7
	g8
	g9
	g10
	g11
	g12
	g13
	g14
where x is the simulation number, starting from 1, and g1, g2, . . . , g14 are the fourteen gem colours in the same order as above, taken from the set {red, green, blue, yellow, purple}.

Sample Input:

1		Number of simulations
red		Colour of gem in location 01
red		Colour of gem in location 02
red
blue
blue
blue
green
green
green
yellow
yellow
yellow
purple
purple		Colour of gem in location 14
5		Number of rotations
L W		Ring and direction for the first rotation
R D		Ring and direction for the second rotation
L D
R W
L D		Ring and direction for the fifth rotation

Sample Output:

Simulation 1:
green
red
red
red
blue
green
green
purple
blue
yellow
yellow
yellow
purple
blue


Return to Problem Index


 

The statements and opinions included in these pages are those of 2002 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.
Site maintained by: Isaac Traxler
© 2000,2001,2002    Last modified: Saturday, 26 February, 2005 14:40:39