Quantcast
Channel: Solve the Halting Problem for Befinge - Code Golf Stack Exchange
Viewing all articles
Browse latest Browse all 12

Solve the Halting Problem for Befinge

$
0
0

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<vv^<>v^<

Non-Halting:

>..v^..<

>v<v<.>v.v<.>.^

>.>.>.v.><.<.<

This is , so the shortest program (in bytes) wins.


Viewing all articles
Browse latest Browse all 12

Latest Images

Trending Articles



Latest Images