Welcome to the Brain$!_* programming language tutorial! Brain$!_* is an esoteric programming language designed to be minimalistic and challenging. It operates on a simple memory model with a pointer and a set of commands.
To write Brain$!_* programs, you only need a few commands:
+
: Increment the value at the current memory cell.-
: Decrement the value at the current memory cell.>
: Move the pointer to the right.<
: Move the pointer to the left.[
: Jump forward to the command after the matching ]
if the value at the current memory cell is 0.]
: Jump back to the command after the matching [
if the value at the current memory cell is nonzero..
: Output the ASCII character of the value at the current memory cell.,
: Read a single character of input and store its ASCII value in the current memory cell.Increment the current memory cell value by 5:
+++++
Explanation: The +
command increases the value at the current memory cell by 1. In this example, it's done five times, so the cell ends up with a value of 5.
Decrement the current memory cell value by 2:
--
Explanation: The -
command decreases the value at the current memory cell by 1. In this example, it's done twice, resulting in a value of -2.
Here's a more intricate example:
+++>++<-
Explanation: Here it starts getting interesting. <
and >
introduce multiple cells, with the command moving to a different cell. The code adds 3 to cell 1, moves to cell 2, adds 2 to cell 2, goes back to cell 1, and subtracts 1. The memory ends up being 2;2, showcasing how <
and >
control the movement between cells.
Read input, increment the value, and output the result:
,+.
Explanation: This code introduces ,
and .
commands. The , takes a input (number only) so you can input 6 and the current cell gets set to 6. the + increases 6 to 7, and the .
outputs the ASCII be version of the cell, 49 is 1, 65 is A and so on.
Let's create a loop to multiply the current memory cell value by 3 and output:
+[->+++<]
Explanation: In this example, we're using a loop structure to multiply the value at the current memory cell by 3. The + at the start is the input, The loop [ ... ]
runs while the value in the current cell is not zero. The +
command increments the value, the -
command decrements a temporary cell. We get the multiplied value in memory cell 2.
After this point, the code gets extremly complicated and confusing:
>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.
Explanation: In the code, 9 gets added to cell 2 and multiplied by 8 in cell 8. Achieving 72 which is "H" in ascii. 7 gets added to cell 2 and multiplied by 4, adding to cell 1, getting 101 in memory and printing "e". 101+7 gets "l" which gets printed twice, and finally 108+3 gets "o". finally getting "Hello" in output.
This code is really complicated, good luck figuring this one out:
++[->+>+<<]>>[-<<+>>]<<[>[->+>+<<]>>[-<<+>>]<<<-]
Explanation: This Brainfuck code utilizes nested loops and pointer movements to square the value in the current memory cell. Let's break it down:
++
: This is like the input number, in this example we have 2 which is the number we will square[->+>+<<]
: The start of the loop moves the input number into cell 2 and 3.>>
: Move to the third cell.[-<<+>>]
: Moves cell 3 to cell 1.<<[>[->+>+<<]>>[-<<+>>]<<<-]
: The loop starts at the first cell, goes to cell 2 and duplicates to cell 3 and 4, and moves cell 4 back to cell 2, goes to cell 1, subtracts cell 1 once and starts subtracting cell 2 while adding in 3 and 4, cell 4 gets moves to cell 2. This repeats until cell 1 equals 0. Leaving with cell 2 being the original number and cell 3 having the squared number, these values stay in memory This complex arrangement of loops and pointer movements effectively squares the value in the current memory cell. The final squared result will be in the original cell.
Here's a Brain$!_* program that outputs "Hello, World!":
++++++++++[>++++++++>+++++++++++>+++++<<<-]>.>++.+++++++..+++.>-.------------.<++++++++.--------.+++.------.--------.>+.
Feel free to explore and experiment with different Brain$!_* programs. The language's simplicity makes it a fun challenge for programming enthusiasts.
A
: 65B
: 66C
: 67D
: 68E
: 69F
: 70G
: 71H
: 72I
: 73J
: 74K
: 75L
: 76M
: 77N
: 78O
: 79P
: 80Q
: 81R
: 82S
: 83T
: 84U
: 85V
: 86W
: 87X
: 88Y
: 89Z
: 90a
: 97b
: 98c
: 99d
: 100e
: 101f
: 102g
: 103h
: 104i
: 105j
: 106k
: 107l
: 108m
: 109n
: 110o
: 111p
: 112q
: 113r
: 114s
: 115t
: 116u
: 117v
: 118w
: 119x
: 120y
: 121z
: 122Use the Brain$!_* Simulator to run and test your Brain$!_* programs. Enter your code, provide input, and see the output. Have fun coding!
Try the Brain$!_* Simulator.
For more information and advanced topics, refer to the official Brain$!_* documentation.
++++++[->+++++++++++<]>.[-]<++++++[->+++++++++++++++++++<]>.[-]++++++++[->++++++++++++<]>+.[-]<+++++++[->+++++++++++++++<]>.[-]<++++++++++[->+++++++++++<]>.[-]<+++++++[->++++++++++<]>.[-]+++++++++[->+++++++++++++<]>.[-]+++++++++[->+++++++++++<]>.[-]<+++++++[->+++++++++++++++<]>++.[-]
+++++++[->+++++++++++<]>.[-]<
++++++++[->++++++++++++<]>+.[-]<
++++++++++[->++++++++++<]>.[-]<
+++++++[->+++++++++++<]>.[-]<
++++++++[->++++++++++++<]>+.[-]<
++++++++++[->+++++++++++<]>.[-]<
+++++++[->++++++++++++<]>.[-]<
++++++++++[->+++++++++++<]>+.[-]<
+++++++++++++++++++++++[->+++++<]>.[-]<
+++++++++++++++++++++++[->+++++<]>.[-]<