Compass Walk (Enums)
Define a Direction enum (N, E, S, W). Start at 0 0, read a string of moves like NNEW and print the final position x y. N is y+1, S is y−1, E is x+1, W is x−1.
Input: One line of N/E/S/W letters.
Output: x y.
Difficulty: Easy. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.
Hint
- Map each letter to a Direction, then each Direction to a (dx, dy).