Questions tagged [brainfuck]
Brainfuck (bf) is an esoteric, Turing-complete programming language famous for its minimalistic, eight-character syntax.
185
questions
-1
votes
1
answer
64
views
How is Brainfuck interpereting loops that makes this code work?
This might sound stupid, but i need help with brainfuck.
so im writing an interpreter in c#, and I tried to use my interpreter on a real piece of code (+[----->+++<]>+.+.) which should print ...
2
votes
2
answers
53
views
Absolute of number in brainfuck
How would you go about getting the absolute of a number in brainfuck?
I originally thought squaring the number ([->+>+<<]>>[-<<+>>]<<[>[->+>+<<]>&...
2
votes
2
answers
114
views
How do I implement the looping functionality in my BrainFuck Interpreter?
There's multiple questions here already, but I'll still proceed. This is a simple BrainFuck interpreter. I figured out all the other symbols, but I can't figure out how to implement loops. Can anyone ...
3
votes
1
answer
53
views
Can anyone explain why this brainfuck if/else code doesn't work?
// if x = y then {if_code}; else then {else_code}
,>,< / empty memory
[->-<]> / (x)'y
[>->]< / 0'(y-x)
+[
{if_code}
->>
]< / {if x=y then} (0)'0; {else then} 0'...
1
vote
1
answer
90
views
How to optimize brainf*ck instructions
I'm trying to write an optimisation feature for my brainf*ck interpreter.
It basically combines same instructions into 1 instruction.
I wrote this function but It doesn't work properly:
pub fn ...
0
votes
1
answer
28
views
Does the new location have to be zero for the loop to end in brainf*uck
I was wondering abt bf loops then it just got much more complicated.
when you open the loop([) at the pointer location 0, then go forward(>) in the loop([>). Does the new location have to be ...
2
votes
1
answer
89
views
how to set an array with the size of n to a specific number in brainfuck
I want to set an array of n elements to a predefined value (which isn't copying from a cell but setting a value from the code itself). How could I do that? without changing other cells as I went ...
0
votes
1
answer
97
views
Why does every brainf*ck interpreter (except the web ones) show these characters? (♀♂)
So I tried doing my own Brainf*ck interpreter in C++, and everything was going fine until I tried this program:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[.-]
It just goes to ...
1
vote
1
answer
97
views
implementing loops in a c brainfuck interpreter
I have written a simple brainfuck interpreter in c. all the commands work fine, except for loops. currently, I am handeling them like this:
I have a function to find the matching square bracket:
int ...
-2
votes
1
answer
124
views
compiling a Brainfuck hello world program [closed]
I found this weird programming language that is an attempt to create the smallest possible compiler called brainf*ck, and i honestly want to try it but i don't have any knowlegde about how to compile ...
-1
votes
2
answers
103
views
How should I handle possible negatives in my BrainF**k interpreter?
I'm building my first interpreter to learn Rust better, and I'm sort of stuck on this problem, because me tape/memory is a vector of unsigned 8-bit integers, but loops sometimes result on negatives.
I'...
1
vote
1
answer
42
views
Exit condition loop BrainF*ck
I've used the BrainFuck Visualizer to check out this small piece of code but I don't understand how the exit conditions work on the loops starting with -. It suddenly just stops and jumps to the next ...
3
votes
0
answers
39
views
Are BrainF*ck tape spots overflowing? [duplicate]
Can I assume that if you do - on a tape spot with 0, that it loops around to 255?
Otherwise I don't understand how you can start a loop with - without first incrementing?
e.g:
+[----->+++<]>+....
-1
votes
1
answer
71
views
List has no items to pop however there was something there?
Trying to make a brainfuck interpreter in python from scratch just for fun, I'm almost done with the code however this small error is coming up whenever I try interpreting ",[>++++<]" ...
-1
votes
1
answer
126
views
My Brainf*** interpreter Does Not Work With Common Hellow World Program
I am trying to make a brainf*** interpreter in c++. when I test it with the Esolang hello world example:
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-...
4
votes
1
answer
170
views
How do I print “What happened on the 4th of June 1989?” in BrainFuck?
I need to learn how to display this text in BrainFuck among other programming languages, BrainFuck included.
1
vote
0
answers
179
views
Brainfuck interpreter has peculiar problems with loops
I am writing a cpp program to execute live inputs of Brainfuck code,
like how you can use python live in a terminal.
Everything works fine, except when nested loops come into play:
This nested loop ...
1
vote
1
answer
89
views
Moving the pointer by a given amount in brainfuck
My array looks like this at the moment, data pointer at the [n]. The code will give a number from 2-10
0 10 45 45 45 45 45 45 45 45 45 0 [n] 0
I need to move the pointer to the left by n spaces ...
0
votes
1
answer
57
views
How to add Brainfuck into Atom
I know nothing about grammars or that type of stuff and i don't know how to make brainfuck work in
Atom. I have installed script and brainfuck, but if I try to run it just prints the error "...
0
votes
1
answer
196
views
BrainF*ck interpreter in x86 32-bit Assembly
I started to write a BrainF*ck interpreter for my OS in 32-bit x86 assembly. I have already written one in C that just works and tried to implement it in assembly but the one written in assembly doesn'...
2
votes
2
answers
128
views
Optimized cell increasing in brainfuck
So my aim:
put the value n into a cell with smallest amount of instructions.
I could do + twenty times for the value 20.
But a shorter way is for example to do >++++[<+++++>-]<.
How could ...
1
vote
1
answer
144
views
Is this possible to write a Quine in ook
According to this comment from the general question Is it possible to create a quine in every turing-complete language? it seems like it is said that it's possible.
However I didn't find any Ook! ...
-4
votes
1
answer
92
views
Why the brainfuck interpreter in C may not work when executing a program with loops?
I decided to write another one BF interpreter in order of personal development, and despite the fact that this is his second version written from scratch, one way or another it doesn't work correctly ...
2
votes
1
answer
108
views
Brain**** implementation in C
I'm trying to run a hello world program with the brainfuck implementation that I made this week but I'm getting a strange output.
This is the hello world file that I'm trying to run.
++++++++[>++++[...
0
votes
0
answers
61
views
Why is this assertion failing for my Scheme-based Brainfuck interpreter?
I am writing a Brainfuck interpreter in Scheme (Chez Scheme). It seems like no matter which Brainfuck program I throw at it, it never works, and I cannot figure out why. I figured that I would try it ...
0
votes
1
answer
40
views
What is causing the abort trap in the output C file for my Brainfuck transpiler?
I am working on a C to Brainfuck transpiler, based on the translation described in Brainfuck's Wikipedia page. Each program that I have tested works perfectly, until the end. In the beginning, I ...
0
votes
1
answer
78
views
BF Interpreter in F# Issue [closed]
Ok so i am working on a small project as you can tell in the title i am making an BrainFuck interpeter in f# and i am new to this language but it is fun except that you fight with the compiler lot but ...
0
votes
1
answer
88
views
My BF to NASM compiler makes asm that doesn't work, for a known working BF program
Meta: I am new to assembly language in general and NASM in particular. After playing around with NASM for a couple of evenings I got confident enough to write a simple Brainf*uck compiler: it takes bf ...
0
votes
2
answers
116
views
cannot get two inputs in brainf**k
So for some reason, when trying to get two different inputs in brainf**k, It only prompts me for one, then quits. I am trying to make something that takes two numbers and adds them, here is the code:
,...
2
votes
1
answer
225
views
How to make a fully functional brainf*ck interpreter?
I have tried to implement a BF interpreter in Javascript. It works for many programs like printing Hello world, looping, etc.
Here is link to a sample interpreter that I use for comparing outputs: ...
2
votes
1
answer
413
views
How can I print the ascii value of an input in Brainfuck?
What I want to do is for a Brainfuck code to print out the ascii value of the input. For example, typing in an input of "a" will give an output of 97. The python equivalent of this is print(...
3
votes
1
answer
337
views
How can I duplicate a cell value to another cell in Brainfuck?
What I want to do is to first ask for an input for the value of cell 0(the first cell), then duplicate that input into the next cell(cell 1) while retaining the input value on cell 0. For example, if ...
0
votes
1
answer
1k
views
How is input handled in Brainf***?
I can't really seem to find a standard for this. I know inputs are taken as ASCII values, but are they required to be single characters? If not, how are multi-character inputs handled?
2
votes
2
answers
393
views
Brainfuck try to - in a 0 cell
What happens in Brainfuck if I try to "-" in a cell that contains a 0?
>-
Also, what happens if I try to start a loop while pointing to a 0 cell?
>[]
Edit:
I forgot to mention it, but I'm ...
0
votes
1
answer
286
views
Smallf*ck (simple brainfuck dialect) interpreter endless loop
I'm trying to implement a Smallf*ck interpreter.
Smallfuck is an even more laconic dialect of Brainfuck, which operates on bits instead of bytes, has a limited size of memory tape and has no I/O ...
1
vote
1
answer
139
views
spawnSync input not working as expected (want array of inputs)
my code:
const { spawnSync } = require('child_process');
let child
child = spawnSync('brainfuck', ['-e', '>,[>,]<[.<]'], { input: 'hello' })
console.log('stdout ', child.stdout);
console....
1
vote
0
answers
57
views
how pass inputs before javascript execution, WITHOUT PROMPTING IN TERMINAL
i have the following code:
'use strict';
// const exec = require('child_process').exec
var brainfuck = require('brainfuck')
let source = '>,[>,]<[.<]'
brainfuck.exec(source, function(err,...
2
votes
1
answer
289
views
Brainfuck interpreter not working on some codes, while every instruction is taken care off
I made a Brainfuck interpreter in assembly (AT&T syntax, GCC). It works on most stuff. All the desired actions work (+ - > <). I made sure to take care of nested loops as well (pushing the ...
2
votes
1
answer
219
views
Brainfuck interpreter not running some codes
I'm kinda new to C programming and decided that making a brainfuck interpreter in C would be a good way to learn the language. I could write and tested with these bf codes:
this should print a hello ...
1
vote
2
answers
138
views
In brainfuck, how does the interpreter deal with going below 0 in the tape?
I am not sure that I understand what exactly the interpreter does to handle moving the current index of the tape below zero. Should the interpreter allow the tape to go below 0? Thank you!
9
votes
1
answer
409
views
Why does my program keep getting stuck while running the mandelbrot brainf*** program?
I wanted to improve my C skills, so I search some program's ideas.
Someone propose to create a simple Brainf*** interpreter and then a compiler. So here I am.
I created the interpreter and it works ...
2
votes
1
answer
870
views
Why is Kotlin much faster than Java at interpreting Brainfuck?
In this Brainfuck v2.0 benchmark, the Java version seems to be equivalent to the Kotlin version, as far as I can tell.
However, it runs twice slower and uses much more memory. Why is that?
I would ...
0
votes
2
answers
186
views
Making an executable by running an executable
I wanted to write a brainfuck compiler, but when I went to write one I was stuck at this problem
I want to create an ELF executable (using C/C++) that reads a brainfuck code from a file and generates ...
-1
votes
2
answers
386
views
Which would compile and/or calculate the first 100 numbers of the fibonacci sequence faster: C or Brainfuck [closed]
I know very little about what makes a language "fast", but it stands to reason for me that a language designed for extreme minimalism would also be extremely fast, right?
C is far closer to English ...
-25
votes
1
answer
281
views
ASCII patterns with for loops [closed]
00**00
00**00
**00**
**00**
00**00
00**00
print this pattern using for loop.
0
votes
2
answers
433
views
Why does a program created by a Brainfuck into assembly compiler crash?
I'm writing a Brainfuck to NASM compiler in Haskell. It can compile small programs, but fails to do so correctly with big ones.
Consider the following Brainfuck code:
++++++++[>++++[>++>+++&...
1
vote
1
answer
100
views
Indirect Addressing in Brainfuck
How would I move the memory pointer to a location described in a memory cell? Super confused.
So if cell 4 is 10, how would I set the memory pointer to 10 given the address of cell 4. Absolutely no ...
-4
votes
1
answer
151
views
Why does this Java code behave differently than this C code?
Long story how I got here; involves a Brainfuck to C compiler and a Brainfuck to JVM Bytecode compiler... seems irrelevant.
The Brainfuck code in question is as follows:
>-[[<+>>>-<-...
4
votes
5
answers
1k
views
How to print numbers from 1 to 10 using a loop in Brainfuck? Is it even possible?
How to print numbers from 1 to 10 using a loop in Brainfuck? Is it even possible?
I am looking for a solution to this issue.
0
votes
1
answer
98
views
In Brainfuck, how can I write a loop that prints a matrix whose elements are given by the user?
I'm trying to make a Gaussian elimination in Brainfuck, but I can't figure out how to print a matrix of given numbers
,>, this receives the number of rows and columns;
<[>>>+<<&...