Simon says brainfuck
Brainfuck that only does what Simon says.
None1 · Turing complete: yes · ●○○ easy · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
None1 based Simon says brainfuck on brainfuck. Every line of code has to begin with Simon says: , with a capital S, the colon and one space after it. A line that begins any other way is ignored, like an order in the children's game that Simon did not give. What is left is plain brainfuck, so the language is Turing complete.
The machine
| Command | Does |
|---|---|
+ - | Add or take 1, wrapping at 256 |
< > | Move the pointer |
. , | Print the cell as a byte; read a byte into it |
[ ] | Loop while the cell is not 0 |
Only the lines that begin with Simon says: are code, and they are joined before the run. The interpreter on the specification has a million cells. It cannot read input at all, so the specification leaves the end of input open. , reads 0 there, which is what the cat needs to stop.
Example
The Hello World, in three lines that Simon says.
The Hello World, in three lines that Simon says.
The second line does not begin with Simon says: , so its . never runs and the ! is printed once.
The cat is Simon says: +[,.]. It stops when , reads the 0 at the end of the input, and prints that 0 as well. Without the space after the colon, which the specification calls mandatory, the line is not code and the program does nothing.
Patterns it teaches
- Turing tarpit: brainfuck's eight commands, with a password on every line.
See also
Simon says brainfuck builds on Brainfuck.
Brainfuck equivalents
Brainfuck derivatives
Write your own in Run Convert a program from Simon says brainfuck
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: simon-says-brainfuck.
Command line
shib run simon-says-brainfuck -e 'Simon says: +[,.]' --input 'cat '