Today, you head to the Cargo Hold for your next assignment. The room is brightly
lit in a white light, and you see thick tubes and chutes crisscrossing the walls and
the high ceiling. Immediately in front of you, centered in the room, you see a
row of 40 giant capsule-filled tubes with an opening for each
at the very top and at the front of the bottom, like upside-down
PEZ dispensers. Beside this dispensing
system, bolted to the floor, is a large
robotic arm.
It is nearly as tall as the ceiling and features grips for spherical objects at the
end of its long arm.
You're greeted by the supervisor of the Cargo Hold, who has a kind voice and an
even kinder smile. She explains what you need to do:
The spherical capsules inside these
tubes are all different kinds of cargo. They are heavy metallic balls studded with
rivets and embellishments. To tell them apart, most of the capsules are
painted with a large, bright red character (either
alphabetical or a punctuation symbol). The ones that lack any marking are all the
same item, so it might be helpful to think of them as a space character (" ").
What's inside them? She has no idea. She just gets a request from somewhere and
runs the machine to fulfill it. Requests come on a piece of paper with three sections.
-
The first line: a number from 0 to 39.
This indicates
which dispenser to set the machine to start at.
-
The next line: a series of commands for the robotic arm,
separated by commas.
Each command begins with an R, L, T, or
D, followed by a number.
-
The following lines: lines of text representing the initial
state of capsules in all dispensers.
Each line shows the contents of the
dispensers, ordered from 0 to 39. The capsule characters are listed
from the bottom of each dispenser to
the top, separated by commas.
-
When the machine gets an R or L command, the robotic arm
moves its position either Right or
Left by the numberof places indicated
-
When the machine gets a T command, the robotic arm
Takes a single capsule from the bottom of the dispenser at its
current position, letting the remaining capsules in the dispenser descend
to fill the empty space
-
The grabbed capsule is then vacuumed into the robotic arm's C-shaped
tube, where capsules are stored, always inserting itself
into the entry point of the tube
-
This process is completed as many times as indicated by the number in the command,
always one-at-a-time and never multiple capsules
simultaneously
-
When the machine gets a D command, the robotic arm
Drops the specified number of capsules, one-at-a-time, into
the top of the dispenser it's currently facing
-
Because of the C-shaped tube, capsules are dispensed from the
opposite end of the tube
You need to manually control the machine while following the instructions. Once the
order is complete, you press the "release" button and one capsule
from each dispenser rolls out from the bottom, in order, onto the delivery cart
to be sent out to the appropriate area of the ship.
For example (with a shorter 5-dispenser system):
If your instructions are
3
L1,T3,R2,D1,L4,T3,R3,D4,L2,T1,L1,D1
Y,R,S
H,P
F,C,B,A
E
START
Dispensers: |
0 | 1 | 2 | 3 | 4 |
| | A | | |
S | | B | | |
R | P | C | | |
Y | H | F | | E |
C-Shaped Tube: |
| | | | |
Command: L1
Dispensers: |
0 | 1 | 2 | 3 | 4 |
| | A | | |
S | | B | | |
R | P | C | | |
Y | H | F | | E |
C-Shaped Tube: |
| | | | |
Command: T3
Dispensers: |
0 | 1 | 2 | 3 | 4 |
| | | | |
S | | | | |
R | P | | | |
Y | H | A | | E |
C-Shaped Tube: |
B | C | F | | |
Command: R2
Dispensers: |
0 | 1 | 2 | 3 | 4 |
| | | | |
S | | | | |
R | P | | | |
Y | H | A | | E |
C-Shaped Tube: |
B | C | F | | |
Command: D1
Dispensers: |
0 | 1 | 2 | 3 | 4 |
| | | | |
S | | | | |
R | P | | | F |
Y | H | A | | E |
C-Shaped Tube: |
B | C | | | |
Command: L4
Dispensers: |
0 | 1 | 2 | 3 | 4 |
| | | | |
S | | | | |
R | P | | | F |
Y | H | A | | E |
C-Shaped Tube: |
B | C | | | |
Command: T3
Dispensers: |
0 | 1 | 2 | 3 | 4 |
| | | | |
| | | | |
| P | | | F |
| H | A | | E |
C-Shaped Tube: |
S | R | Y | B | C |
Command: R3
Dispensers: |
0 | 1 | 2 | 3 | 4 |
| | | | |
| | | | |
| P | | | F |
| H | A | | E |
C-Shaped Tube: |
S | R | Y | B | C |
Command: D4
Dispensers: |
0 | 1 | 2 | 3 | 4 |
| | | R | |
| | | Y | |
| P | | B | F |
| H | A | C | E |
C-Shaped Tube: |
S | | | | |
Command: L2
Dispensers: |
0 | 1 | 2 | 3 | 4 |
| | | R | |
| | | Y | |
| P | | B | F |
| H | A | C | E |
C-Shaped Tube: |
S | | | | |
Command: T1
Dispensers: |
0 | 1 | 2 | 3 | 4 |
| | | R | |
| | | Y | |
| | | B | F |
| P | A | C | E |
C-Shaped Tube: |
H | S | | | |
Command: L1
Dispensers: |
0 | 1 | 2 | 3 | 4 |
| | | R | |
| | | Y | |
| | | B | F |
| P | A | C | E |
C-Shaped Tube: |
H | S | | | |
Command: D1
Dispensers: |
0 | 1 | 2 | 3 | 4 |
| | | R | |
| | | Y | |
| | | B | F |
S | P | A | C | E |
C-Shaped Tube: |
H | | | | |
Then, pressing the release button will dispense one capsule from each dispenser, in
order, giving you the capsules: SPACE.
Let's get that first delivery out. Your instructions are right in front of you...
Your instructions are: