LearnBrainfuck basics

Moving

By the end of this lesson you can fill several cells, and you know why it matters where the pointer stands.

Walk along the tape

The tape has five cells again, now with two more buttons, Left and Right. Make cell 0 hold 2 and cell 2 hold 3, and leave the other cells at 0:

One, two, three

Now you write the line. Make cell 0 hold 1, cell 1 hold 2 and cell 2 hold 3. The tape under the box shows what your program leaves, and the line under the figure says what is still wrong:

One step too many

This program was meant to leave 3 in cell 0 and 2 in cell 1. It does not. Drag the slider back to the start and step through it, watching where the pointer goes, then repair the line in the box:

The edge

The pointer stands on cell 0, and the program is a single <. Press Step once and read the line under the tape:

Check yourself

A free exercise

Write 1, 0, 1, 0, 1 into the first five cells, and make the program end with the pointer back on cell 0. Nothing is checked here:

What you can do now

You can walk along the tape and put numbers in several cells. These are the commands you know:

The commands of Lessons 1 and 2.
CommandWhat it does
+ −Add 1 to the cell under the pointer, or take 1 off.
> <Move the pointer one cell to the right or to the left.

Numbers in cells are fine, but a program should say something. Lesson 3 makes the machine print.