## CCC '05 J3 - Returning Home

View as PDF

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

Problem type
##### Canadian Computing Competition: 2005 Stage 1, Junior #3

Jane's family has just moved to a new city and today is her first day of school. She has a list of instructions for walking from her home to the school. Each instruction describes a turn she must make. For example, the list

R
QUEEN
R
FOURTH
R
SCHOOL

means that she must turn right onto Queen Street, then turn right onto Fourth Street, then finally turn right into the school. Your task is to write a computer program which will create instructions for walking in the opposite direction: from her school to her home.

The input and output for your program will be formatted like the samples below. You may assume that Jane's list contains at least two but at most five instructions, and you may assume that each line contains at most 10 characters, all of them capital letters. The last instruction will always be a turn into the SCHOOL.

#### Sample Input 1

R
QUEEN
R
FOURTH
R
SCHOOL

#### Sample Output 1

Turn LEFT onto FOURTH street.
Turn LEFT onto QUEEN street.
Turn LEFT into your HOME.

#### Sample Input 2

L
MAIN
R
SCHOOL

#### Sample Output 2

Turn LEFT onto MAIN street.
Turn RIGHT into your HOME.

CCC problem statements in large part from the PEG OJ

• commented on May 15, 2021, 8:58 p.m.

how do you make the street names flip over?

• commented on July 8, 2021, 8:32 p.m.

Check if they are L or R and switch correspondingly.

• commented on Dec. 29, 2020, 7:22 p.m.

why does everybody downvote the comments for no reason even if they are helpful?

• commented on June 21, 2021, 7:42 p.m.

c'est le internet. people are garbage. also if you give people a downvote button they'll want to use it.

• commented on Aug. 24, 2020, 8:13 a.m.

How do you take input?? I can’t seem to do it properly.

• commented on Aug. 24, 2020, 10:17 a.m.

You can just keep reading in each line of input until the line that you read in is equal to "SCHOOL", where then you stop reading in any input.

• commented on Jan. 18, 2019, 9:52 a.m.

Does anyone know why I am getting WA on Testcases 2 & 3?

Thanks.

• commented on Sept. 22, 2020, 3:15 p.m.

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

• commented on Feb. 2, 2020, 10:15 a.m.

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

• commented on June 5, 2020, 11:15 p.m.

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

• commented on Jan. 17, 2019, 9:24 p.m. edited

Shouldn't Sample Input 2 be:

Turn RIGHT onto MAIN street.

Since R = L and L = R?

EDIT: I realized my mistake.

• commented on Jan. 17, 2019, 9:32 p.m.

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

• commented on Jan. 18, 2019, 9:50 a.m.

No, sorry, I now realize that the Sample is correct.

• commented on Nov. 26, 2014, 10:34 a.m.

Dont you need to tell us how many turns will be made at the very beginning?

• commented on Nov. 26, 2014, 1:55 p.m.

It will always end with SCHOOL.