2005 Canadian Computing Competition, Stage 1

Problem J3: Returning Home

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.

All Submissions
Best Solutions


Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Sep 29, 2008

Problem Types: [Show]

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

I had to use def, hash, each_slice, transpose, to_a, map, reverse, pop, while, zip and if.

He used def and if...

I wish I was as cool as FatalEagle.

FatalEagle has always been my idol ever since he registered.

SourSpinach > FatalEagle

I haven't even solved this problem, so FatalEagle is better.

Is this Python you're talking about?
'Cause def is define, which is a function, if I'm not mistaken.

is the sample input correct?
because it says...
R
QUEEN
R
FOURTH
R
SCHOOL
and the output is:
Turn LEFT onto FOURTH street.
Turn LEFT onto QUEEN street.
Turn LEFT into your HOME.
I thought R was RIGHT, not LEFT.

ohhhh
i didnt read the question

why is my code giving a RE, a run time error??

I don't see any submission on this problem by you...

that's werid. I'll submit it again then.

You're making an assumption that causes a certain case to fail. As it turns out, all three test cases incorporate this case. I suggest changing how you read your input.