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 ...
Alexandru's user avatar
  • 6,134
89 votes
57 answers
12k views

BrainF***edBotsForBattling - A Brainf*** Tournament

All bots at the battle arena suddenly got brainfucked and no one can explain why. But who cares as long as they are still able to fight - although Brainfuck is the only language they understand ...
redevined's user avatar
  • 1,331
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 (...
Doorknob's user avatar
  • 71.5k
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 ...
Dennis's user avatar
  • 210k
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 ...
Mason's user avatar
  • 2,155
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 ...
JiminP's user avatar
  • 3,452
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 ...
Ronald's user avatar
  • 431
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 ...
Jo King's user avatar
  • 47.2k
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 ...
Zgarb's user avatar
  • 42.7k
29 votes
2 answers
2k views

Zero an arbitrarily large cell in Brainf***

Your task is to write a piece of code that zeros the current cell in the Brainfuck variant that, each cell can contain a signed integer of arbitrarily large magnitude, instead of the normal 0 to 255. ...
jimmy23013's user avatar
28 votes
2 answers
1k views

Convert Brainfuck to MarioLANG

MarioLANG is a two-dimensional programming language where the source code resembles a Super Mario Bros. level. Furthermore, its instruction set is very similar to Brainfuck's. This means that ...
Martin Ender's user avatar
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 ...
RAM's user avatar
  • 957
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, ...
PurkkaKoodari's user avatar
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....
Yeow_Meng's user avatar
  • 391
23 votes
4 answers
3k views

Minify Brainfuck

Your challenge is to minify Brainfuck code, according to these rules: Remove anything that is not one of +-><[].,. For any group of consecutive ...
Doorknob's user avatar
  • 71.5k
22 votes
1 answer
631 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 ...
EPICI's user avatar
  • 409
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 ...
Fmbalbuena's user avatar
  • 3,867
21 votes
4 answers
2k views

Convert Fractran into Brainfuck

Background Fractran is an esoteric Turing-complete programming language invented by John Conway. A Fractran program consists of an ordered list of fractions. The program starts by taking a single ...
PhiNotPi's user avatar
  • 29.1k
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, ...
emanresu A's user avatar
  • 38.8k
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 ...
null's user avatar
  • 12.1k
20 votes
3 answers
1k views

Brainf*ck Loop Problem

I have a problem for a cyber club that asks you to print: ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"! Using Brainf**k in 29 bytes or ...
Nick Rod's user avatar
  • 311
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 ...
randomra's user avatar
  • 20.9k
20 votes
1 answer
1k views

Bootloader golf: Brainf***

Create a bootloader that executes given Brainfuck program. This is code-golf, so the program with least bytes wins. Being a bootloader, the size of the program is counted in non-zero bytes in the ...
Hannes Karppila's user avatar
18 votes
3 answers
930 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 ...
Bubbler's user avatar
  • 76.9k
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 ...
user12205's user avatar
  • 9,008
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 ...
Maltysen's user avatar
  • 25.7k
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 ...
Wheat Wizard's user avatar
  • 98.8k
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 ...
AShelly's user avatar
  • 4,651
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: <...
captncraig's user avatar
  • 4,633
15 votes
2 answers
963 views

Translate RoboCritters into Brainf***

RoboCritters (etymology) is a brand new esoteric programming language (don't bother searching for it, I just invented it). It's a variant of Brainfuck (BF), slightly more complex than the usual ...
Calvin's Hobbies's user avatar
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 ...
Owen's user avatar
  • 369
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 ...
Galen Ivanov's user avatar
14 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 ...
Kamila Szewczyk's user avatar
14 votes
4 answers
2k views

Busy Brain Beaver

Write a brainfuck program of no more than 256 characters that takes as many steps as possible, but does not loop infinitely. The program may not take any input. More specifically: Assume an ...
Komi Golov's user avatar
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! ...
Thomas Ayoub's user avatar
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: ...
aditsu quit because SE is EVIL's user avatar
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, ...
xiver77's user avatar
  • 2,365
13 votes
1 answer
934 views

Brainf**k Debugger

Your challenge is to take input like this (a Hello World program): ...
Doorknob's user avatar
  • 71.5k
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 ...
Nelson G.'s user avatar
  • 347
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 ...
l4m2's user avatar
  • 24.5k
11 votes
8 answers
1k views

Generate a Brainf_ck program that outputs a string of given length

Your friend is trying to break into a vault that has a peculiar locking system: it requires a certain number of gentle knocks in a particular spot. Your friend discovered the number (which is in the ...
anatolyg's user avatar
  • 13.7k
11 votes
4 answers
1k views

Encoding an URL in brainfuck

Inspired by this question, your goal today is to encode an URL in brainfuck. My browser has been hacked! The location bar has been turned into a brainfuck interpreter. I need a program that turns an ...
orlp's user avatar
  • 39.1k
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 ...
Maltysen's user avatar
  • 25.7k
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 ...
alan2here's user avatar
  • 333
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***...
Christopher King's user avatar
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 (...
xiver77's user avatar
  • 2,365
10 votes
5 answers
444 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 ...
Esolanging Fruit's user avatar
10 votes
1 answer
620 views

Braincopterify an image

Introduction Braincopter is an esoteric Brainf*** derivative that encodes a Brainf*** program as an image. As a 2D language, it uses two additional commands; they rotate the instruction pointer (...
Copper's user avatar
  • 3,930
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",...
Peter Wirdemo's user avatar
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 ...
durron597's user avatar
  • 4,810