5050BrainF
Brainfuck where every plus, minus and step is a coin toss.
Joe, 2024 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Joe made 5050BrainF in 2024. It is brainfuck, but +, -, < and > each do their work only half the time. Loops, input and output always work. So most programs print something different on every run, and the specification shows seven runs of one program giving seven different characters.
Read the story
Some programs come out the same anyway. A loop runs until its cell is 0, however many tosses that takes, so [-] always clears a cell and [>] always stops on an empty one.
The machine
| Command | Does |
|---|---|
+ - | Add or take 1 from the cell, at even odds |
> < | Move right or left, at even odds |
. , | Print or read a byte |
[ ] | Loop while the cell is not 0 |
Every other character is a comment. Cells are bytes and wrap, the tape has no end either way, and the end of input reads as 0; the specification leaves these open. This implementation uses a fixed pseudo-random sequence for the coin, so a program prints the same thing on every run.
Example
The specification's program is 70 + and a .
The specification's program is 70 + and a . inside quotes. In its runs it printed character codes from 25 to 43, around the 35 that half of 70 gives. With this implementation's coin 34 of the 70 tosses come up, and it prints ", which was also its last result.
A cat uses only input, output and a loop, so it never misses.
Patterns it teaches
- Nondeterminism: a coin under most commands, and loops that win anyway.
Further
See also
Probabilistic
Cell-based
Write your own in Run Convert a program from 5050BrainF
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: 5050brainf.
Command line
shib run 5050brainf -e '[>]'shib manual 5050brainfSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/5050brainf.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org