"Yarr!! We had a laddie who called himself a "programmer" make a map t' our hidden treasure! But 'tis written wit' weird numbers 'n letters! "E5, N2, E3"... what does it even mean? Madness! Can't even scribe a proper treasure map, t' useless cretin. Fix it fer us! We'll gift ye a share o' t' treasure!"
A group of pirates are having trouble reading a treasure map. Can you write a program to convert it into a more... piratey form?
As input, you'll receive the original treasure map. It's a list of comma separated strings, each string which consists of a letter portion (which tells the pirates which direction they need to walk in), and a number portion (which tells the pirates how many steps to take in that direction). For instance, the following treasure map:
would mean, "walk two steps to the east, walk four steps to the north, walk five steps to the east, walk two steps to the south, walk one step to the west, then walk three steps to the south."
As output, you'll output the map in a graphical form, using the characters
< as pointers. Here's the output for the above input:
>>>>>v ^ v ^ v< ^ v >>^ X
Notice that we've replaced the last step to the south with an
X instead. This is because the last step is where the treasure is, and as we all know, pirates must have an X on their treasure maps, otherwise they won't know how to read it.
By the way, the map won't ever cross itself, so you don't need to worry about dealing with overlaps. Also, you are allowed to have a trailing new line at the end of the output.
Sample Inputs and Outputs
v v v v v X<
>>>>>>v ^>>>>vv ^^>>vvv ^^^Xvvv ^^^^<vv ^^^<<<v ^^<<<<<
>>>>>>>>>>>v ^ v ^ v ^ v ^ v ^ v ^ v ^ v ^ v ^ X v ^ ^ v ^ ^ v ^ ^<<