Problem A
Adrift At Sea
You are developing a navigation system for sailing boats, but unfortunately the normal navigation systems do not work for a couple of reasons. First, instructions like “turn left” are meaningless because there are no roads. Such instructions must be followed by the amount to turn (in degrees). In addition, “left” and “right” are not used in naval navigation. Instead, “port” and “starboard” are used for “left” (counterclockwise) and “right” (clockwise), respectively.
Given the current heading and the desired heading of the sailing boat, your task is to provide an instruction to turn to the desired heading. All headings are given by the 8 compass directions: N, NE, E, SE, S, SW, W, NW. Each direction is 45 degrees clockwise from the previous one in this list. In addition to turning, it is also possible for the instruction to be “Keep going straight” or “U-turn” (go in the opposite direction). You may assume turns can be made instantaneously.
Input
The input consists of two lines. The first line is the current heading, and the second line is the desired heading. All headings are one of the 8 compass directions listed above.
Output
Output a single line in one of three forms:
-
Keep going straight
-
U-turn
-
Turn $d$ degrees $dir$
In the last case, $d$ should be an integer between 1 and 179, and $dir$ should be either the word port or starboard.
| Sample Input 1 | Sample Output 1 |
|---|---|
N S |
U-turn |
| Sample Input 2 | Sample Output 2 |
|---|---|
NW NW |
Keep going straight |
| Sample Input 3 | Sample Output 3 |
|---|---|
N SW |
Turn 135 degrees port |
| Sample Input 4 | Sample Output 4 |
|---|---|
N E |
Turn 90 degrees starboard |
