#C9891. Final Direction
Final Direction
Final Direction
This problem challenges you to determine the final direction Maria is facing after making a sequence of turns. Initially, she faces north. For each character in the given sequence:
- L: Turn left (90° counterclockwise).
- R: Turn right (90° clockwise).
The directions follow the order: North
, East
, South
, and West
. Formally, if we denote the list of directions as
$$
D = [North,\ East,\ South,\ West], \quad \text{and the initial index as } 0,
$$
then for each turn t in the sequence, the current index is updated as
$$
\text{{index}} = (\text{{index}} + \delta) \mod 4, \quad \text{{with}} \quad \delta = \begin{cases}-1,&\text{if } t = 'L'\\1,&\text{if } t = 'R'\end{cases}.
$$
Output the direction corresponding to the final index after processing the entire sequence.
inputFormat
The input is a single line string consisting of characters 'L' and 'R' only, representing the sequence of left and right turns respectively. The input is provided via standard input.
outputFormat
Output a single line string indicating the final direction Maria is facing, which can be one of the following: "North", "East", "South", or "West". The output should be printed to standard output.
## sampleLRLRL
West