<divclass="sourceCode"id="cb4"><preclass="sourceCode sh"><codeclass="sourceCode bash"><spanid="cb4-1"><ahref="#cb4-1"aria-hidden="true"tabindex="-1"></a><spanclass="bu">echo</span><spanclass="st">'Want to hear me beep?'</span><spanclass="kw">|</span><spanclass="ex">./prog</span><spanclass="op">></span> audio_file.raw</span>
<spanid="cb3-3"><ahref="#cb3-3"aria-hidden="true"tabindex="-1"></a><spanclass="co"># For those who believe in '"intelligent" design' or want to see how easy it is</span></span>
<spanid="cb3-4"><ahref="#cb3-4"aria-hidden="true"tabindex="-1"></a><spanclass="co"># to prove evolution is a proven fact:</span></span>
<spanid="cb3-7"><ahref="#cb3-7"aria-hidden="true"tabindex="-1"></a><spanclass="co"># For those who want to see if Eric the monkey can type the word 'words' before</span></span>
<spanid="cb3-8"><ahref="#cb3-8"aria-hidden="true"tabindex="-1"></a><spanclass="co"># falling asleep or giving up:</span></span>
<spanid="cb5-3"><ahref="#cb5-3"aria-hidden="true"tabindex="-1"></a><spanclass="co"># For those who believe in '"intelligent" design' or want to see how easy it is</span></span>
<spanid="cb5-4"><ahref="#cb5-4"aria-hidden="true"tabindex="-1"></a><spanclass="co"># to prove evolution is a proven fact:</span></span>
<spanid="cb5-7"><ahref="#cb5-7"aria-hidden="true"tabindex="-1"></a><spanclass="co"># For those who want to see if Eric the monkey can type the word 'words' before</span></span>
<spanid="cb5-8"><ahref="#cb5-8"aria-hidden="true"tabindex="-1"></a><spanclass="co"># falling asleep or giving up:</span></span>
<p>If you wanted <code>YOU ARE A MONKEY</code>:</p>
<divclass="sourceCode"id="cb16"><pre
<divclass="sourceCode"id="cb16"><pre
class="sourceCode sh"><codeclass="sourceCode bash"><spanid="cb16-1"><ahref="#cb16-1"aria-hidden="true"tabindex="-1"></a><spanclass="ex">./weasel</span><spanclass="st">"YOU ARE A MONKEY"</span></span>
<spanid="cb16-2"><ahref="#cb16-2"aria-hidden="true"tabindex="-1"></a><spanclass="ex">./weasel</span><spanclass="st">'YOU ARE A MONKEY'</span></span></code></pre></div>
<p>If you wanted <code>YOU ARE A MONKEY</code>:</p>
<divclass="sourceCode"id="cb17"><pre
<divclass="sourceCode"id="cb17"><pre
class="sourceCode sh"><codeclass="sourceCode bash"><spanid="cb17-1"><ahref="#cb17-1"aria-hidden="true"tabindex="-1"></a><spanclass="ex">./weasel</span><spanclass="st">"METHINKS IT IS A"</span><spanclass="st">"MONKEY"</span></span>
class="sourceCode sh"><codeclass="sourceCode bash"><spanid="cb17-1"><ahref="#cb17-1"aria-hidden="true"tabindex="-1"></a><spanclass="ex">./weasel</span><spanclass="st">"YOU ARE A MONKEY"</span></span>
<spanid="cb17-2"><ahref="#cb17-2"aria-hidden="true"tabindex="-1"></a><spanclass="ex">./weasel</span>METHINKS IT IS A MONKEY</span></code></pre></div>
<spanid="cb17-2"><ahref="#cb17-2"aria-hidden="true"tabindex="-1"></a><spanclass="ex">./weasel</span><spanclass="st">'YOU ARE A MONKEY'</span></span></code></pre></div>
<p>If you do one of:</p>
<divclass="sourceCode"id="cb18"><pre
class="sourceCode sh"><codeclass="sourceCode bash"><spanid="cb18-1"><ahref="#cb18-1"aria-hidden="true"tabindex="-1"></a><spanclass="ex">./weasel</span><spanclass="st">"METHINKS IT IS A"</span><spanclass="st">"MONKEY"</span></span>
<spanid="cb18-2"><ahref="#cb18-2"aria-hidden="true"tabindex="-1"></a><spanclass="ex">./weasel</span> METHINKS IT IS A MONKEY</span></code></pre></div>
<p><br/>
<p><br/>
It will search for <code>MONKEY</code> in both cases; in other words
It will search for <code>MONKEY</code> in both cases; in other words
it’s the last one. If the string is too long given the value of
it’s the last one. If the string is too long given the value of
@@ -479,14 +515,14 @@ truncated.</p>
<p>If you actually do want to search for a string starting with a
<p>If you actually do want to search for a string starting with a
<code>-</code> you must disable further parsing of options by using the
<code>-</code> you must disable further parsing of options by using the
<code>-</code> option itself; for example if you were to do any of:</p>
<code>-</code> option itself; for example if you were to do any of:</p>
<spanid="cb22-3"><ahref="#cb22-3"aria-hidden="true"tabindex="-1"></a><spanclass="ex">mutation</span> rate out of range</span>
<spanid="cb23-3"><ahref="#cb23-3"aria-hidden="true"tabindex="-1"></a><spanclass="ex">mutation</span> rate out of range</span>
<spanid="cb22-4"><ahref="#cb22-4"aria-hidden="true"tabindex="-1"></a><spanclass="ex">target</span><spanclass="st">'METHINKS IT IS LIKE A WEASEL'</span></span>
<spanid="cb23-4"><ahref="#cb23-4"aria-hidden="true"tabindex="-1"></a><spanclass="ex">target</span><spanclass="st">'METHINKS IT IS LIKE A WEASEL'</span></span>
<spanid="cb22-6"><ahref="#cb22-6"aria-hidden="true"tabindex="-1"></a><spanclass="ex">Generation</span> 440 Offspring 20: METHINKS IT IS LIKE A WEASEL</span></code></pre></div>
<spanid="cb23-6"><ahref="#cb23-6"aria-hidden="true"tabindex="-1"></a><spanclass="ex">Generation</span> 440 Offspring 20: METHINKS IT IS LIKE A WEASEL</span></code></pre></div>
<p>Similarly this would set quiet output, then an invalid mutation rate
<p>Similarly this would set quiet output, then an invalid mutation rate
<spanid="cb35-5"><ahref="#cb35-5"aria-hidden="true"tabindex="-1"></a><spanclass="st">'</span> not in keyboard <spanclass="st">" !"</span>#$<spanclass="op"><</span>%:<spanclass="op">>&</span><spanclass="st">'()*+,-./0123456789;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`{|}~"</span></span></code></pre></div>
<spanid="cb36-5"><ahref="#cb36-5"aria-hidden="true"tabindex="-1"></a><spanclass="st">'</span> not in keyboard <spanclass="st">" !"</span>#$<spanclass="op"><</span>%:<spanclass="op">>&</span><spanclass="st">'()*+,-./0123456789;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`{|}~"</span></span></code></pre></div>
<p>I showed that <code>'</code> is in the keyboard already; however the
<p>I showed that <code>'</code> is in the keyboard already; however the
user sent a <code>\n</code> (hence the secondary prompt
user sent a <code>\n</code> (hence the secondary prompt
<code>></code> on line two) before literally typing the closing
<code>></code> on line two) before literally typing the closing
@@ -793,9 +829,9 @@ read.</p>
(like <code>S</code>) as well as some C keywords.</p></li>
(like <code>S</code>) as well as some C keywords.</p></li>
<li><p>The way <code>main()</code> is declared is:</p></li>
<li><p>The way <code>main()</code> is declared is:</p></li>
</ol>
</ol>
<divclass="sourceCode"id="cb36"><preclass="sourceCode c"><codeclass="sourceCode c"><spanid="cb36-1"><ahref="#cb36-1"aria-hidden="true"tabindex="-1"></a><spanclass="co">/* Special C main() handler (encapsulation): */</span></span>
<divclass="sourceCode"id="cb37"><preclass="sourceCode c"><codeclass="sourceCode c"><spanid="cb37-1"><ahref="#cb37-1"aria-hidden="true"tabindex="-1"></a><spanclass="co">/* Special C main() handler (encapsulation): */</span></span>
<spanid="cb36-3"><ahref="#cb36-3"aria-hidden="true"tabindex="-1"></a>r<spanclass="op">(</span>k main<spanclass="op">(</span>k a<spanclass="op">,</span> E <spanclass="op">**</span>V<spanclass="op">))</span><spanclass="op">{</span></span></code></pre></div>
<spanid="cb37-3"><ahref="#cb37-3"aria-hidden="true"tabindex="-1"></a>r<spanclass="op">(</span>k main<spanclass="op">(</span>k a<spanclass="op">,</span> E <spanclass="op">**</span>V<spanclass="op">))</span><spanclass="op">{</span></span></code></pre></div>
<pre><code>It appears to be recursively defined but is it? And is it truly</code></pre>
<pre><code>It appears to be recursively defined but is it? And is it truly</code></pre>
<p>encapsulation? And is it executing code of any kind? It mightn’t seem
<p>encapsulation? And is it executing code of any kind? It mightn’t seem
like it isn’t encapsulation and also isn’t executing code but assuming
like it isn’t encapsulation and also isn’t executing code but assuming
@@ -852,18 +888,22 @@ wrong. Yes some of it might look like a blob but this is clearly false;
or misleading it should be made clear in the comments! :)</em></p>
or misleading it should be made clear in the comments! :)</em></p>
<h2id="how-to-build"><strong>5. <aname="build">How to
<h2id="how-to-build"><strong>5. <aname="build">How to
build</a></strong></h2>
build</a></strong></h2>
<h3id="s-and-n-constants"><aname="constants">S and N
<h3id="s-m-and-n-constants"><aname="constants">S, M and N
Constants</a></h3>
Constants</a></h3>
<p>Skip to <ahref="#compiling">Compilation</a>.</p>
<p>Skip to <ahref="#compiling">Compilation</a>.</p>
<p>These two<code>#define</code>d constants can be redefined at
<p>There are three<code>#define</code>d constants that can be redefined
compilation to modify the behaviour of the program in a number of ways
at compilation to modify the behaviour of the program in a number of
(see the <strong><ahref="#compiling">Compilation</a></strong>
ways (see the <strong><ahref="#compiling">Compilation</a></strong>
subsection for example invocations). Both are capped to be no greater
subsection for example invocations). Both are capped to be no greater
than <code>SIZE_MAX - 1</code>. This is handled by the C
than <code>SIZE_MAX - 1</code> or whatever <code>M</code> (which can’t
preprocessor.</p>
be lower than 100) is set to (maximum attempts before giving up). This
<p><code>S</code></p>
is handled by the C preprocessor.</p>
<p>This determines the maximum size of the target string but it
<ul>
<strong>must be at least 38</strong>; this is because
<li><code>S</code></li>
</ul>
<p>The macro <code>S</code> (or <code>MAX_SIZE</code> in the Makefile)
is the maximum size of the target string but it <strong>must be at least
38</strong> (which is protected against in the code); this is because
<code>38 >= 29</code> and because
<code>38 >= 29</code> and because
<code>strlen("METHINKS IT IS LIKE A WEASEL") == 28</code> (which is the
<code>strlen("METHINKS IT IS LIKE A WEASEL") == 28</code> (which is the
default target string - it would hardly be an implementation of the
default target string - it would hardly be an implementation of the
@@ -874,33 +914,58 @@ works</a></strong> and specifically an Easter egg I referenced there
(it’s <em>not the only Easter egg</em> but it’s the only Easter egg I
(it’s <em>not the only Easter egg</em> but it’s the only Easter egg I
won’t spoil; yes this ironically and amusingly means I’ve left a rotten
won’t spoil; yes this ironically and amusingly means I’ve left a rotten
egg somewhere!).</p>
egg somewhere!).</p>
<p><code>N</code></p>
<p>The Makefile simplifies how to reconfigure this value with the
<p>This is the number of offspring per generation. Anything less than 4
variable <code>MAX_SIZE</code>:</p>
will be set to 3 (that’s not a typo!) and this is part of an Easter
<spanid="cb41-2"><ahref="#cb41-2"aria-hidden="true"tabindex="-1"></a><spanclass="fu">clang</span> version 4.0.1 <spanclass="er">(</span><spanclass="ex">tags/RELEASE_401/final</span><spanclass="kw">)</span></span>
<spanid="cb46-2"><ahref="#cb46-2"aria-hidden="true"tabindex="-1"></a><spanclass="fu">clang</span> version 4.0.1 <spanclass="er">(</span><spanclass="ex">tags/RELEASE_401/final</span><spanclass="kw">)</span></span>
<spanid="cb41-4"><ahref="#cb41-4"aria-hidden="true"tabindex="-1"></a><spanclass="fu">gcc</span><spanclass="er">(</span><spanclass="ex">GCC</span><spanclass="kw">)</span><spanclass="ex">7.3.1</span> 20180130 <spanclass="er">(</span><spanclass="ex">Red</span> Hat 7.3.1-2<spanclass="kw">)</span></span>
<spanid="cb46-4"><ahref="#cb46-4"aria-hidden="true"tabindex="-1"></a><spanclass="fu">gcc</span><spanclass="er">(</span><spanclass="ex">GCC</span><spanclass="kw">)</span><spanclass="ex">7.3.1</span> 20180130 <spanclass="er">(</span><spanclass="ex">Red</span> Hat 7.3.1-2<spanclass="kw">)</span></span>
<spanid="cb41-6"><ahref="#cb41-6"aria-hidden="true"tabindex="-1"></a><spanclass="ex">GNU</span> C Library <spanclass="er">(</span><spanclass="ex">GNU</span> libc<spanclass="kw">)</span><spanclass="ex">stable</span> release version 2.25</span>
<spanid="cb46-6"><ahref="#cb46-6"aria-hidden="true"tabindex="-1"></a><spanclass="ex">GNU</span> C Library <spanclass="er">(</span><spanclass="ex">GNU</span> libc<spanclass="kw">)</span><spanclass="ex">stable</span> release version 2.25</span>
<spanid="cb42-2"><ahref="#cb42-2"aria-hidden="true"tabindex="-1"></a><spanclass="fu">clang</span> version 3.4.2 <spanclass="er">(</span><spanclass="ex">tags/RELEASE_34/dot2-final</span><spanclass="kw">)</span></span>
<spanid="cb47-2"><ahref="#cb47-2"aria-hidden="true"tabindex="-1"></a><spanclass="fu">clang</span> version 3.4.2 <spanclass="er">(</span><spanclass="ex">tags/RELEASE_34/dot2-final</span><spanclass="kw">)</span></span>
<spanid="cb42-4"><ahref="#cb42-4"aria-hidden="true"tabindex="-1"></a><spanclass="fu">gcc</span><spanclass="er">(</span><spanclass="ex">GCC</span><spanclass="kw">)</span><spanclass="ex">4.8.5</span> 20150623 <spanclass="er">(</span><spanclass="ex">Red</span> Hat 4.8.5-16<spanclass="kw">)</span></span>
<spanid="cb47-4"><ahref="#cb47-4"aria-hidden="true"tabindex="-1"></a><spanclass="fu">gcc</span><spanclass="er">(</span><spanclass="ex">GCC</span><spanclass="kw">)</span><spanclass="ex">4.8.5</span> 20150623 <spanclass="er">(</span><spanclass="ex">Red</span> Hat 4.8.5-16<spanclass="kw">)</span></span>
<spanid="cb42-6"><ahref="#cb42-6"aria-hidden="true"tabindex="-1"></a><spanclass="ex">GNU</span> C Library <spanclass="er">(</span><spanclass="ex">GNU</span> libc<spanclass="kw">)</span><spanclass="ex">stable</span> release version 2.17</span>
<spanid="cb47-6"><ahref="#cb47-6"aria-hidden="true"tabindex="-1"></a><spanclass="ex">GNU</span> C Library <spanclass="er">(</span><spanclass="ex">GNU</span> libc<spanclass="kw">)</span><spanclass="ex">stable</span> release version 2.17</span>
<spanid="cb43-2"><ahref="#cb43-2"aria-hidden="true"tabindex="-1"></a><spanclass="fu">clang</span> version 5.0.1 <spanclass="er">(</span><spanclass="ex">tags/RELEASE_501/final</span><spanclass="kw">)</span></span>
<spanid="cb48-2"><ahref="#cb48-2"aria-hidden="true"tabindex="-1"></a><spanclass="fu">clang</span> version 5.0.1 <spanclass="er">(</span><spanclass="ex">tags/RELEASE_501/final</span><spanclass="kw">)</span></span>
<spanid="cb43-4"><ahref="#cb43-4"aria-hidden="true"tabindex="-1"></a><spanclass="fu">gcc</span><spanclass="er">(</span><spanclass="ex">GCC</span><spanclass="kw">)</span><spanclass="ex">7.3.1</span> 20180303 <spanclass="er">(</span><spanclass="ex">Red</span> Hat 7.3.1-5<spanclass="kw">)</span></span>
<spanid="cb48-4"><ahref="#cb48-4"aria-hidden="true"tabindex="-1"></a><spanclass="fu">gcc</span><spanclass="er">(</span><spanclass="ex">GCC</span><spanclass="kw">)</span><spanclass="ex">7.3.1</span> 20180303 <spanclass="er">(</span><spanclass="ex">Red</span> Hat 7.3.1-5<spanclass="kw">)</span></span>
<spanid="cb43-6"><ahref="#cb43-6"aria-hidden="true"tabindex="-1"></a><spanclass="ex">GNU</span> C Library <spanclass="er">(</span><spanclass="ex">GNU</span> libc<spanclass="kw">)</span><spanclass="ex">stable</span> release version 2.26</span>
<spanid="cb48-6"><ahref="#cb48-6"aria-hidden="true"tabindex="-1"></a><spanclass="ex">GNU</span> C Library <spanclass="er">(</span><spanclass="ex">GNU</span> libc<spanclass="kw">)</span><spanclass="ex">stable</span> release version 2.26</span>
<spanid="cb44-3"><ahref="#cb44-3"aria-hidden="true"tabindex="-1"></a><spanclass="ex">Apple</span> LLVM version 9.1.0 <spanclass="er">(</span><spanclass="ex">clang-902.0.39.1</span><spanclass="kw">)</span></span>
<spanid="cb49-3"><ahref="#cb49-3"aria-hidden="true"tabindex="-1"></a><spanclass="ex">Apple</span> LLVM version 9.1.0 <spanclass="er">(</span><spanclass="ex">clang-902.0.39.1</span><spanclass="kw">)</span></span>
<spanid="cb44-8"><ahref="#cb44-8"aria-hidden="true"tabindex="-1"></a><spanclass="ex">Darwin</span> 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar 5 22:24:32 PST 2018<spanclass="kw">;</span><spanclass="ex">root:xnu-4570.51.1~1/RELEASE_X86_64</span> x86_64</span></code></pre></div>
<spanid="cb49-8"><ahref="#cb49-8"aria-hidden="true"tabindex="-1"></a><spanclass="ex">Darwin</span> 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar 5 22:24:32 PST 2018<spanclass="kw">;</span><spanclass="ex">root:xnu-4570.51.1~1/RELEASE_X86_64</span> x86_64</span></code></pre></div>
<h4id="an-aside"><aname="bugs">An aside</a></h4>
<h4id="an-aside"><aname="bugs">An aside</a></h4>
<p>Skip to <ahref="#rpm">Installing</a>.</p>
<p>Skip to <ahref="#rpm">Installing</a>.</p>
<p>Any undocumented bugs are the result of insolent monkeys tampering
<p>Any undocumented bugs are the result of insolent monkeys tampering
@@ -1082,8 +1147,8 @@ we quickly added additional cryptic features and evolved into B, BCPL,
and finally C. We stopped when we got a clean compile on the following
and finally C. We stopped when we got a clean compile on the following
<spanid="cb5-2"><ahref="#cb5-2"aria-hidden="true"tabindex="-1"></a><spanclass="co"># And watch closely for 15-20 seconds</span></span></code></pre></div>
<h2id="judges-remarks">Judges’ remarks:</h2>
<h2id="judges-remarks">Judges’ remarks:</h2>
<p>You may be tempted to use a mirror. Resist the temptation! Try
<p>You may be tempted to use a mirror. Resist the temptation! Try
figuring out how the clock hands are drawn. Can you change the program
figuring out how the clock hands are drawn. Can you change the program
@@ -142,7 +145,7 @@ second hand?</p>
your perception of time might depend on what time it is.</p>
your perception of time might depend on what time it is.</p>
<spanid="cb4-5"><ahref="#cb4-5"aria-hidden="true"tabindex="-1"></a><spanclass="co"># Play output2.mid with your favorite player</span></span></code></pre></div>
<h2id="judges-remarks">Judges’ remarks:</h2>
<h2id="judges-remarks">Judges’ remarks:</h2>
<p>In an entry that boasts not using literals, one would expect to see
<p>In an entry that boasts not using literals, one would expect to see
straightforward ways to produce small integers like
straightforward ways to produce small integers like
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.