Files
ioccc/2011/blakely/index.html
T
Landon Curt Noll c1466f5165 build index.html for all winners
Updated manifest as per recent file changes.

Updated winner `.winner.json` to reflect the manifest changes.

Added [bin/all_run.sh](bin/all_run.sh) tool to run a command over
all winning entries.

These tools had slight improvements in the help usage message:

* bin/gen-author.sh VERSION="1.3.1 2024-01-16"
* bin/gen-inventory.sh VERSION="1.0.1 2024-01-16"
* bin/pandoc_wrapper.sh VERSION="1.3.1 2024-01-16"
* bin/subst.default.sh VERSION="1.1.1 2024-01-16"
* bin/subst.winner-index.sh VERSION="1.1.1 2024-01-16"

The `bin/readme2index.sh` tool was improved so that
if the `index.html` file exists and the tool forms
the exact same content, then the file `index.html`
file is NOT touched.

* bin/readme2index.sh VERSION="1.1 2024-01-16"

We used the following command to generate `index.html` files
for all winning entries:

```sh
bin/all_run.sh -v 3 bin/readme2index.sh
```

NOTE: We have not (yet) built HTML files above the winner directory
level (e.g., no year level nor top level HTML), nor have be built
non-index HTML files for winners.

NOTE: By default we are running `pandoc(1)` with:

```
--fail-if-warnings=true
```

This means that any problems with markdown to HTML
generates an error.  This is done to be sure that
the HTML conversion is clean.

We had to fix the following `README.md` files:

* `2000/rince/README.md`

The reference [^2] was never used.  We made a guess that [^2] applies
to the same spot as [^1].  Perhaps there is a better spot where
[^2] applies?

NOTE: For every reference, there MUST be some place where that
reference is used.

* 2012/vik/README.md

The string "$...$" is assumed to be a TeX encoded string.

NOTE: Every "$..$" needs to be backslashed as in "\$..\$".

* 2018/burton1/README.md

The reference [2] was duplicated.  We changed the
second [2] to [3].

NOTE: Every reference needs to have a unique number.

* 2020/carlini/README.md

The string "$...$" is assumed to be a TeX encoded string.

NOTE: Every "$..$" needs to be backslashed as in "\$..\$".

We also found 2 errors in the `author/author_handle.json` file set:

* author/Anonymous_2001.json

The `author/Anonymous_2001.json` file was missing.

* author/Jari_Arkko.json

The winner ID for `1989_jar.1` had a typo.
2024-01-17 00:32:39 -08:00

