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

+206
View File
@@ -0,0 +1,206 @@
#!/usr/bin/env make
#
# 2012 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
LD= ld
MAKE= make
RM= rm
SED= sed
TAR= tar
TRUE= true
# Set X11_LIBDIR to the directory where the X11 library resides
#
X11_LIBDIR= /usr/X11R6/lib
# Set X11_INCLUDEDIR to the directory where the X11 include files reside
#
X11_INCDIR= /usr/X11R6/include
# Compiler warnings
#
#CWARN=
CWARN= -Wall -W
#CWARN= -Wall -W -pedantic
# compiler standard
#
#CSTD=
#CSTD= -ansi
CSTD= -std=c99
# compiler bit architecture
#
# Some entries require 32-bitness:
# ARCH= -m32
#
# Some entries require 64-bitess:
# ARCH= -m64
#
# By default we assume nothing:
#
ARCH=
# 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.
#
#OPT=
#OPT= -O
#OPT= -O1
OPT= -O2
#OPT= -O3
# Libraries needed to build
#
LIBS=
# default flags for ANSI C compilation
#
CFLAGS= ${CWARN} ${CSTD} ${ARCH} ${OPT} ${LIBS}
# 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
##############################
#
ENTRY= kang
DATA=
ALT_OBJ= kang.orig.o
ALT_ENTRY= kang.orig
#################
# build the entry
#################
#
all: ${ENTRY} ${DATA}
@${TRUE}
${ENTRY}: ${ENTRY}.c
${CC} ${CFLAGS} $< -o $@
# alternative executable
#
alt: ${ALT_ENTRY}
@${TRUE}
kang.orig: kang.orig.c
${CC} ${CFLAGS} $< -o $@
# data files
#
data: ${DATA}
@${TRUE}
###############
# utility rules
###############
#
everything: all alt
clean:
${RM} -f ${ENTRY}.o ${ALT_OBJ}
clobber: clean
${RM} -f ${ENTRY} ${ALT_ENTRY}
nuke: clobber
@${TRUE}
dist_clean: nuke
@${TRUE}
install:
@echo "Surely you're joking Mr. Feynman!"
@${TRUE}
# backwards compatibility
#
build: all
@${TRUE}
##################
# 133t hacker rulz
##################
#
love:
@echo 'not war?'
@${TRUE}
haste:
$(MAKE) waste
@${TRUE}
waste:
@echo 'waste'
@${TRUE}
easter_egg:
@echo you expected to mis-understand this $${RANDOM} magic
@echo chongo '<was here>' "/\\oo/\\"
@echo Readers shall be disallowed from not being unable to partly misunderstand this partocular final echo.
# Understand the history of "I Am the Walrus" and
# and in particular John Lennon's remarks on that
# song and you might be confused about these next
# rules in a different way. :-)
#
supernova: nuke
@-if [ -r .code_anal ]; then \
${RM} -f .code_anal_v3; \
else \
echo "You are not expected to understand this"; \
fi
@${TRUE}
deep_magic:
@-if [ -r .code_anal ]; then \
ccode_analysis --deep_magic 1c2c85c7a02c55d1add91967eca491d53c101dc1 --FNV1a_hash 256-bit "${ENTRY}"; \
else \
echo "Understand different"; \
fi
@${TRUE}
magic: deep_magic
@-if [ -r .code_anal ]; then \
ccode_analysis --mode 21701 --level 23209 --FNV1a_hash 256-bit "${ENTRY}"; \
else \
echo "These aren't the droids you're looking for Mr. Spock!"; \
fi
@${TRUE}
+201
View File
@@ -0,0 +1,201 @@
<!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>Best short program</title>
</head>
<body>
<h1>Best short program</h1>
<p>Seonghoon Kang<br>
<a href="&#109;&#97;&#105;&#108;&#116;&#x6f;&#x3a;&#x6b;&#x61;&#x6e;&#x67;&#46;&#115;&#x65;&#x6f;&#110;&#103;&#104;&#111;&#111;&#110;&#64;&#x6d;&#101;&#97;&#114;&#x69;&#101;&#x2e;&#111;&#114;&#x67;">&#x6b;&#97;&#x6e;&#x67;&#46;&#115;&#101;&#x6f;&#x6e;&#x67;&#x68;&#x6f;&#111;&#x6e;&#x40;&#109;&#x65;&#x61;&#114;&#105;&#101;&#x2e;&#111;&#114;&#x67;</a></p>
<h2>Judges' comments:</h2>
<h3>To build:</h3>
<pre><code>make kang
</code></pre>
<h3>To run:</h3>
<pre><code>echo "full spelling of an English cardinal numeral less than a quadrillion" | ./kang
</code></pre>
<h3>Try:</h3>
<pre><code>echo Nineteen hundred and eighty-four | ./kang
echo uno | ./kang
echo trois | ./kang
echo fier | ./kang
echo "shest'" | ./kang
</code></pre>
<h3>Selected Judges Remarks:</h3>
<p>The judges were able to appreciate the Indo-European language family
relation by making this entry successfully recognize <em>some</em> French,
German, Italian, Russian, and Spanish numerals.</p>
<p>Also worth mentioning is this entry&rsquo;s ability to understand the
colloquial year numbers of the last millennium.</p>
<p>We&rsquo;ve added a linefeed to the print format for convenience.</p>
<h2>Author&rsquo;s comments:</h2>
<h2>Synopsis</h2>
<p>This short program reads a spelt number (e.g. <code>forty-two</code>) and writes a
corresponding decimal number (e.g. <code>42</code>). Too long for one-liners, alas,
but it still qualifies as a <em>short</em> program as it has less than 0x100 bytes.</p>
<p>It accepts a variety of spelt numbers:</p>
<ul>
<li>It correctly handles <code>zero</code>.</li>
<li>Hyphen does not make a difference: <code>forty-two</code> and <code>forty two</code> are same.
So does period or comma.</li>
<li>Cases do not make a difference either: <code>TWO</code>, <code>Two</code>, <code>two</code> are same.</li>
<li><code>one</code> and <code>a</code> are interchangeable: <code>one hundred</code> and <code>a hundred</code> are same.</li>
<li><code>and</code> is optional: <code>one hundred twenty-three</code> and <code>one hundred and twenty-three</code>
are same.</li>
<li>It supports every non-negative integer less than 10<sup>15</sup>-1. It uses
the small scale (i.e. American): <code>billion</code> is 10<sup>9</sup> and <code>trillion</code> is
10<sup>12</sup>.</li>
</ul>
<p>It does <em>not</em> accept some spelt numbers, which I found mostly irrelevant:</p>
<ul>
<li>A bare <code>hundred</code>, <code>thousand</code> etc. do not work.</li>
<li><code>one million million</code> does not work. Get used to <code>one trillion</code>!</li>
</ul>
<h2>Requirements</h2>
<p>This program is quite portable, only requiring the following:</p>
<ul>
<li>The signature <code>int main(int, int)</code> should be accepted by the linker.</li>
<li><code>char</code> should be at least 8 bits long (as dictated by the standard), <code>int</code>
should be at least 32 bits long, <code>long long</code> should be at least 64 bits long.</li>
<li>Both the compiler and execution environment should use an ASCII-compatible
character set and two&rsquo;s complement representation.</li>
<li>Overflow and underflow on <code>char</code> should wrap around, if your <code>char</code> is unsigned.</li>
<li><a href="http://cm.bell-labs.com/who/ken/trust.html">A trustworthy compiler</a>.</li>
</ul>
<p>The design of the program explicitly allows for <code>EOF</code> which does not equal to -1
(it has to be negative per the standard) and both signed and unsigned <code>char</code>,
for example. Furthermore it is endian-independent.</p>
<h2>Obfuscations</h2>
<p>Many obfuscations used are typical for standard IOCCC entries:</p>
<ul>
<li>Two arguments from <code>main</code> function are reused as normal variables.</li>
<li>Every conditional has been replaced with <code>?:</code> ternary operator and <code>||</code>
short-circuiting operator.</li>
<li>It has exactly three nested <code>for</code> loops and nothing else.</li>
<li>Common two&rsquo;s complement tricks: <code>~-a</code> instead of <code>a-1</code>,
<code>~a?...:...</code> instead of <code>a!=-1?...:...</code>, etc.</li>
<li>Comma operators (<code>,</code>) for multiple statements. The number of them is
minimized, however, as it is too easy to (ab)use them.</li>
<li>It lacks most parentheses around bitwise and arithmetic operators. It was
originally written for shortness so parentheses were <strong>EVIL</strong>.</li>
<li><code>n["string"]</code> instead of <code>"string"[n]</code>. Both are fine for this program but
I went to the former just for fun.</li>
<li>Utter lack of any kind of layouts. (Oh, except for the first column.)</li>
</ul>
<p>Other obfuscations are more subtle:</p>
<ul>
<li>The string <code>"1+DIY/.K430x9G(kC["</code> is 18 bytes long, but actually 19 bytes
including the final null character are used.</li>
<li>It internally represents numbers as hexadecimal. When the input is <code>two
hundred and three</code>, it actually writes 0x203 as hexadecimal.</li>
<li>Some variables (notably, <code>n</code>) have dual uses.</li>
<li>The magic number <a href="http://en.wikipedia.org/wiki/Answer_to_The_Ultimate_Question_of_Life,_the_Universe,_and_Everything">42</a> makes an appearance.</li>
<li>It has a long long numb-<code>main</code>-er within it!</li>
</ul>
<p>But the most important obfuscation is the clever construction of lookup table.
The program uses 11 different characters required for recognizing 22 lexemes:</p>
<pre><code>zero one tw- th(i)r- fo(u)r- fi- six-
seven- eigh- nin- ten eleven twelve
hundred(s) thousand(s) million(s) billion(s) trillion(s)
a and -teen -ty
</code></pre>
<p>So that they are internally represented as like:</p>
<pre><code>r n tw- tr- fr- f- s-
sn- g- nn- tn ln twl
nr(s) tsan(s) lln(s) blln(s) trlln(s)
a an -tn -ty
</code></pre>
<p>The stemmer recognizes the longest matching prefix, so every lexeme can be
recognized by at most three characters (e.g. <code>trl</code> instead of <code>trlln</code>). This is
also handy for ignoring plurals. But that would make that the table does not fit
in the printable byte&mdash;11<sup>2</sup> is already almost 2<sup>7</sup>!</p>
<p>The trick is to use octal; three characters (<code>a</code>, <code>b</code> and <code>g</code>) are interpreted
as sequences of two characters (<code>ny</code>, <code>nn</code> and <code>nw</code> respectively). Asides from
a smaller lookup table, it has many good consequences:</p>
<ul>
<li>Both <code>a</code> and <code>and</code> share the common prefix, <code>ny</code>, and can be discarded
altogether. Note that <code>ny</code> itself does not appear from other entries.</li>
<li><code>thousand</code> is interpreted as <code>tsan</code>, which is equivalent to <code>tfyn</code> in the
octal scheme. As it is the only entry with <code>tf</code> prefix, it can be shorten by
one character.</li>
</ul>
<p>Having said this important trick, other details should be relatively easier to
follow. The order of lookup table, for example, is very important,
and the biggest constant 6177 is not arbitrarily chosen.</p>
<h2>Acknowledgement</h2>
<p>[Removed for proper judgement: I&rsquo;ll fill this section if I do win.]</p>
<p>[Note: If you think you&rsquo;ve seen this program elsewhere, you are probably right;
I&rsquo;m submitting a program I have published years ago (and I have written myself,
of course). Neither rules nor guidelines disallow such a resubmission, so I guess
it&rsquo;s fine.]</p>
<hr />
<!--
(c) Copyright 1984-2015, [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-2015,
<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>
+160
View File
@@ -0,0 +1,160 @@
# Best short program
Seonghoon Kang
<kang.seonghoon@mearie.org>
## Judges' comments:
### To build:
make kang
### To run:
echo "full spelling of an English cardinal numeral less than a quadrillion" | ./kang
### Try:
echo Nineteen hundred and eighty-four | ./kang
echo uno | ./kang
echo trois | ./kang
echo fier | ./kang
echo "shest'" | ./kang
### Selected Judges Remarks:
The judges were able to appreciate the Indo-European language family
relation by making this entry successfully recognize *some* French,
German, Italian, Russian, and Spanish numerals.
Also worth mentioning is this entry's ability to understand the
colloquial year numbers of the last millennium.
We've added a linefeed to the print format for convenience.
## Author's comments:
## Synopsis
This short program reads a spelt number (e.g. `forty-two`) and writes a
corresponding decimal number (e.g. `42`). Too long for one-liners, alas,
but it still qualifies as a *short* program as it has less than 0x100 bytes.
It accepts a variety of spelt numbers:
* It correctly handles `zero`.
* Hyphen does not make a difference: `forty-two` and `forty two` are same.
So does period or comma.
* Cases do not make a difference either: `TWO`, `Two`, `two` are same.
* `one` and `a` are interchangeable: `one hundred` and `a hundred` are same.
* `and` is optional: `one hundred twenty-three` and `one hundred and twenty-three`
are same.
* It supports every non-negative integer less than 10<sup>15</sup>-1. It uses
the small scale (i.e. American): `billion` is 10<sup>9</sup> and `trillion` is
10<sup>12</sup>.
It does *not* accept some spelt numbers, which I found mostly irrelevant:
* A bare `hundred`, `thousand` etc. do not work.
* `one million million` does not work. Get used to `one trillion`!
## Requirements
This program is quite portable, only requiring the following:
* The signature `int main(int, int)` should be accepted by the linker.
* `char` should be at least 8 bits long (as dictated by the standard), `int`
should be at least 32 bits long, `long long` should be at least 64 bits long.
* Both the compiler and execution environment should use an ASCII-compatible
character set and two's complement representation.
* Overflow and underflow on `char` should wrap around, if your `char` is unsigned.
* [A trustworthy compiler][trustingtrust].
[trustingtrust]: http://cm.bell-labs.com/who/ken/trust.html
The design of the program explicitly allows for `EOF` which does not equal to -1
(it has to be negative per the standard) and both signed and unsigned `char`,
for example. Furthermore it is endian-independent.
## Obfuscations
Many obfuscations used are typical for standard IOCCC entries:
* Two arguments from `main` function are reused as normal variables.
* Every conditional has been replaced with `?:` ternary operator and `||`
short-circuiting operator.
* It has exactly three nested `for` loops and nothing else.
* Common two's complement tricks: `~-a` instead of `a-1`,
`~a?...:...` instead of `a!=-1?...:...`, etc.
* Comma operators (`,`) for multiple statements. The number of them is
minimized, however, as it is too easy to (ab)use them.
* It lacks most parentheses around bitwise and arithmetic operators. It was
originally written for shortness so parentheses were **EVIL**.
* `n["string"]` instead of `"string"[n]`. Both are fine for this program but
I went to the former just for fun.
* Utter lack of any kind of layouts. (Oh, except for the first column.)
Other obfuscations are more subtle:
* The string `"1+DIY/.K430x9G(kC["` is 18 bytes long, but actually 19 bytes
including the final null character are used.
* It internally represents numbers as hexadecimal. When the input is `two
hundred and three`, it actually writes 0x203 as hexadecimal.
* Some variables (notably, `n`) have dual uses.
* The magic number [42][hhgg] makes an appearance.
* It has a long long numb-`main`-er within it!
[hhgg]: http://en.wikipedia.org/wiki/Answer_to_The_Ultimate_Question_of_Life,_the_Universe,_and_Everything
But the most important obfuscation is the clever construction of lookup table.
The program uses 11 different characters required for recognizing 22 lexemes:
zero one tw- th(i)r- fo(u)r- fi- six-
seven- eigh- nin- ten eleven twelve
hundred(s) thousand(s) million(s) billion(s) trillion(s)
a and -teen -ty
So that they are internally represented as like:
r n tw- tr- fr- f- s-
sn- g- nn- tn ln twl
nr(s) tsan(s) lln(s) blln(s) trlln(s)
a an -tn -ty
The stemmer recognizes the longest matching prefix, so every lexeme can be
recognized by at most three characters (e.g. `trl` instead of `trlln`). This is
also handy for ignoring plurals. But that would make that the table does not fit
in the printable byte---11<sup>2</sup> is already almost 2<sup>7</sup>!
The trick is to use octal; three characters (`a`, `b` and `g`) are interpreted
as sequences of two characters (`ny`, `nn` and `nw` respectively). Asides from
a smaller lookup table, it has many good consequences:
* Both `a` and `and` share the common prefix, `ny`, and can be discarded
altogether. Note that `ny` itself does not appear from other entries.
* `thousand` is interpreted as `tsan`, which is equivalent to `tfyn` in the
octal scheme. As it is the only entry with `tf` prefix, it can be shorten by
one character.
Having said this important trick, other details should be relatively easier to
follow. The order of lookup table, for example, is very important,
and the biggest constant 6177 is not arbitrarily chosen.
## Acknowledgement
[Removed for proper judgement: I'll fill this section if I do win.]
[Note: If you think you've seen this program elsewhere, you are probably right;
I'm submitting a program I have published years ago (and I have written myself,
of course). Neither rules nor guidelines disallow such a resubmission, so I guess
it's fine.]
--------------------------------------------------------------------------------
<!--
(c) Copyright 1984-2015, [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/
-->
+5
View File
@@ -0,0 +1,5 @@
long long n,u,m,b;main(e,r)char **r;{f\
or(;n++||(e=getchar()|32)>=0;b="ynwtsflrabg"[n%=11]-e?b:b*8+
n)for(r=b%64-25;e<47&&b;b/=8)for(n=19;n;n["1+DIY/.K430x9\
G(kC["]-42&255^b||(m+=n>15?n:n>9?m%u*~-u:~(int)r?n+
!(int)r*16:n*16,b=0))u=1ll<<6177%n--*4;printf("%llx\n",m);}
+5
View File
@@ -0,0 +1,5 @@
long long n,u,m,b;main(e,r){f\
or(;n++||(e=getchar()|32)>=0;b="ynwtsflrabg"[n%=11]-e?b:b*8+
n)for(r=b%64-25;e<47&&b;b/=8)for(n=19;n;n["1+DIY/.K430x9\
G(kC["]-42&255^b||(m+=n>15?n:n>9?m%u*~-u:~r?n+
!r*16:n*16,b=0))u=1ll<<6177%n--*4;printf("%llx",m);}