You are trapped in a room with a puzzle grid painted on the floor. You are in a start square, just below the puzzle grid, facing up. Your task is to get to a target square (or suffer a terrible fate). Your first move must be to step into the main puzzle grid if you can. Once in, you may not step outside the grid unless it is onto a target square. Once you step onto a target square, you are finished and can make no further moves.
Each square in the puzzle grid has a symbol painted on it representing a possible move (up, down, left, right, clockwise, or counterclockwise). You can only move one grid square at a time and you can only turn




In the sequence of moves shown above, the user starts at the bottom, facing up. Her target is the square above the maze at the top. For her first move, the choices are UP
or LEFT
(just the moves she sees in front of her). She can't go left, so she chooses UP
. Then her choices are UP
or LEFT
again and she chooses LEFT
. Now her choices have changed: CLOCKWISE
, COUNTERCLOCKWISE
, or DOWN
. She can't move down and if she turns counterclockwise, she will have no moves in front of her. So she chooses CLOCKWISE
. For her next move, she can now choose from UP
or CLOCKWISE
.
The input will contain U
, D
, L
, R
, C
, and B
for UP
, DOWN
, LEFT
, RIGHT
, CLOCKWISE
, and COUNTERCLOCKWISE
respectively. The start square is marked S
and can be anywhere on the bottom row. There will be five possible target squares, marked T
, which can appear anywhere around the outside of the puzzle grid. Squares which are out of bounds are marked with the .
character (ASCII code
Write a program to determine which of the target squares can be reached from the given start square. You should output a single line of T
for that square. If not, output F
.
Note that in the sample input below, there are
Puzzle Concept: | Andrea Gilbert |
---|---|
Puzzle Boards: | James Stephens (original boards have been adapted for ECOO) |
Puzzle Images: | http://clickmazes.com |
Sample Input
..TT..
TCURC.
.DLRD.
.BUBB.
.CUCCT
.TS...
.T.T..
TRCDU.
.UCLDT
.RCBL.
TDUCU.
.S....
Sample Output
TTFFT
FTFFF
Question Development Team
Sam Scott (Sheridan College) | President of ECOO-CS |
---|---|
Kevin Forest (Sheridan College) | David Stermole |
Greg Reid (St. Francis Xavier Secondary School, Mississauga) | |
Dino Baron (University of Waterloo) | Communications |
Nathan Schucher (University of King's College) | John Ketelaars |
Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org
Comments