Challenge:
Your challenge (should you choose to accept it) is to compress and decompress the 5MB "Complete Works of William Shakespeare" as found here: http://www.gutenberg.org/cache/epub/100/pg100.txt
(MD5: a810f89e9f8e213aebd06b9f8c5157d8
)
Rules:
- You must take input via
STDIN
and output viaSTDOUT
... - ...and you must provide an identical decompressed result to the input.
- (This is to say you must be able to
cat inpt.txt | ./cmprss | ./dcmpress | md5
and get the same MD5 as above.) - (Anything via
STDERR
is to be discarded.)
- (This is to say you must be able to
You must use less than 2048 characters for your total source code.- (This is not code-golf. You are not being scored based on length of source-code. This
iswas just a rule to keep things finite.) (Take the concatenated length of all source code if you have split it out.)
- (This is not code-golf. You are not being scored based on length of source-code. This
- You must be able to (theoretically) process similar plain-text inputs too.
- (e.g. hard coding a mechanism which is only capable of outputting the provided Shakespeare input is unacceptable.)
- (The compressed size of other documents is irrelevant - provided the decompressed result is identical to the alternative input.)
- You may use any choice of language(s).
- (e.g. feel free to compress using
awk
and decompress usingjava
)
- (e.g. feel free to compress using
- You may write two separate programs or combine them with some form of "switch" as you please.
- (There must be clear demonstrations of how to invoke both the compression and decompression modes)
- You may not use any external commands (e.g. through
exec()
).- (If you are using a shell language - sorry. You'll have to make do with built-ins. You're welcome to post an "unacceptable" answer for the sake of sharing and enjoyment - but it won't be judged!)
- You may not use any built-in or library provided functions who's stated purpose is to compress data (like
gz
, etc)- (Altering the encoding is not considered compression in this context. Some discretion may be applied here. Feel free to argue the acceptableness of your solution in the submission.)
- Please try to have fun if choose to participate!
All good competitions have an objective definition of winning; ergo:
- Provided all rules are adhered to, the smallest compressed output (in
STDOUT
bytes) wins.- (Report your output please via
./cmprss | wc -c
)
- (Report your output please via
- In the event of a draw (identical output sizes), the most community up-voted wins.
- In the event of a second draw (identical community up-votes), I'll pick a winner based on completely subjective examination of elegance and pure genius.
;-)
How to submit:
Please format your entry using this template:
<language>, <compressed_size>
-----------------------------
<description> (Detail is encouraged!)
<CODE...
...>
<run instructions>
I would encourage readers and submitters to converse through comments - I believe there's real opportunity for people to learn and become better programmers through codegolf.stack.
Winning:
I'm away on vacation soon: I may (or may not) be monitoring submissions over the next few weeks and will draw the challenge to a close on the 19th September. I hope this offers a good opportunity for people to think and submit - and for a positive sharing of techniques and ideas.
If you've learned something new from participating (as a reader or submitter) please leave a comment of encouragement.
code-challenge
. \$\endgroup\$