aemkei / jsfuck

Write any JavaScript with 6 Characters: []()!+
jsfuck.com
Do What The F*ck You Want To Public License
8.12k stars 672 forks source link

Proposition (and solution): COMPRESION Technique idea #70

Closed kamil-kielczewski closed 4 years ago

kamil-kielczewski commented 6 years ago

Hi,

You JSFuck compiler is very interesting however it has some drawback - it produce very large code from small code JS :( . So I have following idea:

  1. Lets Compress our STRING with CODE by switch it to base4 (not 64!) characters, however instead using character 0,1,2,3 we change '3' to letter 'a' becouse in brainfuck letter 'a' is shorter than '3' representation:
var input = "alert('Hello world' + \x22 in 2018! :) \\uC548\\uB155\\uD558\\uC138\\uC694 \x22)"; // our input program as STRING (we can only use code which use ASCII character - for utf8 characters we need to use escape characters as in this example)

// code string
var encode = function(input) {
    let output = ""
    input.split('').map(function(letter) {
    let c =letter.charCodeAt(0).toString(4).split('3').join('a');
    if(c.length==3) c="0"+c;
    if(c.length==2) c="00"+c;
    if(c.length==1) c="000"+c;
    if(c.length==0) c="0000";
    output = output + '' + c;    
}) 
return output;
};

var code = encode(input);

Ok so in variable 'code' we get following value (remeber number '3' in our base4 we change to letter 'a'):

120112a012111a021a100220021a1020121112a012a012aa02001a1a12aa1a0212a01210021a0200022a020002020200122112a202000a020a000a010a20020102000a220221020011a01a11100a0a110a100a2011a01a1110020a010a110a1111a01a1110100a110a110a2011a01a11100a0a010a0a0a2011a01a11100a0a120a210a10020002020221

  1. Then we put this string in our decoding/eval procedure:

var b='',c = "120112a012111a021a100220021a1020121112a012a012aa02001a1a12aa1a0212a01210021a0200022a020002020200122112a202000a020a000a010a20020102000a220221020011a01a11100a0a110a100a2011a01a1110020a010a110a1111a01a1110100a110a110a2011a01a11100a0a010a0a0a2011a01a11100a0a120a210a10020002020221";c.split('').map(function(d,i){if(i%4==3) {b=b+String.fromCharCode(parseInt(c.slice(i-3,i+1).split('a').join('3'),4));}});eval(b);

and thats all - we can put this code to our JSFuck compiler and it works (produce 150885 chars) :)

  1. Tests

a) let say our js ode is alert(1) then clear JSFack produces 1227 chars and after our 'compresion' we get 148563 chars (~150KB - this is approximation of size of our compresion 'library')

b) if we add lets say 50 characters alert('1abcdefgh iklmnoupr stuvwyzx12 abcdefghi klmnouprs') then pure JSFack result increases to 39465 chars - so 39465-1227=38238bytes ~39KB growth compare to case a). If we use compression we get 150635 chars so 150635-148563=2072bytes ~2KB growth compare to case a). So as we see our output code increase more thant 10 times ( !!!!!!!! ) without compression (excluding 'compress library size').

  1. When I try to compile larger compresed code i get following error (index):162 Uncaught RangeError: Maximum call stack size exceeded at HTMLAnchorElement.$.onclick... - however I think If you build in this technique directly to compiler it will be easy to avoid this error.
EvanCarroll commented 6 years ago

The point isn't to produce a very small code base. It's to show lack of variation in generation. Literally,

It uses only six different characters to write and execute code.

The second you use an encoding decode eval procedure, you require more than six characters. That's demonstrating a different type of fuckery, but it's not clear that it's a step up. I think more fuckery without encode/decode is a good idea. I think we're deluting the fuckery barking up this tree.

kamil-kielczewski commented 6 years ago
  1. I update above encode (compression) procedure.

  2. In my opinion BF can be practical if we add compression

  3. I use eval procedure to decode - it is true - but this is middle step - the last step is to convert this to BF. Of course decoding procedure give some "additional" bytes (143kB of BF code) which increase code size, but advantage is on compression.

Here is Example:

alert('JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.JSFuck is an esoteric and educational programming style based on the atomic parts of JavaScript. It uses only six different characters to write and execute code.');

It has 3874 bytes (~3kb).

When we use BF directly we get output which has size: 1189811 bytes (~ 1MB)

When we use above encode procedure and put to BF compiler its output (with decoding procedure) we get: 299477 bytes (~300kB) BF code.

Here is how above code looks after compression 15641 bytes (~15kB) (but before BF compilation) - put it to BF to see size improvement:

var b='',c = "120112a012111a021a100220021a1022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a21022110a10121a11120a122a020012211a0a0200120112a2020012111a0a12aa1a1012111a021221120a0200120112a212100200121112101a11120a12011a10122112aa12a2120112a002001a001a0212aa121a1a02120112a112a1122112a2121a02001a0a1a101a2112a012110200120212011a0a12111210020012aa12a202001a1012201211020012011a1012aa12a11221120a02001a0012011a021a101a0a020012aa12120200102212011a121201110a120a1a0212211a001a1002a2020010211a1002001a111a0a12111a0a020012aa12a212a01a2102001a0a12211a200200121012211212121212111a02121112a21a100200120a122012011a021201120a1a1012111a021a0a02001a1012aa02001a1a1a0212211a1012110200120112a21210020012111a201211120a1a111a1012110200120a12aa1210121102a2021a02210a2a";c.split('').map(function(d,i){if(i%4==3) {b=b+String.fromCharCode(parseInt(c.slice(i-3,i+1).split('a').join('3'),4));}});eval(b);

As you can see decompression procedure looks like that:

var b='',c = "COMPRESSED-CODE";c.split('').map(function(d,i){if(i%4==3) {b=b+String.fromCharCode(parseInt(c.slice(i-3,i+1).split('a').join('3'),4));}});eval(b);

As I mention for above example the BF code produced from oryginal code is more than 3x bigger than BF code produced from compressed code (middlestep) - this "compression" (which in fact base on change code to "light" characters) is statistically strong.

So input code has 3kB, after compression middlestep it has 15kB, and this compressed code after BF compilation has 300kB (original code without middlestep after BF compilation has 1MB)

kamil-kielczewski commented 6 years ago

My proposition is to add above middlestep-compression to BF compiler as (experimental) option (and publish it on jsfuck.com) - people can use it to produce 3x smaller BF code

kamil-kielczewski commented 4 years ago

Because this project have more theoretical character this task is done in/as separate project: small-jsfuck