BrainF Language

In the Brainf*ck language, only the following eight commands are recognised:

'>' increment pointer

'<' decrement pointer

'+' increment value at pointer

'-' decrement value at pointer

'[' begin loop (continues while value at pointer is not-zero) (if value is zero then skip over code to end of loop)

']' end loop

',' read one character from input into value at pointer

'.' print value at pointer to output as a character

There are different cells, starting from 0, so the following code:

'+>++>+++'

would output 123 (cell 1 has 1 value in it, cell 2 has been incremented twice so has value 2, and so forth).

Considering that each number prints out as its ASCII value, found here http://www.asciitable.com/ and considering that the following code prints 'Hello, world!' :

'++++++++++[>+++++++>++++++++++>+++>++++< <<<-]>++.>+.+++++++..+++.>>++++.<++.<+++ +++++.--------.+++.------.--------.>+.'

Because this code gives changes each address (cell) to the following values: Address 0 value 0, Address 1 value 72, Address 2 value 100, Address 3 value 33, Address 4 value 44,

then what (efficient) brainf*ck code would change each address to the following values: Address 0 Value 1, Address 1 Value 0 Address 2 Value 100

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<<+ +>>[++++++++++]*10 +>++++++++++[>++++++++++<-] +>++++++++++[>++++++++++]

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Ralph Richards
Mar 28, 2014

First, you increase address 0 by 1 (+) and then move on to the next address with > Then you increment address 1 by 10. Don't worry, this will be decreased back to 0 in the loop. The loop is created, and this increases address 3 by 10, moves back a space and decreases address 1 by 1. This happens ten times, so 10 is added to address 3 by 10 ten times, and each time address 1 decreases by one, until address 1 is 0 and address 2 is 100.

brainf ck always f cks me up lol -_-

Nelvson Shine - 7 years, 2 months ago

OMG i know BF

Aayush Gupta - 7 years, 2 months ago

BF is awesome. How about we start a BF wiki?

Agnishom Chattopadhyay - 5 years, 4 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...