IOCCC image by Matt Zucker

The International Obfuscated C Code Contest

2011/fredriksson - Most useful

← eastman ↑ 2011 ↑ goren → C code Makefile Inventory





Author:

To build:

make

Bugs and (Mis)features:

The current status of this entry is:

STATUS: INABIAF - please **DO NOT** fix

For more detailed information see 2011 fredriksson bugs.

To use:

./fredriksson [-icvtnk#] regexp < file

Try:

./try.sh

NOTE: you need to be allowed to change your stack size or else the last command in the script would likely cause the program to dump core, which is why the script checks the exit code of ulimit first.

Judges’ remarks:

The author of this entry was making sure that it does not win the “Best Short Program” award. On the outside, the program behaves as an approximate grep. On the inside, it is a Burrows-Wheeler transform decompressor that produces the source code of the actual obfuscated approximate grep program and calls it. As an exercise, try writing the compressor.

Author’s remarks:

Approximate grep

Implements a variant of grep.

Usage

To search regexp from file, do:

./fredriksson [-icvtnk#] regexp < file

Pipes might not work, see the section Limitations. The options -i, -c, -v and -n are the classic ones:

This version of grep recognizes two more options, not present in normal grep implementations:

Of course, one could construct a standard regexp that matches the same patterns, but the problem is that such a regexp grows exponentially in size when the number of allowed edit operations is increased.

This version does not recognize all regular expressions, but the following are allowed:

The special characters must be escaped, if they are to be taken literally (e.g. \. to match period). You might want to protect these with ', i.e. use 'foo\[bar' instead of foo\[bar. If you want to use the literal - in bracket expression, protect that too (\-), otherwise this is not needed. Note that the syntax differs from standard (?) grep a bit, i.e. in plain grep you can use ] and - in bracket expressions by putting ] as the first character, and putting - last.

Other uses

./fredriksson -k3 cat < file
./fredriksson -nk3 cat < file

Other features

Limitations and remarks

Obfuscations (a.k.a. spoilers…)

Inventory for 2011/fredriksson

Jump to top

Primary files

Secondary files