## CCC '02 S3 - Blindfold

View as PDF

Points: 5
Time limit: 2.0s
Memory limit: 16M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
##### Canadian Computing Competition: 2002 Stage 1, Junior #5, Senior #3

Rose and Colin are playing a game in their backyard. Since the backyard is rectangular we can think of it as a grid with rows and columns. Rose and Colin place obstacles on some of the squares. The game is played as follows: Colin covers his eyes with a blindfold then Rose carries him to some grid square in the backyard. She sets him down so that he is facing north, south, east or west. Colin does not know this initial position or direction. Rose then instructs Colin to make a series of moves through the backyard. Each move is one of:

• F - moves forward one grid square in the direction that he is facing, or
• L - turns 90 degrees counter-clockwise, remaining on the same square, or
• R - turns 90 degrees clockwise, remaining on the same square.

After making these moves, Colin is standing at some final position. He must now figure out where he is standing. You will help him by writing a program to determine all possible final positions. Assume that Colin's initial position, final position, and all intermediate positions lie within the backyard but never in a square that contains an obstacle. You may also assume that Colin is always facing a direction that is parallel to the sides of the backyard (north, south, east, or west).

#### Input Specification

The input begins with and , each on a separate line. Next are lines of characters describing the backyard: a . denotes a grid square that Colin may walk through; an X denotes a grid square with an obstacle. Below the grid is the number followed by lines describing Colin's moves. Each line has a single character: F, L, or R.

#### Output Specification

Your program should output the backyard grid, indicating all possible final positions with the * character.

#### Sample Input

2
4
....
.XX.
3
F
R
F

#### Sample Output

.*..
.XX*

• commented on June 24, 2020, 11:56 a.m.

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Nov. 26, 2019, 12:15 p.m. edited

How are you supposed to solve this question if you were blindfolded?

• commented on Oct. 7, 2018, 1:56 a.m.

how is this a 5 pointer??

• commented on June 20, 2020, 3:00 p.m. edit 2

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Jan. 19, 2020, 11:12 p.m. edited

This should be worth at least 7 points. Most of the other CCC S3's are all 7+.

• commented on Oct. 3, 2017, 1:27 p.m.

This comment is hidden due to too much negative feedback. Click here to view it.

• commented on Oct. 3, 2017, 2:00 p.m.

YOU DON'T