Has someone been defenestrated? Defenestration is the act of throwing someone or something out of a window.
  —Wikipedia


Input

The input will consist of two parts:


A floor plan and a person inside the house/building.


v&gt;&lt;^ represents a person, pointing in the direction signified by the arrow. The input will contain exactly one person.
- and | represent walls, and # represents a window.   is empty space.


This portion of the input may be taken as either a single string, or an array/list/etc. of lines. There will never be any trailing or leading spaces, and the input will always be a rectangle.

Example:

-----###---
|         |
|     ^   |
-----------

An integer ≥ 1 signifying how far (in characters) the person travels.


Output

The output should be


1 if the person ends up "inside" a window (i.e. after moving forwards the distance specified in the input, the person is on top of a #).
2 if the person has been defenestrated (come into contact with a # and then continued further on).
3 if the person has hit a wall (come into contact with a - or |. Once hitting the wall, the person stops and does not continue through it).
0 if none of the above are true (and all the person has done is travel through empty space).


Assumptions

All of the following can be assumed to be true:


The person will never travel "out of bounds" of the input area.
After being defenestrated, the person will never come into contact with another # or a -/| (so you don't have to worry about if 2 and 1 or 3 are both true).


Test cases

For the following "floor plan":

-----
|   |
|###|
|   |
| ^ |




In   Out
1    0
2    1
3    2


For this floor plan:

&gt; | # |




In   Out
1    0
2-99 3    * that is, any input 2-99 outputs 3


For this floor plan:

||####|#|#|##|&lt;




In   Out
any  3


Final test case:

|v|
|#|
| |
| |
| |
| |




In   Out
1    1
2-5  2
JavaScript (ES6), 147 146 bytes
(p,n)=&gt;eval('l=p.search`\n`+1;m=p.match`[&lt;&gt;v^]`;for(r=d=i=0;i++&lt;n&amp;r&lt;3;r-1?0:d=2)r=(c=p[m.index+i*({v:l,&quot;&lt;&quot;:-1,&quot;&gt;&quot;:1}[m]||-l)])&gt;&quot;#&quot;?3:c&gt;&quot; &quot;;+r||d')

Saved 1 byte thanks to @NinjaBearMonkey!
Explanation
Takes a floorplan as a string and the number of moves. Returns a number.
(p,n)=&gt;                               // p = floor plan as string, n = number of moves
  eval(`                              // use eval to enable for loop without {} or return
    l=p.search\`\n\`+1;               // l = line length
    m=p.match\`[&lt;&gt;v^]\`;              // m = the position and orientation of the person
    for(
      r=                              // r = result at the current step
        d=                            // d = 2 if the person has been defenestrated
          i=0;                        // i = current step
      i++&lt;n&amp;r&lt;3;                      // for each step while the person has not hit a wall
      r-1?0:d=2                       // set d to 2 once the person enters the window
    )
      r=(                             // r = 0 if on &quot; &quot;, 1 if on &quot;#&quot; or 3 if on &quot;|&quot; or &quot;-&quot;
        c=p[m.index+i*                // c = character after current step
          ({v:l,&quot;&lt;&quot;:-1,&quot;&gt;&quot;:1}[m]||-l) // get the index offset of each step
        ]
      )&gt;&quot;#&quot;?3:c&gt;&quot; &quot;;
    +r||d                             // return the result of the current step or d
  `)

Test


var solution = (p,n)=&gt;eval('l=p.search`\n`+1;m=p.match`[&lt;&gt;v^]`;for(r=d=i=0;i++&lt;n&amp;r&lt;3;r-1?0:d=2)r=(c=p[m.index+i*({v:l,"&lt;":-1,"&gt;":1}[m]||-l)])&gt;"#"?3:c&gt;" ";+r||d')
&lt;textarea id="floorplan" rows="6" cols="30"&gt;-----
|   |
|###|
|   |
| ^ |&lt;/textarea&gt;&lt;br /&gt;
Moves = &lt;input type="text" id="moves" value="3" /&gt;
&lt;button onclick="result.textContent=solution(floorplan.value,moves.value)"&gt;Go&lt;/button&gt;
&lt;pre id="result"&gt;&lt;/pre&gt;