esolang

Puzzlang

Brainfuck with one symbol. Every X is a command, and which command depends on the three characters above it.

Daedalus, 2009 · Turing complete: yes · ●●● hard · esolangs.org

Tested with 3 known programs · Hello World on Try It Online: identical · Test method

Run it

Expected: a

The idea

Daedalus made Puzzlang in 2009. The name joins "puzzle" and "language", for the logic puzzle that even a small program turns into. The only meaningful character is X. Each X is one brainfuck command, run in reading order, left to right and top to bottom. Which command it is depends on its three neighbours on the line above: above left, straight above and above right.

Read the story

So every X also helps decide the X's below it, and changing one command can change three others.

The machine

A brainfuck tape of bytes. Reading the three characters above an X as X or not:

AboveCommandAboveCommand
X>X .
X <X X,
XXX+XX [
- XX]

The neighbours wrap around like a torus: an X on the first line looks at the last line, and an X at the edge looks across to the other edge. Execution does not wrap; it reads the X's in order.

Every X under a blank line is a -, and a byte wraps around from 0 to 255. That makes decrements the cheapest way to build a character. TIO's hello world prints H with a line of over 180 X's.

Example

The first line is two -, since the line above it, the last one, is blank.

The first line is two -, since the line above it, the last one, is blank. The X on the second line has X X above it, which reads a byte. The X on the third line has X above it, which prints.

Expected: aa

One more X under the printing one prints again, since it has the same X above it.

Patterns it teaches

  • Turing tarpit: every brainfuck command is there, but each costs a carefully padded block of X's.
  • Two-dimensional control flow: the code runs in a line, but its meaning comes from a grid.
  • Encoding tricks: a command is written in the shape of the line above, not in the character itself.

Try this

  1. Print the input byte three times.
  2. Add 3 to the input byte before printing it.
  3. Hard: a cat that copies every byte of the input.

Further

Puzzlang builds on Brainfuck.

Two-dimensional languages

Brainfuck derivatives

Write your own in Run Convert a program from Puzzlang

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: puzzlang.

Command line

shib run puzzlang -e 'X X
 X
 X
' --input 'a'
shib manual puzzlang

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/puzzlang.js

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

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