# 2D Path Drawing [duplicate]

(This is not a duplicate of Follow the path, as this challenge have invalid path detection and use ><^v in the output.)

So your task is to take in the description of the path and draw it out in a "Befunge(or a lot of other 2D esolangs)-like" format, and detect if it is invalid. Note that if the path is invalid, you shall not output anything except a printable custom character which cannot be one of ><^v or space.

• The path would be invalid if the path is crossed.

• Or, if you moved off the top or left edge.

You begins at the top-left corner.

• >n moves you right n characters. Your trail is >.

• ^n moves you up n characters. Your trail is ^.

• <n moves you left n characters. Your trail is <.

• vn moves you down n characters. Your trail is v.

# Test Cases

Input: >3v3

Output:
>>>v
v
v

Input: v4>1^2>3

Output:
v
v
v>>>
v^
>^

Input: >5<3

Output:
!

(Or any character you want, except ><^v and space.)

Input: [NONE]

Output: [NONE]

Input: >4v2<2^2

Output:
>>>>v
^ v
^<<

Input: >4v2<2^3

Output:
!

(Or any character you want, except ><^v and space.)

Input:
>3v3<6

Output:
!

(Or any character you want, except ><^v and space.)



# Rules

• Standard loopholes are forbidden.

• Least bytes wins.

• This was written in a hurry.

• @JonathanAllan Well, >4v2<2^3 crosses itself and is thus... invalid, so I outputted a ! (or custom character). I didn't get what you mean?
– null
Dec 21 '19 at 13:46
• Just noticed I read above rather than below, sorry! Dec 21 '19 at 13:47
• Can we input an array/list of (direction, number) tuples/arrays/lists? Dec 21 '19 at 14:06
• @mypronounismonicareinstate Yes.
– null
Dec 21 '19 at 14:07
• @HighlyRadioactive I'm pretty sure requiring different IO, removing the last-character-must-be-X requirement and requiring input validation doesn't make this less of a duplicate, as the only reason the answers can't ported from that question trivially is the input validation requirement, and that is boring Dec 21 '19 at 14:20

# Charcoal, 46 bytes

≔⁰ηＦ⪪Ｓ²ＦＩ§ι¹«≧⁺℅ＫＫη✳⊗⌕>^<§ι⁰§ι⁰≧⁺∨‹ⅈ⁰‹ⅉ⁰η¿η«⎚!


Try it online! Link is to verbose version of code. Explanation:

≔⁰η


Assume everything is OK.

Ｆ⪪Ｓ²


Loop over the instructions.

ＦＩ§ι¹«


Loop over the number of steps.

≧⁺℅ＫＫη


Check whether the path has crossed.

✳⊗⌕>^<§ι⁰§ι⁰


Output each character in the appropriate direction.

≧⁺∨‹ⅈ⁰‹ⅉ⁰η


Check whether the path has moved off the top or left edge.

¿η«⎚!


If something went wrong, replace the output with a !.

• I like how you make use of the feature that you can "clean" the output. Neat!
– null
Dec 21 '19 at 12:34