esolang

Binary Insanity

One counter, seven commands of three bits each, and a program that is one long line of 0s and 1s.

TheMCoder · Turing complete: no · ●○○ easy · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: !

The idea

TheMCoder made Binary Insanity with seven commands, each written as three binary digits. A program is a single line, read three characters at a time. There is one counter, no jumps and no tests. The only loop starts the whole program again, so a program ends, repeats forever, or repeats until the input runs out.

Read the story

The Hello World program is 1,098 characters long, because every step of the counter costs three of them.

The machine

BitsDoes
111Add 1 to the counter
101Subtract 1
110Set the counter to 0
010Print the character with the counter's code, and a line break
100Read a line; the counter becomes the code of its first character
001End the run
000Start again from the first command, with the counter at 0

The specification's Python interpreter swaps 100 and 001. This implementation keeps that table, which the cat needs. The rest follows that interpreter, so every printed character gets a line break of its own. A read that finds no line left ends the run.

Example

Thirty-three times 111 makes 33, the code of !.

Thirty-three times 111 makes 33, the code of !. Then 010 prints it and 001 ends the run before the second print.

The cat reads a line, prints its first character and starts again, until the input is spent.

Expected: c a t

Patterns it teaches

  • Encoding tricks: seven commands spelled in three bits, so a program is mostly runs of 111.

Further

Also in Turing tarpits

Write your own in Run Convert a program from Binary Insanity

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: binary-insanity.

Command line

shib run binary-insanity -e '100010000' --input 'c
a
t
'
shib manual binary-insanity

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/binary-insanity.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org