CompressedFuck

From Esolang
Jump to: navigation, search

CompressedFuck, made by User:LegionMammal978 in 2015, is yet another compression scheme for brainfuck, designed to be at most half the size of the original program for sufficiently large programs.

Language

A CompressedFuck program is interpreted as a series of triplets of bits according to this table:

Triplet Instruction
000 +
001 -
010 <
011 >
100 .
101 ,
110 [
111 ]

It is then interpreted as brainfuck. Note that it must be padded with some unnecessary instructions to ensure that the byte count is a multiple of 3.

Examples

Hello, World!

�3������=��le���I��������I��I1���

Doesn't make much sense? Well, here's the translation:

00000000 00000000 00000000 11001100 00000000 00110011 00000001 10000000 00011000 00000001 10000100 10010010 00111101 10000110 00011001 01101100 01100101 11010001 11101101 11000110 01001001 10000000 00000000 00000000 10010000 00000001 00011011 10001000 11000101 00000000 00010000 10010010 01001001 10000100 10010010 01001001 00110001 10110001 00011000 00010000 00000000 00000000
000 000 000 000 000 000 000 000 110 011 000 000 000 000 110 011 000 000 011 000 000 000 011 000 000 000 011 000 010 010 010 010 001 111 011 000 011 000 011 001 011 011 000 110 010 111 010 001 111 011 011 100 011 001 001 001 100 000 000 000 000 000 000 000 100 100 000 000 000 100 011 011 100 010 001 100 010 100 000 000 000 100 001 001 001 001 001 001 100 001 001 001 001 001 001 001 001 100 011 011 000 100 011 000 000 100 000 000 000 000 000 000
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.++++++

As you see, there are 6 extra + instructions at the end for padding. Still, however, a 60.38% reduction in code size was achieved. The following examples will be encoded in Base64.

Cat program

ul4A

A 40% reduction was achieved.

Truth-machine

buKCDfAAAxRJJJL6y0/U

A 62.5% reduction was achieved.

Implementations

Interpreter Written in Perl here. Supports Base 64 Encoding/Decoding.