Skip to main content

Questions tagged [brainfuck]

This challenge is related to the BF language. Note that challenges that require the answers to be in a specific language are generally discouraged.

Filter by
Sorted by
Tagged with
150 votes
83 answers
26k views

Interpret brainfuck

Write the shortest program in your favourite language to interpret a brainfuck program. The program is read from a file. Input and output are standard input and standard output. Cell size: 8bit ...
15 votes
3 answers
4k views

Bitwise Operators in Brainfuck

Your task is to create one brainfuck program for each of the following binary operators. Each program should take one or two 8-bit numbers (A and B) from input and calculate the specified operation: <...
18 votes
3 answers
931 views

Magical BF: BF code that works in two ways

Challenge In this challenge, we will use a language that is very similar to Brainfuck but slightly different. This variant of BF does not have any input and output commands; instead, it simply takes ...
21 votes
16 answers
5k views

Write a Stack Exchange compliant brainfuck explainer

You are to take a string representing a piece of brainfuck code and Explanations, containing only printable ASCII characters and newlines ( to ...
23 votes
36 answers
5k views

bfcat - encode a file as a brainf*** program

Challenge Write a program or function that given a string, returns a valid Brainfuck program that when compiled and executed as Brainfuck, returns that string.. Assume all inputs are encoded as ASCII....
16 votes
10 answers
2k views

Brainf**k to Unary and Back

A language that is very useful in restricted source and other such challenges is Unary, a brainfuck derivative in which programs are written in with only one character. Your job is to write a program ...
45 votes
28 answers
6k views

Translate oOo CODE

Given an input of a program written in oOo CODE, output the BF code that it represents. Here is a short description of how oOo CODE works: First, all non-alphabetic characters are removed (...
15 votes
45 answers
2k views

Is it a brainfuck instruction?

A very simple challenge today. Output a truthy value whether the ASCII character (or it's code) supplied is a brainfuck instruction (one of +-,.<>[]), and a ...
10 votes
3 answers
1k views

Build an optimizing Brainfuck compiler/interpreter

the goal Build an optimizing Brainfuck implementation. Whether it is a compiler, an interpreter, a JIT compiler, or whatever else is up to you. scoring A reference implementation (...
6 votes
8 answers
672 views

Transpile Brainstract to Brainfuck

Introduction Brainstract, a newly created dialect of Brainfuck adds a bit more elements to the syntax. In addition to the normal Brainfuck syntax, there are macros. To define a macro: ...
-2 votes
3 answers
363 views

Make a Brainfuck Interpreter [duplicate]

There already is a Brainfuck interpreter question, but it is from 2011 and not up to date with current site standards and vague in places. I have proposed reposting this in chat, and it was well-...
10 votes
5 answers
2k views

Largest Number in Brainfuck BigInt for each program length up to 50 instructions

This challenge is for the largest finite number you can get BrainFuck programs of given lengths to contain in memory. We must use one of the BF versions that uses big integers for the cells rather ...
3 votes
4 answers
638 views

ASCII Brainfuck

Given a random code written using Brainfuck commands. You program should translate that code into the following ascii art: each Brainfuck command represents as 5x9 ...
4 votes
1 answer
395 views

Convert 256-wrap brainfuck into 257-wrap brainfuck

Usually each cell in brainfuck has 256 states, which is not enough to tell whether input is EOF or a character (usually \xFF). To fix it we can add one more state ...
20 votes
20 answers
4k views

Verify Brainfuck program

Yet another Brainfuck parsing problem, but this time... different. You are working in the Infinite Monkeys Incorporated, the company making Brainfuck programs, to solve various interesting problems ...
13 votes
2 answers
439 views

Translate an arithmetic expression to Brainfuck

Write a program that translates an arithmetic expression to a Brainfuck program which evaluates the expression and prints the result in decimal numbers. For example, this arithmetic expression, ...
21 votes
5 answers
3k views

Will one-cell brainfuck halt?

Brainfuck is an esoteric programming language that is Turing Complete, meaning you can't tell whether a given program will halt without running it. It's cell-based and has an infinite tape of cells, ...
7 votes
8 answers
898 views

Brainf*** to tinyBF converter

You don't need to know these languages to participate. All necessary information has been provided in this question. You should write a program or function which given a brainfuck (BF) code as input ...
45 votes
3 answers
3k views

Enumerate valid Brainf**k programs

Golunar/Unary is a way to encode all valid Brainfuck programs, but it is not an enumeration, since most natural numbers do not correspond to a valid program. For the purpose of this challenge, assume ...
39 votes
18 answers
8k views

Generate Brainfuck for the numbers 1–255

Write a program that, for the numbers 1 through 255, prints out BF code that will produce the given number in some byte of the array, plus a newline. For example, the first four lines of the output ...
9 votes
1 answer
444 views

BF memory layout optimizer

Given a BF program consisting of only the characters +-[]<>., with the property that there's an equal number of < and <...
14 votes
29 answers
6k views

RLE Brainfuck dialect

RLE Brainfuck (related to BF-RLE) The hypothetical RLE (Run-Length Encoding) dialect of Brainfuck accepts the symbols for the 8 commands and also accepts digits. The digits are used to represent the ...
4 votes
0 answers
218 views

5 tasks in (modified) BrainF**k from the Estonian OI [closed]

Introduction This challenge appeared in the 2020 Estonian Open Informatics Olympiad and was created Sandra Schumann. I thought it was interesting because it involves symmetry and is quite hard even to ...
35 votes
11 answers
16k views

Brainf*** Golfer

One of easiest code written by a programming language is a program printing sequence of characters (ex. "Hello, world!"). However, some esoteric programming languages like Brainfuck, even this ...
9 votes
7 answers
2k views

Generating BF-code with single purpose

I'd like to see you create code (in any programming language) that output working BF (Brain***k) code. Your program have a single character input on stdin. The input should be one digit ("0", "1", "2",...
9 votes
8 answers
1k views

Convert Brainfuck to a Non-Golfing Language

Input: Any Brainfuck program. This includes brainfuck programs with comments such as +++COMMENT[>+++<-].. Output: A program in one of the below languages that ...
0 votes
2 answers
205 views

Brainfuck movement [closed]

A normal Brainfuck program starts out with an array of cells, all containing the number 0. This program, on the other hand, must be able to run starting with any ...
27 votes
5 answers
3k views

Tips for golfing in brainfuck

What general tips do you have for golfing in brainfuck? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to brainfuck (e.g. "remove ...
3 votes
9 answers
907 views

Lazy brainfuck programmer [closed]

Background Joe is working on his new Brainfuck answer on Codegolf. The algorithm he's using to solve the challenge is a bit complicated, so Joe came up with idea of simplifying his Brainfuck notation ...
12 votes
3 answers
3k views

Print 'A' 1000 times with BrainFuck

What is the best BrainFuck code (in terms of code size) to print 'A' 1000 times ? My approach is: set 'A' to p[0] set 255 to p[1] to display 255 'A', 3 times set 235 to p[1] to display 235 'A' This ...
20 votes
2 answers
2k views

Brainf*** subprograms with unique outputs

You should write a 100-byte long brainfuck (BF) program. One character will removed from it in every possible way the resulting 100 new (99-byte long) programs. E.g. for the program ...
6 votes
1 answer
626 views

Multiplication in Brainfuck - minimum number of evaluations [closed]

Given two numbers in tape location #0 and tape location #1 in Brainfuck, compute their product into another tape location (specify with answer). Optimize for the least amount of time-units used, where ...
-2 votes
1 answer
271 views

BF Last binary digit [duplicate]

Task Your task is to write as short as possible program preferably in Brainf**k which determines the last digit of given number after it's conversion from decimal to binary system. Input An integer ...
10 votes
5 answers
445 views

Interpret TwoMega

In this challenge, you will write an interpreter for 2Ω (transcribed as TwoMega), a language based loosely on brainfuck with an infinite-dimensional storage space. The Language 2Ω contains three ...
16 votes
3 answers
979 views

Make a longer lenguage program

Lenguage is a brainfuck dialect that is notorious for breaking source restriction challenges. That is because Lenguage cares only about the length of it's source and not the contents. First, the ...
25 votes
7 answers
2k views

Generating Brainf*** NOPs

Sometimes when writing brainfuck code, you feel the need to make it longer than needed to encourage debugging. You could do it by just plopping a >< in there, ...
8 votes
1 answer
747 views

Large Numbers in BF

Background The language BrainF*** (or simply BF), is an extremely minimal programming language. We're going to strip it back even further by eliminating IO operations; only the sub-langage defined by ...
22 votes
1 answer
632 views

Traceless Busy Beaver

All those busy beavers made quite a mess. They wrote all over the tape. At this rate, our neighbour will stop lending us unbounded tapes. We need a new way to play the busy beaver game, one that ...
10 votes
4 answers
980 views

Partially Solve the halting problem for brainf***

To solve the Halting Problem you are given a description of a program, and must determine whether or not it will ever finish. You can never do this for all programs. Yet for programs like (in brainf***...
11 votes
5 answers
1k views

Compose two Brainfuck programs

Given 2 brainfuck code snippets A and B, output some brainfuck code C which has the same ...
17 votes
9 answers
3k views

Write a brainfuck translator

In any programming or scripting language x, write a program that takes a valid brainfuck sourcecode from stdin and output, to stdout, the sourcecode of a program, written in language x, that would ...
32 votes
3 answers
1k views

The cell at the end of the rainbow

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 ...
32 votes
14 answers
3k views

Are circular tapes exciting?

A Brainfuck derivative Let's define a simple Brainfuck-like programming language. It has a two-directional tape of cells, and each cell holds one bit. All bits are initially 0. There is a moving head ...
-4 votes
1 answer
912 views

Biggest number challenge (Brainfuck) [duplicate]

This is a brainfuck version of Largest Number Printable, and this. Let's think about brainfuck interpreter such that, Has array that can be stretched left & right arbitrary large Each cell can ...
15 votes
1 answer
665 views

Programming in two time dimensions

It's a funny accident that this world happens to have just 1 time dimension, but it doesn't have to be like that. It's easy to imagine worlds with 2 or more time dimensions, and in those worlds you ...
13 votes
3 answers
2k views

Write a brainfuck compiler

Write a program that takes a brainfuck program and compiles it to executable machine code. You can target x86, x86_64, jvm (java bytecode) or armv6, and use one of the following executable formats: ...
11 votes
3 answers
831 views

Randomized Brainfuck Compiler

Joe is your average BF developer. He is about to check in his code changes to their repository when he gets a call from his boss. "Joe! The new client's machine is broken! The brainfuck interpreter ...
32 votes
2 answers
7k views

Implement QuickSort in BrainF*** [closed]

As discussed in the Lounge room on Stack Overflow: if you can't implement the Quicksort algorithm given en.wikipedia.org/wiki/Quicksort in any language you have minimal knowledge of, you might want ...
15 votes
5 answers
3k views

Fastest Sort in BrainF***

After having implemented QuickSort in BrainF***, I realized it probably wasn't that quick. Operations that are O(1) in normal languages (like array indexing) are significantly longer in BF. Most of ...
13 votes
5 answers
1k views

Hide a Brainf*** greeting in other code

The goal is to write a program (anything except explicit brainfuck) which prints Barney Stinson's best rule: New is always better. when interpreted normally, but Legen... wait for it... dary! ...