esolang

Expensive

Brainfuck with a price. A program runs only when the SHA-512 of its source starts with eight hex zeros.

Hakerh400, 2020 · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: Hello, World!

The idea

Hakerh400 made Expensive in 2020. It runs brainfuck as it is, but it accepts a program only when the SHA-512 of its source starts with four zero bytes. A random source passes about once in 4,294,967,296 tries. So a program is written twice. First the brainfuck, then a tail of commands that change nothing anyone sees, tried over and over until the hash comes out right.

Read the story

Brainfuck reads every other character as a comment. Expensive forbids them, so there is no room for a comment, a space or a line break.

The machine

CommandDoes
> <Move to the next or previous cell
+ -Add or take 1; a cell wraps at 256
.Print the cell as a byte
,Read a byte into the cell, 0 at the end of the input
[ ]Skip past the matching ] when the cell is 0; jump back while it is not

Before anything runs, the source is hashed. The three programs pass. Change one character and the program stops with an error before it prints anything.

Example

The Hello World does its work in the first 72 characters.
Expected: Hello, cat!
Expected: 0

The Hello World does its work in the first 72 characters. The 16 after it, ><-<>-++>--<++>>, run after the last letter is printed and only move along the tape and change cells. They are there for the hash. The cat ends in 17 such characters and the truth machine in 16. On 1 the truth machine prints 1 forever.

Patterns it teaches

  • Hostile design: the language is brainfuck, and the hostility is all in the cost of getting a program accepted.
  • Turing tarpit: eight commands on a tape of bytes.

Further

Expensive builds on Brainfuck.

Brainfuck derivatives

Write your own in Run Convert a program from Expensive

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: expensive.

Command line

shib run expensive -e ',[.,]+>+<>->><>+<+--<+' --input 'Hello, cat!'
shib manual expensive

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/expensive.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org