Brainspin
Brainfuck on three cells that never stop turning.
Nmcassa, 2022 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
Nmcassa made Brainspin in 2022. It is brainfuck with only three cells, set in a ring. After every command the pointer moves one cell to the right, and from the third cell it goes back to the first. So < and > are gone. In their place is *, which does nothing but let the ring turn once more.
Read the story
Every command lands on a different cell from the one before. Three + in a row add 1 to each cell and leave the pointer where it started. To work on one cell you follow each command with **.
The machine
| Command | Does, then moves one cell right |
|---|---|
+ - | Add or take 1 |
. | Print the cell |
, | Read a number into the cell |
[ ] | Brainfuck's loop |
* | Nothing |
Every other character is a comment and does not turn the ring. The specification shows the language is Turing complete by turning 3-cell brainfuck into it. > becomes *, < becomes **, and +, -, [ and ] each get ** after them. Cells are bytes that wrap. , reads a whole number, as typing 72 gives the code of H.
Example
The first is a Hello with input.
The first is a Hello with input. The three , fill the three cells with H, E and L, and the three . print them. Each ** then brings the pointer back to the third cell, which prints L once more and takes three + to become O. The second is the brainfuck cat ,[.,] with ** after each command, as the specification's table does for + and -. It stops when the numbers run out.
Patterns it teaches
- Turing tarpit: brainfuck with fewer cells and no pointer moves.
- Turing completeness: shown by turning 3-cell brainfuck into it.
Further
See also
Brainspin builds on Brainfuck.
Brainfuck derivatives
Write your own in Run Convert a program from Brainspin
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: brainspin.
Command line
shib run brainspin -e ', type 72 for Cell #1 to be the ascii for H
, type 69 for Cell #2 to be the ascii for E
, type 76 for Cell #3 to be the ascii for L
...**.**+**+**+**.' --input '72
69
76
'shib manual brainspinSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/brainspin.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org