Contents

Brainfuck

This is one of most popular esoteric programming languages - i.e. ones, which were created not for real work but for small puzzles end logic exercises - i.e. for fun and amusement.

Main feature of the language is extreme simplicity. Nevertheles it allows hypotetically to create any program, though the source code could be extremely large and execution time insanely long.


Language Specification

Brainfuck program is a sequence of characters. Each character is a command. In core implementation there are just 8 commands which work with the following 4 areas of memory:

So there are 8 commands in total, of them 6 do some action on memory and move the code pointer to the next command:

Two more commands are used to change the code pointer in specific way, to create loops and conditions:

I.e. with code like +-[->[>-].]. the first opening bracket makes the interpreter jump to the end, behind last closing bracket.

Any other characters are usually ignored so it is safe to use verbal comments, spaces and line breaks.


Our Extension

To make the language bit more handy, we will extend it a bit, adding two more input/output commands:

The reason for this addition is obvious - the original version of Brainfuck make it rather difficult to manipulate numbers in human-readable format.

So the program ,: for example being fed on input with the symbol A will print to output value 65 (it is the ascii code of capital A letter).

We will call this extended variant Brainfuck++ in the problem statements.


Stack operations

Some problems will allow two more operations, assuming that interpreter has additional internal storage - stack:

So the program ;#>$[-<+>]<: will double the entered value.


Examples

Printing 5:

+++++:

Printing !:

++++++++ ++++++++ ++++++++ ++++++++ +.

Printing Hello world:

++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.
>---.
+++++++.
.
+++.
>>.
<-.
<.
+++.
------.
--------.
>>+.
>++.

Summing two values:

;>;[-<+>]<: