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

+117
View File
@@ -0,0 +1,117 @@
#!/usr/bin/env make
#
# 2011 makefile
#
# Copyright (C) 2011, Landon Curt Noll, Simon Cooper, and Leonid A. Broukhis.
#
# 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
# 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= -O2
# bitness
#
# Some entries require 32-bitness,
# other entries require 64-bitess.
# By default we assume nothing.
#
ARCH=
# default flags for ANSI C compilation
#
CFLAGS= -Wall -W ${ARCH} ${OPT}
# ANSI compiler
#
# Set CC to the name of your ANSI compiler.
#
CC= cc
##############################
# Special flags for this entry
##############################
#
ENTRY= richards
DATA=
#################
# build the entry
#################
#
all: ${ENTRY} ${DATA}
@${TRUE}
${ENTRY}: ${ENTRY}.c
${CC} ${CFLAGS} ${ENTRY}.c -o ${ENTRY}
# alternative executable
#
alt:
@${TRUE}
###############
# utility rules
###############
#
everything: all alt
clean:
${RM} -f ${ENTRY}.o
clobber: clean
${RM} -f ${ENTRY}
nuke: clobber
@echo gnab gib!
install:
@echo "Surely you're joking Mr. Feynman!"
# backwards compatibility
#
build: all
##################
# 133t hacker rulz
##################
#
love:
@echo 'not war?'
haste:
$(MAKE) waste
waste:
@echo 'waste'
easter_egg:
@echo you expected to mis-understand this $${RANDOM} magic
@echo chongo '<was here>' "/\\oo/\\"
@echo Readers shall not be disallowed from being unable to partly misunderstand this final echo.
@${TRUE}
+112
View File
@@ -0,0 +1,112 @@
<!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.3 DL=DISCOUNT">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<link rel="stylesheet"
type="text/css"
href="../hint.css">
<title>Most surprisingly portable</title>
</head>
<body>
<h1>Most surprisingly portable</h1>
<p>Gregor Richards<br>
<a href="&#x6d;&#x61;&#105;&#108;&#116;&#111;&#58;&#82;&#105;&#99;&#x68;&#97;&#114;&#100;&#x73;&#64;&#x63;&#111;&#100;&#117;&#46;&#111;&#x72;&#103;">&#82;&#105;&#99;&#104;&#x61;&#114;&#100;&#115;&#x40;&#99;&#111;&#x64;&#117;&#x2e;&#x6f;&#x72;&#x67;</a></p>
<h2>Judges' comments:</h2>
<h3>To build:</h3>
<pre><code>make richards
</code></pre>
<h3>To run:</h3>
<pre><code>./richards
</code></pre>
<h3>Try:</h3>
<pre><code>echo '10 9 8 7 6 5 4 3 2 1*p*p*p*p*p*p*p*p*p' | ./richards
</code></pre>
<h3>Selected Judges Remarks:</h3>
<p>Oh no, yet another dc-style calculator? (see 2000/dlowe using an embedded Perl
interpreter and deemed Worst Abuse of the Rules).
Well, this one does it (expression calculation, that is, not the rule abuse) in a different way.
The author claims that his calculator does just-in-time compilation.
What would you do to prove or disprove his claim without attempting to unravel the source?</p>
<h2>Author&rsquo;s comments:</h2>
<p>This is an implementation of the classic UNIX dc command, the reverse-polish
calculator. Actually it&rsquo;s a pretty bad implementation, since it only implements
32-bit integers (well, sizeof(int)-sized integers). It only implements the
commands +, -, *, /, p (only for numbers), register stacks, macros and
comparisons. Wow, you&rsquo;d think I could&rsquo;ve done better in 2K of code.</p>
<p>OH! I forgot to mention! It&rsquo;s a JIT.</p>
<p>Wait, don&rsquo;t stop reading! I know what you&rsquo;re thinking, platform-specific code
is discouraged in IOCCC. But do you see any platform-specific code? There&rsquo;s no
assembler here! This JIT works on a dozen platforms, and the only
platform-specific assumptions it makes are that the stack grows down and
integers are at least 32-bit.</p>
<p>You will probably get warnings while compiling the code. In particular:</p>
<ul>
<li>If your system requires the inclusion of alloca.h to use alloca, use the
compile flag -DAH</li>
<li>If your system cannot use mmap, use the compile flag -DNM</li>
<li>I don&rsquo;t include any headers I don&rsquo;t strictly need to, so you&rsquo;ll get warnings
about (at least) memcpy, isdigit, atoi, calloc, malloc and alloca if you
didn&rsquo;t use -DAH.</li>
<li>GCC likes to complain about while (a = b) (assignments as a condition).</li>
<li>I don&rsquo;t return from main, even though it&rsquo;s declared to return int.</li>
</ul>
<p>Platforms on which all known/tested optimization levels work with no additional
flags:</p>
<ul>
<li>gcc 4.6.2 + x86[_64] + GNU/Linux, Mac OS X or Windows</li>
<li>clang 2.9-16 + x86[_64] + GNU/Linux or Mac OS X</li>
<li>tcc 0.9.25</li>
<li>gcc 4.4.5 + alpha, arm, mips[el], powerpc[64], s390x (IBM zSeries)</li>
<li>gcc 4.1.3 + vax + NetBSD</li>
</ul>
<p>Platforms which work but not at all optimization levels or needing special
flags:</p>
<ul>
<li>owcc 1.9 + x86 + Windows: Needs -DNM -DAH -fno-stack-check</li>
<li>gcc 4.4.5 + sh4: -O0 works, higher optimization levels don&rsquo;t work for unknown reasons.</li>
</ul>
<hr />
<!--
(c) Copyright 1984-2012, [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-2012,
<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>
+76
View File
@@ -0,0 +1,76 @@
# Most surprisingly portable
Gregor Richards
<Richards@codu.org>
## Judges' comments:
### To build:
make richards
### To run:
./richards
### Try:
echo '10 9 8 7 6 5 4 3 2 1*p*p*p*p*p*p*p*p*p' | ./richards
### Selected Judges Remarks:
Oh no, yet another dc-style calculator? (see 2000/dlowe using an embedded Perl
interpreter and deemed Worst Abuse of the Rules).
Well, this one does it (expression calculation, that is, not the rule abuse) in a different way.
The author claims that his calculator does just-in-time compilation.
What would you do to prove or disprove his claim without attempting to unravel the source?
## Author's comments:
This is an implementation of the classic UNIX dc command, the reverse-polish
calculator. Actually it's a pretty bad implementation, since it only implements
32-bit integers (well, sizeof(int)-sized integers). It only implements the
commands +, -, *, /, p (only for numbers), register stacks, macros and
comparisons. Wow, you'd think I could've done better in 2K of code.
OH! I forgot to mention! It's a JIT.
Wait, don't stop reading! I know what you're thinking, platform-specific code
is discouraged in IOCCC. But do you see any platform-specific code? There's no
assembler here! This JIT works on a dozen platforms, and the only
platform-specific assumptions it makes are that the stack grows down and
integers are at least 32-bit.
You will probably get warnings while compiling the code. In particular:
* If your system requires the inclusion of alloca.h to use alloca, use the
compile flag -DAH
* If your system cannot use mmap, use the compile flag -DNM
* I don't include any headers I don't strictly need to, so you'll get warnings
about (at least) memcpy, isdigit, atoi, calloc, malloc and alloca if you
didn't use -DAH.
* GCC likes to complain about while (a = b) (assignments as a condition).
* I don't return from main, even though it's declared to return int.
Platforms on which all known/tested optimization levels work with no additional
flags:
* gcc 4.6.2 + x86[_64] + GNU/Linux, Mac OS X or Windows
* clang 2.9-16 + x86[_64] + GNU/Linux or Mac OS X
* tcc 0.9.25
* gcc 4.4.5 + alpha, arm, mips[el], powerpc[64], s390x (IBM zSeries)
* gcc 4.1.3 + vax + NetBSD
Platforms which work but not at all optimization levels or needing special
flags:
* owcc 1.9 + x86 + Windows: Needs -DNM -DAH -fno-stack-check
* gcc 4.4.5 + sh4: -O0 works, higher optimization levels don't work for unknown reasons.
--------------------------------------------------------------------------------
<!--
(c) Copyright 1984-2012, [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/
-->
+199
View File
@@ -0,0 +1,199 @@
#ifdef AH
#include<alloca.h>
#endif
#include<setjmp.h>
#include<stdio.h>
#if !NM
#include<sys/mman.h>
#endif
#define vo volatile
#define A(x,y,z) O(x,y,z##1)O(x,y,z##2)O(x,y,z##3)
#define B(x,y) A(x,y,1)A(x,y,2)A(x,y,3)
#define C(x,y) B(x,y##1)B(x,y##2)B(x,y##3)
#define D(x) C(x,1)C(x,2)C(x,3)
#define E(x) D(x##1)D(x##2)D(x##3)
#define G E(1)E(2)E(3)
#define S d->
#define M S a
#define R(x) ; S r(#x);
#define L(x,y) S l[x](d)R(y)
#define F(x) void l##x(vo dt d) {
#define Q(x); M--; *M=*M x M[1]; R(x)
#define O(x,y,z) x##y##z,
#define q typedef
#define H 9<<16
#define I case
#define J(i) calloc(i,1)
#define W(c) e=(k*)memcpy(e,x[(u)c],y[(u)c])+y[(u)c];
#define N break; I
q char k;
q void o;
q int u;
q o(*f) (vo o *);
q struct {
u *a, **R, *m, h, c;
k **s;
f *l, *j, r;
} *dt;
u m[] = { G 0 } ;
u n[H];
dt st;
u sk[H];
k *w;
o *x[H];
u y[H];
k *j, *e;
u l=256;
o g(u v)
{
if (v > l) {
g(v / l);
g(l);
W('*') g(v % l);
W('+')} else {
W(m[v])}
}
f K(k * p, dt d)
{
k c, n = 0;
f r = (f) e;
W(1) while ((c = *p)) {
switch (c) {
I '#':
while (*++p != 10);
N '[':c = 1;
S s[S c] = ++p;
for (; c; p++) {
if (*p == '[')
c++;
else if (*p == ']')
c--;
}
p[-1] = 0;
g(S c++);
N '!':n = 1;
c = *++p;
if (!(c & 1))
I '<': I '>':
c ^= 2;
I '=':W(c) if (n) {
W('!') n = 0;
}
g(*++p);
W('|') p++;
N 's': I 'S': I 'l':
I 'L':g(*++p);
W(c) p++;
N '_':p++;
default:
if (isdigit(*p)) {
g(atoi(p));
while (isdigit(*p))
p++;
} else
p++;
W(c)}
}
W(2) return r;
}
o t(vo dt d)
{
S r("\01") Q(+)Q(-)Q(*) * M = -*M;
R(_)Q( ==) Q(<)Q(>) * M = !*M;
R(!)M[-1] ^= *M;
*M ^= M[-1] R(r) M[1] = *M;
M++ R(d) * S R[*M] = M[-1];
M--;
R(s) * ++S R[*M] = M[-1];
M--;
R(S) * M = *S R[*M];
R(l) * M = *S R[*M]--;
R(L) L(1, /)L(2, p) L(3, x) L(4, |)
#undef O
#define O(x,y,z) *++M=S m[(x*S h+y)*S h+z]; S r("");
G S l[0] (d);
}
o T()
{
}
o rd(u v)
{
k *a = 0, **b = &a, **c = b + 32;
x[v] = w;
for (; b < c && (*b < w || *b > (k *) T || *b == (k *) (long) v); b++);
if (b == c) {
jmp_buf *j = alloca(sizeof(*j));
setjmp(*j);
rd(v);
} else {
y[v] = *b - w;
w = *b;
}
}
q o(*rt) (u);
vo rt rs = rd;
o re(vo k * rec)
{
static u i = 0;
*(st->a = sk + 9) = 0;
rs(*rec ? *rec : m[i++]);
} F(d) M--;
*M /= M[1];
} F(p) printf("%d\n", *M);
} F(x) u n = *M--;
if (!S j[n])
S j[n] = K(S s[n], d);
S j[n] (d);
}
F(1) M -= 2;
if (M[1])
{
M++;
*M = *S R[M[1]];
lx(d);
}
}
o *lib1[] = { T, T, T, T, T } ;
o *lib2[] = { T, ld, lp, lx, l1 } ;
u main()
{
u i;
k *b;
dt d = st = J(sizeof(*st));
M = sk + 9;
S R = J(l * sizeof(k *));
for (i = 0; i < l; i++)
S R[i] = J(H);
S m = n;
S s = J(H);
S l = (f *) lib1;
S j = J(H);
S r = (f) re;
for (i = 0; m[i]; i++)
n[m[i]] = i;
w = (k *) t;
t(d);
x[2] = w;
y[2] = (k *) T - w + 8;
S h = 100;
S l = (f *) lib2;
S r = (f) T;
j = e =
#if NM
malloc(H);
#else
mmap(0, H, -1, MAP_PRIVATE | MAP_ANON, -1, 0);
#endif
while (b = fgets(malloc(999), 999, stdin))
((f) K(b, d)) (d);
}