Lesson 5
Hello World in brainfuck
The classic Hello World nests two multiplication loops to set up several cells near the letters it needs, then nudges each one into place before printing.
The lesson
Change any + in the example and watch which letter moves.
Brainfuck has its own page, and Run opens this example in the editor.
Example
Output
Exercise 1
Print Hi! (bytes 72, 105, 33).
Run tries your program on the input below. Check runs it on every test.
| Input | Expected output |
|---|---|
(empty) | Hi! |
Output
A hint
72 is 8 × 9; from 105 to 33 is 72 back down.
One answer
Answer: Print Hi! (bytes 72, 105, 33).
Expected output
Hi!
| Input | Expected output |
|---|---|
(empty) | Hi! |
Output
Exercise 2
Copy the input, then print a newline (byte 10).
Run tries your program on the input below. Check runs it on every test.
| Input | Expected output |
|---|---|
hello | hello
|
abc | abc
|
(empty) |
|
Output
A hint
After the copy loop the cell is 0, so add ten and print.
One answer
Answer: Copy the input, then print a newline (byte 10).
Expected output
hello
| Input | Expected output |
|---|---|
hello | hello
|
abc | abc
|
(empty) |
|
Output