Author:
- Name: Volker Diels-Grabsch
Location: DE - Federal Republic of Germany (Germany)
Award: Best one liner
To build:
make all
To use:
./prog n e e d s a r g u m e n t s < infile > outfile.Z
Try:
./try.sh
Judges’ remarks:
Some of our wishes are granted after quite a few years, and some previous IOCCC winners turn out prescient by a decade.
A fun challenge
Explain the purpose of the constant 9018655 in prog.c.
The above fun challenge is still open. See the “Fun challenge Info” section for details.
Author’s remarks:
Description
This one-liner is an implementation of the following Judges’ remark on 2019/diels-grabsch1:
can you compress it down to a one-liner, still producing files in the UNIX compress format, albeit sacrificing the compression ratio?
Challenge accepted! This one-liner does exactly that … if you ask nicely.
Usage
cc -ansi -w -o prog prog.c
./prog p l e a s e c o m p r e s s < remarks.md > remarks.md.Z
wc -c remarks.md
wc -c remarks.md.Z
Output:
2638 remarks.md
1999 remarks.md.Z
Note about 9-bit mode
This tool produces compressed files with a maximum code word size
of 9 bits. Due to a
bug in ncompress
that was only fixed after the 5.0 release, you should not use that
widespread version of ncompress, but instead compile the latest
main branch of ncompress to verify the compressed data:
git clone -b main https://github.com/vapier/ncompress
cd ncompress
make
cd ..
./ncompress/compress -dc < remarks.md.Z | diff -s - remarks.md
Output:
Files - and remarks.md are identical
Pure IOCCC verification
Alternatively, you can use
2015/mills2 which provided a
correct 9-bit mode implementation right from the start. This is
remarkable as the unmodified 2015/mills2 only supports 16-bit mode,
but can be turned into 9-bit mode by changing a single constant from
16 to 9 in the code:
curl -Lso mills2.c https://github.com/ioccc-src/winner/raw/refs/heads/master/2015/mills2/prog.c
sed s/16/9/ < mills2.c > mills2-9bit.c
cc -ansi -w mills2-9bit.c -o mills2-9bit
./mills2-9bit remarks.md.Z | diff -s - remarks.md
Output:
Files - and remarks.md are identical
Compression ratio
You might be suprised to learn that this one-liner beats ncompress
on any random input!
head -c 10000 /dev/urandom | ./prog p l e a s e c o m p r e s s | wc -c
11214
head -c 10000 /dev/urandom | compress | wc -c
14498
Joking aside, using just 9-bit codes means that this one-liner of
course has a worse compression ratio than ncompress:
cat remarks.md | ./prog p l e a s e c o m p r e s s | wc -c
1999
cat remarks.md | compress | wc -c
1660
But on the other hand, as seen above, using just 9-bit codes also
makes it less worse than ncompress on hopelessly incompressible
input.
Inventory for 2025/diels-grabsch
Primary files
- prog.c - entry source code
- Makefile - entry Makefile
- prog.orig.c - original source code
- try.sh - script to try entry
Secondary files
- 2025_diels-grabsch.tar.bz2 - download entry tarball
- README.md - markdown source for this web page
- .entry.json - entry summary and manifest in JSON
- .gitignore - list of files that should not be committed under git
- .path - directory path from top level directory
- .date-range - copyright date range for this directory
- index.html - this web page
Jump to: top
