31
2
We all know of, or at least have heard of, brainfuck, one of the most famous and influential esoteric languages. While these days most implementations use an infinite tape, the original compiler by Urban Müller had a tape of 30000 cells. A little known fact* is that there is actually a special value at the end of the tape, something that is almost never interacted with in a typical brainfuck program.
While you could print this value with 29999 >
s and a .
, brainfuck is known for its short and concise solutions, so your aim is to print this value with the minimum number of characters.
*fiction
Rules:
- A refresher on the brainfuck instructions:
+
/-
: Increment/decrement the current cell, wrapping from 255 to 0 when 255 is incremented and vice-versa<
/>
: Move the pointer left/right on the tape.
: Print the value of the current cell.[
: Jump to the corresponding]
if the value at the cell is 0]
: Jump to the corresponding[
if the value at the cell is not 0
- In this case
,
(Get input) does nothing, as the original compiler leaves the cell unchanged on EOF, and this program should receive no input. - The tape is initially filled with all 0s, except for cell 30000, which contains an unknown value
- The pointer starts at cell 1 and should end on cell 30000, having printed it.
- Cells to the left of 1 and to the right of 30000 have undefined behaviour, so solutions should not visit these cells.
- Note that the value at 30000
ismay be a 0, so simply looping until you hit a non-zero cell will not work. - You should print only the value at cell 30000
- The shortest solution wins!
- Tie-breaker is the more efficient program (executes in the least steps), followed by the fastest submission time.
Tip: Esolanging Fruit suggests using https://copy.sh/brainfuck to test your code. The specs are as described in this challenge, and you can select the abort
option so your program halts if it goes out of bounds.
Sandbox (deleted) – Jo King – 2018-03-01T04:32:40.817
Can we assume the implementation allows for holding values up to and including 30000 in a cell? – hakr14 – 2018-03-01T05:18:20.950
@hakr14 "
+
/-
: Increment/decrement the current cell, wrapping from 255 to 0 when 255 is incremented and vice-versa" – Jo King – 2018-03-01T05:20:11.08731 byte:
.
. I win. – Esolanging Fruit – 2018-03-01T05:23:50.7201@EsolangingFruit Let me have my delusions please... – Jo King – 2018-03-01T05:38:29.520
@JoKing oh, whoops. Well in that case, I have no idea. Here's a basic (not golfed) solution for 16-bit cells, if anyone wants to use the ideas for a real solution.
– hakr14 – 2018-03-01T05:39:21.650@hakr14 Your link doesn't seem to show anything – Jo King – 2018-03-01T05:48:19.930
@JoKing Oh. Yeah, that's cool. Not like I worked hard on that or anything.
This link should work. Sorry about that.
What happens if the memory pointer moves past the cell boundary? – user202729 – 2018-03-01T06:06:59.593
@user202729 Your solution becomes invalid – Jo King – 2018-03-01T06:07:56.453
1I suggest changing the rule to "initially all the cells have the value of 0, except the last cell which have an unknown value". – user202729 – 2018-03-01T06:07:58.027
Done, thanks @user202729 – Jo King – 2018-03-01T06:09:16.950
4
Tip for anyone doing this: copy.sh/brainfuck is probably the best site for doing this, as it implements BF as described in this challenge and has a 30k tape by default. Moving right past the end of the tape causes the interpreter to hang.
– Esolanging Fruit – 2018-03-01T06:33:04.087@EsolangingFruit That's my favorite BF interpreter. The input capabilities are nice, you can choose cell size and wrapping, and the memory dumping/inspection is helpful as well. – mbomb007 – 2018-03-09T22:51:23.590