Cratefuck
A crane carries 256 crates between rooms, one at a time. A room prints the character its count of crates spells.
DigitalDetective47, 2022 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
DigitalDetective47 made Cratefuck in 2022, a brainfuck derivative with a limited number of data markers. A warehouse has a row of rooms, endless to the right. All 256 crates start in room 0, and no crate is ever made or lost. To raise the count in one room the crane has to take crates from another, one at a time. The only test is whether the crane holds a crate.
The machine
| Command | Does |
|---|---|
< > | Move the crane one room left or right; it stays in room 0 at the left end |
* | Drop the crate it holds, or pick one up if it holds none and the room has one |
. | Print the character whose code is the number of crates in this room |
[ | Jump past the matching ] if the crane holds nothing |
] | Jump back to the matching [ |
The crate in the crane does not count for .. Every other character is a comment, and brackets that do not match stop the program before it starts. There is no input.
Example
The Hello, world! First a loop carries crates out of room 0, four per round, into rooms 1 to
The Hello, world! First a loop carries crates out of room 0, four per round, into rooms 1 to
- It stops when room 0 is empty and the crane comes back with nothing, which leaves 64 crates in
each. After that >*<* carries one crate from a room to the room on its left, and . prints a room once it holds 72 for H, 101 for e and so on.
The truth machine takes its input as crates in room 1. As it stands it gets 0. It puts one crate in room 6 and spreads the other 255 over rooms 1 to 5, 51 each. Then it takes three out of room 1 and prints the 48 left there, the character 0. Put *>*< in front and room 1 starts with one crate; then it prints 1 forever.
*[] is the infinite loop. The crane picks up a crate and never puts it down.
Patterns it teaches
- Turing tarpit: six commands and one bit of control.
- Counter machines: each room is a bag of crates, but the bags share one fixed total.
Further
See also
Cratefuck builds on Brainfuck.
Brainfuck derivatives
Cell-based
Write your own in Run Convert a program from Cratefuck
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: cratefuck.
Command line
shib run cratefuck -e '>*[>>>>>*<<<<<<*[>*<*>>*<<*>>>*<<<*>>>>*<<<<*>>>>>*<<<<<*]>*<*>*[.]]<*>>>>>>*<<<<<<*[>*<*>>*<<*>>>*<<<*>>>>*<<<<*>>>>>*<<<<<*]>*<*>*<*>*.'shib manual cratefuckSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/cratefuck.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org