Problem G
Treasure Map

You have come into possession of a pirate map that gives a
series of steps to get from your landing place on a desert isle
to the spot marked
After spending most of your savings chartering a boat, you
arrive at the island and, with the help of your portable GPS
receiver, duly execute the instructions on the map. Alas, no
treasure! On your return home you are astonished to learn that
the pirates had no knowledge of GPS and used a magnetic compass
to create the map. The pirates were unaware that their compass
pointed to magnetic north rather than true north. The
relative angle between magnetic north and true north varies
depending where you are on the planet, but you are able to
determine that on this particular desert isle, magnetic north
is
Input
There are several test cases. Each test case begins with
Note: We use combinations of the letters N, E, S, W, b to abbreviate the names of the compass points. For example, NEbE stands for north-east by east. The 32 points are equally spaced about the compass. Clockwise, they are: N NbE NNE NEbN NE NEbE ENE EbN E EbS ESE SEbE SE SEbS SSE SbE S SbW SSW SWbS SW SWbW WSW WbS W WbN WNW NWbW NW NWbN NNW NbW.
Output
For each test case, output a single number, rounded to two decimal places, giving the least distance (in paces) that separated you from the treasure at any point while you were following the map.
Sample Input 1 | Sample Output 1 |
---|---|
2 NbE 10 EbS 10 90.00 2 NbE 10 EbS 10 -90.00 0 |
14.14 10.00 |