Add preview of 1984-2019

The 2020 winners are hinted it, but the source code is not there,
nor are the hints. Someone could look into the HTML and
see what was commented out, but that is not a problem because
WHO won is known and the name of their AWARD is known already.
Moreover a number of the winners have talked about what their
entirs do, so the commented out spoiler text is not a bit problem.

One will find HTML commented out with:

    <!-- XXX remove when 2020 is ready
    2020 links here
    XXX remove when 2020 is ready -->

The "XXX remove when 2020 is ready" string is found at the
start and end comment blocks.  Again, soneone could read
what was commented out, but that is OK since most of that
information is known or can be known.  The following files
have such HTML comment blocks in them.

    ./winners.html
    ./years-spoiler.html
    ./years.html

In addition, ./all/summary.txt was modified to not
include the 2020 entries for the momemt.

The 2020 winner code AND write-ups are NOT part of this set.

p.s. The all/all.tar.bz2 does not contain the 2020 source code (yet?).
This commit is contained in:
Landon Curt Noll committed 2020-12-30 16:57:03 -08:00
1 parent 28efc67f5d
commit c0663537cb
1683 files changed
+220064

No files matched your search

+288
View File
@@ -0,0 +1,288 @@
#!/usr/bin/env make
#
# 2018 makefile
#
# This work by Landon Curt Noll, Simon Cooper, and Leonid A. Broukhis
# is licensed under:
#
# Creative Commons Attribution-ShareAlike 3.0 Unported License.
#
# See: http://creativecommons.org/licenses/by-sa/3.0/
################
# tool locations
################
#
SHELL= /bin/bash
CP= cp
CPP= cpp
GUNZIP= gunzip
BUNZIP2= bunzip2
GZIP_PROG= gzip
BZIP2= bzip2
CURL= curl
DD= dd
LD= ld
MAKE= make
RM= rm
SED= sed
TAR= tar
TRUE= true
MKDIR= mkdir
MV= mv
TR= tr
GREP= grep
SORT= sort
UNIQ= uniq
STRIP= strip
# Set X11_LIBDIR to the directory where the X11 library resides
#
#X11_LIBDIR= /usr/X11R6/lib
#X11_LIBDIR= /usr/X11/lib
X11_LIBDIR= /opt/X11/lib
# Set X11_INCLUDEDIR to the directory where the X11 include files reside
#
#X11_INCDIR= /usr/X11R6/include
#X11_INCDIR= /usr/X11/include
X11_INCDIR= /opt/X11/include
# Compiler warnings
#
#CWARN=
#CWARN= -Wall
#CWARN= -Wall -Wextra
CWARN= -Wall -Wextra -pedantic ${CSILENCE}
#CWARN= -Wall -Wextra -Weverything
#CWARN= -Wall -Wextra -Weverything -pedantic
#CWARN= -Wall -Wextra -Weverything -pedantic ${CSILENCE}
# Silence warnings that ${CWARN} would normally complain about
#
CSILENCE= -Wno-unused-value -Wno-shift-op-parentheses -Wno-sign-conversion \
-Wno-comma -Wno-missing-prototypes -Wno-unused-result -Wno-parentheses
#CSILENCE= -Wno-implicit-int
# compiler standard
#
#CSTD=
#CSTD= -ansi
CSTD= -std=c11
# compiler bit architecture
#
# Some entries require 32-bitness:
# ARCH= -m32
#
# Some entries require 64-bitness:
# ARCH= -m64
#
# By default we assume nothing:
#
ARCH=
# defines that are needed to compile
#
CDEFINE=
#CDEFINE= -DIOCCC=25
# include files that are needed to compile
#
CINCLUDE=
#CINCLUDE= -include stdlib.h
#CINCLUDE= -include stdio.h
#CINCLUDE= -include stdlib.h -include stdio.h
#CINCLUDE= -I ${X11_INCDIR}
# optimization
#
# Most compiles will safely use -O2. Some can use only -O1 or -O.
# A few compilers have broken optimizers or this entry make break
# under those buggy optimizers and thus you may not want anything.
# Reasonable compilers will allow for -O3.
#
#OPT=
#OPT= -O
#OPT= -O1
#OPT= -O2
OPT= -O3
# default flags for ANSI C compilation
#
CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT}
# Libraries needed to build
#
LIBS=
#LIBS= -L ${X11_LIBDIR}
# ANSI compiler
#
# Set CC to the name of your ANSI compiler.
#
# Some entries seem to need gcc. If you have gcc, set
# both CC and MAY_NEED_GCC to gcc.
#
# If you do not have gcc, set CC to the name of your ANSI compiler, and
# set MAY_NEED_GCC to either ${CC} (and hope for the best) or to just :
# to disable such programs.
#
CC= cc
#CC=clang
MAY_NEED_GCC= gcc
##############################
# Special flags for this entry
##############################
#
OBJ= prog.o
DATA=
TARGET= prog
#
ALT_OBJ=
ALT_TARGET= prog.orig
#################
# build the entry
#################
#
all: ${TARGET} ${DATA}
@${TRUE}
prog: prog.c
${CC} ${CFLAGS} $< -o $@ ${LIBS}
prog.orig: prog.orig.c
${CC} ${CFLAGS} $< -o $@ ${LIBS}
# alternative executable
#
alt: ${ALT_TARGET}
@${TRUE}
# data files
#
data: ${DATA}
@${TRUE}
###############
# utility rules
###############
#
everything: all alt
clean:
${RM} -f ${OBJ} ${ALT_OBJ}
clobber: clean
${RM} -f ${TARGET} ${ALT_TARGET}
@-if [ -e sandwich ]; then \
${RM} -f sandwich; \
echo 'ate sandwich'; \
fi
nuke: clobber
@${TRUE}
dist_clean: nuke
@${TRUE}
install:
@echo "Surely you are performing, Dr. May!"
@${TRUE}
# backwards compatibility
#
build: all
@${TRUE}
##################
# 133t hacker rulz
##################
#
love:
@echo 'not war?'
@${TRUE}
haste:
$(MAKE) waste
@${TRUE}
waste:
@echo 'haste'
@${TRUE}
make:
@echo 'Attend a maker faire'
@${TRUE}
easter_egg:
@echo you expected to often mis-understand this $${RANDOM} magic
@echo chongo '<was here>' "/\\oo/\\"
@echo Eggy
fabricate fashion form frame manufacture produce: make
@${TRUE}
sandwich:
@if [ `id -u` -eq 0 ]; then \
echo 'Okay.'; \
echo $${RANDOM}`date +%s`$${RANDOM} > $@; \
else \
echo 'What? Make it yourself.'; \
exit 1; \
fi
# Understand the history of the Homebrew Computer Club
# as well as the West Coast Computer Faire and
# you might be confused different. :-)
#
supernova: nuke
@-if [ -r .code_anal ]; then \
${RM} -f .code_anal_v6; \
else \
echo "planet deniers, like some members of the IAU, are so cute when they try to defend their logic"; \
fi
@echo A $@ helps ${MAKE} the elements that help form planets
@${TRUE}
deep_magic:
@-if [ -r .code_anal ]; then \
ccode_analysis --deep_magic 3a3fabb90892eeb2f610ae0f74a35a970060665a063ab702bd686c17c4ae07f6 --FNV1a_hash_256_bit "prog"; \
else \
echo "Wrong! Do it again!"; \
sleep 2; \
echo "Wrong! Do it again!"; \
sleep 2; \
echo "Wrong! Do it again!"; \
fi
@${TRUE}
magic: deep_magic
@-if [ -r .code_anal ]; then \
ccode_analysis --mode 216091 --level 216193 --FNV1a_hash_256_bit "prog"; \
else \
echo "If you don't eat yer meat, you can't have any pudding!"; \
echo "How can you have any pudding if you don't eat yer meat?!"; \
fi
@${TRUE}
# The IOCCC resident astronomer states
#
charon: supernova
@echo $@ is a dwarf planet
@echo dwarf is a type of planet
@echo $@ is a planet
pluto: supernova
${MAKE} charon
@echo $@ is a dwarf planet
@echo dwarf is a type of planet
@echo $@ is a planet
@echo get used to having lots of planets because a $< can ${MAKE} a lot of them
+316
View File
@@ -0,0 +1,316 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<link rel="stylesheet"
type="text/css"
href="../hint.css">
<title>Most likely to be awarded</title>
</head>
<body>
<h1>Most likely to be awarded</h1>
<p>Marcin Ciura <a href="&#x6d;&#97;&#x69;&#108;&#x74;&#111;&#58;&#x6d;&#x63;&#105;&#x75;&#114;&#97;&#64;&#103;&#109;&#97;&#105;&#x6c;&#x2e;&#x63;&#x6f;&#109;">&#x6d;&#99;&#x69;&#117;&#x72;&#97;&#64;&#103;&#x6d;&#97;&#x69;&#x6c;&#46;&#x63;&#x6f;&#x6d;</a><br>
Twitter: @mciura</p>
<h2>Judges' comments:</h2>
<h3>To use:</h3>
<pre><code>make
./prog &lt; text
</code></pre>
<h3>Try:</h3>
<pre><code>./prog &lt; Makefile
./prog &lt; hint.text
</code></pre>
<h3>Selected Judges Remarks:</h3>
<p>This text was processed by prog. You may get confused.
We&rsquo;re not really sure: prog.c wasn&rsquo;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?</p>
<h2>Author&rsquo;s comments:</h2>
<h1>The Program</h1>
<p>&ldquo;The Elements of Style&rdquo; 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.</p>
<p>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:</p>
<ul>
<li>Plain passive voice.
Foo was bazzed by bar.</li>
<li>Passive voice with &ldquo;get&rdquo;.
I got almost quuxed.</li>
<li>Contractions.
I&rsquo;m not really quuxed: foo wasn&rsquo;t bazzed.</li>
<li>Questions.
Who has been quuxed? Was foo indeed bazzed? How was it bazzed?</li>
<li>Clause-initial inversion.
Also bazzed is bar.</li>
</ul>
<p>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.</p>
<h1>The Big String</h1>
<p>Here is the purpose of every byte inside the <strong><code>c[]</code></strong> string:</p>
<ul>
<li>0-9: highlighting passive constructions in the output;</li>
<li>10-50: classifying characters - called by <strong><code>V(4)</code></strong>;</li>
<li>52: outputting the newline character;</li>
<li>51-187: tokenizing text and detecting passive constructions - two
type A state machines, called by <strong><code>V(2)</code></strong> and <strong><code>V(3)</code></strong>;</li>
<li>186-2786: determining word categories (past participles, present
simple and past simple forms of &ldquo;to be&rdquo;, other forms of &ldquo;to be&rdquo;,
adverbs, wh-words, and other words) and recognizing abbreviations -
two type B state machines, called by <strong><code>V(808)</code></strong> and <strong><code>V(205)</code></strong>.</li>
</ul>
<h1>The State Machines</h1>
<p>I heard you don&rsquo;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.</p>
<p>Both types of state machines in the program are Mealy machines: we can
think of their transitions as triples (<strong><code>transition_label</code></strong>,
<strong><code>next_state</code></strong>, <strong><code>output</code></strong>).</p>
<h2>Type A</h2>
<p>A state of type A state machine consists of eight transitions whose
representations occupy consecutive bytes. The byte
<strong><code>c[3 + 8*state + transition_label]</code></strong> contains
<strong><code>(unsigned char)(30 + 5*next_state + output)</code></strong>.</p>
<p>The <code>transition_label</code> is either one of character classes:</p>
<ul>
<li><strong><code>nil</code></strong> = 0,</li>
<li><strong><code>space</code></strong> = 1,</li>
<li><strong><code>new_line</code></strong> = 2,</li>
<li><strong><code>uppercase</code></strong> = 3,</li>
<li><strong><code>lowercase</code></strong> = 4,</li>
<li><strong><code>period</code></strong> = 5,</li>
<li><strong><code>bang_question</code></strong> = 6,</li>
<li><strong><code>punctuation</code></strong> = 7,</li>
</ul>
<p>or one of word classes:</p>
<ul>
<li><strong><code>adverb</code></strong> = 0,</li>
<li><strong><code>other</code></strong> = 2,</li>
<li><strong><code>past_participle</code></strong> = 3,</li>
<li><strong><code>to_be</code></strong> = 4,</li>
<li><strong><code>are_were</code></strong> = 5,</li>
<li><strong><code>wh_word</code></strong> = 6 (cf. the <strong><code>output</code></strong> of type B state machines).</li>
</ul>
<p>The <strong><code>output</code></strong> is either one of:</p>
<ul>
<li><strong><code>end_of_text</code></strong> = 0,</li>
<li><strong><code>sentence_start</code></strong> = 1,</li>
<li><strong><code>sentence_end</code></strong> = 2,</li>
<li><strong><code>token_end</code></strong> = 3,</li>
<li><strong><code>ignore</code></strong> = 4,</li>
</ul>
<p>or one of</p>
<ul>
<li><strong><code>passive_construction_start</code></strong> = 1,</li>
<li><strong><code>ignore</code></strong> = 2,</li>
<li><strong><code>passive_construction_end</code></strong> = 3.</li>
</ul>
<p>Type A state machines run continuously. Their state is kept in
<strong><code>k[2]</code></strong> and <strong><code>k[3]</code></strong>.</p>
<p>Below are sample steps of scanning a sequence of characters with
classes <strong><code>uppercase</code></strong>, <strong><code>lowercase</code></strong>, <strong><code>period</code></strong>, <strong><code>space</code></strong>,
and <strong><code>uppercase</code></strong>.</p>
<ul>
<li><strong><code>state</code></strong> = 7, <strong><code>transition_label</code></strong> = 3 (<strong><code>uppercase</code></strong>), <strong><code>output</code></strong> = <strong><code>sentence_start</code></strong></li>
<li><strong><code>state</code></strong> = 14, <strong><code>transition_label</code></strong> = 4 (<strong><code>lowercase</code></strong>), <strong><code>output</code></strong> = <strong><code>ignore</code></strong></li>
<li><strong><code>state</code></strong> = 15, <strong><code>transition_label</code></strong> = 5 (<strong><code>period</code></strong>), <strong><code>output</code></strong> = <strong><code>token_end</code></strong></li>
<li><strong><code>state</code></strong> = 13, <strong><code>transition_label</code></strong> = 1 (<strong><code>space</code></strong>), <strong><code>output</code></strong> = <strong><code>token_end</code></strong></li>
<li><strong><code>state</code></strong> = 18, <strong><code>transition_label</code></strong> = 3 (<strong><code>uppercase</code></strong>), <strong><code>output</code></strong> = <strong><code>sentence_end</code></strong></li>
</ul>
<p>And here are sample steps of scanning tokens with classes <strong><code>to_be</code></strong>,
<strong><code>adverb</code></strong>, <strong><code>past_participle</code></strong>.</p>
<ul>
<li><strong><code>state</code></strong> = 8, <strong><code>transition_label</code></strong> = 4 (<strong><code>to_be</code></strong>), <strong><code>output</code></strong> = <strong><code>passive_construction_start</code></strong></li>
<li><strong><code>state</code></strong> = 22, <strong><code>transition_label</code></strong> = 0 (<strong><code>adverb</code></strong>), <strong><code>output</code></strong> = <strong><code>ignore</code></strong></li>
<li><strong><code>state</code></strong> = 22, <strong><code>transition_label</code></strong> = 3 (<strong><code>past_participle</code></strong>), <strong><code>output</code></strong> = <strong><code>passive_construction_end</code></strong></li>
</ul>
<h2>Type B</h2>
<p>Type B state machines are built by a variant of the algorithm described
in the paper
<em><a href="http://sun.aei.polsl.pl/~mciura/publikacje/lexicon.pdf">How to squeeze a lexicon</a></em>.
Their states are represented as interlaced sparse arrays of transitions.</p>
<p>The <strong><code>transition_label</code></strong> is one of:</p>
<ul>
<li><strong><code>word_start</code></strong> = 0,</li>
<li><strong><code>period_or_apostrophe</code></strong> = 1,</li>
<li><strong><code>a_z_letter</code></strong> = 2..27.</li>
</ul>
<p>The <code>output</code> is either one of word classes:</p>
<ul>
<li><strong><code>adverb</code></strong> = 0,</li>
<li><strong><code>ignore</code></strong> = 1,</li>
<li><strong><code>other</code></strong> = 2,</li>
<li><strong><code>past_participle</code></strong> = 3,</li>
<li><strong><code>to_be</code></strong> = 4,</li>
<li><strong><code>are_were</code></strong> = 5,</li>
<li><strong><code>wh_word</code></strong> = 6,</li>
</ul>
<p>or</p>
<ul>
<li><strong><code>ignore</code></strong> = 1,</li>
<li><strong><code>abbreviation</code></strong> = 2.</li>
</ul>
<p>The byte <strong><code>c[186 + (state + transition_label)] = (unsigned char)(2 + transition_label + 28 * output)</code></strong>.</p>
<p>The byte <strong><code>c[836 + 2*(state + transition_label)] =</code></strong></p>
<ul>
<li><strong><code>' '</code></strong> when <strong><code>next_state / 376 == 0</code></strong>,</li>
<li><strong><code>';'</code></strong> when <strong><code>next_state / 376 == 1</code></strong>.</li>
</ul>
<p>The byte <strong><code>c[837 + 2*(state + transition_label)] =</code></strong></p>
<ul>
<li><strong><code>' '</code></strong> when <strong><code>next_state / 94 % 4 == 0</code></strong>,</li>
<li><strong><code>';'</code></strong> when <strong><code>next_state / 94 % 4 == 1</code></strong>,</li>
<li><strong><code>'{'</code></strong> when <strong><code>next_state / 94 % 4 == 2</code></strong>,</li>
<li><strong><code>'}'</code></strong> when <strong><code>next_state / 94 % 4 == 3</code></strong>.</li>
</ul>
<p>The byte <strong><code>c[2136 + (state + transition_label)] = (unsigned char)(32 + next_state % 94)</code></strong>.</p>
<p>A type B state machine starts in a given <strong><code>state</code></strong> with <strong><code>output</code></strong>
set to <strong><code>ignore</code></strong>. It scans a word backwards, converting character by
character to <strong><code>transition_label</code></strong>. When it meets <strong><code>word_start</code></strong>, it
returns, leaving the most recently stored <strong><code>output</code></strong> in <strong><code>v</code></strong>.
It also returns when
<strong><code>c[186 + (state + transition_label)] != (unsigned char)(2 + transition_label + 28 * output)</code></strong>,
i.e. when the <strong><code>transition_label</code></strong> in the byte mismatches the
<strong><code>transition_label</code></strong> used to compute the index. Otherwise, if the
<strong><code>output</code></strong> in this byte differs from <strong><code>ignore</code></strong>, the state machine
stores it in <strong><code>v</code></strong>. Regardless of the value of the <strong><code>output</code></strong>,
it also assigns <strong><code>next_state</code></strong> to <strong><code>state</code></strong> and proceeds to scan
the previous character. The state machine that determines the word
class is set up so that it never returns <strong><code>ignore</code></strong>.</p>
<p>Below are sample steps of scanning the word &ldquo;chiefly&rdquo;.</p>
<ul>
<li><strong><code>state</code></strong> = 623, <strong><code>transition_label</code></strong> = 26 (&lsquo;y&rsquo;), <strong><code>output</code></strong> = <strong><code>other</code></strong></li>
<li><strong><code>state</code></strong> = 602, <strong><code>transition_label</code></strong> = 13 (&lsquo;l&rsquo;), <strong><code>output</code></strong> = <strong><code>adverb</code></strong></li>
<li><strong><code>state</code></strong> = 594, <strong><code>transition_label</code></strong> = 7 (&lsquo;f&rsquo;), <strong><code>output</code></strong> = <strong><code>other</code></strong></li>
<li><strong><code>state</code></strong> = 549, <strong><code>transition_label</code></strong> = 6 (&lsquo;e&rsquo;), <strong><code>output</code></strong> = <strong><code>ignore</code></strong></li>
<li><strong><code>state</code></strong> = 543, <strong><code>transition_label</code></strong> = 10 (&lsquo;i&rsquo;), <strong><code>output</code></strong> = <strong><code>adverb</code></strong></li>
<li><strong><code>state</code></strong> = 0, <strong><code>transition_label</code></strong> = 9 (&lsquo;h&rsquo;) mismatches the value stored
in the byte. Return <strong><code>adverb</code></strong>.</li>
</ul>
<p>And here are sample steps of scanning the string &ldquo;i.e.&rdquo;:</p>
<ul>
<li><strong><code>state</code></strong> = 19, <strong><code>transition_label</code></strong> = 1 (&lsquo;.&rsquo;), <strong><code>output</code></strong> = <strong><code>ignore</code></strong></li>
<li><strong><code>state</code></strong> = 24, <strong><code>transition_label</code></strong> = 6 (&lsquo;e&rsquo;), <strong><code>output</code></strong> = <strong><code>ignore</code></strong></li>
<li><strong><code>state</code></strong> = 3, <strong><code>transition_label</code></strong> = 1 (&lsquo;.&rsquo;), <strong><code>output</code></strong> = <strong><code>ignore</code></strong></li>
<li><strong><code>state</code></strong> = 2, <strong><code>transition_label</code></strong> = 10 (&lsquo;i&rsquo;), <strong><code>output</code></strong> = <strong><code>ignore</code></strong></li>
<li><strong><code>state</code></strong> = 1, <strong><code>transition_label</code></strong> = 0 (&lsquo;\0&rsquo;), <strong><code>output</code></strong> = <strong><code>abbreviation</code></strong>.
Return <strong><code>abbreviation</code></strong>.</li>
</ul>
<h1>Remarks</h1>
<p>The judges found a bug in the handling of contractions: <strong><code>prog.orig.c</code></strong>
outputs &ldquo;foo wasn'<strong>[t bazzed]</strong>&rdquo;. I fixed the bug in <strong><code>prog.c</code></strong>, making
it output &ldquo;foo <strong>[wasn&rsquo;t bazzed]</strong>&rdquo; instead, and took the liberty to merge
one statement into a <strong><code>for</code></strong> loop inside its <strong><code>main()</code></strong> function.</p>
<p>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 <strong><code>C[]</code></strong>
and the expression <strong><code>9&lt;&lt;20</code></strong> inside the call to <strong><code>read()</code></strong>.</p>
<p>I have tested it on:</p>
<ul>
<li>Linux with gcc version 5.4.0 20160609,</li>
<li>Linux with clang version 3.4-1ubuntu3,</li>
<li>OS/X with Apple LLVM version 6.0 (clang-600.0.57).</li>
</ul>
<p>For a clean compile under c89 and c90, add <strong><code>-Woverlength-strings</code></strong>
to <strong><code>CSILENCE</code></strong>.</p>
<hr />
<!--
(c) Copyright 1984-2018, [Leo Broukhis, Simon Cooper, Landon Curt Noll][judges] - All rights reserved
This work is licensed under a [Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].
[judges]: http://www.ioccc.org/judges.html
[cc]: http://creativecommons.org/licenses/by-sa/3.0/
-->
<TABLE><TR>
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
<TD><P>&copy; Copyright 1984-2018,
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
- All rights reserved<BR>
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
<TD>&nbsp;<!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
</TR></TABLE>
</body>
</html>
+249
View File
@@ -0,0 +1,249 @@
# Most likely to be awarded
Marcin Ciura <mciura@gmail.com>
Twitter: @mciura
## Judges' comments:
### To use:
make
./prog < text
### Try:
./prog < Makefile
./prog < hint.text
### Selected 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 comments:
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:
* Plain passive voice.
Foo was bazzed by bar.
* Passive voice with "get".
I got almost quuxed.
* Contractions.
I'm not really quuxed: foo wasn't bazzed.
* Questions.
Who has been quuxed? Was foo indeed bazzed? How was it bazzed?
* Clause-initial inversion.
Also bazzed is bar.
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:
* 0-9: highlighting passive constructions in the output;
* 10-50: classifying characters - called by **`V(4)`**;
* 52: outputting the newline character;
* 51-187: tokenizing text and detecting passive constructions - two
type A state machines, called by **`V(2)`** and **`V(3)`**;
* 186-2786: determining word categories (past participles, present
simple and past simple forms of "to be", other forms of "to be",
adverbs, wh-words, and other words) and recognizing abbreviations -
two type B state machines, called by **`V(808)`** and **`V(205)`**.
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:
* **`nil`** = 0,
* **`space`** = 1,
* **`new_line`** = 2,
* **`uppercase`** = 3,
* **`lowercase`** = 4,
* **`period`** = 5,
* **`bang_question`** = 6,
* **`punctuation`** = 7,
or one of word classes:
* **`adverb`** = 0,
* **`other`** = 2,
* **`past_participle`** = 3,
* **`to_be`** = 4,
* **`are_were`** = 5,
* **`wh_word`** = 6 (cf. the **`output`** of type B state machines).
The **`output`** is either one of:
* **`end_of_text`** = 0,
* **`sentence_start`** = 1,
* **`sentence_end`** = 2,
* **`token_end`** = 3,
* **`ignore`** = 4,
or one of
* **`passive_construction_start`** = 1,
* **`ignore`** = 2,
* **`passive_construction_end`** = 3.
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`**.
* **`state`** = 7, **`transition_label`** = 3 (**`uppercase`**), **`output`** = **`sentence_start`**
* **`state`** = 14, **`transition_label`** = 4 (**`lowercase`**), **`output`** = **`ignore`**
* **`state`** = 15, **`transition_label`** = 5 (**`period`**), **`output`** = **`token_end`**
* **`state`** = 13, **`transition_label`** = 1 (**`space`**), **`output`** = **`token_end`**
* **`state`** = 18, **`transition_label`** = 3 (**`uppercase`**), **`output`** = **`sentence_end`**
And here are sample steps of scanning tokens with classes **`to_be`**,
**`adverb`**, **`past_participle`**.
* **`state`** = 8, **`transition_label`** = 4 (**`to_be`**), **`output`** = **`passive_construction_start`**
* **`state`** = 22, **`transition_label`** = 0 (**`adverb`**), **`output`** = **`ignore`**
* **`state`** = 22, **`transition_label`** = 3 (**`past_participle`**), **`output`** = **`passive_construction_end`**
Type B
------
Type B state machines are built by a variant of the algorithm described
in the paper
*[How to squeeze a lexicon](http://sun.aei.polsl.pl/~mciura/publikacje/lexicon.pdf)*.
Their states are represented as interlaced sparse arrays of transitions.
The **`transition_label`** is one of:
* **`word_start`** = 0,
* **`period_or_apostrophe`** = 1,
* **`a_z_letter`** = 2..27.
The `output` is either one of word classes:
* **`adverb`** = 0,
* **`ignore`** = 1,
* **`other`** = 2,
* **`past_participle`** = 3,
* **`to_be`** = 4,
* **`are_were`** = 5,
* **`wh_word`** = 6,
or
* **`ignore`** = 1,
* **`abbreviation`** = 2.
The byte **`c[186 + (state + transition_label)] = (unsigned char)(2 + transition_label + 28 * output)`**.
The byte **`c[836 + 2*(state + transition_label)] =`**
* **`' '`** when **`next_state / 376 == 0`**,
* **`';'`** when **`next_state / 376 == 1`**.
The byte **`c[837 + 2*(state + transition_label)] =`**
* **`' '`** when **`next_state / 94 % 4 == 0`**,
* **`';'`** when **`next_state / 94 % 4 == 1`**,
* **`'{'`** when **`next_state / 94 % 4 == 2`**,
* **`'}'`** when **`next_state / 94 % 4 == 3`**.
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".
* **`state`** = 623, **`transition_label`** = 26 ('y'), **`output`** = **`other`**
* **`state`** = 602, **`transition_label`** = 13 ('l'), **`output`** = **`adverb`**
* **`state`** = 594, **`transition_label`** = 7 ('f'), **`output`** = **`other`**
* **`state`** = 549, **`transition_label`** = 6 ('e'), **`output`** = **`ignore`**
* **`state`** = 543, **`transition_label`** = 10 ('i'), **`output`** = **`adverb`**
* **`state`** = 0, **`transition_label`** = 9 ('h') mismatches the value stored
in the byte. Return **`adverb`**.
And here are sample steps of scanning the string "i.e.":
* **`state`** = 19, **`transition_label`** = 1 ('.'), **`output`** = **`ignore`**
* **`state`** = 24, **`transition_label`** = 6 ('e'), **`output`** = **`ignore`**
* **`state`** = 3, **`transition_label`** = 1 ('.'), **`output`** = **`ignore`**
* **`state`** = 2, **`transition_label`** = 10 ('i'), **`output`** = **`ignore`**
* **`state`** = 1, **`transition_label`** = 0 ('\0'), **`output`** = **`abbreviation`**.
Return **`abbreviation`**.
Remarks
=======
The judges found a bug in the handling of contractions: **`prog.orig.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()`**.
I have tested it on:
* Linux with gcc version 5.4.0 20160609,
* Linux with clang version 3.4-1ubuntu3,
* OS/X with Apple LLVM version 6.0 (clang-600.0.57).
For a clean compile under c89 and c90, add **`-Woverlength-strings`**
to **`CSILENCE`**.
--------------------------------------------------------------------------------
<!--
(c) Copyright 1984-2018, [Leo Broukhis, Simon Cooper, Landon Curt Noll][judges] - All rights reserved
This work is licensed under a [Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].
[judges]: http://www.ioccc.org/judges.html
[cc]: http://creativecommons.org/licenses/by-sa/3.0/
-->
+126
View File
@@ -0,0 +1,126 @@
#include<unistd.h>
#define W ),write(1,
static unsigned char c[]=
"]\33[0m\33[7m[&&'% $ # ! ########## \" # !& \n oo 6''GLB=.* eoj* 5SXINE@199999999777777775]bNNE@@5]bNNE@E5SXOO0?05SXOOD?06TYJOE@16Y%JOE@16^c%O%%%6c%%O%%%f !! k k! p !oo :;;\37;;;;;\37;($\"%$##(\37(/1$1.,,,$%&/1rs!58&30123$$-O@2=\2?(2-'VZ$3:'i/3+ O#&B2%1,: 2=' (1J!1AC) @:,+_M1H/:J I\"?.Ak'.c2G$gj!j.@O&'(P +,jk/Y1$3%56.8 Y1. .4, W +nd\\rs1( ++(-.331i\".>.-[!.^'.\00281\216\217\252\253's 6\b.$\252\2534''0(\0226 6!'# +[\34.-\"+,-\"(4123Z5_]3-+46(44ij3.jneij41$3+%16s c` 3!#6.(n _\".] R+'4.jjkf`'\\..Y.(' i1 f%nG. $=i$#$ `'3V*+.b2&.!23+5.'n9\\\2ij&1j_3k^_n/+i_ij cd-$$11j(%3&'..\n!1$.4 623$ \2$' rs6${$\"\25($3-5.3''' $2.'\b(1( -.\0253,63''6 8\241+ 6\37 $-$I(P(($\252\253cZ/2\b'i4j3$86&4 j!k-J &1N]'+,fcY-ej/$fgl8 n4!$cd (^'$4+bc-g -2($.iZn$%Yc\20 4+Z,)$.'.\0071 1.'g1\37 4-$$%1'(D=+,-./+12 4,,7\f$ 1:3'+,?.='= #.%$)K!(123&(J3:4$J4 $52#(<! ,$AK;( !+# ./'1 \17 1\252\253<=>?@ABCDEFGHIJKLMNOPQRSTU ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; { { ; ; ; { ; ; { { ; ; { { { { { ; ; ; { { { { ; { { ; { { ; { { ; ; { { { ; { { { ; ; { { { ; ; { { { { { { { { { } ; { { { ; } } { { } } { { { { { } } { } } } } ; } } } { ; } } ; } } } } } } } ; } } } } } } } } } { } ; ; } } } }; ; ; } } { }; } }; ; ; ; ; ; ; ; ; ; ;; ; }; ; ; } ;; ; ; ; ; ; ; ; ; ;; ; ; ; ; {; ; ; ; ; ; } ; } ; ;;; } ; ; ; ; ;;; ; } };; } ; ;;; ;; ;;;; ;;; ;;;; ;; { ;;; ; ;; ; ; ; ;;; ; ;;; ;;;;;;;;; ;;;;;; ; ;; ;; ;; ;; ; ;; ;; ;; ;{ ;;;{ ;{ ;; ;{;;;; ;;;; {;{;; ;;;{ ;;; ;{ ;{ ; { { { { { { { } } ; ; ;; ;; ;{ \" ' !!!!$!!(8I!!,%&!!!#*)2. C!!CH'-/0@B+ L UJM< N4 [Q?DX[ Jc !ad' in fit` !w !V mL r L p z s Vv e x _ vb !VY o\\q j (x [|!E\"&@+10y?UJ W$ 6 [OPUDXAF]US Zj lac[q $n We y |) #w zk)Us |$ `Ub,5 )F8V_h;#4\"u% 0 $<CJUIJG $X < @67$X)Z$ | YUC])ZZ h dO m s<Ky < ^wUW x#${ oU@r Z 2 Ufg<$T| njv U+/[u(>1C$ \" . I4 U $+ Al 6M3UQ 8Uv+kV5 U;pBKU`P)jX Xe Cw }\" ++{UyZo$lC}*C,& .#C>'+ 52|4/B)7+ +|@1--9M6 L ||Q =P R ? )GH\\Vk[ [ f ICfB [[[!r 6 b$! UI!z[p |sC$)x[ U$IU[e+B XU >zU 0U-?$O @Yx:) 4EZCU/lUAco 'q.*9[}G_HLBI j(! m!!t , l x!q!|! ! !!!!! ! q$ ( $U! < c 'do nN)\"S w4k} = 0 A Y1+-9 =Scaf !OZ B F "
,C[3^9
<<20],*k[
4]={
1+C,
0,59
+c}
,**K
,*l,*L,*
o,O,p,
P,s,S=1,v=4 ;
int V(int w){
return
1<w
?3<
w?4
<w?
5<w
?6<
w?O=(O=*
--l,O/64-
1?1 &129
>>O -39
:27>(O%=
32)&&0<O
?1+ O:0
),w +=O
,O- (c[
w]- 2)%
28|| (1-
(O= (c[
w]- 2)/
28) ?v=
O:0 ,V(
154+ 1950
[w+c]+94*
(464[w+
c+w ]/3
%5+ 465
[w+c +w]
%26/7 )))
:!( 3- v?2
>v? L=1[k
]=* k,3[
k]= 67+
c:3 >v?
V(0 ),p
?(0 W L,
*k- L W
52+ c,
1),p=
0:0 ,L
:L: (v=
1,l =*k
,V( 205
),1-v
?2 [k]
=75 +c:
o,V(
3), v%3 ?2>
v?V (1), o=
1[k ]:L:(
p=(P=1 W L,o
-L W c +s,S
W o ,*k
- o W c
,S) ,L=
*k) , 1[k
]=* k )):
(l= *k, V (
808 ),v ):(
v=* ++*k
,39 -c[
v>> 7 ?
15: 1-v
/32 ?10
-v?(312-v %
32)/26+v/32
*2: 13:
82- v])
:!( w[k
]+= V(2
+w)
,v=
*w[
k]%
5,w
[k]
=*w
[k]
/5*
8+3+c):(K=k+w
,33>*(*K-=!w)
?*K
+=w
,V(
w):
!(*
K+=
!w)
);}int main()
{ read(s,2+C,
9<<
20);for(s
=isatty(S
)?S
=5:
9;v; V(2))V(6
); return P;}
+126
View File
@@ -0,0 +1,126 @@
#include<unistd.h>
#define W ),write(1,
static unsigned char c[]=
"]\33[0m\33[7m[&&'% $ # ! ########## \" !& \n oo 6''GLB=.* eoj* 5SXINE@199999999777777775]bNNE@@5]bNNE@E5SXOO0?05SXOOD?06TYJOE@16Y%JOE@16^c%O%%%6c%%O%%%f !! k k! p !oo :;;\37;;;;;\37;($\"%$##(\37(/1$1.,,,$%&/1rs!58&30123$$-O@2=\2?(2-'VZ$3:'i/3+ O#&B2%1,: 2=' (1J!1AC) @:,+_M1H/:J I\"?.Ak'.c2G$gj!j.@O&'(P +,jk/Y1$3%56.8 Y1. .4, W +nd\\rs1( ++(-.331i\".>.-[!.^'.\00281\216\217\252\253's 6\b.$\252\2534''0(\0226 6!'# +[\34.-\"+,-\"(4123Z5_]3-+46(44ij3.jneij41$3+%16s c` 3!#6.(n _\".] R+'4.jjkf`'\\..Y.(' i1 f%nG. $=i$#$ `'3V*+.b2&.!23+5.'n9\\\2ij&1j_3k^_n/+i_ij cd-$$11j(%3&'..\n!1$.4 623$ \2$' rs6${$\"\25($3-5.3''' $2.'\b(1( -.\0253,63''6 8\241+ 6\37 $-$I(P(($\252\253cZ/2\b'i4j3$86&4 j!k-J &1N]'+,fcY-ej/$fgl8 n4!$cd (^'$4+bc-g -2($.iZn$%Yc\20 4+Z,)$.'.\0071 1.'g1\37 4-$$%1'(D=+,-./+12 4,,7\f$ 1:3'+,?.='= #.%$)K!(123&(J3:4$J4 $52#(<! ,$AK;( !+# ./'1 \17 1\252\253<=>?@ABCDEFGHIJKLMNOPQRSTU ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; { { ; ; ; { ; ; { { ; ; { { { { { ; ; ; { { { { ; { { ; { { ; { { ; ; { { { ; { { { ; ; { { { ; ; { { { { { { { { { } ; { { { ; } } { { } } { { { { { } } { } } } } ; } } } { ; } } ; } } } } } } } ; } } } } } } } } } { } ; ; } } } }; ; ; } } { }; } }; ; ; ; ; ; ; ; ; ; ;; ; }; ; ; } ;; ; ; ; ; ; ; ; ; ;; ; ; ; ; {; ; ; ; ; ; } ; } ; ;;; } ; ; ; ; ;;; ; } };; } ; ;;; ;; ;;;; ;;; ;;;; ;; { ;;; ; ;; ; ; ; ;;; ; ;;; ;;;;;;;;; ;;;;;; ; ;; ;; ;; ;; ; ;; ;; ;; ;{ ;;;{ ;{ ;; ;{;;;; ;;;; {;{;; ;;;{ ;;; ;{ ;{ ; { { { { { { { } } ; ; ;; ;; ;{ \" ' !!!!$!!(8I!!,%&!!!#*)2. C!!CH'-/0@B+ L UJM< N4 [Q?DX[ Jc !ad' in fit` !w !V mL r L p z s Vv e x _ vb !VY o\\q j (x [|!E\"&@+10y?UJ W$ 6 [OPUDXAF]US Zj lac[q $n We y |) #w zk)Us |$ `Ub,5 )F8V_h;#4\"u% 0 $<CJUIJG $X < @67$X)Z$ | YUC])ZZ h dO m s<Ky < ^wUW x#${ oU@r Z 2 Ufg<$T| njv U+/[u(>1C$ \" . I4 U $+ Al 6M3UQ 8Uv+kV5 U;pBKU`P)jX Xe Cw }\" ++{UyZo$lC}*C,& .#C>'+ 52|4/B)7+ +|@1--9M6 L ||Q =P R ? )GH\\Vk[ [ f ICfB [[[!r 6 b$! UI!z[p |sC$)x[ U$IU[e+B XU >zU 0U-?$O @Yx:) 4EZCU/lUAco 'q.*9[}G_HLBI j(! m!!t , l x!q!|! ! !!!!! ! q$ ( $U! < c 'do nN)\"S w4k} = 0 A Y1+-9 =Scaf !OZ B F "
,C[3^9
<<20],*k[
4]={
1+C,
0,59
+c}
,**K
,*l,*L,*
o,O,p,
P,s,S=1,v=4 ;
int V(int w){
return
1<w
?3<
w?4
<w?
5<w
?6<
w?O=(O=*
--l,O/64-
1?1 &129
>>O -39
:27>(O%=
32)&&0<O
?1+ O:0
),w +=O
,O- (c[
w]- 2)%
28|| (1-
(O= (c[
w]- 2)/
28) ?v=
O:0 ,V(
154+ 1950
[w+c]+94*
(464[w+
c+w ]/3
%5+ 465
[w+c +w]
%26/7 )))
:!( 3- v?2
>v? L=1[k
]=* k,3[
k]= 67+
c:3 >v?
V(0 ),p
?(0 W L,
*k- L W
52+ c,
1),p=
0:0 ,L
:L: (v=
1,l =*k
,V( 205
),1-v
?2 [k]
=75 +c:
o,V(
3), v%3 ?2>
v?V (1), o=
1[k ]:L:(
p=(P=1 W L,o
-L W c +s,S
W o ,*k
- o W c
,S) ,L=
*k) , 1[k
]=* k )):
(l= *k, V (
808 ),v ):(
v=* ++*k
,39 -c[
v>> 7 ?
15: 1-v
/32 ?10
-v?(312-v %
32)/26+v/32
*2: 13:
82- v])
:!( w[k
]+= V(2
+w)
,v=
*w[
k]%
5,w
[k]
=*w
[k]
/5*
8+3+c):(K=k+w
,33>*(*K-=!w)
?*K
+=w
,V(
w):
!(*
K+=
!w)
);}int main()
{ read(s,2+C,
9<<
20)
;s=isatty(S)
?S=
5:9;
for(;v;V(2))V
(6);return P;}