Oh no, I am lost on the way to finding the great treasures of Marakov! And all I have are these useless instructions that look like
S10R10D30... I have no idea what they mean! Can you help me?
Given directions consisting of
N E S W U D L R 1 2 3 4 5 6 7 8 9 0, output how far I will be from where I started when I follow those directions (i.e. Euclidean Distance).
N E S W refer to me turning North, East, South, and West;
U D L R refer to me turning Up, Down, Left, and Right (So
NR is the same as
E, and so is
SLL is the same as
N). Up means keep going forward; Down means turn around.
After each letter direction will be a number, which is how far I will go in that direction.
N10E20 means go North 10 units, then turn East, and go East 20 units.
- Input will always start with one of
NESW(so blank input need not be accounted for).
- Two letter instructions in a row are allowed.
NEshould be interpreted, "Turn North, then immediately turn East". It's the same as just
SLLis "Turn South, then immediately turn Left twice". It's the same as
- All numbers will be integers (note how
.isn't in the character set)
- Input will only consist of
NESWUDLR1234567890(If it needs something else, like '\0' in C; or if your language's input functions has a trailing newline, or something, that's fine.)
- The norm.
- If using a function, should output a numeric datatype or a string.
- Must be accurate to 3 decimal places.
This is codegolf, so lowest bytes after a week wins!