29
1
Let's define a simple 2D language, which we'll give the incredibly original name befinge. Befinge has 5 instructions:
<>^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:
>.v
..<
Non-Halting:
>....v
..v..<
..>v..
^..<..
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>
>^
....v....
....>...v
.^..<....
.......v<
.......v.
....^..<.
v<>v>v^
>v^>^>v
<>>^v<v
v^<>v^<
Non-Halting:
>..v
^..<
>v<
v<.
>v.
v<.
>.^
>.>.>.v
.><.<.<
This is code-golf, so the shortest program (in bytes) wins.
What about 아희(Aheui)?
– JungHwan Min – 2016-11-09T01:10:33.623Some test cases where not every arrow is hit would be good. – xnor – 2016-11-09T01:13:29.283
Turing proved that the Halting problem is not solvable for any Turing-Complete language, so I had to make up a fake one that wasn't Turing complete. A language that will always eventually halt is not Turing complete. – Esolanging Fruit – 2016-11-09T01:14:08.887
1We also don't have any examples where the path makes a non-90-degree turn like
>..>.
or><
. – xnor – 2016-11-09T01:18:41.757Related (slightly harder version) – Sp3000 – 2016-11-09T01:20:05.970
Related – Adnan – 2016-11-09T01:23:01.493
"work how you'd expect", could you elaborate a bit on that? – Buffer Over Read – 2016-11-11T21:52:11.890
@EsolangingFruit Why not just use the calculus of constructions? It's halting problem is also computable (assuming ZFC is consistient). – PyRulez – 2018-03-04T01:54:59.220
2@PyRulez Because I wanted processing directional motion to be part of the challenge. – Esolanging Fruit – 2018-03-04T02:01:51.977