From ccdd8133ed75da22a14b249e0d27f41adc904650 Mon Sep 17 00:00:00 2001
From: Landon Curt Noll
Winning thoughts: What it means to me to win as well as some dedications and thanks. Here too I include a link to a website which will be dedicated to this entry beyond what will be published on the IOCCC website.
-Skip to How it works.
It is an implementation of Richard Dawkins’ Weasel program (Wikipedia). According to Wikipedia in chapter three of his book The Blind Watchmaker @@ -312,7 +314,9 @@ more details.
algorithm) towards the solution of the stringMETHINKS IT IS LIKE A WEASEL
(note that I use toupper() so it doesn’t matter what case the input is the
comparison and output will always be capitalised).
-Skip to Hints.
Here you can find a general explanation of a genetic algorithm as well as a brief history. Although the link provides more information (including images to @@ -394,11 +398,11 @@ such a monkey isn’t typing or even doesn’t exist (because it’s not the ). So although the user might not be a monkey the program makes the assumption that the user could in fact be a monkey called Eric although it isn’t insolent enough to say the user is a monkey for certain!
-Skip to Obfuscation.
I noted that there are a number of additional features and here I will document some of them.
-Skip to Options.
The keyboard, as noted, has more than just the alphabet and space. To be
precise the following characters are acceptable; it equates to this in C (note
@@ -410,7 +414,7 @@ it includes a literal space ' ' but it doesn’t include other
The program makes sure that the target string only has characters the keyboard can actually produce but there is a certain type of input error that might appear to be a bug; see specifically Input Error Example.
-Skip to Spoilers.
There are a number of options you can pass to the program besides the target
string; some I will document here (the summary being in the man page). You can
@@ -517,7 +521,9 @@ itself) and then the target string would literally be set to -r
it no longer cares about the - for option parsing. In other words options
are only parsed if the first character is - and if the parser hasn’t seen
the - - in an earlier element of argv. This is not a bug!
Skip to Example Invocations.
The Easter egg: Since Dawkins references the Infinite Monkey Theorem it simulates a monkey using a typewriter! This mode has the following changes:
@@ -528,7 +534,9 @@ the string is of length 28 (the default) then all 28 characters in each offspring of each generation will be assigned a pseudo-randomly positioned character in the keyboard. If you want to enable this specially you can use the-m option (-m for monkey).
-Skip to Input Error Example.
The following examples are used to demonstrate better the command line parsing.
In order to do that though I had to first document the -m option because
@@ -645,10 +653,11 @@ has no parents; it is generation 1 that starts working towards the goal. You’l
see also (mutation) at the end of the line at this point (if you enable
monkey mode you’ll find that it shows something else). The lines that only have
are separators: you won't see this between generation 0 and 1 but you will between future generations - as well as the final answer (if the answer is in generation 0 you won't see the).
-One final thing to consider is that the program doesn’t directly read from a
+ One final thing to consider is that the program doesn’t directly read from a
file. This combined with the way the shell works could possibly confuse some
people. Take the following invocations: (1) $ echo test > test
(2) $ ./weasel test
(3) $ ./weasel < test
@@ -706,7 +715,9 @@ search for TEST. In other words if you want to pass options
script you will have to directly pass the options to the script like the above
example shows (but the strings will still only be read from the
test-strings.txt file).
Skip to Obfuscation.
There is a type of input error, as I said, that might appear to be a bug. What
actually is going on though is due to a technicality on how spaces are printed
@@ -730,7 +741,7 @@ invalid character ('\n' itself which means another line break) and
finally the closing '. Specifically isspace() characters aren’t
distinctly seen like a letter, digit or symbol is: isprint('\n') == 0 && isspace('\n') == 1. You can add these characters but the output will be
rather confusing and hard to read.
Skip to Beauty.
The following might be some of the techniques used in this entry:
@@ -772,7 +783,7 @@ code.In case you wondered deciphering #5 won’t decipher #7 (neither will deciphering #7 help you decipher #5).
-Skip to How to build.
On the subject of beauty: the judges stated in the guidelines the following:
We want to get away from source that is simply **a compact blob of
@@ -786,8 +797,12 @@ set your thinking straight:
some of it might look like a blob but this is clearly false; as all good
programmers know if something is potentially confusing or misleading it should
be made clear in the comments! :)
-5. How to build
-S, M and N Constants
+
+5. How to build
+
+
+S, M and N Constants
+
Skip to Compilation.
There are three #defined constants that can be redefined at compilation to modify the
behaviour of the program in a number of ways (see the
@@ -828,7 +843,9 @@ and the larger the values the more memory it’ll require.
The Makefile simplifies how to reconfigure this value with the variable
OFFSPRING:
make clobber OFFSPRING=55 all
-Compilation
+
+Compilation
+
Skip to Portability.
The following options must always be passed to the compiler:
-DQ='typedef' -D'g(o)'='goto o;' -D'w(x)'="x:" -D'H(main)'='r(main)'
@@ -844,7 +861,7 @@ result. Remember too that S (MAX_SIZE) cannot be less
N are capped at SIZE_MAX - 1 or whatever M (MAX_ATTEMPTS) is set to.
If you wanted to change the maximum number attempts to 100 you could do:
make clobber MAX_ATTEMPTS=100 everything
-Portability
+Portability
Skip to An aside on bugs.
This entry requires at least C99 even if you translate digraphs. The program
doesn’t require third-party libraries and should work on any Unix based system.
@@ -890,7 +907,9 @@ Kernel Version: Darwin 17.5.0
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ uname -srmv
Darwin 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar 5 22:24:32 PST 2018; root:xnu-4570.51.1~1/RELEASE_X86_64 x86_64
-Skip to Installing.
Any undocumented bugs are the result of insolent monkeys tampering with any number of things. That includes but is not limited to running the program on a @@ -904,12 +923,16 @@ and easy fashion if ever; or any other meddling including being petulant and/or unreasonable monkeys. I will say though that there is at least one place I see after having won that could be slightly more efficient (can you find it?); I am however leaving it as it is because this is what won.
-Skip to Final thoughts.
I have included a RPM spec file for those with a Red Hat based Linux distribution; see rpm.html for details (including why I implemented this) if for some (strange or maybe even mad) reason you’re interested.
-Skip to Winning comments.
The judges suggested that making them laugh helps entries chance of winning. Well laughter helps everything so in case you haven’t seen - and even if you @@ -919,7 +942,9 @@ that book) I include it below; because I agree that looking at a lot of twisted code must be quite difficult (though maybe not as much as if you were to have to look at Microsoft Windows code or code for Windows in any case ? :)) and these two things I think are rather amusing (in order of least to most):
-Dennis Ritchie’s Anti-Foreword:
+Dennis Ritchie’s Anti-Foreword:
+ Anti-Foreword
By Dennis Ritchie
@@ -966,7 +991,9 @@ two things I think are rather amusing (in order of least to most):
and since it doesn’t break his message it’s not broken - it’s just obfuscated
albeit not very much (and it still ‘compiles’!); and isn’t that what this
contest is about? :)
-Ken Thompson’s ending:
+
+Ken Thompson’s ending:
+
Creators Admit C, Unix Were Hoax
FOR IMMEDIATE RELEASE
@@ -1036,7 +1063,9 @@ I’m missing but either way it’s a funny piece. It could also be for irony it
(actually I had previously thought of somehow implementing something like that
for the contest but decided for the message by itself in the end). I would
prefer believing that whether true or not.
-7. Winning comments, thanks, dedications, links, etc.
+
+7. Winning comments, thanks, dedications, links, etc.
+
I feel incredibly honoured, privileged and I am extremely happy and proud to
have won! I am more proud and happy about this than anything I have ever done in
my life and I don’t think there can be anything else I can be more proud of in