Brainfuсk is one of the most famous esoteric programming languages, and has inspired the creation of a host of other languages. Due to the fact that the last half of its name is often considered one of the most offensive words in the English language, it is sometimes referred to as "brainf***", "brainf*ck", "brainfsck", "b****fuсk" (as a joke), "brainf**k", "branflakes", "brainoof", "brainfrick", "bf", etc. This can make it a bit difficult to search for information regarding brainf**k on the web, as the proper name might not be used at all in some articles.
Brainf**k operates on an array of memory cells, each initially set to zero. (In the original implementation, the array was 30,000 cells long, but this may not be part of the language specification; different sizes for the array length and cell size give different variants of the language). There is a pointer, initially pointing to the first memory cell. The commands are as follows:
> Move the pointer to the right
< Move the pointer to the left
+ Increment the memory cell at the pointer
- Decrement the memory cell at the pointer
. Output the character signified by the cell at the pointer
, Input a character and store it in the cell at the pointer
[ Jump past the matching ] if the cell at the pointer is 0
] Jump back to the matching [ if the cell at the pointer is nonzero
All characters other than ><+-.,[] should be considered comments and ignored.
Brainf**k was invented by Urban Müller in 1993, in an attempt to make a language for which he could write the smallest possible compiler for the Amiga OS, version 2.0. He managed to write a 240-byte compiler. The language was inspired by FALSE, which had a 1024-byte compiler. Müller chose to name the language brainf**k (with the initial letter in lower case, although it is now often capitalised).
It is not known to what extent Müller was aware of or influenced by Böhm's language P′′ published in 1964, of which brainf**k can be considered a minor variation.
When the array is unbounded, or when the array is at least three cells long and can store unbounded values, brainf**k is Turing-complete, meaning that it is in the same computational class as universal Turing machines. This, plus its dearth of commands, makes it a canonical example of a Turing tarpit.
This can be shown in a number of ways and with various restrictions on the brainf**k program and/or interpreter. The following formulations require the array to be unbounded, but allow