I love ><>, ><> is life! 2D langages are amazing! In this challenge, you will have to say if a "fishy" road has an end, while code-golfing.
Definition
A fishy road is constructed with tiles, including the following ones:
v (go down)
> (go right)
^ (go up)
< (go left)
/ (mirror)
\ (mirror)
Any other character (except -|+
) may be considered as a distraction, like some flowers (or fish heads) on the border of the road.
A road always start on the upper-left corner of a rectangular grid, delimited by -|+
symbols. The road has an end if, by following it, you end up on a border, else, you'll be trapped in an infinite path.
Finding your way on the road is accomplished by following directions given by v>^<
and mirrors. A mirror will reflect by 90° depending on where you came from. Here's how it works (using v>^<
to show directions):
^ ^
>/< >\<
v v
</> <\>
^ ^
A road might be looking like this if it ends:
+--------------------+
|>\/ this way >\/> | this one ends here
| v^ \/ |
| v^ ^.^ |
| \/\ >v |
| /\/ ^< |
+--------------------+
An infinite loop :
+--------+
|>>\ This|
|\\ is |
| \\ a |
| \ /trap|
+--------+
Specifics
A road doesn't necessarily consist only of instructions. Spaces or letters can be used to complete it. This means you have to continue moving in the same direction except if you cross a character in <v^>-|
.
There will always be one of v>^<
in the upper-left corner, <
or ^
implies this road ends.
You may submit a function taking a string as parameter, or a standalone program using STDIN/whatever is the closest alternative in your language.
Your submission must return or print on STDOUT truthy/falsy values when it's done. Truthy values meaning the road has an end, while falsy means it is an infinite loop.
Test cases
+--------------------+
|>\/ this way >\/> | this one ends here
| v^ \/ |
| v^ ^.^ |
| \/\ >v |
| /\/ ><> ^< |
+--------------------+
True
+--------+
|>>\ This|
|\\ is |
| \\ a |
| \ /trap|
+--------+
False
+--+
|<v|
|^<|
+--+
True
+--+
|>v|
|^<|
+--+
False
+----------+
|v Hello \ |
|\\/\/ / |
| \/\\ \ |
|/ // >\ |
| ^/\>\\/ |
|\ /\/\/ |
+----------+
False
+-----+
|>\/\\|
|//\\/|
|\/\\\|
|//\//|
|\/\/ |
+-----+
True
2 test cases added as suggested by @MartinBüttner
+----+
|v |
|\\ |
|//\ |
|\\v |
| \/ |
+----+
False
+----+
|v |
|\\ |
|//\ |
|\\^ |
| \/ |
+----+
False
Test case inspired by @ETHproductions
+-------------------------+
|><> |
|something smells fishy...|
+-------------------------+
False
Standard loopholes are forbidden (as always).
The winner will be the one with the shortest code in bytes. (it would be amazing to see a ><> answer :))