Menu
  • HOME
  • TAGS

BrainFuck implementation problems:

c,brainfuck

The line switch (file.val++) { just can't be right. Currently it's just incrementing the first "val" of the file chain like the "mem.val++" below it. I expect you'll need to get rid of the ++ on that line then do something about incrementing a pointer to an instruction rather than...

Handling loops in Brainf*ck

c,loops,brainfuck

The condition for premature end of the program execution is here: while (indexOfCommands < length && numOfCommands < 60000) { ^^^^^^^^^^^^^^^^^^^^^ // interpret BF opcodes numOfCommands++; } You have underestimated how many instruction BF needs to do simple things. (I'm not sure why that condition is in there. Remove it...

Why do I get a Perl error in this brainfuck program?

perl,interpreter,brainfuck

Your interpreter likely uses a Perl function such as “chr” to convert cell values to characters upon output, and does not limit cell values to [0;255]. While this can be useful in some calculations, the Brainfuck output is normally bytes, whereas Unicode codepoints are usually encoded as UTF-8, and even...

“Access is denied” error when running brainfuck interpreter from cmd

cmd,brainfuck

Your problem are not square backets. You problem are < and >. They are intended to handle stream redirection, < xxx means get input from xxx, > xxx means send output to xxx You can enclose the text in double quotes or can escape the "problematic" characters preceding them with...

Sum of number in brainfuck

brainfuck

Here is a simple version. Assume we name the first three cells y, temp0 and x. Then we can simply use this algorithm within a decrementing loop: +++ # Input number [ # loop while this is not 0 >[-] # addition algorithm <[>>+<+<-] # addition algorithm >[<+>-] # addition...

Divmod algorithm in brainfuck

algorithm,division,modulo,brainfuck,divmod

Here's what happens: # >n 0 d This line, is a comment line telling you what the memory should be like before the operation. Dividend as n, divisor as d. According to the code the next 3 cells should be empty as well, but it is ignored here, assuming you...

Implementing Brainf*ck loops with JavaScript

javascript,brainfuck

You need to properly handle nesting of [ and ]. I would do this by having a count variable. For example, when you encounter a [ and need to find the matching ], initialize count to 1 and go through the characters. When you come across a [, increment it;...

How to write a “comment” containing a period (.) in Brainfuck?

comments,brainfuck

There's a trick you can use: a loop will not execute what's inside if it's not run and fits syntactically. [This is a comment.]+++++++++++++++++++++++++++++++. Indeed, if you leave out the [], this will print a NUL byte too much. You still cannot use brackets though ;) This is akin to...