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><^
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.
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 if2
and1
or3
are both true).
Test cases
For the following "floor plan":
-----
| |
|###|
| |
| ^ |
In Out
1 0
2 1
3 2
For this floor plan:
> | # |
In Out
1 0
2-99 3 * that is, any input 2-99 outputs 3
For this floor plan:
||####|#|#|##|<
In Out
any 3
Final test case:
|v|
|#|
| |
| |
| |
| |
In Out
1 1
2-5 2
Has someone been for-sparta'd?
\$\endgroup\$