Solve the Halting Problem for Befinge Let's define a simple 2D language, which we'll give the incredibly original name befinge. Befinge has 5 instructions:


&lt;&gt;^v, as in most 2D esolangs, redirect the instruction pointer in their respective directions.
. is  a no-op.


The instruction pointer starts out at the top-left corner going right. If the instruction pointer gets to an edge, the program halts. Every Befinge program will obviously either halt or go into an infinite loop which does nothing. Here are two examples:

Halting:

&gt;.v
..&lt;


Non-Halting:

&gt;....v
..v..&lt;
..&gt;v..
^..&lt;..


The halting problem is not solvable for a Turing-complete language, but it is for this one. Your task is to write a program (or function) that takes as input a string representing the befinge program and returns a truthy or falsey value depending on whether it halts or not.


You can assume that the input will consist only of these characters and will be padded with spaces to form a rectangle.
You can use any set of five characters for the instructions (e.g. adws ).


Test Cases

Halting:

.




v&gt;
&gt;^




....v....
....&gt;...v
.^..&lt;....
.......v&lt;
.......v.
....^..&lt;.




v&lt;&gt;v&gt;v^
&gt;v^&gt;^&gt;v
&lt;&gt;&gt;^v&lt;v
v^&lt;&gt;v^&lt;


Non-Halting:

&gt;..v
^..&lt;




&gt;v&lt;
v&lt;.
&gt;v.
v&lt;.
&gt;.^




&gt;.&gt;.&gt;.v
.&gt;&lt;.&lt;.&lt;


This is code-golf, so the shortest program (in bytes) wins.
ES6 (JavaScript), 111,101 bytes
EDIT: changed output values to true and false, instead of Y and N, to shave off 10 bytes more
Golfed
F=(I,M=[...I],c=0,i)=&gt;(i={j:v=I.search`\n`+1,k:-v,h:-1,l:1,q:i,0:0}[M[c]])?F(I,M,c+i+(M[c]=0),i):i!=0

Test
F=(I,M=[...I],c=0,i)=&gt;(i={j:v=I.search`\n`+1,k:-v,h:-1,l:1,q:i,0:0}[M[c]])?F(I,M,c+i+(M[c]=0),i):i!=0  

//Alphabet Map
tr={
'&lt;':'h',
'&gt;':'l',
'^':'k',
'v':'j',
'.':'q',
'\n':'\n'
};

//Test
T=(I,A)=&gt;{
console.log({&quot;Y&quot;:&quot;#Halting&quot;,&quot;N&quot;:&quot;#Non-Halting&quot;}[A]);
console.log(&quot;I=\n&quot;,I,&quot;\nF(I)=&quot;,O=F([...I].map(s=&gt;tr[s]).join('')));
console.log('NY'[O*1] == A ? &quot;OK !&quot; : &quot;NOT OK !&quot;);
}

//Halting
T(
`&gt;.v
..&lt;`
,'Y');

//Non-Halting
T(
`&gt;....v
..v..&lt;
..&gt;v..
^..&lt;..`
,'N');

//Halting
T(
`.`
,'Y')

//Halting
T(
`v&gt;
&gt;^`
,'Y');

//Halting
T(
`....v....
....&gt;...v
.^..&lt;....
.......v&lt;
.......v.
....^..&lt;.`
,'Y');

//Halting
T(
`v&lt;&gt;v&gt;v^
&gt;v^&gt;^&gt;v
&lt;&gt;&gt;^v&lt;v
v^&lt;&gt;v^&lt;`
,'Y');

//Non-Halting
T(
`&gt;..v
^..&lt;`
,'N');

//Non-Halting
T(
`&gt;v&lt;
v&lt;.
&gt;v.
v&lt;.
&gt;.^`
,'N');

//Non-Halting
T(
`&gt;.&gt;.&gt;.v
.&gt;&lt;.&lt;.&lt;`
,'N');

Sample Output
#Halting
I=
&gt;.v
..&lt; 
F(I)= true
OK !    

#Non-Halting
I=
&gt;....v
..v..&lt;
..&gt;v..
^..&lt;.. 
F(I)= false
OK !

#Halting
I=
 . 
F(I)= true
OK !

#Halting
I=
v&gt;
&gt;^ 
F(I)= true
OK !

#Halting
I=
....v....
....&gt;...v
.^..&lt;....
.......v&lt;
.......v.
....^..&lt;. 
F(I)= true
OK !

#Halting
I=
v&lt;&gt;v&gt;v^
&gt;v^&gt;^&gt;v
&lt;&gt;&gt;^v&lt;v
v^&lt;&gt;v^&lt; 
F(I)= true
OK !

#Non-Halting
I=
&gt;..v
^..&lt; 
F(I)= false
OK !

#Non-Halting
I=
&gt;v&lt;
v&lt;.
&gt;v.
v&lt;.
&gt;.^ 
F(I)= false
OK !

#Non-Halting
I=
&gt;.&gt;.&gt;.v
.&gt;&lt;.&lt;.&lt; 
F(I)= false
OK !