Brainf**k


Brainf**k is an esoteric programming language. It consists of the following eight commands:

> Increments the data pointer
< Decrements the data pointer
+ Increments the byte at the data pointer
Decrements the byte at the data pointer
. Output the byte at the data pointer
Get one byte of input and store it in the byte at the data pointer
[ If the byte at the data pointer is zero, jump forward to the matching ] command
] If the byte at the data pointer is nonzero, jump backward to the matching [ command

Any other symbols or characters are treated as comments.

The following Brainf**k program prints “Hello World!”:

+++++ +++++             initialize counter (cell #0) to 10
[                       use loop to set the next four cells to 70/100/30/10
    > +++++ ++              add  7 to cell #1
    > +++++ +++++           add 10 to cell #2 
    > +++                   add  3 to cell #3
    > +                     add  1 to cell #4
    <<<< -                  decrement counter (cell #0)
]                   
> ++ .                  print 'H'
> + .                   print 'e'
+++++ ++ .              print 'l'
.                       print 'l'
+++ .                   print 'o'
> ++ .                  print ' '
<< +++++ +++++ +++++ .  print 'W'
> .                     print 'o'
+++ .                   print 'r'
- - - - - - .           print 'l'
- - - - - - - - .       print 'd'
> + .                   print '!'
> .                     print '\n'

Just as in a previous puzzle, write an interpreter for the Brainf**k programming language

Remember, to solve this puzzle and appear on the leaderboard, email both your solution and your source code (in any language) to lewiscornwall13@gmail.com. Good luck!!

View all puzzles »

Advertisements