Long time ago, when I was spending more time playing RPG, one of the issues what some players had, was to track party movement and to draw proper map. So I come with idea, to check how you guys come deal with this issue.
Task is to write a function, which takes as input parameter list of directions (passed as structure of your choice) ^v<>
, display map of dungeon.
In example for input: >>>vvv<<<^^^
output will be:
+----+ +----+
| | |>>>v|
| ++ | |^++v|
| ++ | because |^++v|
| | |^<<<|
+----+ +----+
Testcases
>>>>>>vvvvv<<<<^^^>>v
+-------+
| |
+-+---+ |
| | |
| + | |
| +-+ |
| |
+-----+
^^^^^vvv<<<^^vv>>>>>>>>vv>><<^^^^v>>>>v^<^
+-+
+-+| | +-++-+
| || | | ++ ++
| ++ +-+ |
| +-+ |
+--+ +-+ +-+-+
| | | |
+-+ +---+
As it is golf code challenge, shortest code wins.
Happy golfing.
EDIT Sorry for late edit, I didn't have much time recently.
Map is generated based on movement. It should contain only corridors which were visited during walk. Hence creating one big room won't be a valid answer.
There are three valid symbols in the map:
|
vertical wall|
horizontal wall+
intersection of vertical and horizontal wall.
Maximum length of the path is 255 character (but if you can, do not limit yourself).
More test cases:
><><><><
+--+
| |
+--+
>^<v
+--+
| |
| |
+--+
I hope now everything is clear.
vvv>>^^^<<
would produce (crosses? pipes?) \$\endgroup\$