Questions tagged [brainfuck]

Brainfuck (bf) is an esoteric, Turing-complete programming language famous for its minimalistic, eight-character syntax.

Filter by
Sorted by
Tagged with
-1 votes
1 answer
82 views

Brainfuck Compiler in javascript [duplicate]

I wrote a BrainFuck compiler in JavaScript and it works fine with this input: ++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++.....
Laczkó Lajos's user avatar
0 votes
0 answers
64 views

Interpreter in C++ for Brainfuck printing the wrong results

I written a Interpreter in C++ for Brainfuck und it works fine with "Hello World" Brainfuck Code to give me the right output. Now I'm trying a different Brainfuck Code, that generates the ...
PascalND's user avatar
0 votes
0 answers
80 views

ifstream stuck on `\n` when trying to read the previous character

I'm writing a brainfuck interpreter in C++. One of its language features is that in a loop if the current byte != 0 then go back to the beginning of the loop until it's == 0. My approach is reading a ...
ahmed's user avatar
  • 98
1 vote
2 answers
67 views

Copy byte value from an address to the specified address

I have this bf code: > ++++ ++ @1=6 How do I copy current value (6) in address @1 to the specified address for example address @8 I can do it with this: > ++++ ++ @1=6 [ >>>> >&...
Muhammad Ikhwan Perwira's user avatar
1 vote
1 answer
104 views

Why does this interpreter results in a segmentation fault?

I am trying to write a brainf*ck Interpreter in C. The current pointer, the array and the length of the array are given in a struct. The interpreter method receives pointers to the array struct and ...
HeapUnderStop's user avatar
0 votes
1 answer
72 views

How to have text before the input in Brainfuck?

How do I make it so that the question is asked before the input in Brainfuck? What I want: What is your number: 3 What I get: 3 What is your number: So the input executes before the text is printed ...
Baseed's user avatar
  • 1
0 votes
0 answers
137 views

Unexpected "10" when converting a string to ascii code in rust

I am trying to covert a string to an ascii code in rust to turn the string into BrainFuck code: (The variable "input" is the string "hello" and this snippet starts at line 12) for ...
Cody's user avatar
  • 3
1 vote
2 answers
179 views

Prints '+' to the screen 20 times using a loop and arithmetic operators

I have a simple Brainfuck program called "PuraPuraNanya", which prints the character + to the screen 20 times using a loop and arithmetic operators. ++++++++++[>+>+++>++++>+++++&...
Wahyu Kristianto's user avatar
1 vote
1 answer
159 views

Is there a way to print out the value at the pointer an a number in brainfuck?

So, i was wondering how could i print this value as a number NOT as a character an example would be that the pointer is on (125) (0)(0)(125)(0)(0) In this case when this snippet of would start, the ...
Pertz Hertz's user avatar
0 votes
0 answers
109 views

How to access the whole screen in x64 assembly, without BIOS or C

I'm currently working on an operating system. I have written an interpreter (which is also a compiler, oddly enough, but that's not the point). I basically did everything; I just need to build a GUI. ...
Xulum12's user avatar
  • 19
2 votes
1 answer
245 views

How do you use the comma command in Brainfuck?

I've been experimenting with the BF esolang today, as I graduated from hello world to an addition program, (which requires the data take in command), I could not for the life of me figure out how this ...
WrathOfCon's user avatar
0 votes
0 answers
108 views

How to fix "borrowed value does not live long enough" issue in rust

I have been writing a brainf*ck interpreter in rust, and was stupid enough to not use a lexer. I use recursion to tackle loops. let mut ret = exec(i, file, tape, ptr); i = &(ret.0); file = &...
SamuelFischerCode's user avatar
0 votes
2 answers
139 views

How can i add a+b in brainfuck?

How can i sum a and b without removing them? Example we have [A,B] and i want [A,B,A+B] and not [A+B,0]? ;>; < [->>+>+<<<] > [->+>>+<<<] >> [<&...
31b4's user avatar
  • 3
0 votes
1 answer
201 views

Unoptimized Brainfuck code runs faster than optimized Brainfuck code

I am currently trying to program a Brainfuck interpreter in Java. I try to optimize the Brainfuck code by removing comments and code that is redundant (I use regex for this). However, my unoptimized ...
Setvizan's user avatar
0 votes
2 answers
174 views

How can I check if user input is equal to a value in brainfuck?

I am trying to write a program (which I'm sure has been done before, just trying to challenge myself) that takes two user inputs per loop, one for the letter/number, and one to check if the user is ...
jjToad's user avatar
  • 1
3 votes
2 answers
129 views

Is brainfuck still Turing complete if opening brackets do nothing

I am working on a physical breadboard 8bit CPU that directly interpret brainfuck. The language specification indicates that both opening and closing brackets have logic : [ => Jump to matching ] ...
Gatoyu's user avatar
  • 652
0 votes
1 answer
68 views

Why does this end up as 72 in Brainfuck?

so I started looking into Brainfuck and I found this line as a part of a "Hello World" Program: -[>+<-------]>-. This line produces the output "H". If I understood it ...
Tom291's user avatar
  • 509
2 votes
2 answers
107 views

Brainfuck: Why does this happen?

I have this pretty simple program: +[----->+++<]>. +[----->+++<]>. Trying to log two g's however the output is gØ how can i make a newline break the code? operator? Not possible?
bruh5000's user avatar
0 votes
1 answer
78 views

How can you check if brainf*ck program is in an loop more than 5 seconds in python?

I am making a program that makes a random Brainf*ck program in python and runs it. I have an interpreter and I need it to check for long loops (more than 5 seconds). The interpreter is: while i < ...
Unresolved's user avatar
0 votes
1 answer
58 views

My BF program worked yesterday but doesn't today

I know that may seem silly, but yesterday, I found out about Brainfuck, and had fun with it. I made some programs and had a lot of fun. Though, today, when I try the same program, it simply prints ...
PetitFrapo's user avatar
3 votes
2 answers
105 views

How do I make a program in Brainfuck that will add two digits?

I'm trying to make a program in Brainfuck which I think is also called "Brainflake", that will add two single digit decimal integers input with ASCII numeric characters and display the sum ...
Jose's user avatar
  • 31
-1 votes
1 answer
154 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 ...
bruh's user avatar
  • 93
2 votes
2 answers
153 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 ([->+>+<<]>>[-<<+>>]<<[>[->+>+<<]>&...
Demi's user avatar
  • 23
3 votes
2 answers
363 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 ...
justanotherguy's user avatar
3 votes
1 answer
120 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'...
user17301834's user avatar
1 vote
1 answer
171 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 ...
d3r1n's user avatar
  • 45
0 votes
1 answer
49 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 ...
AllinOne-Gaming's user avatar
2 votes
1 answer
140 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 ...
silver takana's user avatar
0 votes
1 answer
217 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 ...
user avatar
1 vote
1 answer
233 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 ...
MichaPehlivan's user avatar
-2 votes
1 answer
335 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 ...
Cozer's user avatar
  • 15
-1 votes
2 answers
302 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'...
Caio Ishikawa's user avatar
1 vote
1 answer
125 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 ...
Mout Pessemier's user avatar
3 votes
0 answers
41 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: +[----->+++<]>+....
Mout Pessemier's user avatar
-1 votes
1 answer
89 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 ",[>++++<]" ...
Tristen Gordon's user avatar
-1 votes
1 answer
148 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: ++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-...
Ed May's user avatar
  • 43
4 votes
1 answer
197 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.
Marcox's user avatar
  • 102
1 vote
0 answers
295 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 ...
LeSgHsW's user avatar
  • 11
1 vote
1 answer
167 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 ...
S.Wil's user avatar
  • 11
0 votes
1 answer
70 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 "...
ValliHalli's user avatar
0 votes
1 answer
364 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'...
Richard Anyalai's user avatar
3 votes
2 answers
163 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 ...
dev_null's user avatar
1 vote
1 answer
305 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! ...
Butanium's user avatar
  • 752
-4 votes
1 answer
134 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 ...
BurovB's user avatar
  • 1
2 votes
1 answer
112 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. ++++++++[>++++[...
AKRA's user avatar
  • 290
0 votes
0 answers
72 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 ...
Caspian Ahlberg's user avatar
0 votes
1 answer
69 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 ...
Caspian Ahlberg's user avatar
0 votes
1 answer
93 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 ...
koukah's user avatar
  • 59
0 votes
1 answer
129 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 ...
hello world's user avatar
0 votes
2 answers
161 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: ,...
user avatar

1
2 3 4 5