esolang
Learn · LessonsLesson 1 of 18

Lesson 1

Brainfuck's row of cells

Brainfuck has a long row of byte cells, all zero, and a pointer at the first one. Four of its eight commands work on the cell under the pointer.

The lesson

+ adds one to that cell and - takes one away; 255 + 1 wraps to 0. . prints the cell as a byte and , reads one byte of input into it. Everything else in the program is a comment.

The example adds 48, the code of 0, and prints three digits.

Brainfuck has its own page, and Run opens this example in the editor.

Example

Output


Exercise 1

Read one byte and print it back.

Run tries your program on the input below. Check runs it on every test.

The tests they must pass
InputExpected output
aa
ZZ
77

Output


A hint

Two commands. One reads, one prints.

One answer

Answer: Read one byte and print it back.

Expected output

a
The tests they must pass
InputExpected output
aa
ZZ
77

Output


Exercise 2

Read one byte and print the byte after it (a becomes b).

Run tries your program on the input below. Check runs it on every test.

The tests they must pass
InputExpected output
ab
YZ
01

Output


A hint

Read, add one, print.

One answer

Answer: Read one byte and print the byte after it (a becomes b).

Expected output

b
The tests they must pass
InputExpected output
ab
YZ
01

Output