Puzzlang is a brainfuck derivative by Daedalus. In Puzzlang, the only symbol, X, tells the interpreter to execute an instruction. The instruction is determined by the state of the three "neighbor" characters above the X, and is a direct brainfuck analogue.
The name is a portmanteau of "puzzle" and "language", due to the hideous logic puzzle that results from attempting to create simple programs in this language. It also sounds like "puzzling", which it certainly is.
There are two operators, X and every other character (NOP).
The following lists the equivalent BF command to each arrangement of neighbor states.
> < + - . , [ ] X X XXX X X X XX XX X X X X X X X X
The neighbor topology of Puzzlang is toroidal, although execution is not. In other words, the program is read in the usual order, but an X on the first line will have neighbors on the bottom line.
Note that most short Puzzlang code is not modular; several of the following examples rely on the topology of Puzzlang, and can't be inserted into larger programs.
Increment the memory cell eight times. This program demonstrates the ease of incrementing cells in Puzzlang. This is good, because nothing else is very easy.
Clear the current cell. The extraneous while loop is necessary to simplify the program's design and allow for the gap needed to decrement.
X X X X X
A version that doesn't use wrapping:
(blank line) XX XX X X X
Non-destructively copies the first cell to the second (non-wrapping)
(blank line) XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXX XXXXXXXXXXXXXXXXXXXXXXXX XX XXX XXX X XX X XX X X XXX X XX X X XX X X X X X X X X X X X X X X XX X X
This code is modular. It exploits the - operator, which allows one to decrement past 0 to 255 and below. As 151 decrements are needed just to reach 'z', every column after #16 has been snipped out and replaced with '...'.
X XXXXXXXXXXXXX...XXXXX Print 'H' X X XX Print 'e' and move (we'll need this later) X X X XXXXXXXXXXXXX...XXXXX Print 'l' twice and move X X X X XXXXXXXXXXXXX...XXXXX 'o' and move X X X XXXXXXXXXXXXX...XXXXX ',' X X XXXXXXXXXXX The space X X XXXXXXXXXXXXX...XXXXX Print 'W' X X Move back to 'o' cell and print 'o' X X XXXXXXXXXXXXX...XXXXX 'r' X X Back to 'l' and print X X X Back to 'e' and decrement once for 'd' X X XXXXXXXXXXXXX...XXXXX '!' X
brainfuck: ( _ = "...")
It is relatively easy to translate brainfuck into Puzzlang by using blocks padded with NOPs to avoid interference between parts.
+ XXXXXXX XXXXX XXX
A similar approach to the increment can be used for the other commands.
> XXXXXX XXXX XX X
< XXXXXX XXXX XX X
. XXXXXXX XXXXX X X X
, XXXXXXX XXXXX X X X
[ XXXXXX XXXX XX X
] XXXXXX XXXX XX X
Therefore, Puzzlang is Turing-complete.
- Orthogonal Puzzlang uses the characters directly above, left and right of an operation to determine the outcome:
This significantly changes the approach to coding.
- Nightmare Puzzlang uses all eight characters in the Moore neighborhood, thus giving it a full character set. The characters would likely be ASCII, and the language could be any conventional one. Do