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

+94
View File
@@ -0,0 +1,94 @@
This file is a brief description of the files in this entry.
prog.c This is the source file to the `weasel'
program [1].
prog-simple.c This is the source code file to the
`weasel-simple' program [1].
test.sh Script provided to test the weasel program [1].
test-strings.txt The test.sh script reads from this file and runs
the weasel program for each line read.
Makefile The Makefile that simplifies compilation as well as
providing some deep magic and other things designed
by the IOCCC judges. There's also a `make test'
target that runs the 'test.sh' script. The hint
file shows how to pass options to the script
itself [1].
weasel.man The local version of the man page; that is if it's
not installed. You can still use 'man' on the
'weasel.1' file but 'weasel.man' references
different file paths from 'weasel.1'.
weasel.1 The system wide version of the man page for when
(if) it's installed [2]. Note that the suggested
invocation 'man -l ./weasel.man' can be replaced
with 'man -l ./weasel.1' too but if the weasel
package is installed 'man weasel.1' (note the
missing '-l ./') would read the from the system
man page.
hint.text The source of the hint.html file [3].
hint.txt 'hint.txt' is a possible name in the future
according to the judges.
hint.html More thorough documentation including example
invocations, how to compile, final and winning
thoughts, some of the obfuscation techniques that
might be used, etc. [3].
hint.css The CSS file for the hint.html file [3].
rpm.markdown This file briefly answers 'why' I submitted a rpm
spec file 'weasel.spec' as well as the possibility
of building the RPM for others (despite the fact I
am confident that I'm the only one who would make
use of it). This file isn't included in the RPM
itself; it remains only on the IOCCC website.
weasel.spec The RPM spec file for building the RPM. This is
specific to the entry on the IOCCC website but
would also be available in the source rpm file if
it was built.
FILES If you want a brief description of the FILES file
(this file) then read this file (the file FILES).
* Footnotes
The follow footnotes are for if the weasel program is installed into the
system. As I noted before it was primarily personal reasons that I submitted
the spec file. Please note that the paths below are dependent on the prefix
used in installation; where I suggest '/usr' it is equally possible it could be
under '/usr/local', for example.
[1] Note that 'prog.c' and 'prog-simple.c' would be
linked to 'weasel.c' and 'weasel-simple.c'
(respectively) in the '/usr/src/weasel'
subdirectory.
[2] The file would most likely be compressed as
'weasel.1.gz' under the '/usr/share/man/man1'
subdirectory.
[3] These files would be in the
'/usr/share/doc/weasel' subdirectory.
+301
View File
@@ -0,0 +1,301 @@
#!/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=
#CSILENCE= -Wno-implicit-int
# compiler standard
#
#CSTD=
#CSTD= -ansi
CSTD= -std=c11
#CSTD= -std=c99
# 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= -DQ='typedef' -D'g(o)'='goto o;' -D'w(x)'="x:" -D'H(main)'='r(main)'
#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
#OPT= -O0
# 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 weasel
#
ALT_OBJ= prog-simple.o
ALT_TARGET= prog-simple weasel-simple prog.orig
#################
# build the entry
#################
#
all: ${TARGET} ${DATA} ${ALT_TARGET}
@${TRUE}
prog: prog.c
${CC} ${CFLAGS} $< -o $@ ${LIBS}
weasel: prog
${CP} -f $< $@
test: prog test.sh
./test.sh
# alternative executable
#
alt: ${ALT_TARGET}
@${TRUE}
prog-simple: prog-simple.c
${CC} ${CFLAGS} $< -o $@ ${LIBS}
weasel-simple: prog-simple
${CP} -f $< $@
prog.orig: prog.orig.c
${CC} ${CFLAGS} $< -o $@ ${LIBS}
# 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
+77
View File
@@ -0,0 +1,77 @@
* {
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
}
body {
max-width: 50em;
margin: 0 auto;
color: #111;
}
pre, code {
font-family: Monaco, Courier New, monospace;
font-size: 12px;
}
h1 {
font-size: 40px;
font-weight: bold;
letter-spacing: -1px;
margin-bottom: -5px;
}
h1 code {
font-size: 40px;
}
h2 {
color: rgb(43,105,145);
font-weight: bold;
margin-bottom: -5px;
}
h2 code {
font-size: 22px;
}
h3 {
/* color: rgb(43,105,145); */
font-weight: bold;
margin-bottom: -5px;
}
h3 code {
font-size: 16px;
}
a {
color: blue;
text-decoration: underline;
}
a:visited {
color: navy;
}
a:hover {
text-decoration: underline;
}
pre {
border-radius: 10px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.3);
border-width: 1px;
border-color: rgb(16,48,0);
border-style: solid;
padding: 0.6em;
padding-left: 1em;
margin-left: 5%;
margin-right: 8%;
background-color: rgb(0,47,53);
overflow: auto;
color: rgb(181,199,255);
}
p, li {
font-size: 14px;
line-height: 18px;
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+80
View File
@@ -0,0 +1,80 @@
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<time.h>
#include<stdint.h>
Q unsigned d; Q char E; Q int k;
Q long u; Q size_t t; Q const char U;
#define L toupper
#define M SIZE_MAX-1
#ifndef S
#define S 38
#elif S < 38
#undef S
#define S 38
#elif S > M
#undef S
#define S M
#endif
#define l S-1
#define Y strlen
#define Z printf
#define K static
#define z do{
K E W[]="stqvvwxzwtzuvvryusuxvtrqsruxttrxvwqxq"; K E T[S]= {77,69,84,72,73,78,75,83,32,73,84,32,73,83,32,76,73,75,69,32,65,32,87,69,65,83,69,76,0} ;
K U C[]=" !\"&'(),.0123456789;?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
/*NO*/
K E P[2][sizeof(T)]; K t G=0;
#ifndef N
#define N 25
#elif N < 4
#undef N
#define N 3
#elif N > M
#undef N
#define N M
#endif
/*BLOB*/
K u R=1; K d D=0; K k X(k f,k t){ return (rand()%((t)-(f)+1)+(f)); }
K E c() {return C[X(0,(k)Y(C)-1)];%> Q struct x { E G[sizeof T];
t F; } x; K x O[N];
/* Special C main() handler (encapsulation): */
#define r(main) main
r(k main(k a, E **V)) { x x; E*b;
U *A=T; k h=0,s,q=0,m=0,y=0,n=N==97,J=0; t i,j,
/* prototype for special C parser H() below */
F H(); H(<% H(for (s = 1; s < a && *V[s++]; ) H(<%
H(E *v=V[s-1]; H(if (*v!='-'||h) H(g(o) w(f) H(
while (*++v) H(switch (*v) { w(case '-') h=1; g(f)
w(case 'r') H(if ((R=strtol(v+1,&b,0)) < 1 || R > 100)/*CODING*/
<% Z("mutation rate out of range\n") ; m=1); %> else m=0; g(f)
w(case 'q') q=1; Z("quiet output\n") ; g(f) w(case 'm') J=1;
g(f) w(default) g(f) %>); H(continue))); H(w(o) H(y=1;
H(i = Y(V<:s-1]); H(if(i > l) i=l; H( strncpy(T,V[s-1:>,i)
; H(T[i]='\0')))))))); })); }); H(H(if (n&&!y) for (j=0
; j<37; ++j) T[j]=W[j]-'A'); H(for ( ; *A && strchr(C, L(*A))
; ++A)); H(if (*A) <% Z("'%c' not in keyboard \"%s\"\n", *A,C)
; return 1; })/*THIS*/); H(srand((d)time(0)); memset(&x, 0, sizeof x);
memset(O,0,sizeof O)); H(Z(/*IS*/"target '%s'\n", T); H(Z(
"mutation rate %ld\n", R)); H(if((m=(m||J||N<4)))
Z("monkey at typewriter\n"); H(for ( j=0; j<N; ++j) H(for
(i=0; i<Y(T); ++i) O[j].G[i]=c())))); H(while (!D) { H(if (++
G==M) {Z("Too many attempts, blaming the monkey Eric even if "
"he isn't typing or doesn't exist. Bye.\n"); return 1; } H(for
(j=0; j<N&&!D; ++j) { F = 0;/*NOT*/ H(for (i =0; i < Y(T); ++i)) { H(
if (L(O[j].G[i]) == L(T[i]))) ++F; } /*A*/ O[j].F=F; H(if (((D=(F==Y(T)))
||G==1)&&(!q||D)) Z("Generation %4zu\tOffspring %2zu: %s\n",G
-1,j+1,O[j] .G); })); H(if (D)break;); s=0; /*COMPACT*/ H(if (m) g(p) else H(z
s=1; H(for(i=0; i<N-1; ++i) { H(if (O<:i].F >= O[i+1].F) g(h)) x=O[
i+1:>; O[i]=O[i+1]; O[i+1]=x; s=0; w(h); }); }while(!s))); w(p
) H(strcpy(P[0],O[0].G); strcpy(P[1],O[1].G)); H(for (j=0; j<N; ++j)
{ H(for (i=0;!m&&i<Y(T); ++i) H(if ( X(0,9)<5) O[j] .
G[i]=P[0][i]); H(else O[j] . G[i]=P[1][i];)); /*BLOB*/ H(if (!
q) Z("Generation %4zu\tOffspring %2zu: %s -> " ,G,j+1,O[j].
G); H(for/*OF*/ (i=0; i<Y(T); ++i) { H(if (X(1,100) <= R || m)
O[j].G[i]=c(); })); H(if (!q) Z("%s (%s)\n",O[j].G,m
?"monkey typing" : "mutation"))); /*OCTETS*/ }); H(if (!
q) Z("**\n")); })); return 0; }
+80
View File
@@ -0,0 +1,80 @@
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<time.h>
#include<stdint.h>
Q unsigned d; Q char E; Q int k;
Q long u; Q size_t t; Q const char U;
#define L toupper
#define M SIZE_MAX-1
#ifndef S
#define S 38
#elif S < 38
#undef S
#define S 38
#elif S > M
#undef S
#define S M
#endif
#define l S-1
#define Y strlen
#define Z printf
#define K static
#define z do{
K E W[]="stqvvwxzwtzuvvryusuxvtrqsruxttrxvwqxq"; K E T[S]= {77,69,84,72,73,78,75,83,32,73,84,32,73,83,32,76,73,75,69,32,65,32,87,69,65,83,69,76,0} ;
K U C[] =" !\"#$<%:>&'()*+,-./0123456789;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`{|}~";
/*NO*/
K E P[2][sizeof(T)]; K t G=0;
#ifndef N
#define N 25
#elif N < 4
#undef N
#define N 3
#elif N > M
#undef N
#define N M
#endif
/*BLOB*/
K u R=1; K d D=0; K k X(k f,k t){ return (rand()%((t)-(f)+1)+(f)); }
K E c() {return C[X(0,(k)Y(C)-1)];%> Q struct x { E G[sizeof T];
t F; } x; K x O[N];
/* Special C main() handler (encapsulation): */
#define r(main) main
r(k main(k a, E **V)) { x x; E*b;
U *A=T; k h=0,s,q=0,m=0,y=0,n=N==97,J=0; t i,j,
/* prototype for special C parser H() below */
F H(); H(<% H(for (s = 1; s < a && *V[s++]; ) H(<%
H(E *v=V[s-1]; H(if (*v!='-'||h) H(g(o) w(f) H(
while (*++v) H(switch (*v) { w(case '-') h=1; g(f)
w(case 'r') H(if ((R=strtol(v+1,&b,0)) < 1 || R > 100)/*CODING*/
<% Z("mutation rate out of range\n") ; m=1); %> else m=0; g(f)
w(case 'q') q=1; Z("quiet output\n") ; g(f) w(case 'm') J=1;
g(f) w(default) g(f) %>); H(continue))); H(w(o) H(y=1;
H(i = Y(V<:s-1]); H(if(i > l) i=l; H( strncpy(T,V[s-1:>,i)
; H(T[i]='\0')))))))); })); }); H(H(if (n&&!y) for (j=0
; j<37; ++j) T[j]=W[j]-'A'); H(for ( ; *A && strchr(C, L(*A))
; ++A)); H(if (*A) <% Z("'%c' not in keyboard \"%s\"\n", *A,C)
; return 1; })/*THIS*/); H(srand((d)time(0)); memset(&x, 0, sizeof x);
memset(O,0,sizeof O)); H(Z(/*IS*/"target '%s'\n", T); H(Z(
"mutation rate %ld\n", R)); H(if((m=(m||J||N<4)))
Z("monkey at typewriter\n"); H(for ( j=0; j<N; ++j) H(for
(i=0; i<Y(T); ++i) O[j].G[i]=c())))); H(while (!D) { H(if (++
G==M) {Z("Too many attempts, blaming the monkey Eric even if "
"he isn't typing or doesn't exist. Bye.\n"); return 1; } H(for
(j=0; j<N&&!D; ++j) { F = 0;/*NOT*/ H(for (i =0; i < Y(T); ++i)) { H(
if (L(O[j].G[i]) == L(T[i]))) ++F; } /*A*/ O[j].F=F; H(if (((D=(F==Y(T)))
||G==1)&&(!q||D)) Z("Generation %4zu\tOffspring %2zu: %s\n",G
-1,j+1,O[j] .G); })); H(if (D)break;); s=0; /*COMPACT*/ H(if (m) g(p) else H(z
s=1; H(for(i=0; i<N-1; ++i) { H(if (O<:i].F >= O[i+1].F) g(h)) x=O[
i+1:>; O[i]=O[i+1]; O[i+1]=x; s=0; w(h); }); }while(!s))); w(p
) H(strcpy(P[0],O[0].G); strcpy(P[1],O[1].G)); H(for (j=0; j<N; ++j)
{ H(for (i=0;!m&&i<Y(T); ++i) H(if ( X(0,9)<5) O[j] .
G[i]=P[0][i]); H(else O[j] . G[i]=P[1][i];)); /*BLOB*/ H(if (!
q) Z("Generation %4zu\tOffspring %2zu: %s -> " ,G,j+1,O[j].
G); H(for/*OF*/ (i=0; i<Y(T); ++i) { H(if (X(1,100) <= R || m)
O[j].G[i]=c(); })); H(if (!q) Z("%s (%s)\n",O[j].G,m
?"monkey typing" : "mutation"))); /*OCTETS*/ }); H(if (!
q) Z("**\n")); })); return 0; }
+80
View File
@@ -0,0 +1,80 @@
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<time.h>
#include<stdint.h>
Q unsigned d; Q char E; Q int k;
Q long u; Q size_t t; Q const char U;
#define L toupper
#define M SIZE_MAX-1
#ifndef S
#define S 38
#elif S < 38
#undef S
#define S 38
#elif S > M
#undef S
#define S M
#endif
#define l S-1
#define Y strlen
#define Z printf
#define K static
#define z do{
K E W[]="stqvvwxzwtzuvvryusuxvtrqsruxttrxvwqxq"; K E T[S]= {77,69,84,72,73,78,75,83,32,73,84,32,73,83,32,76,73,75,69,32,65,32,87,69,65,83,69,76,0} ;
K U C[] =" !\"#$<%:>&'()*+,-./0123456789;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`{|}~";
/*NO*/
K E P[2][sizeof(T)]; K t G=0;
#ifndef N
#define N 25
#elif N < 4
#undef N
#define N 3
#elif N > M
#undef N
#define N M
#endif
/*BLOB*/
K u R=1; K d D=0; K k X(k f,k t){ return (rand()%((t)-(f)+1)+(f)); }
K E c() {return C[X(0,(k)Y(C)-1)];%> Q struct x { E G[sizeof T];
t F; } x; K x O[N];
/* Special C main() handler (encapsulation): */
#define r(main) main
r(k main(k a, E **V)) { x x; E*b;
U *A=T; k h=0,s,q=0,m=0,y=0,n=N==97,J=0; t i,j,
/* prototype for special C parser H() below */
F H(); H(<% H(for (s = 1; s < a && *V[s++]; ) H(<%
H(E *v=V[s-1]; H(if (*v!='-'||h) H(g(o) w(f) H(
while (*++v) H(switch (*v) { w(case '-') h=1; g(f)
w(case 'r') H(if ((R=strtol(v+1,&b,0)) < 1 || R > 100)/*CODING*/
<% Z("mutation rate out of range\n") ; m=1); %> else m=0; g(f)
w(case 'q') q=1; Z("quiet output\n") ; g(f) w(case 'm') J=1;
g(f) w(default) g(f) %>); H(continue))); H(w(o) H(y=1;
H(i = Y(V<:s-1]); H(if(i > l) i=l; H( strncpy(T,V[s-1:>,i)
; H(T[i]='\0')))))))); })); }); H(H(if (n&&!y) for (j=0
; j<37; ++j) T[j]=W[j]-'A'); H(for ( ; *A && strchr(C, L(*A))
; ++A)); H(if (*A) <% Z("'%c' not in keyboard \"%s\"\n", *A,C)
; return 0; })/*THIS*/); H(srand((d)time(0)); memset(&x, 0, sizeof x);
memset(O,0,sizeof O)); H(Z(/*IS*/"target '%s'\n", T); H(Z(
"mutation rate %ld\n", R)); H(if((m=(m||J||N<4)))
Z("monkey at typewriter\n"); H(for ( j=0; j<N; ++j) H(for
(i=0; i<Y(T); ++i) O[j].G[i]=c())))); H(while (!D) { H(if (++
G==M) {Z("Too many attempts, blaming the monkey Eric even if "
"he isn't typing or doesn't exist. Bye.\n"); return 1; } H(for
(j=0; j<N&&!D; ++j) { F = 0;/*NOT*/ H(for (i =0; i < Y(T); ++i)) { H(
if (L(O[j].G[i]) == L(T[i]))) ++F; } /*A*/ O[j].F=F; H(if (((D=(F==Y(T)))
||G==1)&&(!q||D)) Z("Generation %4zu\tOffspring %2zu: %s\n",G
-1,j+1,O[j] .G); })); H(if (D)break;); s=0; /*COMPACT*/ H(if (m) g(p) else H(z
s=1; H(for(i=0; i<N-1; ++i) { H(if (O<:i].F >= O[i+1].F) g(h)) x=O[
i+1:>; O[i]=O[i+1]; O[i+1]=x; s=0; w(h); }); }while(!s))); w(p
) H(strcpy(P[0],O[0].G); strcpy(P[1],O[1].G)); H(for (j=0; j<N; ++j)
{ H(for (i=0;!m&&i<Y(T); ++i) H(if ( X(0,9)<5) O[j] .
G[i]=P[0][i]); H(else O[j] . G[i]=P[1][i];)); /*BLOB*/ H(if (!
q) Z("Generation %4zu\tOffspring %2zu: %s -> " ,G,j+1,O[j].
G); H(for/*OF*/ (i=0; i<Y(T); ++i) { H(if (X(1,100) <= R || m)
O[j].G[i]=c(); })); H(if (!q) Z("%s (%s)\n",O[j].G,m
?"monkey typing" : "mutation"))); /*OCTETS*/ }); H(if (!
q) Z("**\n")); })); return 0; }
+36
View File
@@ -0,0 +1,36 @@
What? Install an IOCCC entry? I realise it seems odd so why did I make a rpm
spec file and why did I hint at building RPMs for others? I can't say precisely;
**certainly I'm under no impression that anyone else will want to use it** *but
the entry was fun enough for me that I actually will* (a number of my programs
over the years are programs I actually install and I already have done so with
this entry). I already have my own RPM repository and initially after having won
I set it up so that I could host the weasel rpm (binary and source) there. At
the same time though I feel the entry belongs on the IOCCC website; that is to
say the only place the raw files should be downloadable from is the IOCCC
website itself. Simon Cooper (the judge who deals with setting up the entries on
the IOCCC website) asked me if there is any real attachment in having the RPM
built as part of the entry and the answer is 'no'. He did suggest too that if
I were to have the RPM hosted on the IOCCC website not only would it place a
burden on me to keep it up to date but it would place a burden on the judges -
in other words he himself. Even if it wasn't a burden to me I agree on the other
part and so I have instead come to the following ideas:
* I will not host the actual source code or scripts on my website; they will
remain on the IOCCC website. This will most likely never change; instead I would
link to the entry directory so that they remain where they belong: the IOCCC
website itself. I have set up an [errata page][] however should there be anything
requiring a fix.
* I am keeping the weasel.spec file in the entry as it was part of my
submission but I do not explain here how to set up the build environment or how
to build a RPM: if you know how to use **`rpmbuild`** then you should be able to
work it out.
* Because I strongly suspect I am the only one who has any desire for actually
installing an IOCCC entry I will not worry about setting up a repository; if I
do set up a repository in the future I will include information on it somewhere
at [https://ioccc.xexyl.net/2018/weasel][].
[errata page]: https://ioccc.xexyl.net/2018/weasel/errata
[https://ioccc.xexyl.net/2018/weasel]: https://ioccc.xexyl.net/2018/weasel
+8
View File
@@ -0,0 +1,8 @@
YOU ARE LIKE A WEASEL
YOU SMELL LIKE A WEASEL
YOU ARE A WEASEL
I AM THE WEASEL
I AM THE WALRUS
YOU ARE THE WALRUS
YOU ARE THE WEASEL
PAULINE HANSEN ACTS LIKE A WEASEL
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
# Make sure the program has been compiled
make weasel 1> /dev/null|| exit 1
while read f; do
./weasel $* "${f}" # full line because of quotes
# ./weasel $* $f would just be the final word
sleep 2
done < test-strings.txt || exit 1
echo "All done. Goodbye."
+192
View File
@@ -0,0 +1,192 @@
.TH weasel 1 "20 February 2018" "weasel" "IOCCC 2018"
.SH NAME
weasel \- The IOCCC 2018 Implementation of Richard Dawkins's Weasel program
.SH SYNOPSIS
\fBweasel\fP [\fI\-r<rate>\fP] [\fI\-m\fP] [\fI\-q\fP] [\fI<chromosomal string>\fP]
.PP
\fBweasel\-simple\fP [\fI\-r<rate>\fP] [\fI\-m\fP] [\fI\-q\fP] [\fI<chromosomal string>\fP]
.SH DESCRIPTION
\fBweasel\fP is an obfuscated implementation of Richard Dawkins' \fIWeasel program\fP.
According to Wikipedia in chapter three of his book \fIThe Blind Watchmaker\fP Dawkins wrote:
.PP
.RS
I don't know who it was first pointed out that, given enough time,
a monkey bashing away at random on a typewriter could produce all
the works of Shakespeare. The operative phrase is, of course, given
enough time. Let us limit the task facing our monkey somewhat.
Suppose that he has to produce, not the complete works of Shakespeare
but just the short sentence 'Methinks it is like a weasel', and we
shall make it relatively easy by giving him a typewriter with a
restricted keyboard, one with just the 26 (capital) letters, and
a space bar. How long will he take to write this one little sentence?
.RE
.PP
He refers to the \fIInfinite Monkey Theorem\fP in particular and as he
points out it is \fBgiven enough time.\fP The weasel program uses a \fIgenetic
algorithm (GA)\fP to intelligently come to a conclusion but this implementation
has several additions: \fBtwo Easter eggs,\fP a \fBquiet output mode,\fP
an \fBoption to change the mutation rate\fP as well as the ability to
\fBspecify the chromosomal string.\fP
Furthermore the keyboard isn't as limited as Dawkins's implementation.
The \fBweasel\-simple\fP keyboard is a more limited keyboard but not
as limited as Dawkins's Weasel program keyboard.
.SH OPTIONS
.PP
\fB\-r\fP\fI<rate>\fP
This sets the mutation rate to \fI<rate>\fP; valid range is 1 through 100.
Anything outside this range will disable the genetic algorithm and simulate
a monkey in front of a typewriter.
If a valid mutation rate is set after this then the monkey typewriter mode
will be disabled but if monkey mode has been explicitly requested by the
\fB\-m\fP option the mutation rate is ignored.
Note that there cannot be a space between the \fB\-r\fP and \fI<rate>\fP.
The default is 1; valid range is >= 1 && <= 100.
.PP
\fB\-m\fP
Set monkey mode. This disables the genetic algorithm and is disables the
mutation rate entirely; instead it will pseudo-randomly select a character
from the keyboard in every offspring for every generation and selection
will not take place: parents are simply the first two offspring
regardless of their fitness score. Once this is enabled you
cannot disable it: be wary of the typing monkeys!
.PP
\fB\-q\fP
Quiet output.
Only display settings like mutation rate, quiet output,
target string and the final answer - if it comes to one.
Just like monkey mode you cannot disable this once it's been enabled.
.PP
\fB--\fP
Disable parsing of additional options (but not target strings); see
.B EXAMPLES
for a subtle point.
.SH EXIT STATUS
On error of any kind (including reaching the maximum number of attempts)
return 1; otherwise return 0.
.SH BUGS
Bugs? What's this? :) Any bugs are actually insolent monkeys tampering
with the program! But if you insist I do include errata on my website.
.SH EXAMPLES
.PP
\fBweasel\fP
.PP
.NF
Using the GA with the default mutation rate of 1 and output mode (verbose)
look for the default string in Hawkins's Weasel program; note that in
all cases the string to be found is capitalised.
.FI
.PP
\fBweasel \-qr5
weasel \-q \-r5\fP
.NF
.PP
Enables quiet output and sets a mutation rate of 5.
.PP
.FI
\fBweasel \-rqr10\fP
.NF
.PP
First sets an invalid mutation rate, then enables quiet output and
finally sets (a valid) mutation rate of 10.
.FI
.PP
.NF
\fBweasel \-m 'I AM A MONKEY TYPING'\fP
.PP
.FI
Simulate a monkey typing at the typewriter trying to type out the
string \fBI AM A MONKEY TYPING\fP without quotes. Note that this will
take some time almost assuredly and you might fall asleep before
the monkey succeeds. Here you would see all the attempts because
quiet output was not requested.
.PP
\fBweasel I AM NOT A MONKEY\fP
.PP
.NF
Using the GA find the final string specified (this always happens);
because the string wasn't quoted the program will have seen each word
as a separate argument and thus it would search for \fBMONKEY\fP.
.FI
.PP
\fBweasel '"WEASEL"'\fP
.PP
.NF
Search for the string \fB"WEASEL"\fP including double quotes ("s).
.FI
.PP
\fBweasel "'WEASEL'"\fP
.PP
.NF
Search for the string \fB'WEASEL'\fP including the single quotes ('s).
.FI
.PP
\fBweasel \-q \-r5 \-\- \-r10\fP
.PP
.NF
Enable quiet output, set mutation rate to 5, disable further option parsing
and set target string to \fB-r10\fP (literally because option parsing was disabled).
.FI
.PP
\fBweasel \-r5\-q \-\- \-r10\fP
.PP
Set mutation rate to 5, enable quiet output, disable further parsing of
options and set target string to \fB-r10\fP (literally - because option parsing
was disabled as above). Observe that here the \fB-r5-q\fP doesn't prevent the
quiet output from being enabled; on the other hand the options
\fB-r5- -q -- -r10\fP would!
.RE
.SH FILES
\fI/usr/src/weasel/weasel.c\fP
.RS
The source code to the \fBweasel\fP program.
.RE
.PP
\fI/usr/src/weasel/weasel\-simple.c\fP
.RS
The source code to the \fBweasel-simple\fP program.
.RE
.PP
\fI/usr/src/weasel/Makefile\fP
.RS
The Makefile to compile the source code should you wish to compile the
source code files.
.RE
.PP
\fI/usr/src/weasel/test.sh\fP
.RS
A test script that demonstrates the weasel program (this script is used
by \fBmake test\fP) by reading in strings, one at a time, and invoking
the program with that string as the target chromosome. See the
\fIhint.text\fP or \fIhint.html\fP for more details on using this script.
.RE
.PP
\fI/usr/src/weasel/test-strings.txt\fP
.RS
The data file the \fItest.sh\fP script reads strings from.
.RE
.PP
\fI/usr/share/doc/weasel/weasel.html\fP, \fI/usr/share/doc/weasel/weasel.markdown\fP
.RS
More detailed documentation.
.RE
.SH HINTS
The IOCCC judges in 2018 asked the following in the guidelines:
.RS
.PP
\fBBTW: What is so special about 2305567963945518424753102147331756070? You tell us!\fP
.RE
.PP
It is the primorial prime of 97; but can you find a way to get the program
to by default search for this number instead? You might need the source code to
find it!
.SH SEE ALSO
.NF
<\fBhttps://ioccc.xexyl.net/2018/weasel\fP>
.PP
<\fBhttps://en.wikipedia.org/wiki/Infinite_monkey_theorem\fP>
.PP
<\fBhttps://en.wikipedia.org/wiki/Weasel_program\fP>
.PP
<\fBhttp://www.doc.ic.ac.uk/~nd/surprise_96/journal/vol1/hmw/article1.html\fP>
.SH AUTHOR
Cody Boone Ferguson <\fBweasel@xexyl.net\fP>
+192
View File
@@ -0,0 +1,192 @@
.TH weasel 1 "20 February 2018" "weasel" "IOCCC 2018"
.SH NAME
weasel \- The IOCCC 2018 Implementation of Richard Dawkins's Weasel program
.SH SYNOPSIS
\fBweasel\fP [\fI\-r<rate>\fP] [\fI\-m\fP] [\fI\-q\fP] [<\fIchromosomal string\fP>]
.PP
\fBweasel\-simple\fP [\fI\-r<rate>\fP] [\fI\-m\fP] [\fI\-q\fP] [<\fIchromosomal string\fP>]
.SH DESCRIPTION
\fBweasel\fP is an obfuscated implementation of Richard Dawkins' \fIWeasel program\fP.
According to Wikipedia in chapter three of his book \fIThe Blind Watchmaker\fP Dawkins wrote:
.PP
.RS
I don't know who it was first pointed out that, given enough time,
a monkey bashing away at random on a typewriter could produce all
the works of Shakespeare. The operative phrase is, of course, given
enough time. Let us limit the task facing our monkey somewhat.
Suppose that he has to produce, not the complete works of Shakespeare
but just the short sentence 'Methinks it is like a weasel', and we
shall make it relatively easy by giving him a typewriter with a
restricted keyboard, one with just the 26 (capital) letters, and
a space bar. How long will he take to write this one little sentence?
.RE
.PP
He refers to the \fIInfinite Monkey Theorem\fP in particular and as he
points out it is \fBgiven enough time.\fP The weasel program uses a \fIgenetic
algorithm (GA)\fP to intelligently come to a conclusion but this implementation
has several additions: \fBtwo Easter eggs,\fP a \fBquiet output mode,\fP
an \fBoption to change the mutation rate\fP as well as the ability to
\fBspecify the chromosomal string.\fP
Furthermore the keyboard isn't as limited as Dawkins's implementation.
The \fBweasel\-simple\fP keyboard is a more limited keyboard but not
as limited as Dawkins's Weasel program keyboard.
.SH OPTIONS
.PP
\fB\-r\fP\fI<rate>\fP
This sets the mutation rate to \fI<rate>\fP; valid range is 1 through 100.
Anything outside this range will disable the genetic algorithm and simulate
a monkey in front of a typewriter.
If a valid mutation rate is set after this then the monkey typewriter mode
will be disabled but if monkey mode has been explicitly requested by the
\fB\-m\fP option the mutation rate is ignored.
Note that there cannot be a space between the \fB\-r\fP and \fI<rate>\fP.
The default is 1; valid range is >= 1 && <= 100.
.PP
\fB\-m\fP
Set monkey mode. This disables the genetic algorithm and is disables the
mutation rate entirely; instead it will pseudo-randomly select a character
from the keyboard in every offspring for every generation and selection
will not take place: parents are simply the first two offspring
regardless of their fitness score. Once this is enabled you
cannot disable it: be wary of the typing monkeys!
.PP
\fB\-q\fP
Quiet output.
Only display settings like mutation rate, quiet output,
target string and the final answer - if it comes to one.
Just like monkey mode you cannot disable this once it's been enabled.
.PP
\fB--\fP
Disable parsing of additional options (but not target strings); see
.B EXAMPLES
for a subtle point.
.SH EXIT STATUS
On error of any kind (including reaching the maximum number of attempts)
return 1; otherwise return 0.
.SH BUGS
Bugs? What's this? :) Any bugs are actually insolent monkeys tampering
with the program! But if you insist I do include errata on my website.
.SH EXAMPLES
.PP
\fBweasel\fP
.PP
.NF
Using the GA with the default mutation rate of 1 and output mode (verbose)
look for the default string in Hawkins's Weasel program; note that in
all cases the string to be found is capitalised.
.FI
.PP
\fBweasel \-qr5
weasel \-q \-r5\fP
.NF
.PP
Enables quiet output and sets a mutation rate of 5.
.PP
.FI
\fBweasel \-rqr10\fP
.NF
.PP
First sets an invalid mutation rate, then enables quiet output and
finally sets (a valid) mutation rate of 10.
.FI
.PP
.NF
\fBweasel \-m 'I AM A MONKEY TYPING'\fP
.PP
.FI
Simulate a monkey typing at the typewriter trying to type out the
string \fBI AM A MONKEY TYPING\fP without quotes. Note that this will
take some time almost assuredly and you might fall asleep before
the monkey succeeds. Here you would see all the attempts because
quiet output was not requested.
.PP
\fBweasel I AM NOT A MONKEY\fP
.PP
.NF
Using the GA find the final string specified (this always happens);
because the string wasn't quoted the program will have seen each word
as a separate argument and thus it would search for \fBMONKEY\fP.
.FI
.PP
\fBweasel '"WEASEL"'\fP
.PP
.NF
Search for the string \fB"WEASEL"\fP including double quotes ("s).
.FI
.PP
\fBweasel "'WEASEL'"\fP
.PP
.NF
Search for the string \fB'WEASEL'\fP including the single quotes ('s).
.FI
.PP
\fBweasel \-q \-r5 \-\- \-r10\fP
.PP
.NF
Enable quiet output, set mutation rate to 5, disable further option parsing
and set target string to \fB-r10\fP (literally because option parsing was disabled).
.FI
.PP
\fBweasel \-r5\-q \-\- \-r10\fP
.PP
Set mutation rate to 5, enable quiet output, disable further parsing of
options and set target string to \fB-r10\fP (literally - because option parsing
was disabled as above). Observe that here the \fB-r5-q\fP doesn't prevent the
quiet output from being enabled; on the other hand the options
\fB-r5- -q -- -r10\fP would!
.RE
.SH FILES
\fIprog.c\fP
.RS
The source code to the \fBweasel\fP program.
.RE
.PP
\fIprog\-simple.c\fP
.RS
The source code to the \fBweasel-simple\fP program.
.RE
.PP
\fIMakefile\fP
.RS
The Makefile to compile the source code should you wish to compile the
source code files.
.RE
.PP
\fItest.sh\fP
.RS
A test script that demonstrates the weasel program (this script is used
by \fBmake test\fP) by reading in strings, one at a time, and invoking
the program with that string as the target chromosome. See the
\fIhint.text\fP or \fIhint.html\fP for more details on using this script.
.RE
.PP
\fItest-strings.txt\fP
.RS
The data file the \fItest.sh\fP script reads strings from.
.RE
.PP
\fIhint.html\fP, \fIhint.text\fP
.RS
More detailed documentation.
.RE
.SH HINTS
The IOCCC judges in 2018 asked the following in the guidelines:
.RS
.PP
\fBBTW: What is so special about 2305567963945518424753102147331756070? You tell us!\fP
.RE
.PP
It is the primorial prime of 97; but can you find a way to get the program
to by default search for this number instead? You might need the source code to
find it!
.SH SEE ALSO
.NF
<\fBhttps://ioccc.xexyl.net/2018/weasel\fP>
.PP
<\fBhttps://en.wikipedia.org/wiki/Infinite_monkey_theorem\fP>
.PP
<\fBhttps://en.wikipedia.org/wiki/Weasel_program\fP>
.PP
<\fBhttp://www.doc.ic.ac.uk/~nd/surprise_96/journal/vol1/hmw/article1.html\fP>
.SH AUTHOR
Cody Boone Ferguson <\fBweasel@xexyl.net\fP>
+76
View File
@@ -0,0 +1,76 @@
%global debug_package %{nil}
Name: weasel
Version: 0.0.1
Release: 3%{?dist}
Summary: Implementation of Richard Dawkins's Weasel program
License: Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
URL: http://ioccc.xexyl.net/weasel
Source0: weasel.tar.bz2
BuildRequires: gcc make
AutoReq: 1
%description
It is an implementation of Richard Dawkins' Weasel program. According
to Wikipedia in chapter three of his book The Blind Watchmaker
Dawkins wrote:
I don't know who it was first pointed out that, given enough time,
a monkey bashing away at random on a typewriter could produce all
the works of Shakespeare. The operative phrase is, of course,
given enough time. Let us limit the task facing our monkey
somewhat. Suppose that he has to produce, not the complete works
of Shakespeare but just the short sentence
'Methinks it is like a weasel',
and we shall make it relatively easy by giving him a typewriter
with a restricted keyboard, one with just the 26 (capital) letters,
and a space bar. How long will he take to write this one little
sentence?
This version has some additional features like a more complicated
keyboard, a couple Easter eggs and the ability to change the target
string amongst others. See weasel(1) for more information.
%prep
%setup -n weasel
%build
make weasel weasel-simple
mv -f hint.txt hint.text 2>/dev/null || :
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_bindir} $RPM_BUILD_ROOT%{_usrsrc}/weasel
install -p -m 755 weasel $RPM_BUILD_ROOT%{_bindir}/weasel
install -p -m 755 weasel-simple $RPM_BUILD_ROOT%{_bindir}/weasel-simple
install -p -m 755 test.sh $RPM_BUILD_ROOT%{_usrsrc}/weasel/test.sh
install -m 644 test-strings.txt $RPM_BUILD_ROOT%{_usrsrc}/weasel/test-strings.txt
install -m 644 prog.c -D $RPM_BUILD_ROOT%{_usrsrc}/weasel/weasel.c
ln -s weasel.c $RPM_BUILD_ROOT%{_usrsrc}/weasel/prog.c
install -m 644 Makefile -D $RPM_BUILD_ROOT%{_usrsrc}/weasel
install -m 644 prog-simple.c -D $RPM_BUILD_ROOT%{_usrsrc}/weasel/weasel-simple.c
ln -s weasel-simple.c $RPM_BUILD_ROOT%{_usrsrc}/weasel/prog-simple.c
install -m 644 weasel.1 -D $RPM_BUILD_ROOT%{_mandir}/man1/weasel.1
install -m 644 hint.html -D $RPM_BUILD_ROOT%{_docdir}/weasel/weasel.html
install -m 644 hint.text -D $RPM_BUILD_ROOT%{_docdir}/weasel/weasel.markdown
install -m 644 hint.css -D $RPM_BUILD_ROOT%{_docdir}/weasel/hint.css
install -m 644 FILES -D $RPM_BUILD_ROOT%{_docdir}/weasel/FILES
%files
%{_bindir}/weasel*
%{_usrsrc}/weasel/*
%doc
%{_mandir}/man1/*
%{_docdir}/weasel/*
%changelog
* Tue May 01 2018 Cody Ferguson <weasel@xexyl.net> 0.0.1-3
- Add FILES file.
* Mon Apr 30 2018 Cody Ferguson <weasel@xexyl.net> 0.0.1-2
- General fixes.
* Mon Apr 16 2018 Cody Ferguson <ioccc@xexyl.net> 0.0.1-1
- Initial spec file.