Showing posts with label Brainfuck. Show all posts
Showing posts with label Brainfuck. Show all posts

Saturday, April 2, 2011

Writing brainfuck in Bitmap format

Inspired by this beautiful answer from Stack Overflow, I decided I'd do something similar.

The following is a bitmap image I drew in Paint visually showing a working brainfuck program:


Download the image, feed it to your brainfuck compiler and then execute the compiled executable.

If everything goes well, you should get something like this:

Friday, June 4, 2010

Brainfuck Wallpaper

Tired of your current wallpaper that's been on your screen forever? Maybe it's not geeky enough for you?

Well here's something for you:



For those of you who can't read, it's the word "geek" (without the quotes) in brainfuck. You can try it with this online Brainfuck Interpreter:




+++++[>+++++[>++++<-]<-]>>+++.--..++++++.


Here are some sizes I made:


Thursday, May 6, 2010

Translating brainfuck code to ANSI-C code with BrainfuckToC

This is my latest project. An application that translates brainfuck code to ANSI-C code.

To download the sources, visit the Google Code brainfucktoc page.

I would also like to thank Reuben Sammut who is a contributer to the project.

Usage

bftoc <source file>

Example:

bftoc bfcode.b

This will take a brainfuck source file and output its equivalent C code.

If you want to redirect the output to a text file, run bftoc as follows:

bftoc bfcode.b > bfcode.c

Examples

Hello World
Input:
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
Output:
#include <stdio.h>
#include <stdlib.h>

int main () {
    char *ptr = calloc(10000, sizeof *ptr), *start = ptr;
    int i = 0;

    *ptr += 10;
    while (*ptr) {
        ++ptr;
        *ptr += 7;
        ++ptr;
        *ptr += 10;
        ++ptr;
        *ptr += 3;
        ++ptr;
        ++*ptr;
        ptr -= 4;
        --*ptr;
    }

    ++ptr;
    *ptr += 2;
    putchar(*ptr);
    ++ptr;
    ++*ptr;
    putchar(*ptr);
    *ptr += 7;
    putchar(*ptr);
    putchar(*ptr);
    *ptr += 3;
    putchar(*ptr);
    ++ptr;
    *ptr += 2;
    putchar(*ptr);
    ptr -= 2;
    *ptr += 15;
    putchar(*ptr);
    ++ptr;
    putchar(*ptr);
    *ptr += 3;
    putchar(*ptr);
    *ptr -= 6;
    putchar(*ptr);
    *ptr -= 8;
    putchar(*ptr);
    ++ptr;
    ++*ptr;
    putchar(*ptr);
    ++ptr;
    putchar(*ptr);

    free(start);
    return 0;
}