The following challenge is basically a simpler version of the one proposed by Dennis (Lossy ASCII art compression). I found the idea super interesting but a bit too convulted, and seeing as it didn't seem to be getting much attention I decided to modify it a little bit.
You'll be downloading 5 ASCII art text files, each of them composed only of the following characters:
@#+';:,.`
Each char represents a different brightness level (1-10 from @ to the whitespace).
Given a quality ratio q, which varies from 0.5 to 0.9 in 0.1 increments, your job is to output a compressed version of each ASCII file, while making those files able to decompress themselves.
That is to say, ImageX.txt is compressed by Program.py into CompImageX-xx.cpp (xx being the quality of the compressed image). Once CompImageX-xx.c is executed, a final decompressed image ImageX-xx.txt is created.
The .py and .c extensions are just an example, you can write the compressor and compressed images in any language that you want (doesn't have to be the same language for both, but you can't use different languages for different images).
The quality changes the image output in a relatively simple way. We'll call the array of usable chars Arr. Each char of ImageX becomes Arr[RoundHalfDown((Arr.Index(char)*q))], with the exception of the whitespace which remains the same no matter the quality.
RoundHalfDown(0.6) = RoundHalfDown(0.7) = RoundHalfDown(1) = 1
RoundHalfDown(0.5) = RoundHalfDown(0.4) = RoundHalfDown(0) = 0
For a short example:
'#;@
at q=0.5 would become
#@+@`
You have to implement your own compressor, can't use any libraries that handle it for you.
You can view the images here and download them from here.
Your score is the square root of the size of your compressor, multiplied by the sum of the size of all the compressed files --> sqrt(c)*sum(f). Lowest score wins.
USER LANGUAGE SCORE
Dennis CJam 1046877
Arr[RoundHalfDown((Arr.Index(char)*q))]
is hideous. Withq=0.4
you're mapping1 2 3 4 5 6 7 8 9 10
to1 2 2 3 3 3 4 4 5 10
. You would actually get a better quality reduction by mapping them to1 1 4 4 4 7 7 7 10 10
, which uses fewer output values but spaces them evenly across the brightness. Unless you're assuming a crazy gamma value in the input images? \$\endgroup\$