377 lines
20 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- -->
<!-- This file was formed by the tool: bin/readme2index.sh version: 1.1 2024-01-16 -->
<!-- -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="/temp-test-ioccc/ioccc.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>2011/blakely</title>
<meta name="description" content="2011 IOCCC winner blakely">
<meta name="keywords" content="IOCCC, 2011, IOCCC 2011, IOCCC winner, blakely">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<img src="/temp-test-ioccc/png/ioccc.png" alt="IOCCC image by Matt Zucker" width=300 height=110>
<h1>The International Obfuscated C Code Contest</h1>
<h2>2011/blakely</h2>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.mid.html -->
<div class="topnav">
<a class="Left" href="../akari/index.html">&larr; akari</a>
<a class="Left" href="../index.html">&uarr; 2011 &uarr;</a>
<a class="Left" href="../borsanyi/index.html">borsanyi &rarr;</a>
<a class="Right" href="#inventory">Inventory</a>
</div>
<!-- END: this line ends content from: inc/topnav.mid.html -->
<!-- START: this line starts content from: inc/begin-row.default.html -->
<div class="row">
<!-- END: this line ends content from: inc/begin-row.default.html -->
<!-- START: this line starts content from: inc/begin-leftcolumn.default.html -->
<div class="leftcolumn">
<!-- END: this line ends content from: inc/begin-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/sidenav.default.html -->
<div class="sidenav">
<a href="#content">Jump to contents</a>
</div>
<hr>
<div class="sidenav">
<a href="/temp-test-ioccc/index.html">IOCCC Home</a>
<a href="/temp-test-ioccc/years.html">Winning Entries</a>
<a href="/temp-test-ioccc/winners.html">People who have won</a>
</div>
<hr>
<div class="sidenav">
<a href="/temp-test-ioccc/news.html">IOCCC News</a>
<a href="/temp-test-ioccc/faq.html#submit">How to enter the IOCCC</a>
<a href="/temp-test-ioccc/faq.html">FAQ</a>
</div>
<hr>
<div class="sidenav">
<a href="/temp-test-ioccc/bugs.html">Bugs &amp; (mis)features</a>
<a href="/temp-test-ioccc/faq.html#fix_a_winner">Fixing IOCCC winners</a>
<a href="/temp-test-ioccc/faq.html#fix_web_site">Fixing the web site</a>
<a href="/temp-test-ioccc/faq.html#fix_author">Fixing winner info</a>
<a href="/temp-test-ioccc/thanks-for-help.html">Thanks for the help</a>
</div>
<hr>
<div class="sidenav">
<a href="/temp-test-ioccc/judges.html">The IOCCC Judges</a>
<a href="/temp-test-ioccc/contact.html">Contacting the IOCCC</a>
</div>
<hr>
<div class="sidenav">
<a href="#top">Jump to top</a>
</div>
<!-- END: this line ends content from: inc/sidenav.default.html -->
<!-- START: this line starts content from: inc/end-leftcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/begin-rightcolumn.default.html -->
<div class="rightcolumn">
<!-- END: this line ends content from: inc/begin-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<a name="content"></a>
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content generated by: bin/gen-author.sh -->
<p><a name="author"><strong>Author:</strong></a> <br><br>Name: <a
href="/temp-test-ioccc/winners.html#Philip_Blakely">Philip
Blakely</a><br> Location: <a
href="/temp-test-ioccc/location.html#GB">GB</a></p>
<!-- END: next line ends content generated by: bin/gen-author.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
<h2 id="to-use">To use:</h2>
<p>Zoom out and make your terminal window 53 or more lines deep.</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./blakely</span> <span class="op">&lt;</span> blakely.c <span class="kw">|</span> <span class="fu">head</span> <span class="at">-300</span></span></code></pre></div>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
<p>For those who have a lot of time, try:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./blakely</span> <span class="op">&lt;</span> t0_3.dat</span></code></pre></div>
<p>though one might or might not need to kill it, depending on your
boredom threshold.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>This program plays <a
href="https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life">Life</a>
(see also <a href="https://conwaylife.com">here</a>), computes Pi to 16
digits if given its own source as input, and allows to check if your
garden is a <a
href="http://en.wikipedia.org/wiki/Garden_of_Eden_%28cellular_automaton%29">Garden
of Eden</a>, all in one source.</p>
<p>If you have enough time to spare, put the plan of your garden in a
text file, and run:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./blakely</span> <span class="at">-</span> <span class="op">&lt;</span> garden.txt</span></code></pre></div>
<h2 id="authors-remarks">Author’s remarks:</h2>
<p>This program uses a well-known algorithm in order to display pi to
fifteen decimal places. The source-layout itself demonstrates the
importance of using the correct amount of whitespace in code and the
clear superiority of spaces over tabs.</p>
<p>In order to see the main feature of the code, type:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./blakely</span> <span class="op">&lt;</span> blakely.c</span></code></pre></div>
<p>and wait for about four seconds before using Ctrl-C (or whatever) to
end the program. The results are best viewed in a terminal window at
least 60 characters high and wide. Alternatively, redirect the output to
a separate file (killing when necessary).</p>
<h3 id="overview">Overview</h3>
<p>The program emulates John Conway’s cellular automaton known as “<a
href="https://conwaylife.com">The Game of Life</a>”, using standard
input as a starting grid. The layout of the source-code is such that it
evolves to a digital representation of the first 15 decimal places of pi
after 4 time steps. This was setup using the other feature of the
program which can be demonstrated as follows:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./blakely</span> <span class="at">-</span> <span class="op">&lt;</span> 3.dat</span></code></pre></div>
<p>The program will first display the grid given in <a
href="3.dat">3.dat</a>, and then three more grids (taking a few minutes
to display the last). Waiting for any more grids will take a substantial
amount of time. The final grid has been put into <a
href="evolve_to_3.dat">evolve_to_3.dat</a>, and if you type</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./blakely</span> <span class="op">&lt;</span> evolve_to_3.dat</span></code></pre></div>
<p>then the 3 will reappear after three time steps.</p>
<p>As should now be clear, this use of the program will attempt to
evolve a given setup backwards in time according to the Life rules. The
resulting grid is clearly not necessarily unique. The program will
evolve backwards given <em>any</em> single command line option.</p>
<p>When evolving forwards, the code can only be stopped by killing the
program. In the reverse direction, the code can either be killed, or
will stop if it is unable to find a grid that will evolve to the current
layout correctly. This can be seen with the sample grid <a
href="t0_3.dat">t0_3.dat</a>, which evolves backwards by only two
time-steps.</p>
<h3 id="input-file-format">Input file format</h3>
<p>The input files must encode a square grid, where a space is a dead
cell, and any other character (except a newline) is a living cell. Each
line must be the same length, and end with a single newline character
<code>\n</code> (ASCII 10), including the last line. When designing
grids, it may help to type full-stops (dots) in place of spaces, and do
a global replace afterwards. Any deviation from this format will cause
errors in the output.</p>
<h3 id="limitations">Limitations</h3>
<p>This is only an approximation to the original Life, as it takes place
on a finite grid, with borders that are automatically killed off before
each time step. However, when evolving backwards, the resulting grids
will not cause any cells on the boundaries to come alive. As the display
is performed before killing off the borders, some boundary cells may
sometimes appear to be alive, but not be treated as such for the
following time-step, although any living cells on the right border will
never be displayed.</p>
<p>The maximum grid size is currently 99 by 99 (exceeding this will
cause a segfault), but changing the two <code>9802</code>s to
<code>MAX_SIZE*MAX_SIZE+1</code> will solve this, although some
reformatting of the code might have to be done to allow larger
numbers.</p>
<h3 id="compiler-warningsassumptions">Compiler warnings/assumptions</h3>
<p>When compiled with the <code>-Wall -pedantic -ansi</code> options of
gcc, some warnings suggesting extra parentheses occur (not necessary for
anyone fully conversant with operator precedence). There is one unused
variable, <code>v</code>, but unnamed function parameters are not
permitted in ANSI C, so naming it is necessary, and gcc no longer warns
about its existence, although earlier versions do.</p>
<p>Since the program calculates ASCII character values for display, an
ASCII based system is required to run it. Also, as mentioned above, any
system that uses anything other than a plain <code>\n</code> to end a
line will cause problems when reading in files.</p>
<h3 id="obfuscation">Obfuscation</h3>
<p>Given the finely-tuned layout required to evolve into pi, this is one
of the main obfuscations used in the code. However, running the code
through the preprocessor, expanding the <code>#define</code>s, and
applying GNU’s indent, although making the location of functions and
statements clear, by no means makes the code entirely clear. Note that
expanding out the <code>#define</code>s does not take the program over
the character limit. The main reason for these is to do with the layout,
since there are few places that keywords or tokens of over 2 characters
can be fitted, and requiring the first few lines to be
<code>#include</code>s would cause similar problems.</p>
<p>Other obfuscations used are:</p>
<ul>
<li>Use of the classic <code>2[a]</code> syntax to access the third
element of the array <code>a</code>.</li>
<li>Nested ternary operators, combined with shortcut evaluation being
required for correct operation.</li>
<li>Use of the comma operator to embed operations inside one
another.</li>
<li>Calculation of ASCII codes.</li>
<li>Needlessly recursive functions.</li>
<li>Use of bitwise-operations.</li>
<li>Storing a variable whose value could easily be found from
another.</li>
<li>Use of <code>goto</code>s to emulate a <code>for</code> loop.</li>
</ul>
<h3 id="algorithm">Algorithm</h3>
<p>The forwards evolution of the grid is straightforward.</p>
<p>The reverse evolution is done using a brute-force method. As far as I
know, a brute-force method is the only viable automatic approach for
general grids, although more intelligent algorithms would be possible
given more space.</p>
<p>The program starts with an empty “trial” grid and, starting from the
top-left, tries all possibilities for the neighbours of the current cell
that will cause the cell to evolve to the required state. It then
proceeds to the right and down. Thus, it only ever needs to look at the
cells below and to the right when testing. However, the already defined
cells above and/or to the left of the cell may mean that there are no
possibilities that will give the correct state, in which case the code
backtracks and tries other possibilities on previous cells. The program
knows it has a valid grid if it gets to the last cell. If it cannot find
a valid grid, the program exits.</p>
<p>Since this uses brute-force, it can be very slow. (In fact, the
various obfuscations have, at least for the gcc compiler, caused a
substantial slowdown.)</p>
<h3 id="program-layout">Program layout</h3>
<p>The “calculation” of pi was chosen purely because algorithms to find
pi are numerous, but the <a
href="https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life">Game of
Life</a> is rarely (if ever?) used for this purpose. Also, separate
digits made determining the layout somewhat easier.</p>
<p>Deriving the layout was the most complicated part of the program. As
is clear from the final layout featuring pi, the grid was divided into
sixteen squares, and layouts that would evolve to each of the nine
digits required were found. (This used the three-by-five digit-layout
embedded in, at first, a nine-by-nine grid, then in larger grids, until
fifteen-by-fifteen was reached.) The fifteen-by-fifteen grids give
enough blank cells around them that the digits will not collide when
evolving.</p>
<p>However, this did not allow for sufficient characters to fit the code
into. Therefore it was necessary to add some regions that would quickly
die off without expanding to collide with the digits’ evolution. Groups
of cells such as singletons, pairs, and larger groups like</p>
<pre><code>* * * * * * * * * *
*****************
* * * * * * * * * *</code></pre>
<p>were useful in this regard.</p>
<p>Other problems were keywords which need to be all in one string,
keywords requiring space after them, and multi-character tokens. Some of
these problems were dealt with by using the <code>#define</code>s and
<code>#include</code>s given in the build-script, as there was no way to
have sufficient separate lines in the code to do this without causing
many difficulties. Some rejigging of the grid’s layout as the code was
fitted into its format was also done, resorting to trial-and-improvement
in some cases. Occasional use of constructs such as <code>f -= -3</code>
was made as <code>f += 3</code> could not be fitted into the required
format. The fact that the borders would be killed off immediately was
also helpful.</p>
<p>It should be noted that evolving a full 60-by-60 grid backwards using
this code would probably take us at least up to the heat-death of the
universe.</p>
<p>The command <code>./blakely - &lt; blakely.c</code> is therefore
<em>not</em> recommended.</p>
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0
License:</h2>
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights
Reserved. You are free to share and adapt this file under the terms of
this license:</p>
<pre><code>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</code></pre>
<p>For more information, see:
https://creativecommons.org/licenses/by-sa/4.0/</p>
<!-- START: this line starts content generated by: bin/gen-inventory.sh -->
<h1 id="inventory-for-2011blakely"><a name="inventory"></a>Inventory for
2011/blakely</h1>
<h2 id="primary-files">Primary files</h2>
<ul>
<li><a href="index.html">index.html</a> - winner home page</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2011/blakely/blakely.c">blakely.c</a>
- winning source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2011/blakely/Makefile">Makefile</a>
- winner Makefile</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2011/blakely/blakely.orig.c">blakely.orig.c</a>
- original source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2011/blakely/3.dat">3.dat</a>
- input data</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2011/blakely/evolve_to_3.dat">evolve_to_3.dat</a>
- input data</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2011/blakely/t0_3.dat">t0_3.dat</a>
- input data</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2011/blakely/try.sh">try.sh</a>
- how to run</li>
<li><a href="2011_blakely.tar.bz2">2011_blakely.tar.bz2</a> - download
winning source</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2011/blakely/.gitignore">.gitignore</a>
- list of files that should not be committed under git</li>
<li><a href=".path">.path</a> - directory path from top directory</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2011/blakely/.winner.json">.winner.json</a>
- description of winner in JSON</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2011/blakely/README.md">README.md</a>
- markdown source for index.html</li>
</ul>
<!-- END: next line ends content generated by: bin/gen-inventory.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/end-rightcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/end-row.default.html -->
</div>
<!-- END: this line ends content from: inc/end-row.default.html -->
<!-- START: this line starts content from: inc/footer.default.html -->
<div class="footer">
<hr>
<h2>Coda</h2>
<p><a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2011%2Fblakely%2Findex.html">Nu HTML check this web page</a></p>
<p><a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a></p>
</div>
<!-- END: this line ends content from: inc/footer.default.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->