IOCCC image by Matt Zucker

The International Obfuscated C Code Contest

2018/ciura - Most likely to be awarded

Author:

To build:

    make

There is an alternate version that lacks a useful bug fix. See Alternate code and the author’s remarks, remarks section, below for more details.

To use:

    ./prog < text

Try:

    ./try.sh

Alternate code:

An alternate version of this entry, prog.alt.c, is provided. As mentioned in the author’s remarks, the alternate version lacks a useful bug fix.

Alternate build:

    make alt

Alternate use:

Use prog.alt as you would prog above.

Alternate try:

    ./try.alt.sh

Do you spot the fix by running both try.sh and try.alt.sh?

Judges’ remarks:

This text was processed by prog. You may get confused. We’re not really sure: prog.c wasn’t commented. Who has been thoroughly puzzled by prog? Also how obfuscated is prog? Having been written in C, how large of a vocabulary has it?

Author’s remarks:

The Program:

“The Elements of Style” by Prof. William Strunk, Jr. and E. B. White is well known for its dislike of the passive voice. Direct, vigorous, active constructions were instead recommended by the authors. The development of this program has been driven by this tenet.

Only passive sentences from the standard input are output. The offending part(s) of each sentence will be highlighted. Several kinds of passive constructions are recognized:

Sentences are never broken by periods that follow abbreviations and initials. Both regular and irregular past participles are properly dealt with. Note that some words are red herrings: even though their ending is -ed, they are not past participles.

The Big String:

Here is the purpose of every byte inside the c[] string:

The State Machines:

I heard you don’t like state machines so I put a state machine in your state machine so you can reject this entry while you reject this entry.

Both types of state machines in the program are Mealy machines: we can think of their transitions as triples (transition_label, next_state, output).

Type A:

A state of type A state machine consists of eight transitions whose representations occupy consecutive bytes. The byte c[3 + 8*state + transition_label] contains (unsigned char)(30 + 5*next_state + output).

The transition_label is either one of character classes:

or one of word classes:

The output is either one of:

or one of

Type A state machines run continuously. Their state is kept in k[2] and k[3].

Below are sample steps of scanning a sequence of characters with classes uppercase, lowercase, period, space, and uppercase.

And here are sample steps of scanning tokens with classes to_be, adverb, past_participle.

Type B:

Type B state machines are built by a variant of the algorithm described in the paper How to squeeze a lexicon. Their states are represented as interlaced sparse arrays of transitions.

The transition_label is one of:

The output is either one of word classes:

or

The byte c[186 + (state + transition_label)] = (unsigned char)(2 + transition_label + 28 * output).

The byte c[836 + 2*(state + transition_label)] =

The byte c[837 + 2*(state + transition_label)] =

The byte c[2136 + (state + transition_label)] = (unsigned char)(32 + next_state % 94).

A type B state machine starts in a given state with output set to ignore. It scans a word backwards, converting character by character to transition_label. When it meets word_start, it returns, leaving the most recently stored output in v.

It also returns when c[186 + (state + transition_label)] != (unsigned char)(2 + transition_label + 28 * output), i.e. when the transition_label in the byte mismatches the transition_label used to compute the index. Otherwise, if the output in this byte differs from ignore, the state machine stores it in v. Regardless of the value of the output, it also assigns next_state to state and proceeds to scan the previous character. The state machine that determines the word class is set up so that it never returns ignore.

Below are sample steps of scanning the word “chiefly”.

And here are sample steps of scanning the string “i.e.”:

Remarks:

The judges found a bug in the handling of contractions: prog.alt.c outputs “foo wasn’[t bazzed]”. I fixed the bug in prog.c, making it output “foo [wasn’t bazzed]” instead, and took the liberty to merge one statement into a for loop inside its main() function.

The program uses a 9,437,187-byte buffer so it probably will not run on 16-bit and smaller machines without changing the size of array C[] and the expression 9<<20 inside the call to read(2).

I have tested it on:

For a clean compile under C89 and C90, add -Woverlength-strings to CSILENCE.

Inventory for 2018/ciura

Primary files

Secondary files


Jump to: top