><>, or Fish, is a two-dimensional esoteric programming language where the instruction pointer (IP) toroidally moves around the codebox, wrapping when it hits an edge.
><> has four basic movement instructions -
v, which respectively mean to change the IP's direction to left, right, up and down. It also has the termination instruction
;, which halts the program.
For any program, some characters may never have the IP move through them. For example, with the program
> v ; <
The program starts at the
>, changes direction at the
<, and halts at the
;. The squares marked with
# are never passed through:
> v ## ; <
So if we wanted to obfuscate this program and make it harder to read, we could replace these with any printable ASCII characters and the program would still do exactly the same thing!
In this challenge, we will be working with a very limited set of <>< - Just the four movement instructions, spaces, the terminator (
;) and newlines.
Your challenge is to, when given a program in this subset of ><> as input, output the same program with all characters that will never be passed through replaced with random printable ASCII characters - 0x20 to 0x7e. For each position, each printable ASCII character should have an equal chance of being printed, including ><> instructions and spaces.
Note that this means replacing all characters that are never passed through, not just spaces.
You can assume that the ><> program will always halt, and will always be a rectangle.
You may take input as a list of lines, a matrix of characters, ascii-art, etc.
The program will only ever contain said instructions.
The IP starts at 0,0, moving left to right.
This is code-golf, shortest wins!
In these testcases,
# represent characters that should be replaced with random characters.
v; > v ^< => v;# > v #^< ; v v <<< => ;## ### ### > v ; ; < => > v ## ; < > v v > > ^ >; => > v v# > > ^# ##>; >v> ^ v<^v< > v>; => >v> ^ v<### > v#;
#in the lower left of the first example output. \$\endgroup\$