>,[>,]<[.<]
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:
>: Moves to the next cell.<: Moves to the previous cell.+: Increments the current cell.-: Decrements the current cell.,: Takes in input in the form of one ASCII character and stores it as its ASCII value ("a" = 97)..: Prints the value of the current cell.[: The start of a while loop that runs while the current cell isn't equal to zero.]: 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
Log in or sign up for Devpost to join the conversation.