## CCC '05 J3 - Returning Home

View as PDF

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

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.

• commented on Jan. 30, 2023, 12:53 p.m.

my program works when I am testing it with the samples, however when I submit it, it does not fully print the answer. instead it does this "Test case #1:
WA [0.030s, 10.16 MB] (0/10)

Your output (clipped) Turn RIGHT onto D street. Turn RIGHT onto C street. Turn RIGHT o

I do not understand what happened.

• commented on Jan. 31, 2023, 7:30 a.m.

DMOJ only shows a clipped version of your output on the site (to make sure nothing major is going wrong). The full version of your output is being seen on the server (and is being judges as WA).

• commented on May 16, 2021, 12:58 a.m.

how do you make the street names flip over?

• commented on July 9, 2021, 12:32 a.m.

Check if they are L or R and switch correspondingly.

• commented on Jan. 18, 2019, 2:24 a.m. edit 2

Shouldn't Sample Input 2 be:

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

Since R = L and L = R?

EDIT: I realized my mistake.

• commented on Jan. 18, 2019, 2:32 a.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on Jan. 18, 2022, 6:42 p.m.

Don't be such a meany

• commented on Jan. 18, 2019, 2:50 p.m.

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

• commented on Nov. 26, 2014, 3:34 p.m.

This comment is hidden due to too much negative feedback. Show it anyway.

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

It will always end with SCHOOL.