>,[>,]<[.<]

Copy and paste into the interactive shell provided in the links.

Brainf*ck uses a collection of "cells" (think of an array, but one that extends infinitely). Each cell contains a number value, which is by default 0. Brainf*ck uses 8 commands:

  1. >: Moves to the next cell.
  2. <: Moves to the previous cell.
  3. +: Increments the current cell.
  4. -: Decrements the current cell.
  5. ,: Takes in input in the form of one ASCII character and stores it as its ASCII value ("a" = 97).
  6. .: Prints the value of the current cell.
  7. [: The start of a while loop that runs while the current cell isn't equal to zero.
  8. ]: Closing while loop bracket.

So the above code works like so for "Hello World!"

>  # Moves to the next cell => [0, here, 0, 0, ...]
,  # Takes one character and stores in current cell => [0, 72, 0, 0, ...]
[>,]  # Moves to the next cell, takes one character in that cell, until end of input => [0, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, ...]
<  # Move back one => [0, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33 (here), ...]
[.<]  # Print value of current cell, move to previous cell until we reach the starting cell => [0 (here), 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, ...]
# => !dlroW olleH

Built With

  • brainf*ck
Share this project:

Updates