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.
This commit is contained in:
Landon Curt Noll committed 2024-01-17 00:32:39 -08:00
1 parent 893cd915b6
commit c1466f5165
350 files changed
+95242 -4217

No files matched your search

+288 -13
View File
@@ -1,4 +1,6 @@
<!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 !!! -->
@@ -6,27 +8,300 @@
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- file: 2012/blakely/index.html created by: fake.gen_index.sh version: 1.0.5 2023-10-31 -->
<html lang="en">
<!-- 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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2012 blakely</title>
<meta name="description" content="IOCCC year: 2012 IOCCC winner: blakely winner index page">
<meta name="keywords" content="IOCCC,2012,blakely,winner index page">
<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>2012/blakely</title>
<meta name="description" content="2012 IOCCC winner blakely">
<meta name="keywords" content="IOCCC, 2012, IOCCC 2012, 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>
<h1>2012 blakely</h1>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<p>XXX - fake content until readme2index is working - XXX</p>
<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>2012/blakely</h2>
</div>
<hr style="width:50%;text-align:left;margin-left:0">
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.first.html -->
<!-- Start Nu Html Checker -->
<p><a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2012%2Fblakely%2Findex.html">Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/blakely/index.html</a></p>
<!-- End Nu Html Checker -->
<div class="topnav">
<a class="Left Disabled" href="#">first entry</a>
<a class="Left" href="../index.html">&uarr; 2012 &uarr;</a>
<a class="Left" href="../deckmyn/index.html">deckmyn &rarr;</a>
<a class="Right" href="#inventory">Inventory</a>
</div>
<!-- END: this line ends content from: inc/topnav.first.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>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
<p>For more detailed information see <a
href="/bugs.md#2012-blakely">2012 blakely in bugs.md</a>.</p>
<h2 id="to-use">To use:</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">./blakely</span> <span class="st">&quot;RPN formula&quot;</span> resolution <span class="op">&gt;</span> output.gif</span></code></pre></div>
<h2 id="try">Try:</h2>
<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="st">&quot;xx*yy*+&quot;</span> 64 <span class="op">&gt;</span> paraboloid.gif</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./blakely</span> 9 32 <span class="op">&gt;</span> empty.gif</span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a><span class="bu">time</span> ./blakely 0 250 <span class="op">&gt;</span> flat.gif</span></code></pre></div>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>Several IOCCC themes (<a
href="https://en.wikipedia.org/wiki/Reverse_Polish_notation">RPN
calculator</a>, animated <a
href="https://en.wikipedia.org/wiki/GIF">GIF</a> generator, <a
href="https://en.wikipedia.org/wiki/Ray_tracing_(graphics)">ray
tracing</a>) in one package! Very impressive!</p>
<p>The checkerboard pattern in the output can be broken. Could you
figure out how?</p>
<p>Larger GIF files confuse some image viewers.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="remarks">Remarks</h3>
<p>This program renders a generic <a
href="https://en.wikipedia.org/wiki/Reverse_Polish_notation">RPN</a>
expression in <a
href="https://en.wikipedia.org/wiki/Ray_tracing_(graphics)">ray-traced</a>
animated <a href="https://en.wikipedia.org/wiki/GIF">GIF</a> form. The
expression in spatial variables <code>x</code> and <code>y</code> is
specified on the command-line with the required resolution, and an
animated GIF showing a fly-around of the resulting surface is output to
<code>stdout</code>.</p>
<h3 id="usage">Usage</h3>
<p>The program should be run as:</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> xy<span class="pp">*</span> 32 <span class="op">&gt;</span> pic.gif</span></code></pre></div>
<p>where the first parameter is a <a
href="https://en.wikipedia.org/wiki/Reverse_Polish_notation">RPN</a>
expression, and the second is the width of the required <a
href="https://en.wikipedia.org/wiki/GIF">GIF</a>, up to a maximum of
250.</p>
<p>The expressions are written in <a
href="https://en.wikipedia.org/wiki/Reverse_Polish_notation">Reverse
Polish Notation</a> with the following characters recognised:</p>
<pre><code>+, -, *, / - usual arithmetic operations
^ - Exponentiation; valid for constant exponent only
s - sin
c - cos
0-9 - single digit integers
d - duplicate number on stack
t - transpose top two elements on stack
x - x coordinate value
y - y coordinate value</code></pre>
<p>NB: all arithmetic is done in double precision, so <code>23/</code>
is two-thirds, rather than 0.</p>
<p>The surface plotted corresponds to <code>-1 &lt;= x,y &lt;= 1</code>
and for best results, the generated <code>z</code> value should lie
between <code>-1</code> and <code>1</code>.</p>
<p>If there is a division by zero, square-root of a negative number, or
similar operation, then the results are undefined.</p>
<h3 id="examples">Examples</h3>
<p>For test-runs, use a resolution of 32. For simple expressions, the <a
href="https://en.wikipedia.org/wiki/GIF">GIF</a> generation should take
only a few seconds with a modern processor and full optimization.
Runtime scales as <a
href="https://en.wikipedia.org/wiki/Big_O_notation">O(N^3)</a> with
resolution <code>N</code>, and more complex expressions take longer to
compute. For example, increasing the resolution of
<code>ripple.gif</code> to 250 took ~35 minutes to render on an <a
href="https://en.wikipedia.org/wiki/Intel_Core#Core_i7">i7
processor</a>.</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> xy<span class="pp">*</span> 32 <span class="op">&gt;</span> saddle.gif</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./blakely</span> xx<span class="pp">*</span>yy<span class="pp">*</span>1++d5<span class="pp">*</span>ct/ 64 <span class="op">&gt;</span> ripple.gif</span></code></pre></div>
<h3 id="algorithm">Algorithm</h3>
<p>A generic root-finding algorithm to find the point of intersection
between a ray and the surface is done using a simple forward search from
the eye. In order to make the rendering realistic, both the value of the
expression, and its derivative with respect to <code>x</code> and
<code>y</code> must be tracked. This is done using an obvious
stack-based approach.</p>
<h3 id="obfuscations">Obfuscations</h3>
<p>Much of the obfuscation is achieved through the use of single-letter
variables and <code>#define</code>s. The characters output for the <a
href="https://en.wikipedia.org/wiki/GIF#File_format">GIF format</a> are
generated in myriad and wonderful ways, making use of <a
href="https://en.wikipedia.org/wiki/Exclusive_or">XOR</a>, return values
from <code>putchar()</code>, and odd expressions. The layout is in the
form of <code>X Y Z</code>.</p>
<h3 id="limitations">Limitations</h3>
<p>ASCII is assumed since many bytes for the <a
href="https://en.wikipedia.org/wiki/GIF">GIF</a> output are generated
from characters given in the source code. On compilation a few warnings
about parentheses come up when using gcc 4.6.3, and one about no return
value from <code>main()</code> (who uses exit codes anyway?), but clang
3.1 emits no warnings.</p>
<h3 id="questions">Questions</h3>
<ul>
<li>Apart from their appearance when computing the <a
href="https://en.wikipedia.org/wiki/Reverse_Polish_notation">RPN
expression</a>, <a
href="https://en.wikipedia.org/wiki/Sine_and_cosine">sin and cos</a> are
not used. How do we then get the correct angles for rotation?</li>
<li>Exactly how many times will the animation repeat?</li>
<li>Why is there an upper limit of 250x250 for the resolution?</li>
<li>What is the point of <code>b[0]</code>?</li>
<li>Where are the words <code>NETSCAPE</code> and <code>GIF</code>
hidden in the source?</li>
</ul>
<p>(Note that the author may or may not be able to answer all of the
above questions.)</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-2012blakely"><a name="inventory"></a>Inventory for
2012/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/2012/blakely/blakely.c">blakely.c</a>
- winning source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/blakely/Makefile">Makefile</a>
- winner Makefile</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/blakely/blakely.orig.c">blakely.orig.c</a>
- original source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/blakely/try.sh">try.sh</a>
- how to run</li>
<li><a href="2012_blakely.tar.bz2">2012_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/2012/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/2012/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/2012/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%2F2012%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 -->
+310 -13
View File
@@ -1,4 +1,6 @@
<!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 !!! -->
@@ -6,27 +8,322 @@
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- file: 2012/deckmyn/index.html created by: fake.gen_index.sh version: 1.0.5 2023-10-31 -->
<html lang="en">
<!-- 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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2012 deckmyn</title>
<meta name="description" content="IOCCC year: 2012 IOCCC winner: deckmyn winner index page">
<meta name="keywords" content="IOCCC,2012,deckmyn,winner index page">
<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>2012/deckmyn</title>
<meta name="description" content="2012 IOCCC winner deckmyn">
<meta name="keywords" content="IOCCC, 2012, IOCCC 2012, IOCCC winner, deckmyn">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<h1>2012 deckmyn</h1>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<p>XXX - fake content until readme2index is working - XXX</p>
<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>2012/deckmyn</h2>
</div>
<hr style="width:50%;text-align:left;margin-left:0">
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.mid.html -->
<!-- Start Nu Html Checker -->
<p><a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2012%2Fdeckmyn%2Findex.html">Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/deckmyn/index.html</a></p>
<!-- End Nu Html Checker -->
<div class="topnav">
<a class="Left" href="../blakely/index.html">&larr; blakely</a>
<a class="Left" href="../index.html">&uarr; 2012 &uarr;</a>
<a class="Left" href="../dlowe/index.html">dlowe &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#Alex_Deckmyn">Alex Deckmyn</a><br>
Location: <a href="/temp-test-ioccc/location.html#BE">BE</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>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
<p>For more detailed information see <a
href="/bugs.md#2012-deckmyn">2012 deckmyn in bugs.md</a>.</p>
<h2 id="to-use">To use:</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">./deckmyn</span> <span class="st">&quot;</span><span class="va">$(</span><span class="fu">cat</span> deckmyn.c<span class="va">)</span><span class="st">&quot;</span> <span class="st">&quot;</span><span class="va">$(</span><span class="fu">cat</span> musicfile.txt<span class="va">)</span><span class="st">&quot;</span> <span class="op">&gt;</span> sheetmusic.pbm</span></code></pre></div>
<h2 id="try">Try:</h2>
<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">./try.sh</span></span></code></pre></div>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>The C of this entry is definitely sharp. The program cleverly uses
its own source at runtime to define the notes, time signature and
accidental bitmaps.</p>
<p>In addition to sheet music, this program is also able to, given the
right input, generate an image of a 10-pin <a
href="https://en.wikipedia.org/wiki/Dual_in-line_package">DIP chip</a>
(a sound processor?).</p>
<h3 id="historical-remarks">Historical remarks:</h3>
<p>We previously wrote that ironically, the way this entry is called
from the command line is an abuse of <a
href="https://en.wikipedia.org/wiki/C_shell">C Shell</a>. Please use <a
href="https://en.wikipedia.org/wiki/Bourne_shell">Bourne-family
shells</a> to run this entry.</p>
<p>… but in 2023 we changed the backticks to be the bash
<code>$(..)</code> construct. This is not done in the author’s remarks,
however.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="example-use">Example use</h3>
<p>You need the source code and example input (either one of the example
files, or manual input as below) ready and a program capable of showing
<a href="https://en.wikipedia.org/wiki/Netpbm">.pbm bitmap format</a>
images.</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">./deckmyn</span> <span class="st">&quot;</span><span class="kw">`</span><span class="fu">cat</span> deckmyn.c<span class="kw">`</span><span class="st">&quot;</span> <span class="st">&quot;</span><span class="kw">`</span><span class="fu">cat</span> example_greensleeves<span class="kw">`</span><span class="st">&quot;</span> <span class="op">&gt;</span> greensleeves.pbm</span></code></pre></div>
<p>If you have macOS you can open the image like:</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">open</span> greensleeves.pbm</span></code></pre></div>
<p>… otherwise, you’ll have to open it in your viewer of choice how you
would normally open an image.</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">./deckmyn</span> <span class="st">&quot;</span><span class="kw">`</span><span class="fu">cat</span> deckmyn.c<span class="kw">`</span><span class="st">&quot;</span> <span class="st">&quot;KF m44c4 c4 g4 g4 : a4 a4 g2 :; &quot;</span> <span class="op">&gt;</span> short_bass.pbm</span></code></pre></div>
<p>If you have macOS you can open the image like:</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">open</span> short_bass.pbm</span></code></pre></div>
<p>… otherwise, you’ll have to open it in your viewer of choice how you
would normally open an image.</p>
<h3 id="description">Description</h3>
<p>Every major C competition should have an entry capable of producing C
major. This is a music notation program. It produces <a
href="https://en.wikipedia.org/wiki/Netpbm">bitmaps</a>
(<code>.pbm</code>) of music based on ASCII input. A full manual is
added as a <a href="deckmyn.md">separate file</a>. Some musical examples
are also included.</p>
<p>The program is capable of printing notes, rests, (double) bar lines
and accidentals on a single melodic line (multiple staves). No chords,
polyphony etc.</p>
<p>The program expects <em>two command line arguments</em>. The first is
a (very long) string that contains the complete music font. Note that it
should <em>not</em> be given as a file name! The default music font is
encoded in the (whitespace of the) source code <a
href="deckmyn.c">deckmyn.c</a> itself. Therefore, the first argument
should be <code>"``</code> <code>cat deckmyn.c</code>
<code>``"</code>.</p>
<p>The second command line argument is the music itself. This is, again,
a string, not a file name. All music signs are entered as tokens of
exactly 3 characters. The code is very sensitive to bad spacing! So for
instance, if you use a file to write the music (e.g. <a
href="example_greensleeves">example_greensleeves</a>), you should keep
in mind that newline is also a character!</p>
<h3 id="internals">Internals</h3>
<p>To minimise the memory footprint, this program has <em>no variable
declarations at all</em>, except for the arguments to
<code>main()</code>. The only available memory space is from the command
line arguments and count (<code>argv</code> and <code>argc</code>).
Parts of <code>argv</code> are cast as <code>int</code> when values
under 0 or beyond 127 are expected.</p>
<p>The “music font” is defined by the source code itself. The first few
lines are not part of the font definition, as this memory space will be
modified by the program. (So as required by the rules, it is only a
(memory) copy of the source code that is modified.)</p>
<p>As there is no memory available, output is directly to
<code>stdout</code>, byte by byte, from the top left to the bottom right
pixel.</p>
<h3 id="limitations">LIMITATIONS</h3>
<p>The memory locations of <code>argv</code> are used for various
purposes. Therefore, the program name (default <code>deckmyn</code>)
must be <em>at least 4 characters long</em>, including possibly the
path. This, along with the ending <code>'\0'</code>, gives minimum 5
bytes of useful memory space. Otherwise, the program may attempt to
write outside the string.</p>
<p>The code is quite sensitive. Errors in the input can lead to strange
results. The code does not read beyond the end of the music input, but
that is about the only error checking available. Any input that is not
according to the rules in the <a href="deckmyn.md">manual</a>, may cause
errors.</p>
<p>The program has no special hardware limitations or requirements,
other than 8bit <code>char</code> (<code>signed</code> or
<code>unsigned</code>) and two’s complement negatives.</p>
<p>The limitations of using <code>char</code> as counters for e.g. the
number of music staves are minor. 127 staves to a page is rather a
lot.</p>
<h3 id="obfuscations">Obfuscations</h3>
<p>The code has no declared variables other than the command line
variables. Not even pointers (we all know how messy code can get with
too many pointers!). As more than one variable needs values beyond 127,
parts of the command line memory are cast to <code>int</code> using a
macro.</p>
<ul>
<li>The formatting of the code is in fact necessary, as this is the
definition of the music font. It is therefore not an obfuscation.</li>
<li>The use of only <code>argv</code>/<code>argc</code> as memory
locations is a matter of reducing the memory footprint. Again, it is not
an obfuscation.</li>
<li>Calling the only remaining variables, and the two defined macros,
<code>c</code> and <code>C</code>, is merely a matter of conforming to
the standard <a href="https://en.wikipedia.org/wiki/WYSIWYG">WYSIWYG</a>
paradigm common in commercial notation programs (’What You
<code>C</code> is What You Get). So once again it is not an obfuscation.
Anyway, it’s a C coding contest, right?</li>
<li>Randomly using the numerical (ASCII) value for characters is
compensated for by replacing some numbers by a character representation.
On average, therefore, it is not an obfuscation.</li>
<li>Randomly changing the way the elements of <code>argv</code> are
addressed is a matter of maintaining a diversified code base. It is
therefore not… Oh all right.</li>
<li>The actual output of the music is done by one <code>printf(3)</code>
call including a 800+ character nested conditional expression.</li>
<li><code>printf()</code> is also used for its return value.</li>
</ul>
<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-2012deckmyn"><a name="inventory"></a>Inventory for
2012/deckmyn</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/2012/deckmyn/deckmyn.c">deckmyn.c</a>
- winning source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/deckmyn/Makefile">Makefile</a>
- winner Makefile</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/deckmyn/deckmyn.orig.c">deckmyn.orig.c</a>
- original source</li>
<li><a href="deckmyn.html">deckmyn.html</a> - user manual</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/deckmyn/example_beethoven">example_beethoven</a>
- music notation</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/deckmyn/example_greensleeves">example_greensleeves</a>
- music notation</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/deckmyn/try.sh">try.sh</a>
- how to run</li>
<li><a href="2012_deckmyn.tar.bz2">2012_deckmyn.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/2012/deckmyn/.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/2012/deckmyn/.winner.json">.winner.json</a>
- description of winner in JSON</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/deckmyn/README.md">README.md</a>
- markdown source for index.html</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/deckmyn/deckmyn.md">deckmyn.md</a>
- markdown source for design.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%2F2012%2Fdeckmyn%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 -->
+248 -13
View File
@@ -1,4 +1,6 @@
<!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 !!! -->
@@ -6,27 +8,260 @@
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- file: 2012/dlowe/index.html created by: fake.gen_index.sh version: 1.0.5 2023-10-31 -->
<html lang="en">
<!-- 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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2012 dlowe</title>
<meta name="description" content="IOCCC year: 2012 IOCCC winner: dlowe winner index page">
<meta name="keywords" content="IOCCC,2012,dlowe,winner index page">
<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>2012/dlowe</title>
<meta name="description" content="2012 IOCCC winner dlowe">
<meta name="keywords" content="IOCCC, 2012, IOCCC 2012, IOCCC winner, dlowe">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<h1>2012 dlowe</h1>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<p>XXX - fake content until readme2index is working - XXX</p>
<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>2012/dlowe</h2>
</div>
<hr style="width:50%;text-align:left;margin-left:0">
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.mid.html -->
<!-- Start Nu Html Checker -->
<p><a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2012%2Fdlowe%2Findex.html">Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/dlowe/index.html</a></p>
<!-- End Nu Html Checker -->
<div class="topnav">
<a class="Left" href="../deckmyn/index.html">&larr; deckmyn</a>
<a class="Left" href="../index.html">&uarr; 2012 &uarr;</a>
<a class="Left" href="../endoh1/index.html">endoh1 &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#J_David_Lowe">J. David Lowe</a><br>
Location: <a href="/temp-test-ioccc/location.html#US">US</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>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
<p>For more detailed information see <a href="/bugs.md#2012-dlowe">2012
dlowe in bugs.md</a>.</p>
<h2 id="to-use">To use:</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">./dlowe</span></span></code></pre></div>
<h2 id="try">Try:</h2>
<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">./dlowe</span></span></code></pre></div>
<p>Watch for a while if you like, then press a key within the
window.</p>
<p>Use up and down keys to escape death.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>The judges lose playing this game. This entry wins!</p>
<p>Q: How did we get past the variadic macro problem on a Mac?</p>
<p>A: Don’t use <code>-pedantic-errors</code> in the Makefile.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="conways-game-of-death">Conway’s Game of DEATH</h3>
<p>This is a challenging, fast-paced arcade game, based on the famous <a
href="https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life">Game of
Life</a>.</p>
<h3 id="story">Story</h3>
<p>In the game, you are Mr.C, a lightweight spaceship making a futile
dash for escape from the rigid rules and predictability of life in the
B3/S23 universe.</p>
<p>Use the up and down arrow keys to steer: collisions are fatal for
Mr.C! Learn to spot incoming gliders, skim the surfaces of beehives and
blocks, and give blinkers plenty of space. Things get crazier as Mr.C
picks up speed… can he escape?</p>
<p>No. There is no winning. Sadly for Mr.C, this universe goes on
forever. Just see how far you can make it!</p>
<p>Press <code>q</code> any time to quit.</p>
<h3 id="features">Features</h3>
<ul>
<li>casual gameplay</li>
<li>infinite, procedurally generated universe</li>
<li>progressive difficulty</li>
<li>animated splash screens</li>
</ul>
<h3 id="limitations">Limitations</h3>
<ul>
<li>Flicker, especially at high speeds, and in spite of
“double-buffering” (X11 doesn’t make it possible to lock drawing to the
display refresh rate.)</li>
<li>Cannot be run outside of the directory containing the data files
(<code>splash.d</code>, <code>dead.d</code> and
<code>sprites.d</code>).</li>
<li>Cannot build or run without X11 (or an X11 compatibility
layer).</li>
</ul>
<h3 id="wish-list">Wish List</h3>
<ul>
<li>Score keeping</li>
<li>Color</li>
<li>In-game instructions</li>
<li>Sound</li>
</ul>
<h3 id="hosts-tested">Hosts Tested</h3>
<ul>
<li>Darwin 10.8.0 i386 (clang 1.6 and gcc 4.2.1)</li>
<li>Linux 2.6.32 i686 (clang 1.1 and gcc 4.4.3)</li>
<li>Linux 3.2.0 x86_64 (clang 3.0 and gcc 4.6.3)</li>
</ul>
<h3 id="obfuscations">Obfuscations</h3>
<p>The code is formatted into a 14-cell shape which will evolve into a
glider in 19 generations.</p>
<p>Lots of globals, including a global <code>struct</code> whose members
have the same names as global variables.</p>
<p>Global variables getting reused in different contexts.</p>
<p>Huge and convoluted expressions, abusing ternary operators and
operator precedence.</p>
<p>Lots of magic numbers, abuse of the relationships between magic
numbers, and abuse of the arithmetic properties of magic numbers.</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-2012dlowe"><a name="inventory"></a>Inventory for
2012/dlowe</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/2012/dlowe/dlowe.c">dlowe.c</a>
- winning source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/dlowe/Makefile">Makefile</a>
- winner Makefile</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/dlowe/dlowe.orig.c">dlowe.orig.c</a>
- original source</li>
<li><a href="2012_dlowe.tar.bz2">2012_dlowe.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/2012/dlowe/.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/2012/dlowe/.winner.json">.winner.json</a>
- description of winner in JSON</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/dlowe/README.md">README.md</a>
- markdown source for index.html</li>
<li><a href="dead.d">dead.d</a> - data file</li>
<li><a href="splash.d">splash.d</a> - data file</li>
<li><a href="sprites.d">sprites.d</a> - data file</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%2F2012%2Fdlowe%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 -->
+455 -13
View File
@@ -1,4 +1,6 @@
<!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 !!! -->
@@ -6,27 +8,467 @@
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- file: 2012/endoh1/index.html created by: fake.gen_index.sh version: 1.0.5 2023-10-31 -->
<html lang="en">
<!-- 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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2012 endoh1</title>
<meta name="description" content="IOCCC year: 2012 IOCCC winner: endoh1 winner index page">
<meta name="keywords" content="IOCCC,2012,endoh1,winner index page">
<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>2012/endoh1</title>
<meta name="description" content="2012 IOCCC winner endoh1">
<meta name="keywords" content="IOCCC, 2012, IOCCC 2012, IOCCC winner, endoh1">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<h1>2012 endoh1</h1>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<p>XXX - fake content until readme2index is working - XXX</p>
<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>2012/endoh1</h2>
</div>
<hr style="width:50%;text-align:left;margin-left:0">
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.mid.html -->
<!-- Start Nu Html Checker -->
<p><a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2012%2Fendoh1%2Findex.html">Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/endoh1/index.html</a></p>
<!-- End Nu Html Checker -->
<div class="topnav">
<a class="Left" href="../dlowe/index.html">&larr; dlowe</a>
<a class="Left" href="../index.html">&uarr; 2012 &uarr;</a>
<a class="Left" href="../endoh2/index.html">endoh2 &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#Yusuke_Endoh">Yusuke Endoh</a><br>
Location: <a href="/temp-test-ioccc/location.html#JP">JP</a></p>
<!-- END: next line ends content generated by: bin/gen-author.sh -->
<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>
<p>There are two alt versions that let you control the compile time
variables that control the fluid behaviour and the added variables to
speed up or slow down the fluid as well as setting a timeout (if not 0):
one for the original black and white and the colour one added by the
author at the request of the judges. Another version is the deobfuscated
version provided by the author as well. See <a
href="#alternate-code">alternate code</a> below for more details.</p>
<h2 id="to-use">To use:</h2>
<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">./endoh1</span> <span class="op">&lt;</span> configuration.txt</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">./endoh1</span> <span class="op">&lt;</span> endoh1.c</span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./endoh1</span> <span class="op">&lt;</span> pour-out.txt</span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="ex">./endoh1</span> <span class="op">&lt;</span> fountain.txt</span></code></pre></div>
<p>Also try using <code>endoh1_color</code> as you would
<code>endoh1</code> above. <code>make</code> will compile this by
default.</p>
<h2 id="alternate-code">Alternate code:</h2>
<p>The files <a href="endoh1.alt.c">endoh1.alt.c</a> and <a
href="endoh1_color.alt.c">endoh1_color.alt.c</a> correspond to <a
href="endoh1.c">endoh1.c</a> and <a
href="endoh1_color.c">endoh1_color.c</a> but which allow you to speed up
or slow down the fluid and change the behaviour of the fluid. The file
<a href="endoh1.alt.c">endoh1.alt2.c</a> is deobfuscated and was
provided by the author.</p>
<h3 id="alternate-build">Alternate build:</h3>
<p>For the default values, 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="fu">make</span> alt alt2</span></code></pre></div>
<p>The <code>alt2</code> is only necessary if you wish to compile the
deobfuscated version but it is equivalent in function to the original
entry, <a href="endoh1.c">endoh1.c</a>.</p>
<p>In the <code>alt</code> versions a default time of 10 seconds is set
as an alarm so that one can more easily go through the list of files to
see them all in succession for fun. That is controlled by the variable
<code>A</code>; 0 disables it.</p>
<p>If you wish to change the speed you should do:</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="fu">make</span> clobber SLEEP=N alt</span></code></pre></div>
<p>where <code>N</code> is number or the letter <code>I</code>.</p>
<p>WARNING: if you’re sensitive to flashing colours or any flashing at
all do make sure you don’t decrease the value of <code>S</code>, the
sleep time passed to <code>usleep(3)</code>, too much.</p>
<p>If however you wish to change the gravity factor, pressure factor
and/or viscosity factor, you should redefine the values <code>G</code>,
<code>P</code> and/or <code>V</code> macros, respectively, with the same
caveat about numbers for <code>S</code> above. For instance if you wish
to change the viscosity and pressure factors but leave the other macros
alone:</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="fu">make</span> clobber VISCOSITY=X PRESSURE=Y alt</span></code></pre></div>
<p>where <code>X</code> and <code>Y</code> are numbers or the letter
<code>I</code> and which are, respectively, the viscosity and pressure
factors.</p>
<p>There is no restriction on what the number is because doing so
prevents the macros from being defined to <code>I</code> which would
prevent the author’s remarks about it from being done.</p>
<p>If you want to disable the alarm time, set <code>A</code> to 0:</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="fu">make</span> clobber TIMER=0 alt</span></code></pre></div>
<p>It cannot be &lt; 0 or &gt; 60 (arbitrarily selected).</p>
<p>Try slowing down the display by increasing the sleep time from
<code>12321</code> to <code>50000</code>:</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="fu">make</span> clobber SLEEP=50000 alt</span></code></pre></div>
<p>Now try using both <code>endoh1.alt</code> and
<code>endoh1_color.alt</code> as you would <code>endoh1</code>
above.</p>
<p>Also try speeding up the display by decreasing the sleep time from
<code>12321</code> to <code>9999</code>:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> clobber SLEEP=9999 alt2</span></code></pre></div>
<p>WARNING: again, be careful with too low a value if you’re sensitive
to flashing colours or anything at all.</p>
<p>Now try using both <code>endoh1.alt</code> and
<code>endoh1_color.alt</code> as you would <code>endoh1</code>
above.</p>
<p>You might also wish to try redefining the macros <code>G</code>,
<code>P</code> and/or <code>V</code>. For instance:</p>
<div class="sourceCode" id="cb10"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> clobber GRAVITY=5 PRESSURE=5 VISCOSITY=5 alt</span></code></pre></div>
<p>You might try even:</p>
<div class="sourceCode" id="cb11"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> clobber GRAVITY=I alt</span></code></pre></div>
<p>See the author’s remarks for details on these macros.</p>
<h3 id="alternate-use">Alternate use:</h3>
<p>Use <code>endoh1.alt</code>, <code>endoh1_color.alt</code> and
<code>endoh1.alt2</code> as you would <code>endoh1</code> and
<code>endoh1_color</code> above.</p>
<h3 id="alternate-try">Alternate try:</h3>
<p>To see two different ways run on the source file and each of the text
files, try:</p>
<div class="sourceCode" id="cb12"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.alt.sh</span></span></code></pre></div>
<p>The second run of each will be with the gravity factor set to
<code>I</code>.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>Let’s play <a
href="https://en.wikipedia.org/wiki/Jeopardy!">Jeopardy!</a></p>
<p>A: An obfuscated program that deals with complex numbers and produces
animated ASCII graphics. Q: What is a Mandelbrot simulator?</p>
<p>Bzzzt!</p>
<p>Such heavily squeezed fluid simulation (this is parsed uniquely as
fluids are not squeezable) has a few quirks that the judges were happy
to experiment with.</p>
<p>One configuration file was inspired by an <a
href="https://web.archive.org/web/20230711134609/https://whatif.xkcd.com/6/">XKCD
what if? entry</a>.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="synopsis">Synopsis</h3>
<p><strong>DO NOT FORGET</strong> <code>-DG=1 -DP=4 -DV=8</code> and
make your terminal window larger than 80 x 25.</p>
<div class="sourceCode" id="cb13"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> endoh1.c <span class="at">-DG</span><span class="op">=</span>1 <span class="at">-DP</span><span class="op">=</span>4 <span class="at">-DV</span><span class="op">=</span>8 <span class="at">-D_BSD_SOURCE</span> <span class="at">-o</span> endoh1 <span class="at">-lm</span></span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./endoh1</span> <span class="op">&lt;</span> endoh1.c</span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./endoh1</span> <span class="op">&lt;</span> logo.txt</span>
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a><span class="ex">./endoh1</span> <span class="op">&lt;</span> column.txt</span>
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a><span class="ex">./endoh1</span> <span class="op">&lt;</span> pour-out.txt</span>
<span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a><span class="ex">./endoh1</span> <span class="op">&lt;</span> tanada.txt</span></code></pre></div>
<h3 id="what-it-is">What it is</h3>
<pre><code> ,___. ,. ,. ,. ,___. ,. ,. ,.
|/--&#39; || `&#39; || |/--&#39; `&#39; || |\_.
|\__. || ,. ,. ,. ,__/| |\__. ,. ,____. ,. ,. || ,_. |/-&#39; ,_. ,__.
|/--&#39; || || || || |/-\| `--\| || |/\/\| || || || ,/-\. || ,/-\. |/-\.
|| || `\_/| || |\_/| ,__/| || |||||| `\_/| || `\_/\.`\_. `\_/&#39; || `&#39;
`&#39; `&#39; `--&#39; `&#39; `---&#39; `---&#39; `&#39; `&#39;`&#39;`&#39; `--&#39; `&#39; `-&#39;`&#39; `-&#39; `-&#39; `&#39;
,.,. ,.,.
,/\/\. ,. ,. ,. ,/\/\. ,. ,. ,__.
|||#/&#39; || `&#39; ,_.|| |||#/&#39; `&#39;,_.,__. || ||\\. ,.
|||#\. || ,. ,. ,.,/#||| |\//\. ,.|#||##| ,. ,. || ,.,. |\/-&#39; ,.,. ,.|\.
|\/--&#39; ||,/\.|| |||#/\/| `\#||| |||#||/\|,/\.|| ||,/&#39;`\.|#| ,/&#39;`\.|\/-\.
`\| ||`\#||| |||#||\| ,//\/| ||`\|||||`\#||| ||`\.,/\/\|,.`\.,/&#39;`\| `&#39;
`&#39; `&#39; `-&#39;`&#39; `&#39;`-&#39;`-&#39; `-&#39;`-&#39; `&#39; `&#39;`&#39;`&#39; `-&#39;`&#39; `&#39; `&#39;`--&#39;`&#39;`&#39; `&#39;`&#39; `&#39;
,_.,_. ,. ,. ,. ,_.,_. ,. ,. ,.
|#||#| || `&#39; || |#||#| `&#39; || ||,_.
||\/#| ||,. ,. ,.,_.,/| |\||#| ,.,_.,__.,. ,. || ,.,. |||#| ,.,. ,.,_.
|||##| |||| || |||#||#| |#||#| |||#||##||| || ||,/||\.||`-&#39;,/||\.|||#\.
||`--&#39; ||`\_.|| |||\||#| |#||#| ||||&#39;||\|`\_.|| ||`\||#|`\.,.`\||/&#39;||`--&#39;
`&#39; `&#39; |#||| `&#39;|#||#| |#||#| `&#39;`&#39; `&#39;`&#39; |#||| `&#39; |||/&#39; |||| |||| `&#39;
`-&#39;`&#39; `-&#39;`-&#39; `-&#39;`-&#39; `-&#39;`&#39; `&#39;`&#39; `&#39;`&#39; `&#39;`&#39;
</code></pre>
<p>This program is a fluid simulator using the <a
href="http://en.wikipedia.org/wiki/Smoothed-particle_hydrodynamics">Smoothed-particle
hydrodynamics (SPH)</a> method.</p>
<p>The SPH particles represent the fluid flow. Particles have
information about the position, density, and velocity. In every
simulation step, they are changed by pressure force, viscosity force,
and external force (i.e., gravity).</p>
<p>This program reads a text from standard input, and uses it as an
initial configuration of the particles. The character <code>#</code>
represents a “wall particle” (a particle with a fixed position), and any
other non-space characters represent free particles.</p>
<p>The compilation options <code>-DG=1 -DP=4 -DV=8</code> represent,
respectively, the factor of gravity, pressure, and viscosity. By
changing their values, you can see different fluid behavior.</p>
<p><a href="http://en.wikipedia.org/wiki/Marching_squares">Marching
square</a>-like algorithm is used to render the particles.</p>
<h3 id="portability">Portability</h3>
<p>The program requires a C99 compiler; it uses <code>complex</code>
types and one-line comments. It also uses <code>usleep(3)</code>, which
may require <code>-D_BSD_SOURCE</code> or so to build with no warning.
Under these conditions, it should be portable. At least, recent
compilers with <code>-std=c99 -Wall -W -Wextra -pedantic</code> say
nothing.</p>
<div class="sourceCode" id="cb15"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> <span class="at">-DG</span><span class="op">=</span>1 <span class="at">-DP</span><span class="op">=</span>4 <span class="at">-DV</span><span class="op">=</span>8 <span class="at">-D_BSD_SOURCE</span> <span class="at">-std</span><span class="op">=</span>c99 <span class="at">-Wall</span> <span class="at">-W</span> <span class="at">-Wextra</span> <span class="at">-pedantic</span> endoh1.c</span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a><span class="fu">clang</span> <span class="at">-DG</span><span class="op">=</span>1 <span class="at">-DP</span><span class="op">=</span>4 <span class="at">-DV</span><span class="op">=</span>8 <span class="at">-D_BSD_SOURCE</span> <span class="at">-std</span><span class="op">=</span>c99 <span class="at">-Wall</span> <span class="at">-W</span> <span class="at">-Wextra</span> <span class="at">-pedantic</span> endoh1.c</span></code></pre></div>
<p>I expect it to work in any Unix-like environment. VTxxx/ANSI
sequences are used to clear screen and move cursor to home.</p>
<p>I’ve tested with gcc-4.6.3 and clang-3.0 on Linux (Ubuntu 12.04) and
gcc-4.5.3 and clang-3.1 on Cygwin. On Cygwin, gcc and clang complain
about a usage of <code>I</code> (complex’s imaginary unit), but I bet
this is cygwin’s issue; it is surely a C99 feature.</p>
<h3 id="obfuscation-w-spoiler">Obfuscation w/ Spoiler</h3>
<p>First of all, the source code itself serves as an initial
configuration. Preprocessing directives (such as
<code>#include</code>)’s <code>#</code> serve as walls.</p>
<p>This program uses <code>double complex</code> to represent any 2D
vector. But, note that the <code>x-axis</code> and <code>y-axis</code>
are swapped (real axis = y-axis, imaginary axis = x-axis). The purpose
of swapping is not only obfuscation, but also short coding: for example,
to add gravity to total force, <code>force += G</code> suffices, rather
than <code>force += G*I</code>.</p>
<p>(Incidentally, you can exert horizontal gravity by using for instance
<code>-DG=I</code>)</p>
<p>Every five entries of <code>double complex a[]</code> contain
information of one particle: position, wall-flag, density, force, and
velocity, in turn.</p>
<p>You can use <code>G</code>, <code>P</code>, and <code>V</code> as a
guide to find the calculation code of gravity, pressure, and viscosity
forces.</p>
<p>Though some assignments may look meaningless, they are actually
meaningful; they extract “integer part of real part” from a complex
value by assigning (and casting) it to an integer-type variable.</p>
<h3 id="notes-about-additional-files">Notes about Additional Files</h3>
<p><a href="logo.txt">logo.txt</a> is a source of the logo in this
remark file.</p>
<p><a href="column.txt">column.txt</a> is a water column collapse, which
is a popular demo of SPH.</p>
<p><a href="pour-out.txt">pour-out.txt</a> pours you a cup of tea.</p>
<p><a href="tanada.txt">tanada.txt</a> simulates “Terrace farming”.
(“Tanada” means a “<a
href="https://en.wikipedia.org/wiki/Terrace_(earthworks)">terraced rice
fields</a>” in Japanese.)</p>
<p><a href="clock.txt">clock.txt</a> is a “water” clock created by
HAMANO Tsukasa.</p>
<p>Other <code>*.txt</code> files are from the judges.</p>
<p><a href="endoh1_color.c">endoh1_color.c</a> is a variant that shows
the density by using terminal 256 colors.</p>
<h3 id="acknowledgments">Acknowledgments</h3>
<p>I would like to thank my wife <span class="citation"
data-cites="hirekoke">@hirekoke</span> for her teaching me the SPH
method.</p>
<p>The judges <strike>ordered</strike> suggested creating a color
version after the contest.</p>
<p>The judges and HAMANO Tsukasa (The silver medalist at this IOCCC)
kindly provided many configuration files.</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-2012endoh1"><a name="inventory"></a>Inventory for
2012/endoh1</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/2012/endoh1/endoh1.c">endoh1.c</a>
- winning source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/Makefile">Makefile</a>
- winner Makefile</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/endoh1.alt.c">endoh1.alt.c</a>
- alternative source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/endoh1.alt2.c">endoh1.alt2.c</a>
- alternate alternative source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/endoh1_color.alt.c">endoh1_color.alt.c</a>
- alternative source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/endoh1.orig.c">endoh1.orig.c</a>
- original source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/clock.txt">clock.txt</a>
- fluid initial state as text</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/column.txt">column.txt</a>
- fluid initial state as text</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/column2.txt">column2.txt</a>
- fluid initial state as text</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/column3.txt">column3.txt</a>
- fluid initial state as text</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/corners.txt">corners.txt</a>
- fluid initial state as text</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/dripping-pan.txt">dripping-pan.txt</a>
- fluid initial state as text</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/evaporation.txt">evaporation.txt</a>
- fluid initial state as text</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/flat.txt">flat.txt</a>
- fluid initial state as text</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/fountain.txt">fountain.txt</a>
- fluid initial state as text</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/funnel.txt">funnel.txt</a>
- fluid initial state as text</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/funnel2.txt">funnel2.txt</a>
- fluid initial state as text</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/funnel3.txt">funnel3.txt</a>
- fluid initial state as text</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/glass-half-empty.txt">glass-half-empty.txt</a>
- fluid initial state as text</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/leidenfrost.txt">leidenfrost.txt</a>
- fluid initial state as text</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/logo.txt">logo.txt</a>
- fluid initial state as text</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/pour-out.txt">pour-out.txt</a>
- fluid initial state as text</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/tanada.txt">tanada.txt</a>
- fluid initial state as text</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/try.alt.sh">try.alt.sh</a>
- how to run alternative code</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/endoh1_color.c">endoh1_color.c</a>
- alternative source using terminal 256 colors</li>
<li><a href="2012_endoh1.tar.bz2">2012_endoh1.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/2012/endoh1/.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/2012/endoh1/.winner.json">.winner.json</a>
- description of winner in JSON</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh1/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%2F2012%2Fendoh1%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 -->
+290 -13
View File
@@ -1,4 +1,6 @@
<!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 !!! -->
@@ -6,27 +8,302 @@
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- file: 2012/endoh2/index.html created by: fake.gen_index.sh version: 1.0.5 2023-10-31 -->
<html lang="en">
<!-- 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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2012 endoh2</title>
<meta name="description" content="IOCCC year: 2012 IOCCC winner: endoh2 winner index page">
<meta name="keywords" content="IOCCC,2012,endoh2,winner index page">
<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>2012/endoh2</title>
<meta name="description" content="2012 IOCCC winner endoh2">
<meta name="keywords" content="IOCCC, 2012, IOCCC 2012, IOCCC winner, endoh2">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<h1>2012 endoh2</h1>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<p>XXX - fake content until readme2index is working - XXX</p>
<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>2012/endoh2</h2>
</div>
<hr style="width:50%;text-align:left;margin-left:0">
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.mid.html -->
<!-- Start Nu Html Checker -->
<p><a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2012%2Fendoh2%2Findex.html">Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/endoh2/index.html</a></p>
<!-- End Nu Html Checker -->
<div class="topnav">
<a class="Left" href="../endoh1/index.html">&larr; endoh1</a>
<a class="Left" href="../index.html">&uarr; 2012 &uarr;</a>
<a class="Left" href="../grothe/index.html">grothe &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#Yusuke_Endoh">Yusuke Endoh</a><br>
Location: <a href="/temp-test-ioccc/location.html#JP">JP</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>
<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">./endoh2</span> <span class="op">&gt;</span> pi.c</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> <span class="at">-o</span> pi pi.c</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./pi</span> <span class="op">&gt;</span> 314.c</span></code></pre></div>
<p>and:</p>
<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">./endoh2</span> e <span class="op">&gt;</span> e.c<span class="dt">\</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>gcc <span class="at">-o</span> e e.c</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./e</span> <span class="op">&gt;</span> 271.c</span></code></pre></div>
<p>…</p>
<h2 id="try">Try:</h2>
<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">./try.sh</span></span></code></pre></div>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>A <a href="https://en.wikipedia.org/wiki/Pi">pi</a>/<a
href="https://en.wikipedia.org/wiki/E_(mathematical_constant)">e</a>
printing quasi-[quine](https://en.wikipedia.org/wiki/Quine_(computing)
in <a href="https://en.wikipedia.org/wiki/ASCII_art">ASCII art</a> with
a compressed font in it; what else to wish for in this program? <a
href="https://en.wikipedia.org/wiki/Virtual_machine">Virtual machine</a>
emulation?</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<p>Yeah, “Again”. Sorry. But I don’t feel guilty or uncomfortable.</p>
<p>This entry is based on ‘over-used themes’ such as self reproducing
program and <a href="https://en.wikipedia.org/wiki/Pi">pi</a> or <a
href="https://en.wikipedia.org/wiki/E_(mathematical_constant)">e</a>)
computation. I know you’re tired of them.</p>
<p>But have you ever seen them <strong>all-in-one</strong>?</p>
<h3 id="what-it-is">What it is</h3>
<p>This program generates a new program in the shape of the Greek letter
<code>pi</code>. Then, the generated program:</p>
<ul>
<li>computes 3 digits of pi and prints it as an ASCII-art program
that:</li>
<li>computes 4 digits of pi and prints it as an ASCII-art program
that:</li>
<li>computes 5 digits of pi and prints it as an ASCII-art program
that:</li>
<li>computes 6 digits of pi and prints it as an ASCII-art program
that:</li>
<li>…</li>
</ul>
<p>One more thing… When you give a command line argument <code>e</code>
to the first program, the generated one will compute <a
href="https://en.wikipedia.org/wiki/E_(mathematical_constant)">Napier’s
constant</a>) rather than pi.</p>
<h3 id="obfuscation">Obfuscation</h3>
<p>This program itself is in the shape of a <a
href="https://en.wikipedia.org/wiki/Tap_(valve)">spigot</a>. This is
derived as an analogy with <a
href="https://en.wikipedia.org/wiki/Spigot_algorithm">spigot
algorithm</a> which infinitely computes the value of a mathematical
constant such as <a href="https://en.wikipedia.org/wiki/Pi">pi</a> or <a
href="https://en.wikipedia.org/wiki/E_(mathematical_constant)">e</a>.</p>
<p>The two sets of programs, <code>314*.c</code> and
<code>271*.c</code>, are almost the same except their shape and constant
computational part. I tailored the common part to parse in both shapes
(<code>3.14...</code> and <code>2.71...</code>), by tweaking the
computational order and adding meaningless code fragments.</p>
<p>On the other hand, to make it fit inside one screen (80 x 25), my
program is shortened properly, more than it looks. (As you may know, <a
href="https://en.wikipedia.org/wiki/Quine_(computing)">quines</a> need
to make its program size doubled.) For example, this program involves
3x5 bitmap font data of ten characters (<code>0</code> –
<code>9</code>), as just 20 bytes: <code>G1%xJ{;Q7wunmuGuu%uu</code>. We
can decode character <code>n</code> as
<code>275*s[n+10] - 8*s[n] - 8</code>. I solved the system of <a
href="https://en.wikipedia.org/wiki/B%C3%A9zout%27s_identity">Bézout’s
identity</a> to find the magic string, with the aid of a brute force.
See <code>find-font-table.rb</code> in detail.</p>
<p>I used many other tricks for short coding.</p>
<p>I’m sorry that many ASCII-art-style winning entries of <a
href="https://www.ioccc.org/years.html">IOCCC</a> ignore <a
href="https://en.wikipedia.org/wiki/C_preprocessor">C preprocessor
directives</a>. In my program, <code>#include</code> is a part of
ASCII-art with comments padded.</p>
<p>These design requirements made my program well-obfuscated
willy-nilly.</p>
<h3 id="portability">Portability</h3>
<p>I expect it to work in any major environment and C compiler. To build
with no warning, it requires two C99 features: allow string literal to
be more than 509 characters and not requiring a return in
<code>main()</code>. In fact, recent compilers with
<code>-std=c99 -Wall -W -Wextra -pedantic</code> would say nothing.</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="fu">gcc</span> <span class="at">-std</span><span class="op">=</span>c99 <span class="at">-Wall</span> <span class="at">-W</span> <span class="at">-Wextra</span> <span class="at">-pedantic</span> spigot.c</span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="fu">clang</span> <span class="at">-std</span><span class="op">=</span>c99 <span class="at">-Wall</span> <span class="at">-W</span> <span class="at">-Wextra</span> <span class="at">-pedantic</span> spigot.c</span></code></pre></div>
<p>I’ve tested with gcc-4.6.3 and clang-3.0 on Linux (Ubuntu 12.04) and
gcc-4.5.3 and clang-3.1 on Cygwin.</p>
<h3 id="synopsis">Synopsis</h3>
<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="fu">cc</span> endoh2.c <span class="at">-o</span> endoh2</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./endoh2</span> <span class="op">&gt;</span> pi.c</span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> pi.c</span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> pi.c <span class="at">-o</span> pi <span class="kw">;</span> <span class="ex">./pi</span> <span class="op">&gt;</span> 314.c <span class="kw">;</span> <span class="fu">cat</span> 314.c</span>
<span id="cb6-7"><a href="#cb6-7" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> 314.c <span class="at">-o</span> 314 <span class="kw">;</span> <span class="ex">./314</span> <span class="op">&gt;</span> 3141.c <span class="kw">;</span> <span class="fu">cat</span> 3141.c</span>
<span id="cb6-8"><a href="#cb6-8" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> 3141.c <span class="at">-o</span> 3141 <span class="kw">;</span> <span class="ex">./3141</span> <span class="op">&gt;</span> 31415.c <span class="kw">;</span> <span class="fu">cat</span> 31415.c</span>
<span id="cb6-9"><a href="#cb6-9" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> 31415.c <span class="at">-o</span> 31415 <span class="kw">;</span> <span class="ex">./31415</span> <span class="op">&gt;</span> 314159.c <span class="kw">;</span> <span class="fu">cat</span> 314159.c</span>
<span id="cb6-10"><a href="#cb6-10" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> 314159.c <span class="at">-o</span> 314159 <span class="kw">;</span> <span class="ex">./314159</span> <span class="op">&gt;</span> 3141592.c <span class="kw">;</span> <span class="fu">cat</span> 3141592.c</span>
<span id="cb6-11"><a href="#cb6-11" aria-hidden="true" tabindex="-1"></a><span class="ex">etc...</span></span>
<span id="cb6-12"><a href="#cb6-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-13"><a href="#cb6-13" aria-hidden="true" tabindex="-1"></a><span class="ex">./endoh2</span> e <span class="op">&gt;</span> e.c</span>
<span id="cb6-14"><a href="#cb6-14" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> e.c</span>
<span id="cb6-15"><a href="#cb6-15" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-16"><a href="#cb6-16" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> e.c <span class="at">-o</span> e <span class="kw">;</span> <span class="ex">./e</span> <span class="op">&gt;</span> 271.c <span class="kw">;</span> <span class="fu">cat</span> 271.c</span>
<span id="cb6-17"><a href="#cb6-17" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> 271.c <span class="at">-o</span> 271 <span class="kw">;</span> <span class="ex">./271</span> <span class="op">&gt;</span> 2718.c <span class="kw">;</span> <span class="fu">cat</span> 2718.c</span>
<span id="cb6-18"><a href="#cb6-18" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> 2718.c <span class="at">-o</span> 2718 <span class="kw">;</span> <span class="ex">./2718</span> <span class="op">&gt;</span> 27182.c <span class="kw">;</span> <span class="fu">cat</span> 27182.c</span>
<span id="cb6-19"><a href="#cb6-19" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> 27182.c <span class="at">-o</span> 27182 <span class="kw">;</span> <span class="ex">./27182</span> <span class="op">&gt;</span> 271828.c <span class="kw">;</span> <span class="fu">cat</span> 271828.c</span>
<span id="cb6-20"><a href="#cb6-20" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> 271828.c <span class="at">-o</span> 271828 <span class="kw">;</span> <span class="ex">./271828</span> <span class="op">&gt;</span> 2718281.c <span class="kw">;</span> <span class="fu">cat</span> 2718281.c</span>
<span id="cb6-21"><a href="#cb6-21" aria-hidden="true" tabindex="-1"></a><span class="ex">etc...</span></span></code></pre></div>
<p>You can do <code>make everything</code> for the process (with no
<code>cat</code>).</p>
<p>Note: The executable may return a failure (non-zero) exit status
unless <code>-std=c99</code> option is given.</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-2012endoh2"><a name="inventory"></a>Inventory for
2012/endoh2</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/2012/endoh2/endoh2.c">endoh2.c</a>
- winning source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh2/Makefile">Makefile</a>
- winner Makefile</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh2/endoh2.orig.c">endoh2.orig.c</a>
- original source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh2/try.sh">try.sh</a>
- how to run</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh2/find-font-table.rb">find-font-table.rb</a>
- tool used to find the magic string</li>
<li><a href="2012_endoh2.tar.bz2">2012_endoh2.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/2012/endoh2/.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/2012/endoh2/.winner.json">.winner.json</a>
- description of winner in JSON</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/endoh2/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%2F2012%2Fendoh2%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 -->
+297 -13
View File
@@ -1,4 +1,6 @@
<!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 !!! -->
@@ -6,27 +8,309 @@
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- file: 2012/grothe/index.html created by: fake.gen_index.sh version: 1.0.5 2023-10-31 -->
<html lang="en">
<!-- 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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2012 grothe</title>
<meta name="description" content="IOCCC year: 2012 IOCCC winner: grothe winner index page">
<meta name="keywords" content="IOCCC,2012,grothe,winner index page">
<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>2012/grothe</title>
<meta name="description" content="2012 IOCCC winner grothe">
<meta name="keywords" content="IOCCC, 2012, IOCCC 2012, IOCCC winner, grothe">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<h1>2012 grothe</h1>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<p>XXX - fake content until readme2index is working - XXX</p>
<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>2012/grothe</h2>
</div>
<hr style="width:50%;text-align:left;margin-left:0">
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.mid.html -->
<!-- Start Nu Html Checker -->
<p><a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2012%2Fgrothe%2Findex.html">Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/grothe/index.html</a></p>
<!-- End Nu Html Checker -->
<div class="topnav">
<a class="Left" href="../endoh2/index.html">&larr; endoh2</a>
<a class="Left" href="../index.html">&uarr; 2012 &uarr;</a>
<a class="Left" href="../hamano/index.html">hamano &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>Authors:</strong></a> <br><br>Name: <a
href="/temp-test-ioccc/winners.html#Aaron_Grothe">Aaron Grothe</a><br>
Location: <a href="/temp-test-ioccc/location.html#US">US</a>
<br><br>Name: <a href="/temp-test-ioccc/winners.html#David_Madore">David
Madore</a><br> Location: <a
href="/temp-test-ioccc/location.html#FR">FR</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>To create a shared secret shared among <code>M</code> people with
<code>N+1</code> needed to reconstruct:</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">./grothe</span> <span class="at">-secret</span> 1-/dev/urandom 2-/dev/urandom ... <span class="dt">\</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> N-/dev/urandom 1+shared1 2+shared2 ... M+sharedM</span></code></pre></div>
<p>To reconstruct the original (an arbitrary combination of
<code>N+1</code> or more shared files with their proper numbers):</p>
<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">./grothe</span> I-sharedI J-sharedJ K-sharedK ... +reconstructed</span></code></pre></div>
<h2 id="try">Try:</h2>
<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">./grothe</span> <span class="at">-grothe.c</span> 1+grothe.c.1 2+grothe.c.2</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./grothe</span> <span class="at">-cookie_recipe.txt</span> 1-/dev/urandom 2-/dev/urandom 1+cookie_piece1.dat 2+cookie_piece2.dat 3+cookie_piece3.dat 4+cookie_piece4.dat</span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a><span class="ex">./grothe</span> 1-cookie_piece1.dat 2-cookie_piece2.dat 4-cookie_piece4.dat 4+cookie_recipe_restore.txt</span></code></pre></div>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>Also known as ‘Best abuse of the judging process’.</p>
<p>The IOCCC 2012 submission page didn’t enforce the 2048 meaningful
character limit. This entry, as submitted, weighed in at 2222 chars but
lucky for it, it was extremely easy to bring down below the limit. There
were a number of strings that when concatenated allowed the program to
slide under the limit.</p>
<p>It was clear to the judges that the extra size was an entry
beautification step. Had it not been, this entry would have been
rejected in round 0.</p>
<p>The judges also took some liberty obfuscating this entry a little
more.</p>
<p>How does this entry work? The only place multiplication is used is to
perform the <code>atoi(3)</code> conversion.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="description">Description</h3>
<p>This program implements a version of <a
href="http://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing">Shamir’s
Secret Sharing</a>. Shamir’s Secret Sharing allows you to encrypt a file
into <code>N</code> parts where it will take <code>M</code> parts to
recreate the original file. E.g. you can split the secret recipe for
Crystal Pepsi into 3 parts and require two of them be available to
extract the original recipe.</p>
<p>Actually surprisingly useful for an IOCCC entry :-)</p>
<h3 id="usage">Usage</h3>
<p>To share a secret. For example:</p>
<ul>
<li>File to share: <a
href="cookie_recipe.txt">cookie_recipe.txt</a>.</li>
<li>Number of pieces: 2 + file to be shared</li>
<li>Total number of pieces created by program: 4</li>
<li>Pieces needed to reassemble recipe: 3 or greater</li>
</ul>
<h3 id="example-usage">Example usage</h3>
<p>To split a secret into 4 pieces of which at least 3 will be needed to
get it (in this case the cookie recipe) back:</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">./grothe</span> <span class="dt">\</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="at">-cookie_recipe.txt</span><span class="dt">\</span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> 1-/dev/urandom 2-/dev/urandom<span class="dt">\</span></span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> 1+cookie_piece1.dat 2+cookie_piece2.dat 3+cookie_piece3.dat 4+cookie_piece4.dat</span></code></pre></div>
<p>To put the recipe back together using the first, second and fourth
pieces:</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">./grothe</span> <span class="dt">\</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> 1-cookie_piece1.dat 2-cookie_piece2.dat 4-cookie_piece4.dat</span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">+cookie_recipe_restore.txt</span></span></code></pre></div>
<h3 id="limitations">Limitations</h3>
<p>The program is limited to 256 input and output files and will slow
down dramatically when you get past 20-50 inputs and outputs.</p>
<h3 id="obfuscations">Obfuscations</h3>
<ul>
<li><p>Nothing is done consistently throughout the program E.g
<code>i+=1</code>, <code>i=i+1</code>, <code>i++</code> and
<code>++i</code> are all used in the program. The mark of true code
buggery: “A foolish consistency is the hobgoblin of little minds.” - <a
href="https://en.wikipedia.org/wiki/Ralph_Waldo_Emerson">Ralph Waldo
Emerson</a></p></li>
<li><p>Uses the most powerful obfuscation of all “Math”. “Any
sufficiently advanced cryptography is indistinguishable from magic.” -
Apologies to <a
href="https://en.wikipedia.org/wiki/Arthur_C._Clarke">Arthur C.
Clarke</a></p></li>
<li><p>Shadows variables by using brackets in main program to create
local copies of variables that are the same as global scope variables.
<code>-Wshadow</code> should probably be a part of <code>-Wall</code> in
gcc.</p></li>
<li><p>Uses <code>array_index[array_name]</code> instead of
<code>array_name[array_index]</code> in several places. Still don’t know
why C continues to allow this (error strings are encoded with offsets
that are also used to select them in the case statement. All strings are
located in one function for easy localization).</p></li>
<li><p>Liberal use of octal numbers, hexadecimal numbers and regular
decimal numbers throughout the program.</p></li>
<li><p>Variables and function names are semi-random and upper and lower
case characters are used.</p></li>
<li><p>Use of <code>#define</code>s from <code>stdio.h</code>,
<code>stdlib.h</code> for values <code>_STDIO_H</code> and
<code>EXIT_SUCCESS</code> used to represent 1 and 0 respectively in the
program.</p></li>
<li><p>Arrays only need to be 256x256 but most are set to greater values
than they need to be so trying to figure it out can be a bit
tough.</p></li>
</ul>
<h3 id="references">References</h3>
<ul>
<li>David Madore’s implementation of Shamir’s Secret Sharing - <a
href="http://www.madore.org/~david/programs/programs-1.36.html"
class="uri">http://www.madore.org/~david/programs/programs-1.36.html</a></li>
<li>Steve’s Recipe Database - source for the $25k Cookie Recipe - <a
href="https://www.mealsteps.com"
class="uri">https://www.mealsteps.com</a></li>
</ul>
<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-2012grothe"><a name="inventory"></a>Inventory for
2012/grothe</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/2012/grothe/grothe.c">grothe.c</a>
- winning source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/grothe/Makefile">Makefile</a>
- winner Makefile</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/grothe/grothe.orig.c">grothe.orig.c</a>
- original source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/grothe/cookie_recipe.txt">cookie_recipe.txt</a>
- cookie recipe</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/grothe/try.sh">try.sh</a>
- how to run</li>
<li><a href="2012_grothe.tar.bz2">2012_grothe.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/2012/grothe/.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/2012/grothe/.winner.json">.winner.json</a>
- description of winner in JSON</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/grothe/README.md">README.md</a>
- markdown source for index.html</li>
<li><a href="cookie_piece1.dat">cookie_piece1.dat</a> - binary support
file</li>
<li><a href="cookie_piece2.dat">cookie_piece2.dat</a> - binary support
file</li>
<li><a href="cookie_piece3.dat">cookie_piece3.dat</a> - binary support
file</li>
<li><a href="cookie_piece4.dat">cookie_piece4.dat</a> - binary support
file</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/grothe/cookie_recipe_restore.txt">cookie_recipe_restore.txt</a>
- encoded cookie recipe</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%2F2012%2Fgrothe%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 -->
+235 -13
View File
@@ -1,4 +1,6 @@
<!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 !!! -->
@@ -6,27 +8,247 @@
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- file: 2012/hamano/index.html created by: fake.gen_index.sh version: 1.0.5 2023-10-31 -->
<html lang="en">
<!-- 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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2012 hamano</title>
<meta name="description" content="IOCCC year: 2012 IOCCC winner: hamano winner index page">
<meta name="keywords" content="IOCCC,2012,hamano,winner index page">
<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>2012/hamano</title>
<meta name="description" content="2012 IOCCC winner hamano">
<meta name="keywords" content="IOCCC, 2012, IOCCC 2012, IOCCC winner, hamano">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<h1>2012 hamano</h1>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<p>XXX - fake content until readme2index is working - XXX</p>
<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>2012/hamano</h2>
</div>
<hr style="width:50%;text-align:left;margin-left:0">
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.mid.html -->
<!-- Start Nu Html Checker -->
<p><a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2012%2Fhamano%2Findex.html">Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/hamano/index.html</a></p>
<!-- End Nu Html Checker -->
<div class="topnav">
<a class="Left" href="../grothe/index.html">&larr; grothe</a>
<a class="Left" href="../index.html">&uarr; 2012 &uarr;</a>
<a class="Left" href="../hou/index.html">hou &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#Tsukasa_Hamano">Tsukasa
Hamano</a><br> Location: <a
href="/temp-test-ioccc/location.html#JP">JP</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>
<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">./hamano</span> <span class="op">&lt;</span> textfile <span class="op">&gt;</span> output.pdf</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>The script will generate a number of PDF files and it will suggest
you look at them as well. You can read <code>hint.pdf</code> with a PDF
reader like <code>acroread hint.pdf</code> or
<code>evince hint.pdf</code>. With macOS you can do
<code>open hint.pdf</code> which by default will open
<code>Preview.app</code>. You may of course use your pdf viewer to open
the file directly instead.</p>
<p>One of the PDF files generated is this README.md file as a PDF,
obfuscated, and the PDF file will then be compiled as C (itself!) and
executed so that it shows README.md!</p>
<p>Another PDF file generated is obfuscated C code. Once this is done it
will compile the PDF as if it was C and then run it like:</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="bu">echo</span> <span class="st">&#39;int main(){puts(&quot;Hello World!&quot;);}&#39;</span> <span class="kw">|</span> <span class="ex">./hamano</span> <span class="op">&gt;</span> hello.pdf</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> <span class="at">-Wno-implicit-function-declaration</span> <span class="at">-xc</span> hello.pdf <span class="at">-o</span> hello2</span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./hello2</span> <span class="kw">|</span> <span class="fu">gcc</span> <span class="at">-Wno-implicit-function-declaration</span> <span class="at">-xc</span> <span class="at">-</span> <span class="at">-o</span> ./hello3</span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a><span class="ex">./hello3</span></span></code></pre></div>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>This entry treads into a new territory for IOCCC - generating PDF
files.</p>
<p>The originally submitted entry could have been thought of as a “Best
abuse of Ghostscript” winner. :-)</p>
<p>The source code and rendered pages are obfuscated for humans (where
is the font?), and the submitted entry created PDF files that left
Ghostscript confused.</p>
<p>The results can be viewed with Acrobat Reader, <a
href="http://en.wikipedia.org/wiki/Evince">evince</a> and Apple’s <a
href="https://en.wikipedia.org/wiki/Preview_(macOS)">Preview</a>.</p>
<p>The updated version can also be viewed using Ghostscript.</p>
<p>There is something strange about the little flags in the output. A
search of English literature will provide a hint. The conclusion you
might draw is too elementary. :-)</p>
<p>So what do those flags really mean?</p>
<p>The <a
href="http://en.wikipedia.org/wiki/The_Adventure_of_the_Dancing_Men">Dancing
men algorithm</a> might be useful.</p>
<p>Don’t forget to take a look at the generated PDF. Perhaps you might
even want to compile the output with a C compiler. When you run it, what
does it output?</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<p>This program obfuscate text file into PDF file with <a
href="http://en.wikipedia.org/wiki/The_Adventure_of_the_Dancing_Men">Dancing
men algorithm</a>.</p>
<p>Probably, the output PDF file is compliant with PDF 1.3 and it’s also
available to compile as C code.</p>
<p>I’ve tested it with GCC 4.7 and Clang 3.0 with Linux, and the
following PDF Readers:</p>
<ul>
<li>Adobe Acrobat Reader</li>
<li>Evince</li>
<li>Ghostscript</li>
<li>Xpdf</li>
</ul>
<h3 id="obfuscations">Obfuscations</h3>
<p>This program is obfuscated by using classical methods. But can you
find the embedded font in the fragmented glyph?</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-2012hamano"><a name="inventory"></a>Inventory for
2012/hamano</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/2012/hamano/hamano.c">hamano.c</a>
- winning source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/hamano/Makefile">Makefile</a>
- winner Makefile</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/hamano/hamano.orig.c">hamano.orig.c</a>
- original source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/hamano/try.sh">try.sh</a>
- how to run</li>
<li><a href="2012_hamano.tar.bz2">2012_hamano.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/2012/hamano/.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/2012/hamano/.winner.json">.winner.json</a>
- description of winner in JSON</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/hamano/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%2F2012%2Fhamano%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 -->
+307 -13
View File
@@ -1,4 +1,6 @@
<!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 !!! -->
@@ -6,27 +8,319 @@
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- file: 2012/hou/index.html created by: fake.gen_index.sh version: 1.0.5 2023-10-31 -->
<html lang="en">
<!-- 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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2012 hou</title>
<meta name="description" content="IOCCC year: 2012 IOCCC winner: hou winner index page">
<meta name="keywords" content="IOCCC,2012,hou,winner index page">
<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>2012/hou</title>
<meta name="description" content="2012 IOCCC winner hou">
<meta name="keywords" content="IOCCC, 2012, IOCCC 2012, IOCCC winner, hou">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<h1>2012 hou</h1>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<p>XXX - fake content until readme2index is working - XXX</p>
<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>2012/hou</h2>
</div>
<hr style="width:50%;text-align:left;margin-left:0">
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.mid.html -->
<!-- Start Nu Html Checker -->
<p><a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2012%2Fhou%2Findex.html">Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/hou/index.html</a></p>
<!-- End Nu Html Checker -->
<div class="topnav">
<a class="Left" href="../hamano/index.html">&larr; hamano</a>
<a class="Left" href="../index.html">&uarr; 2012 &uarr;</a>
<a class="Left" href="../kang/index.html">kang &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#Qiming_HOU">Qiming HOU</a><br>
Location: <a href="/temp-test-ioccc/location.html#CN">CN</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>
<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">./hou</span> syntax-file file-to-process</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>View the <code>remarks.htm</code> file in your web browser.</p>
<p>The result is best viewed in a 80x25 console with ANSI colors.</p>
<h2 id="try-windows">Try (Windows):</h2>
<pre><code>copy header.htm hou.htm /y
hou html.txt hou.c &gt;&gt; hou.htm
start hou.htm</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>What a versatile entry! It can be used to check the size of IOCCC
entries <em>and</em> to publish them as HTML.</p>
<p>For extra credit: what is the meaning of the number
<code>2321237</code>?</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="disclaimer">Disclaimer</h3>
<p>The reviewer may have already noticed that the 2nd page of this
program is a dense blob, which is discouraged by the contest rules. We
wish to point out that a majority of state-of-art programming editors
support syntax highlighting, which should be enabled when reading this
entry. Anticipating that the reviewer’s preferred color setting may
produce a suboptimal visual effect, a few syntax files is provided to
highlight the source code under an author-provided setting, using the
submitted program itself. Syntax highlighting would also visually
improve the 3rd page.</p>
<p>The code may throw a few warnings due to formatting constraints. The
author did try to remove warnings under gcc and Visual Studio,
though.</p>
<p>The author does not own the original anime series where the embedded
ASCII arts come from. For comparison, original non-ASCII art depictions
of the relevant characters and objects can be found by googling the
embedded text messages.</p>
<h3 id="syntax-files">Syntax files</h3>
<p>The syntax file consists of a number of rewriting rules. Each rule
consists of a regular expression, a space, a format string, and a
newline. All text matching the regular expression would be replaced by
the format string. In case of a conflict, rules appearing earlier would
take precedence. One can refer to the original text in the format string
using <code>%s</code>. Other <code>%</code> characters in the format
string must be escaped with another <code>%</code>. The space character
can be used in the regular expression by escaping it with
<code>[]</code> or <code>""</code>.</p>
<p>The following regular expression operators are supported:</p>
<pre><code>() [] * + ? | &quot;&quot;</code></pre>
<p>For example, one can use the following expression to match a certain
declaration statement in <a href="hou.c">hou.c</a>:</p>
<pre class="re"><code> &quot;char&quot;[ *]*[a-zA-Z_][0-9a-zA-Z_]*[ ]*((=[0-9a-zA-Z_ ]+)|(\[[0-9a-zA-Z_ ]*\]))?[ ]*(,[ *]*[a-zA-Z_][0-9a-zA-Z_]*[ ]*((=[0-9a-zA-Z_ ]+)|(\[[0-9a-zA-Z_ ]*\]))?[ ]*)*;</code></pre>
<p>The regex engine is also algorithmically efficient. To illustrate the
point, <a href="ansi.txt">ansi.txt</a> contains a pathological
expression <a href="#fn1" class="footnote-ref" id="fnref1"
role="doc-noteref"><sup>1</sup></a> that guarantees a hang for the
competing Perl engine while matching itself. Try to compare these two
engines:</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">./hou</span> ansi.txt ansi.txt</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="fu">perl</span> patho.pl <span class="op">&lt;</span> ansi.txt</span></code></pre></div>
<h3 id="limitations">Limitations</h3>
<p>Finally, there are a few limitations…</p>
<ul>
<li>The only escape sequence supported is <code>\n</code> and it doesn’t
work in <code>[]</code>.</li>
<li>The maximum file/rule size is a linear function of the hard-coded
constant <code>M</code>.</li>
<li>Single-character matches at the end of file may be missed.</li>
<li>The operator <code>|</code> doesn’t obey precedence rules and some
extra <code>()</code>s may be required.</li>
<li>Incorrect syntax files are not tolerated.</li>
<li>The program relies on ASCII.</li>
</ul>
<h3 id="why-obfuscated">Why obfuscated</h3>
<p>The first layer of obfuscation comes from the challenge of embedding
a large ASCII art in a dense blob. The entire art is composed using only
keywords, strings and character constants. That results in a number of
otherwise useless <code>#define</code>s and quite a number of
unconventionally written constants. While the preprocessor may remove
the former, the later would remain regardless of beautification and
preprocessing.</p>
<p>The second layer of obfuscation comes from the need to squeeze a
reasonably powerful regex engine into the remaining area that isn’t
occupied by excessive keywords and useless constants. To achieve this,
the regex compiler is written using the same threaded virtual machine <a
href="#fn2" class="footnote-ref" id="fnref2"
role="doc-noteref"><sup>2</sup></a> that parses the regex. Due to
compiler limitations, the generated VM code also ends up obscured by a
large amount of spaghetti branches and virtual thread creations.
Finally, the VM in <a href="#fn3" class="footnote-ref" id="fnref3"
role="doc-noteref"><sup>3</sup></a> is extended to track multiple
expression matches for the actual formatting.</p>
<p>As an extra tweak, the text message actually does something useful.
Remove the “Make a contract with me” catch line and the program would
cease to function.</p>
<h3 id="references">References</h3>
<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>
<section id="footnotes" class="footnotes footnotes-end-of-document"
role="doc-endnotes">
<hr />
<ol>
<li id="fn1"><p><a
href="http://swtch.com/~rsc/regexp/regexp1.html">Regular Expression
Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python,
Ruby, …)</a><a href="#fnref1" class="footnote-back"
role="doc-backlink">↩︎</a></p></li>
<li id="fn2"><p><a href="http://swtch.com/~rsc/regexp/regexp2.html">Russ
Cox, Regular Expression Matching: the Virtual Machine Approach</a><a
href="#fnref2" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
<li id="fn3"><p><a href="http://swtch.com/~rsc/regexp/regexp2.html">Russ
Cox, Regular Expression Matching: the Virtual Machine Approach</a><a
href="#fnref3" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
</ol>
</section>
<!-- START: this line starts content generated by: bin/gen-inventory.sh -->
<h1 id="inventory-for-2012hou"><a name="inventory"></a>Inventory for
2012/hou</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/2012/hou/hou.c">hou.c</a>
- winning source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/hou/Makefile">Makefile</a>
- winner Makefile</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/hou/hou.orig.c">hou.orig.c</a>
- original source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/hou/ansi.txt">ansi.txt</a>
- sample input with a pathological expression</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/hou/chk.txt">chk.txt</a>
- sample input</li>
<li><a href="hint.html">hint.html</a> - hint document</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/hou/html.txt">html.txt</a>
- sample input</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/hou/markdown.txt">markdown.txt</a>
- sample input</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/hou/patho.pl">patho.pl</a>
- perl program - takes a long time to process ansi.txt</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/hou/try.sh">try.sh</a>
- how to run</li>
<li><a href="header.htm">header.htm</a> - HTML header</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/hou/perl-notes.txt">perl-notes.txt</a>
- notes about patho.pl</li>
<li><a href="2012_hou.tar.bz2">2012_hou.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/2012/hou/.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/2012/hou/.winner.json">.winner.json</a>
- description of winner in JSON</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/hou/README.md">README.md</a>
- markdown source for index.html</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/hou/hint.md">hint.md</a>
- hint document</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%2F2012%2Fhou%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 -->
+363 -13
View File
@@ -1,4 +1,6 @@
<!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 !!! -->
@@ -6,27 +8,375 @@
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- file: 2012/kang/index.html created by: fake.gen_index.sh version: 1.0.5 2023-10-31 -->
<html lang="en">
<!-- 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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2012 kang</title>
<meta name="description" content="IOCCC year: 2012 IOCCC winner: kang winner index page">
<meta name="keywords" content="IOCCC,2012,kang,winner index page">
<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>2012/kang</title>
<meta name="description" content="2012 IOCCC winner kang">
<meta name="keywords" content="IOCCC, 2012, IOCCC 2012, IOCCC winner, kang">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<h1>2012 kang</h1>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<p>XXX - fake content until readme2index is working - XXX</p>
<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>2012/kang</h2>
</div>
<hr style="width:50%;text-align:left;margin-left:0">
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.mid.html -->
<!-- Start Nu Html Checker -->
<p><a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2012%2Fkang%2Findex.html">Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/kang/index.html</a></p>
<!-- End Nu Html Checker -->
<div class="topnav">
<a class="Left" href="../hou/index.html">&larr; hou</a>
<a class="Left" href="../index.html">&uarr; 2012 &uarr;</a>
<a class="Left" href="../konno/index.html">konno &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#Seonghoon_Kang">Seonghoon
Kang</a><br> Location: <a
href="/temp-test-ioccc/location.html#KR">KR</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>
<p>There is alternate code which fixes some German at the expense of
other German. See <a href="#alternate-code">Alternate code</a> below for
the (fun) rationale here.</p>
<h2 id="to-use">To use:</h2>
<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="bu">echo</span> <span class="st">&quot;full spelling of an English cardinal numeral less than a quadrillion&quot;</span> <span class="kw">|</span> <span class="ex">./kang</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 class="co"># try various languages</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./en.sh</span> <span class="co"># English 0 through 13</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="ex">./de.sh</span> <span class="co"># German 0 through 13 with both umlauts and without (additional &#39;e&#39;)</span></span></code></pre></div>
<p>How does it have no <code>u</code> or <code>o</code> in a string in
the source code and yet it gets <code>uno</code> right?</p>
<h2 id="alternate-code">Alternate code:</h2>
<p>This alternate code fixes the program that would throw off those who
know German where the sound of ‘V’ is ‘F’ and so the program had the
letter be ‘F’. A problem, however, with changing it is that it breaks
other words including in German. Thus there is the alternate version
instead which fixes a problem for Germans that causes problems for
Germans so if you’re German you’ll just have to deal with it :-) It is,
however, good as you might be able appreciate the entry even more.</p>
<h3 id="alternate-build">Alternate build:</h3>
<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="fu">make</span> alt</span></code></pre></div>
<h3 id="alternate-use">Alternate use:</h3>
<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="bu">echo</span> vier <span class="kw">|</span> <span class="ex">./kang.alt</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> uno <span class="kw">|</span> <span class="ex">./kang.alt</span></span></code></pre></div>
<h3 id="alternate-try">Alternate try:</h3>
<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">./de.alt.sh</span> <span class="co"># German 0 through 13 both with and without umlaut</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./en.alt.sh</span> <span class="co"># English 0 through 13</span></span></code></pre></div>
<p>What does it get right? What does it get wrong? How does it compare
to the original entry without the change of <code>f</code> to
<code>v</code>?</p>
<p>Finally why does it get what it gets wrong wrong?</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>The judges were able to appreciate the Indo-European language family
relation by making this entry successfully recognize <em>some</em>
French, German, Italian, Russian, and Spanish numerals.</p>
<p>Also worth mentioning is this entry’s ability to understand the
colloquial year numbers of the last millennium.</p>
<p>We’ve added a linefeed to the print format for convenience.</p>
<p>Can you explain why:</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="bu">echo</span> f hundr<span class="kw">|</span><span class="ex">./kang</span></span></code></pre></div>
<p>correctly reports 500 but:</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="bu">echo</span> hundr<span class="kw">|</span><span class="ex">./kang</span></span></code></pre></div>
<p>does not report 100, instead printing 0?</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="synopsis">Synopsis</h3>
<p>This short program reads a spelt number (e.g. <code>forty-two</code>)
and writes a corresponding decimal number (e.g. <code>42</code>). Too
long for one-liners, alas, but it still qualifies as a <em>short</em>
program as it has less than 0x100 bytes.</p>
<p>It accepts a variety of spelt numbers:</p>
<ul>
<li>It correctly handles <code>zero</code>.</li>
<li>Hyphen does not make a difference: <code>forty-two</code> and
<code>forty two</code> are same. So does period or comma.</li>
<li>Cases do not make a difference either: <code>TWO</code>,
<code>Two</code>, <code>two</code> are the same.</li>
<li><code>one</code> and <code>a</code> are interchangeable:
<code>one hundred</code> and <code>a hundred</code> are the same.</li>
<li><code>and</code> is optional: <code>one hundred twenty-three</code>
and <code>one hundred and twenty-three</code> are the same.</li>
<li>It supports every non-negative integer less than 10<sup>15</sup>-1.
It uses the small scale (i.e. American): <code>billion</code> is
10<sup>9</sup> and <code>trillion</code> is 10<sup>12</sup>.</li>
<li>Sometimes, it can magically correct typos.</li>
</ul>
<p>It does <em>not</em> accept some spelt numbers, which I found mostly
irrelevant:</p>
<ul>
<li>A bare <code>hundred</code>, <code>thousand</code> etc. do not
work.</li>
<li><code>one million million</code> does not work. Get used to
<code>one trillion</code>!</li>
</ul>
<h3 id="requirements">Requirements</h3>
<p>This program is quite portable, only requiring the following:</p>
<ul>
<li>The signature <code>int main(int, int)</code> should be accepted by
the linker. (Original version only).</li>
<li><code>char</code> should be at least 1 byte long (as dictated by the
standard), <code>int</code> should be at least 32 bits long,
<code>long long</code> should be at least 64 bits long.</li>
<li>Both the compiler and execution environment should use an
ASCII-compatible character set and two’s complement representation.</li>
<li>Overflow and underflow on <code>char</code> should wrap around, if
your <code>char</code> is unsigned.</li>
<li><a href="http://cm.bell-labs.com/who/ken/trust.html">A trustworthy
compiler</a>.</li>
</ul>
<p>The design of the program explicitly allows for <code>EOF</code> even
if it does not equal <code>-1</code> (it has to be negative per the
standard but not necessarily <code>-1</code>) and both
<code>signed char</code> and <code>unsigned char</code>, for example.
Furthermore it is endian-independent.</p>
<h3 id="obfuscations-spoilers">Obfuscations (SPOILERS!)</h3>
<p>Many obfuscations used are typical for standard IOCCC entries:</p>
<ul>
<li>Two arguments from <code>main()</code> function are reused as normal
variables.</li>
<li>Every conditional has been replaced with the <code>?:</code> ternary
operator and <code>||</code> short-circuiting operator.</li>
<li>It has exactly three nested <code>for</code> loops and nothing
else.</li>
<li>Common two’s complement tricks: <code>~-a</code> instead of
<code>a-1</code>, <code>~a?...:...</code> instead of
<code>a!=-1?...:...</code>, etc.</li>
<li>Comma operators (<code>,</code>) for multiple statements. The number
of them is minimized, however, as it is too easy to (ab)use them.</li>
<li>It lacks most parentheses around bitwise and arithmetic operators.
It was originally written for shortness so parentheses were
<strong>EVIL</strong>.</li>
<li><code>n["string"]</code> instead of <code>"string"[n]</code>. Both
are fine for this program but I went to the former just for fun.</li>
<li>Utter lack of any kind of layouts. (Oh, except for the first
column.)</li>
</ul>
<p>Other obfuscations are more subtle:</p>
<ul>
<li>The string <code>"1+DIY/.K430x9G(kC["</code> is 18 bytes long, but
actually 19 bytes including the final NUL character are used.</li>
<li>It internally represents numbers as hexadecimal. When the input is
<code>two hundred and three</code>, it actually writes
<code>0x203</code> as hexadecimal.</li>
<li>Some variables (notably, <code>n</code>) have dual uses.</li>
<li>The magic number <a
href="http://en.wikipedia.org/wiki/Answer_to_The_Ultimate_Question_of_Life,_the_Universe,_and_Everything">42</a>
makes an appearance.</li>
<li>It has a long long numb-<code>main</code>-er within it!</li>
</ul>
<p>But the most important obfuscation is the clever construction of
lookup table. The program uses 11 different characters required for
recognizing 22 lexemes:</p>
<pre><code>zero one tw- th(i)r- fo(u)r- fi- six-
seven- eigh- nin- ten eleven twelve
hundred(s) thousand(s) million(s) billion(s) trillion(s)
a and -teen -ty</code></pre>
<p>So that they are internally represented as like:</p>
<pre><code>r n tw- tr- fr- f- s-
sn- g- nn- tn ln twl
nr(s) tsan(s) lln(s) blln(s) trlln(s)
a an -tn -ty</code></pre>
<p>The stemmer recognizes the longest matching prefix, so every lexeme
can be recognized by at most three characters (e.g. <code>trl</code>
instead of <code>trlln</code>). This is also handy for ignoring plurals.
But that would make it so that the table does not fit in the printable
byte—11<sup>2</sup> is already almost 2<sup>7</sup>!</p>
<p>The trick is to use octal; three characters (<code>a</code>,
<code>b</code> and <code>g</code>) are interpreted as sequences of two
characters (<code>ny</code>, <code>nn</code> and <code>nw</code>
respectively). Asides from a smaller lookup table, it has many good
consequences:</p>
<ul>
<li>Both <code>a</code> and <code>and</code> share the common prefix,
<code>ny</code>, and can be discarded altogether. Note that
<code>ny</code> itself does not appear from other entries.</li>
<li><code>thousand</code> is interpreted as <code>tsan</code>, which is
equivalent to <code>tfyn</code> in the octal scheme. As it is the only
entry with <code>tf</code> prefix, it can be shorten by one
character.</li>
</ul>
<p>Having said this important trick, other details should be relatively
easier to follow. The order of lookup table, for example, is very
important, and the biggest constant 6177 is not arbitrarily chosen.</p>
<p>More spoilers can be found at <a
href="https://gist.github.com/lifthrasiir/3909337"
class="uri">https://gist.github.com/lifthrasiir/3909337</a></p>
<h3 id="acknowledgement">Acknowledgement</h3>
<p>The cleaner (size-optimized) version of this program was originally
published in my website in July 2011. Sun Park and others have reviewed
it and made me aware of possible improvements. I’d also like to thank
Seo Sanghyeon for proof-reading remarks.</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-2012kang"><a name="inventory"></a>Inventory for
2012/kang</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/2012/kang/kang.c">kang.c</a>
- winning source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/kang/Makefile">Makefile</a>
- winner Makefile</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/kang/kang.alt.c">kang.alt.c</a>
- alternative source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/kang/kang.orig.c">kang.orig.c</a>
- original source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/kang/de.alt.sh">de.alt.sh</a>
- German words for 0 through 13 for alt</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/kang/de.sh">de.sh</a>
- German words for 0 through 13</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/kang/en.alt.sh">en.alt.sh</a>
- English words for 1 through 13 for alt</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/kang/en.sh">en.sh</a>
- English words for 1 through 13</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/kang/try.sh">try.sh</a>
- how to run</li>
<li><a href="2012_kang.tar.bz2">2012_kang.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/2012/kang/.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/2012/kang/.winner.json">.winner.json</a>
- description of winner in JSON</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/kang/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%2F2012%2Fkang%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 -->
+217 -13
View File
@@ -1,4 +1,6 @@
<!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 !!! -->
@@ -6,27 +8,229 @@
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- file: 2012/konno/index.html created by: fake.gen_index.sh version: 1.0.5 2023-10-31 -->
<html lang="en">
<!-- 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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2012 konno</title>
<meta name="description" content="IOCCC year: 2012 IOCCC winner: konno winner index page">
<meta name="keywords" content="IOCCC,2012,konno,winner index page">
<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>2012/konno</title>
<meta name="description" content="2012 IOCCC winner konno">
<meta name="keywords" content="IOCCC, 2012, IOCCC 2012, IOCCC winner, konno">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<h1>2012 konno</h1>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<p>XXX - fake content until readme2index is working - XXX</p>
<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>2012/konno</h2>
</div>
<hr style="width:50%;text-align:left;margin-left:0">
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.mid.html -->
<!-- Start Nu Html Checker -->
<p><a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2012%2Fkonno%2Findex.html">Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/konno/index.html</a></p>
<!-- End Nu Html Checker -->
<div class="topnav">
<a class="Left" href="../kang/index.html">&larr; kang</a>
<a class="Left" href="../index.html">&uarr; 2012 &uarr;</a>
<a class="Left" href="../omoikane/index.html">omoikane &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#Taketo_Konno">Taketo Konno</a><br>
Location: <a href="/temp-test-ioccc/location.html#JP">JP</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>
<p>There is an unobfuscated version of this entry. See <a
href="#alternate-code">Alternate code</a> below.</p>
<h2 id="to-use">To use:</h2>
<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">./konno</span> N</span></code></pre></div>
<p>NOTE: N is an integer from 0 to 255.</p>
<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>
<h2 id="alternate-code">Alternate code:</h2>
<p>An alternate version of this entry, <a
href="konno.alt.c">konno.alt.c</a>, is provided. This alternate code is
an unobfuscated version of the winning code.</p>
<h3 id="alternate-build">Alternate build:</h3>
<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="fu">make</span> alt</span></code></pre></div>
<h3 id="alternate-use">Alternate use:</h3>
<p>Use <code>konno.alt</code> as you would <code>konno</code> above.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>This entry is a good one-liner to analyze completely.</p>
<p>For extra credit, what are the minimal changes to convert it to
64-bit integers so that it could print 32 lines?</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="remarks">Remarks</h3>
<p>This program outputs <a
href="http://mathworld.wolfram.com/ElementaryCellularAutomaton.html">elementary
cellular automaton</a> patterns.</p>
<p>Try:</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">./konno</span> 30</span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./konno</span> 90</span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./konno</span> 102</span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a><span class="ex">./konno</span> 109</span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="ex">./konno</span> 165</span></code></pre></div>
<p>There are 256 (from 0 through 255) possible rules.</p>
<h3 id="obfuscation">Obfuscation</h3>
<p>This program uses bit operations. I think</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="dv">7</span><span class="op">&amp;</span>O<span class="op">&lt;&lt;!</span>o<span class="op">&gt;&gt;!</span>o<span class="op">+</span><span class="dv">29</span></span></code></pre></div>
<p>is an interesting operation. This isn’t equal to</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="dv">7</span><span class="op">&amp;</span>O<span class="op">&gt;&gt;</span><span class="dv">29</span></span></code></pre></div>
<p>operation. What is the operation doing?</p>
<h3 id="limitation">Limitation</h3>
<p>This program assumes that the size of <code>int</code> is 4.</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-2012konno"><a name="inventory"></a>Inventory for
2012/konno</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/2012/konno/konno.c">konno.c</a>
- winning source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/konno/Makefile">Makefile</a>
- winner Makefile</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/konno/konno.alt.c">konno.alt.c</a>
- alternative source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/konno/konno.orig.c">konno.orig.c</a>
- original source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/konno/try.sh">try.sh</a>
- how to run</li>
<li><a href="2012_konno.tar.bz2">2012_konno.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/2012/konno/.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/2012/konno/.winner.json">.winner.json</a>
- description of winner in JSON</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/konno/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%2F2012%2Fkonno%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 -->
+324 -13
View File
@@ -1,4 +1,6 @@
<!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 !!! -->
@@ -6,27 +8,336 @@
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- file: 2012/omoikane/index.html created by: fake.gen_index.sh version: 1.0.5 2023-10-31 -->
<html lang="en">
<!-- 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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2012 omoikane</title>
<meta name="description" content="IOCCC year: 2012 IOCCC winner: omoikane winner index page">
<meta name="keywords" content="IOCCC,2012,omoikane,winner index page">
<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>2012/omoikane</title>
<meta name="description" content="2012 IOCCC winner omoikane">
<meta name="keywords" content="IOCCC, 2012, IOCCC 2012, IOCCC winner, omoikane">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<h1>2012 omoikane</h1>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<p>XXX - fake content until readme2index is working - XXX</p>
<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>2012/omoikane</h2>
</div>
<hr style="width:50%;text-align:left;margin-left:0">
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.mid.html -->
<!-- Start Nu Html Checker -->
<p><a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2012%2Fomoikane%2Findex.html">Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/omoikane/index.html</a></p>
<!-- End Nu Html Checker -->
<div class="topnav">
<a class="Left" href="../konno/index.html">&larr; konno</a>
<a class="Left" href="../index.html">&uarr; 2012 &uarr;</a>
<a class="Left" href="../tromp/index.html">tromp &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#Don_Yang">Don Yang</a><br> Location:
<a href="/temp-test-ioccc/location.html#US">US</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>
<p>There is an alternate version that will read from the compiled file
itself, in case you don’t have a <code>/dev/urandom</code> file. There
is also a version that should theoretically work with Windows which
distinguishes binary and text. See <a href="#alternate-code">alternate
code</a> below.</p>
<h2 id="to-use">To use:</h2>
<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">./nyaruko</span> <span class="pp">[</span><span class="ss">seed.txt</span><span class="pp">]</span> <span class="op">&lt;</span> original.bin <span class="op">&gt;</span> output.c</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="fu">bash</span> output.c <span class="op">&gt;</span> key.c</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="fu">perl</span> output.c <span class="op">&gt;</span> data.c</span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> key.c data.c <span class="op">&gt;</span> output.c</span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> output.c <span class="at">-o</span> output</span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a><span class="ex">./output</span> <span class="op">&gt;</span> regenerated.bin</span></code></pre></div>
<p>NOTE: if your OS does not have <code>/dev/urandom</code> then you
should specify a seed file or use the <a
href="#alternate-code">alternate version</a> which reads in the compiled
binary itself.</p>
<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>The script <a href="try.sh">try.sh</a> will check if you have perl
before trying to use the perl parts of the script.</p>
<h2 id="alternate-code">Alternate code:</h2>
<p>The alternate version will, if no file is specified, read in the
compiled binary itself rather than trying to open
<code>/dev/urandom</code>, which is the default for the original entry.
This is useful if your system does not have a <code>/dev/urandom</code>
file and you do not want to specify an extra file. The second alternate
version is like the first except it also should theoretically work with
Windows, setting binary mode on <code>stdin</code> and
<code>stdout</code>.</p>
<h3 id="alternate-build">Alternate build:</h3>
<p>For the first version:</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="fu">make</span> alt</span></code></pre></div>
<p>For the second version:</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="fu">make</span> alt2</span></code></pre></div>
<h3 id="alternate-use">Alternate use:</h3>
<p>Use <code>nyaruko.alt</code> or <code>nyaruko.alt2</code> as you
would <code>nyaruko</code> above.</p>
<h3 id="alternate-try">Alternate try:</h3>
<p>For the first alternate version:</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">./try.alt.sh</span></span></code></pre></div>
<p>We have no way to test the second version, sorry (tm Canada :-)
)!</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>The judges have nothing to add that has not already been written
about in the <a href="spoiler.html">spoiler.html</a> (requires
JavaScript) file! :-)</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="usage">Usage</h3>
<p><code>Nyaruko</code> is a binary to text filter. Given some input on
<code>stdin</code>, <code>Nyaruko</code> will produce C code that
reproduces this input on <code>stdout</code>:</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">./nyaruko</span> <span class="op">&lt;</span> original.bin <span class="op">&gt;</span> output.c</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> output.c <span class="at">-o</span> output</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./output</span> <span class="op">&gt;</span> regenerated.bin</span></code></pre></div>
<p>Output is encrypted, but both key and data are included in the
output. To separate the key from the data, run these commands:</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="fu">bash</span> output.c <span class="op">&gt;</span> key.c</span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="fu">perl</span> output.c <span class="op">&gt;</span> data.c</span></code></pre></div>
<p>The key-less <code>data.c</code> still compiles, but produces a
different message on <code>stdout</code> instead of the original input.
This message is a hint to why the code is formatted the way it is.</p>
<p>To combine the key and data, concatenate them together in either
order:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> key.c data.c <span class="op">&gt;</span> output.c</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> data.c key.c <span class="op">&gt;</span> output.c</span></code></pre></div>
<p>By default, <code>Nyaruko</code> generates a unique random key for
every message, using <code>/dev/urandom</code> as the seed. If given an
extra command line argument, <code>Nyaruko</code> will seed using that
file instead of <code>/dev/urandom</code>:</p>
<div class="sourceCode" id="cb10"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./nyaruko</span> seed.txt <span class="op">&lt;</span> input.bin <span class="op">&gt;</span> output.c</span></code></pre></div>
<p>This makes the output key deterministic, allowing the same key to be
shared across different files. On operating systems that do not have
<code>/dev/urandom</code>, users should always specify this extra seed
argument to avoid indeterministic keys, or else use the alternate
version which will by default read the compiled alternate version
itself, which might or might not be deterministic, depending on where
and how it’s used.</p>
<h3 id="features">Features</h3>
<p>Implementation details that make <code>Nyaruko</code> more obfuscated
than usual programs:</p>
<ul>
<li><code>Nyaruko</code> recycles variables and buffers to reduce
internal state. The variable names are also carefully chosen for
mixed-case madness.</li>
<li><code>Nyaruko</code> employs some preprocessor magic to share much
of the same code and state between the encoder and decoder, and to
increase occurrences of smileys ;)</li>
</ul>
<p>Output code has these features:</p>
<ul>
<li>Fits nicely under 80 columns, and does not contain any
trigraphs.</li>
<li>Uses a fairly efficient encoding scheme, better than
<code>uuencode</code> for files larger than ~13K, and better than
<code>base64</code> for files larger than 20K.</li>
<li>Encryption with <a
href="https://en.wikipedia.org/wiki/ISAAC_(cipher)">ISAAC</a>, a
cryptographically secure pseudorandom number generator.</li>
<li>Trivial 3 language polyglot.</li>
</ul>
<p>Code layout is meant to resemble <a
href="https://en.wikipedia.org/wiki/Nyarlathotep">Nyaruko</a>, also
known as <code>Nyarlathotep</code>, the Crawling Chaos. The most obvious
thing to do with chaos is to make a random number generator, and the
most obvious thing to do with a random number generator is to make <a
href="https://en.wikipedia.org/wiki/One-time_pad">one-time-pads</a> for
encryption.</p>
<h3 id="compatibility">Compatibility</h3>
<p><code>Nyaruko</code> has these environment dependencies:</p>
<ul>
<li>Requires ASCII character set.</li>
<li>Assumes <code>sizeof(unsigned int) == 4</code>.</li>
<li>Best viewed with tab stops set to 8 spaces.</li>
</ul>
<p>Output code has the same dependencies, with the additional
requirement that the compiler must support arbitrarily long string
literals. Maximum input size that can be encoded while still producing
standard-compliant output is ~276 bytes for C89, and ~3168 bytes for
C99.</p>
<p><code>Nyaruko</code> has been to verified to work with these
compiler/OS combinations:</p>
<ul>
<li>gcc 4.4.5 on Linux (32bit and 64bit)</li>
<li>clang 3.1 on Windows (Cygwin)</li>
<li>gcc 4.5.3 on Windows (Cygwin)</li>
<li>gcc 4.5.3 on Windows (MingW)</li>
<li>gcc 4.3.5 on JSLinux</li>
<li>tcc 0.9.25 on JSLinux</li>
</ul>
<p>Note that on MingW, <code>stdin</code> and <code>stdout</code> are
not opened in binary mode by default, this means <code>Nyaruko</code>
may not faithfully encode files on MingW.</p>
<h3 id="extra-files">Extra files</h3>
<p><a href="spoiler.html">spoiler.html</a> - Contains full recording of
how the code went from blank state to an obfuscated program, gzipped to
fit under 1MB. Requires JavaScript.</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-2012omoikane"><a name="inventory"></a>Inventory
for 2012/omoikane</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/2012/omoikane/Makefile">Makefile</a>
- winner Makefile</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/omoikane/nyaruko.alt.c">nyaruko.alt.c</a>
- alternative source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/omoikane/nyaruko.alt2.c">nyaruko.alt2.c</a>
- alternate alternative source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/omoikane/nyaruko.orig.c">nyaruko.orig.c</a>
- original source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/omoikane/nyaruko.c">nyaruko.c</a>
- source to generate random data</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/omoikane/try.alt.sh">try.alt.sh</a>
- how to run alternative code</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/omoikane/try.sh">try.sh</a>
- how to run</li>
<li><a href="spoiler.html">spoiler.html</a> - SPOILER WARNING</li>
<li><a href="2012_omoikane.tar.bz2">2012_omoikane.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/2012/omoikane/.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/2012/omoikane/.winner.json">.winner.json</a>
- description of winner in JSON</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/omoikane/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%2F2012%2Fomoikane%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 -->
+606 -13
View File
@@ -1,4 +1,6 @@
<!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 !!! -->
@@ -6,27 +8,618 @@
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- file: 2012/tromp/index.html created by: fake.gen_index.sh version: 1.0.5 2023-10-31 -->
<html lang="en">
<!-- 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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2012 tromp</title>
<meta name="description" content="IOCCC year: 2012 IOCCC winner: tromp winner index page">
<meta name="keywords" content="IOCCC,2012,tromp,winner index page">
<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>2012/tromp</title>
<meta name="description" content="2012 IOCCC winner tromp">
<meta name="keywords" content="IOCCC, 2012, IOCCC 2012, IOCCC winner, tromp">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<h1>2012 tromp</h1>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<p>XXX - fake content until readme2index is working - XXX</p>
<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>2012/tromp</h2>
</div>
<hr style="width:50%;text-align:left;margin-left:0">
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.mid.html -->
<!-- Start Nu Html Checker -->
<p><a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2012%2Ftromp%2Findex.html">Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/tromp/index.html</a></p>
<!-- End Nu Html Checker -->
<div class="topnav">
<a class="Left" href="../omoikane/index.html">&larr; omoikane</a>
<a class="Left" href="../index.html">&uarr; 2012 &uarr;</a>
<a class="Left" href="../vik/index.html">vik &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#John_Tromp">John Tromp</a><br>
Location: <a href="/temp-test-ioccc/location.html#US">US</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> all <span class="co"># On a 64-bit machine (default)</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> tromp32 <span class="co"># On a 32-bit machine</span></span></code></pre></div>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
<p>For more detailed information see <a href="/bugs.md#2012-tromp">2012
tromp in bugs.md</a>.</p>
<h2 id="to-use">To use:</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">./tromp</span> <span class="pp">[-</span><span class="ss">b</span><span class="pp">]</span></span></code></pre></div>
<p>Use <code>./tromp32</code> as you would <code>./tromp</code> if on a
32-bit machine.</p>
<h2 id="to-use-1">To use:</h2>
<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="fu">cat</span> ascii-prog.blc data <span class="kw">|</span> <span class="ex">./tromp</span> <span class="at">-b</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> binary-prog.Blc data <span class="kw">|</span> <span class="ex">./tromp</span></span></code></pre></div>
<h2 id="try">Try:</h2>
<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">./try.sh</span></span></code></pre></div>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>The judges dare to say that the data files this entry is processing
are more obfuscated than the entry itself.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<p>This program celebrates the close connection between obfuscation and
conciseness, by implementing the most concise language known, <a
href="https://tromp.github.io/cl/Binary_lambda_calculus.html">Binary
Lambda Calculus (BLC)</a>.</p>
<p><a
href="https://tromp.github.io/cl/Binary_lambda_calculus.html">BLC</a>
was developed to make <a
href="https://en.wikipedia.org/wiki/Algorithmic_information_theory">Algorithmic
Information Theory</a>, the theory of smallest programs, more concrete.
It starts with the simplest model of computation, the <a
href="https://en.wikipedia.org/wiki/Lambda_calculus">lambda
calculus</a>, and adds the minimum amount of machinery to enable binary
input and output.</p>
<p>More specifically, it defines a universal machine, which, from an
input stream of bits, parses the binary encoding of a <a
href="https://en.wikipedia.org/wiki/Lambda_calculus">lambda calculus</a>
term, applies that to the remainder of input (translated to a lazy list
of <a href="https://en.wikipedia.org/wiki/Boolean_algebra">booleans</a>,
which have a standard representation in lambda calculus), and translates
the evaluated result back into a stream of bits to be output.</p>
<p>Lambda is encoded as 00, application as 01, and the variable bound by
the <code>n</code>th enclosing lambda (denoted <code>n</code> in
so-called <a href="https://en.wikipedia.org/wiki/De_Bruijn_notation">De
Bruijn notation</a>) as <code>1^{n}0</code>. That’s all there is to <a
href="https://tromp.github.io/cl/Binary_lambda_calculus.html">BLC</a>!</p>
<p>For example the encoding of lambda term
<code>S = \x \y \z (x z) (y z)</code>, with <a
href="https://en.wikipedia.org/wiki/De_Bruijn_notation">De Bruijn
notation</a> <code>\ \ \ (3 1) (2 1)</code>, is
<code>00 00 00 01 01 1110 10 01 110 10</code>.</p>
<p>In the closely related <a
href="https://tromp.github.io/cl/Binary_lambda_calculus.html#BLC8:_byte_sized_I.2FO">BLC8</a>
language, I/O is byte oriented, translating between a stream of bytes
and a list of length-8 lists of <a
href="https://en.wikipedia.org/wiki/Boolean_algebra">booleans</a>.</p>
<p>The submission implements the universal machine in the most concise
manner conceivable. It lacks <code>#define</code>s and
<code>#include</code>s, and compiles to a (stripped) executable of under
6K in size.</p>
<p>Without arguments, it runs in byte mode, using standard input and
output. With one (arbitrary) argument, it runs in bit mode, using only
the least significant bit of input, and using characters <code>0</code>
and <code>1</code> for output.</p>
<p>The program uses the following exit codes:</p>
<pre><code>0: OK; result is a finite list
5: Out of term space
6: Out of memory
1,2,3,4,8,9: result not in list form</code></pre>
<p>The size of the term space is fixed at compile time with
<code>-DA</code>.</p>
<h3 id="a-half-byte-cat">A half byte <code>cat</code></h3>
<p>The shortest (closed) lambda calculus term is <code>\x x (\ 1</code>
in <a href="https://en.wikipedia.org/wiki/De_Bruijn_notation">De Bruijn
notation</a>) which is the identity function. When its encoding
<code>0010</code> is fed into the universal machine, it will simply copy
the input to the output (well, not that simply, since each byte is
smashed to bits and rebuilt from scratch). Voila: a half byte cat:</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">$</span> echo <span class="st">&quot; Hello, world&quot;</span> <span class="kw">|</span> <span class="ex">./tromp</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Hello,</span> world</span></code></pre></div>
<p>Since the least significant 4 bits of the first byte are just
arbitrary padding that is ignored by the program, any character from
ASCII 32 (space) through 47 (<code>/</code>) will do, e.g.:</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">$</span> echo <span class="st">&quot;*Hello, world&quot;</span> <span class="kw">|</span> <span class="ex">./tromp</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Hello,</span> world</span></code></pre></div>
<h3 id="bad-programs">Bad programs</h3>
<p>If the input doesn’t start with a valid program, that is, if the
interpreter reaches end-of-file during program parsing, it will crash in
some way. E.g. the following might dump core:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="at">-n</span> <span class="st">&quot;U&quot;</span> <span class="kw">|</span> <span class="ex">./tromp</span></span></code></pre></div>
<p>Furthermore, the interpreter requires the initial encoded lambda term
to be closed, that is, variable <code>n</code> can only appear within at
least <code>n</code> enclosing lambdas. For instance, here the term
<code>\ 5</code> is not closed, causing the interpreter to crash when
looking into a null-pointer environment:</p>
<div class="sourceCode" id="cb10"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">&quot;&gt;Hello, world&quot;</span> <span class="kw">|</span> <span class="ex">./tromp</span></span></code></pre></div>
<p>will likely dump core.</p>
<p>Since these properties can be checked when creating <a
href="https://tromp.github.io/cl/Binary_lambda_calculus.html">BLC</a>
programs, the interpreter doesn’t bother checking for it.</p>
<h3 id="a-self-interpreter">A Self Interpreter</h3>
<p>The <a
href="https://tromp.github.io/cl/Binary_lambda_calculus.html">BLC</a>
universal machine may be small at 650 bytes of C (952 bytes including
layout), but written as a self interpreter in BLC it is downright
minuscule at 232 bits (29 bytes):</p>
<pre><code> 01010001
10100000
00010101
10000000
00011110
00010111
11100111
10000101
11001111
000000111
10000101101
1011100111110
000111110000101
11101001 11010010
11001110 00011011
00001011 11100001
11110000 11100110
11110111 11001111
01110110 00011001
00011010 00011010</code></pre>
<p>The byte oriented BLC8 version weighs in at 43 bytes (shown in
hexadecimal).</p>
<pre><code> 19468
05580
05f00
bfe5f
85f3f
03c2d
b9fc3f8
5e9d65e5f
0decb f0fc3
9befe 185f7
0b7fb 00cf6
7bb03 91a1a
</code></pre>
<div class="sourceCode" id="cb13"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> <span class="er">(</span><span class="fu">cat</span> uni8.Blc<span class="kw">;</span> <span class="bu">echo</span> <span class="st">&quot; Ni hao&quot;</span><span class="kw">)</span> <span class="kw">|</span> <span class="ex">./tromp</span></span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Ni</span> hao</span></code></pre></div>
<h3 id="a-prime-number-sieve">A prime number sieve</h3>
<p>Even shorter than the self-interpreter is this prime number sieve in
167 bits (under 21 bytes):</p>
<pre><code> 000100011001100101000110100
000000101100000100100010101
11110111 101001000
11010000 111001101
000000000010110111001110011
11111011110000000011111001
10111000
00010110
0000110110
</code></pre>
<p>The <code>n</code>th bit in the output indicates whether n is
prime:</p>
<div class="sourceCode" id="cb15"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat primes.blc <span class="kw">|</span> <span class="ex">./tromp</span> <span class="at">-b</span> <span class="kw">|</span> <span class="fu">head</span> <span class="at">-c</span> 70</span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a><span class="ex">0011010100010100010100010000010100000100010100010000010000010100000100</span></span></code></pre></div>
<p>For those who prefer to digest their primes in decimal, there is
<code>oddindices.Blc</code>, which will print the indices of all odd
characters (with <a
href="https://en.wikipedia.org/wiki/Bit_numbering">LSB</a> = 1)
separated by a given character:</p>
<pre><code>$ (cat oddindices.Blc; echo -n &quot; &quot;; cat primes.blc | ./tromp -b) | ./tromp | head -c 70
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97</code></pre>
<h3 id="a-space-filling-program">A Space filling program</h3>
<p>The program <code>hilbert.Blc</code>, at 143 bytes, is a very twisty
“one-liner” (shown in hexadecimal):</p>
<pre><code> 1818181 8111154 6806041 55ff041
9d f9 de 16 ff fe 5f 3f
ef f615ff9 46 84 058117e 05
cb fe bc bf
ee86cb9 4681600 5c0bfac bfbf71a
85 e0 5c f4
14d5fe0 8180b048d0800e078 016445f
fe 5f
f7 ffffe5fff2fc 02f7ad97f5bf ff
ff bf ff ca af ff
7817ffa df76695 4680601 57f7e16
05 c1
3fe80b2 2c18581 bfe5c10 42ff805
de ec 06 c2 c0 c0
60 8191a00167fb cbcfdf65f7c0 a20</code></pre>
<p>It expects <code>n</code> arbitrary characters of input, and draws a
space filling <a
href="https://en.wikipedia.org/wiki/Hilbert_curve">Hilbert curve</a> of
order <code>n</code>:</p>
<div class="sourceCode" id="cb18"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> <span class="er">(</span><span class="fu">cat</span> hilbert.Blc<span class="kw">;</span> <span class="bu">echo</span> <span class="at">-n</span> <span class="st">&quot;1&quot;</span><span class="kw">)</span> <span class="kw">|</span> <span class="ex">./tromp</span></span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">_</span></span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span> <span class="kw">|</span></span>
<span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb18-5"><a href="#cb18-5" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> <span class="er">(</span><span class="fu">cat</span> hilbert.Blc<span class="kw">;</span> <span class="bu">echo</span> <span class="at">-n</span> <span class="st">&quot;12&quot;</span><span class="kw">)</span> <span class="kw">|</span> <span class="ex">./tromp</span></span>
<span id="cb18-6"><a href="#cb18-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">_</span> _</span>
<span id="cb18-7"><a href="#cb18-7" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span></span>
<span id="cb18-8"><a href="#cb18-8" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span></span>
<span id="cb18-9"><a href="#cb18-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span></span>
<span id="cb18-10"><a href="#cb18-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb18-11"><a href="#cb18-11" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> <span class="er">(</span><span class="fu">cat</span> hilbert.Blc<span class="kw">;</span> <span class="bu">echo</span> <span class="at">-n</span> <span class="st">&quot;123&quot;</span><span class="kw">)</span> <span class="kw">|</span> <span class="ex">./tromp</span></span>
<span id="cb18-12"><a href="#cb18-12" aria-hidden="true" tabindex="-1"></a> <span class="ex">_</span> _ _ _</span>
<span id="cb18-13"><a href="#cb18-13" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span></span>
<span id="cb18-14"><a href="#cb18-14" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span></span>
<span id="cb18-15"><a href="#cb18-15" aria-hidden="true" tabindex="-1"></a> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_____</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span></span>
<span id="cb18-16"><a href="#cb18-16" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span> <span class="ex">___</span> ___ <span class="kw">|</span></span>
<span id="cb18-17"><a href="#cb18-17" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span></span>
<span id="cb18-18"><a href="#cb18-18" aria-hidden="true" tabindex="-1"></a> <span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="ex">_</span></span>
<span id="cb18-19"><a href="#cb18-19" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span></span>
<span id="cb18-20"><a href="#cb18-20" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb18-21"><a href="#cb18-21" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> <span class="er">(</span><span class="fu">cat</span> hilbert.Blc<span class="kw">;</span> <span class="bu">echo</span> <span class="at">-n</span> <span class="st">&quot;1234&quot;</span><span class="kw">)</span> <span class="kw">|</span> <span class="ex">./tromp</span></span>
<span id="cb18-22"><a href="#cb18-22" aria-hidden="true" tabindex="-1"></a> <span class="ex">_</span> _ _ _ _ _ _ _</span>
<span id="cb18-23"><a href="#cb18-23" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span></span>
<span id="cb18-24"><a href="#cb18-24" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span></span>
<span id="cb18-25"><a href="#cb18-25" aria-hidden="true" tabindex="-1"></a> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_____</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="kw">|</span><span class="ex">_____</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span></span>
<span id="cb18-26"><a href="#cb18-26" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span> <span class="ex">___</span> ___ <span class="kw">|</span> <span class="kw">|</span> <span class="ex">___</span> ___ <span class="kw">|</span></span>
<span id="cb18-27"><a href="#cb18-27" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span></span>
<span id="cb18-28"><a href="#cb18-28" aria-hidden="true" tabindex="-1"></a> <span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="ex">_</span> _ <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="ex">_</span></span>
<span id="cb18-29"><a href="#cb18-29" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span></span>
<span id="cb18-30"><a href="#cb18-30" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span><span class="ex">_</span> ___ ___ ___ ___ _<span class="kw">|</span></span>
<span id="cb18-31"><a href="#cb18-31" aria-hidden="true" tabindex="-1"></a> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span></span>
<span id="cb18-32"><a href="#cb18-32" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span> <span class="ex">_</span> <span class="kw">|</span> <span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="ex">_</span> <span class="kw">|</span> <span class="ex">_</span> <span class="kw">|</span></span>
<span id="cb18-33"><a href="#cb18-33" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span></span>
<span id="cb18-34"><a href="#cb18-34" aria-hidden="true" tabindex="-1"></a> <span class="ex">_</span> _ <span class="kw">|</span> <span class="ex">___</span> ___ <span class="kw">|</span> <span class="ex">_</span> _</span>
<span id="cb18-35"><a href="#cb18-35" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span></span>
<span id="cb18-36"><a href="#cb18-36" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span></span>
<span id="cb18-37"><a href="#cb18-37" aria-hidden="true" tabindex="-1"></a> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span></span></code></pre></div>
<h3 id="a-brainfuck-interpreter">A <a
href="https://en.wikipedia.org/wiki/Brainfuck">Brainfuck</a>
interpreter</h3>
<p>The smallest known BF interpreter is written in… you guessed it, <a
href="https://tromp.github.io/cl/Binary_lambda_calculus.html">BLC</a>,
coming in at 112 bytes (including 3 bits of padding):</p>
<pre><code>$ od -t x4 bf.Blc
0000000 01a15144 02d55584 223070b7 00f032ff
0000020 7f85f9bf 956fe15e c0ee7d7f 006854e5
0000040 fbfd5558 fd5745e0 b6f0fbeb 07d62ff0
0000060 d7736fe1 c0bc14f1 1f2eff0b 17666fa1
0000100 2fef5be8 ff13ffcf 2034cae1 0bd0c80a
0000120 e51fee99 6a5a7fff ff0fff1f d0049d87
0000140 db0500ab 3bb74023 b0c0cc28 10740e6c
0000160</code></pre>
<p>It expects its input to consist of a <a
href="https://en.wikipedia.org/wiki/Brainfuck">Brainfuck</a> program
(looking only at bits <code>0</code>, <code>1</code> and <code>4</code>
to distinguish among <code>,-.+&lt;&gt;][</code>) followed by a
<code>]</code>, followed by the input for the Brainfuck program.</p>
<pre><code>$ more hw.bf
++++++++++[&gt;+++++++&gt;++++++++++&gt;+++&gt;+&lt;&lt;&lt;&lt;-]&gt;++.&gt;+.+++++++..+++.&gt;++.&lt;&lt;+++++++++++++++.&gt;.+++.------.--------.&gt;+.&gt;.]
$ cat bf.Blc hw.bf | ./tromp
Hello World!</code></pre>
<p>Curiously, the interpreter <code>bf.Blc</code> is the exact same size
as <code>hw.bf</code>.</p>
<h3 id="a-blc-assembler">A BLC assembler</h3>
<p>Writing BLC programs can be made slightly less painful with this
parser that translates single-letter-variable lambda calculus into
BLC:</p>
<div class="sourceCode" id="cb21"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo <span class="st">&quot;\f\x f (f (f x))&quot;</span> <span class="op">&gt;</span> three</span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat parse.Blc three <span class="kw">|</span> <span class="ex">./tromp</span></span>
<span id="cb21-3"><a href="#cb21-3" aria-hidden="true" tabindex="-1"></a><span class="ex">000001110011100111010</span></span></code></pre></div>
<h3 id="converting-between-bits-and-bytes">Converting between bits and
bytes</h3>
<p>The program <code>inflate.Blc</code> and its inverse
<code>deflate.Blc</code> allow us to translate between BLC and BLC8. If
you assemble a byte oriented program, you’ll need to compact it into
BLC8:</p>
<p>So we could assemble an input reversing program as</p>
<div class="sourceCode" id="cb22"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">&quot;\a a ((\b b b) (\b \c \d \e d (b b) (\f f c e))) (\b \c c)&quot;</span> <span class="op">&gt;</span> reverse</span>
<span id="cb22-2"><a href="#cb22-2" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> parse.Blc reverse <span class="kw">|</span> <span class="ex">./tromp</span> <span class="op">&gt;</span> reverse.blc</span></code></pre></div>
<p>and change it to BLC8 with</p>
<div class="sourceCode" id="cb23"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat deflate.Blc reverse.blc <span class="kw">|</span> <span class="ex">./tromp</span> <span class="op">&gt;</span> rev.Blc</span>
<span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> wc rev.Blc</span>
<span id="cb23-3"><a href="#cb23-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">0</span> 1 9 rev.Blc</span></code></pre></div>
<p>and then try it out with:</p>
<div class="sourceCode" id="cb24"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat rev.Blc <span class="at">-</span> <span class="kw">|</span> <span class="ex">./tromp</span></span>
<span id="cb24-2"><a href="#cb24-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Hello,</span> world!</span>
<span id="cb24-3"><a href="#cb24-3" aria-hidden="true" tabindex="-1"></a><span class="ex">^D</span></span>
<span id="cb24-4"><a href="#cb24-4" aria-hidden="true" tabindex="-1"></a><span class="ex">!dlrow</span> ,olleH</span></code></pre></div>
<h3 id="symbolic-lambda-calculus-reduction">Symbolic Lambda Calculus
reduction</h3>
<p>BLC8 program <code>symbolic.Blc</code> shows individual reduction
steps on symbolic lambda terms. Here it is used to show the calculation
of 2^3 in Church numerals:</p>
<div class="sourceCode" id="cb25"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo <span class="st">&quot;(\f\x f (f (f x))) (\f\x f (f x))&quot;</span> <span class="op">&gt;</span> threetwo</span>
<span id="cb25-2"><a href="#cb25-2" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat parse.Blc threetwo <span class="kw">|</span> <span class="ex">./tromp</span> <span class="op">&gt;</span> threetwo.blc</span>
<span id="cb25-3"><a href="#cb25-3" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat symbolic.Blc threetwo.blc <span class="kw">|</span> <span class="ex">./tromp</span></span>
<span id="cb25-4"><a href="#cb25-4" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> b<span class="kw">)))</span> <span class="kw">(</span><span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> b<span class="kw">))</span></span>
<span id="cb25-5"><a href="#cb25-5" aria-hidden="true" tabindex="-1"></a><span class="ex">\a</span> <span class="er">(</span><span class="ex">\b</span> <span class="dt">\c</span> b <span class="er">(</span><span class="ex">b</span> c<span class="kw">))</span> <span class="kw">((</span><span class="ex">\b</span> <span class="dt">\c</span> b <span class="er">(</span><span class="ex">b</span> c<span class="kw">))</span> <span class="kw">((</span><span class="ex">\b</span> <span class="dt">\c</span> b <span class="er">(</span><span class="ex">b</span> c<span class="kw">))</span> <span class="ex">a</span><span class="kw">))</span></span>
<span id="cb25-6"><a href="#cb25-6" aria-hidden="true" tabindex="-1"></a><span class="ex">\a</span> <span class="dt">\b</span> <span class="er">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span><span class="kw">)</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span><span class="kw">)</span> <span class="ex">b</span><span class="kw">)</span></span>
<span id="cb25-7"><a href="#cb25-7" aria-hidden="true" tabindex="-1"></a><span class="ex">\a</span> <span class="dt">\b</span> <span class="er">(</span><span class="ex">\c</span> <span class="er">(</span><span class="ex">\d</span> <span class="dt">\e</span> d <span class="er">(</span><span class="ex">d</span> e<span class="kw">))</span> <span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\d</span> <span class="dt">\e</span> d <span class="er">(</span><span class="ex">d</span> e<span class="kw">))</span> <span class="ex">a</span> c<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span><span class="kw">)</span> <span class="ex">b</span><span class="kw">)</span></span>
<span id="cb25-8"><a href="#cb25-8" aria-hidden="true" tabindex="-1"></a><span class="ex">\a</span> <span class="dt">\b</span> <span class="er">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span><span class="kw">)</span> <span class="ex">b</span><span class="kw">))</span></span>
<span id="cb25-9"><a href="#cb25-9" aria-hidden="true" tabindex="-1"></a><span class="ex">\a</span> <span class="dt">\b</span> <span class="er">(</span><span class="ex">\c</span> a <span class="er">(</span><span class="ex">a</span> c<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span><span class="kw">)</span> <span class="ex">b</span><span class="kw">))</span></span>
<span id="cb25-10"><a href="#cb25-10" aria-hidden="true" tabindex="-1"></a><span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span><span class="kw">)</span> <span class="ex">b</span><span class="kw">)))</span></span>
<span id="cb25-11"><a href="#cb25-11" aria-hidden="true" tabindex="-1"></a><span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> a <span class="er">(</span><span class="ex">a</span> c<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span><span class="kw">)</span> <span class="ex">b</span><span class="kw">)))</span></span>
<span id="cb25-12"><a href="#cb25-12" aria-hidden="true" tabindex="-1"></a><span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span><span class="kw">)</span> <span class="ex">b</span><span class="kw">))))</span></span>
<span id="cb25-13"><a href="#cb25-13" aria-hidden="true" tabindex="-1"></a><span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="er">(</span><span class="ex">\d</span> <span class="dt">\e</span> d <span class="er">(</span><span class="ex">d</span> e<span class="kw">))</span> <span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\d</span> <span class="dt">\e</span> d <span class="er">(</span><span class="ex">d</span> e<span class="kw">))</span> <span class="ex">a</span> c<span class="kw">))</span> <span class="ex">b</span><span class="kw">))))</span></span>
<span id="cb25-14"><a href="#cb25-14" aria-hidden="true" tabindex="-1"></a><span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span> b<span class="kw">)))))</span></span>
<span id="cb25-15"><a href="#cb25-15" aria-hidden="true" tabindex="-1"></a><span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> a <span class="er">(</span><span class="ex">a</span> c<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span> b<span class="kw">)))))</span></span>
<span id="cb25-16"><a href="#cb25-16" aria-hidden="true" tabindex="-1"></a><span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span> b<span class="kw">))))))</span></span>
<span id="cb25-17"><a href="#cb25-17" aria-hidden="true" tabindex="-1"></a><span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> a <span class="er">(</span><span class="ex">a</span> c<span class="kw">))</span> <span class="ex">b</span><span class="kw">))))))</span></span>
<span id="cb25-18"><a href="#cb25-18" aria-hidden="true" tabindex="-1"></a><span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> b<span class="kw">)))))))</span></span></code></pre></div>
<p>As expected, the resulting normal form is <a
href="https://en.wikipedia.org/wiki/Church_encoding">Church numeral</a>
8.</p>
<p>Taking only the first line of output gives us a sort of BLC
disassembler, an exact inverse of the above assembler. The prime number
sieve disassembles as follows:</p>
<div class="sourceCode" id="cb26"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat symbolic.Blc primes.blc <span class="kw">|</span> <span class="ex">./tromp</span> <span class="kw">|</span> <span class="fu">head</span> <span class="at">-1</span></span>
<span id="cb26-2"><a href="#cb26-2" aria-hidden="true" tabindex="-1"></a><span class="ex">\a</span> <span class="er">(</span><span class="ex">\b</span> b <span class="er">(</span><span class="ex">b</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> c c<span class="kw">)</span> <span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> <span class="dt">\e</span> e <span class="er">(</span><span class="ex">\f</span> <span class="dt">\g</span> g<span class="kw">)</span> <span class="kw">((</span><span class="ex">\f</span> c c f <span class="er">(</span><span class="kw">(</span><span class="ex">\g</span> g g<span class="kw">)</span> <span class="kw">(</span><span class="ex">\g</span> f <span class="er">(</span><span class="ex">g</span> g<span class="kw">))))</span> <span class="kw">(</span><span class="ex">\f</span> <span class="dt">\g</span> <span class="dt">\h</span> <span class="dt">\i</span> i g <span class="er">(</span><span class="ex">h</span> <span class="er">(</span><span class="ex">d</span> f<span class="kw">)))))</span> <span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> <span class="dt">\e</span> b <span class="er">(</span><span class="ex">e</span> c<span class="kw">)))))</span> <span class="kw">(</span><span class="ex">\b</span> <span class="dt">\c</span> c <span class="er">(</span><span class="ex">\d</span> <span class="dt">\e</span> d<span class="kw">)</span> <span class="ex">b</span><span class="kw">)</span></span></code></pre></div>
<p>Hardly any less obfuscated…</p>
<p>The last line of</p>
<div class="sourceCode" id="cb27"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> symbolic.Blc primes.blc <span class="kw">|</span> <span class="ex">./tromp</span> <span class="kw">|</span> <span class="fu">head</span> <span class="at">-16</span></span></code></pre></div>
<p>starts out as</p>
<pre><code>\a \b b (\c \d c) (\c c (\d \e d) (\d d (\e \f f) (\e e (\f \g g) ((\f (\g \h \i</code></pre>
<p>The <code>\a</code> is for ignoring the rest of the input (to which
the universal machine applies the decoded lambda term). The
<code>\b b (..) (...)</code> is the list constructor, usually called
<code>cons</code>, applied to a head (a list element) and a tail
(another list). In this case the element is <code>(\c \d c)</code>,
which represents the boolean true, and which we use to represent a 0
bit. This is the bit that says 0 is not prime. The next list element
(following another <code>cons</code>) is <code>(\d \e d)</code>. Another
0 bit, this time saying that 1 is not prime. The third list element is
<code>(\e \f f)</code>, a 1 bit, confirming our suspicion that 2 is
prime. As is the next number, according to <code>(\f \g g)</code>. We
can see that the tail after the first 4 elements is still subject to
further reduction. The bit for number 4 will show up for the first time
in line 30, as <code>(\g \h g)</code>, or 0, as the result of zeroing
out all multiples of the first prime, 2.</p>
<p>Since my computer reaches swap hell before line 40, we can’t see the
next bit arriving, at least not in this symbolic reduction.</p>
<h3 id="performance">Performance</h3>
<p>Performance is quite decent, and amazingly good for such a tiny
implementation, being roughly 50% slower than a Haskell implementation
of the universal machine using so-called <a
href="https://en.wikipedia.org/wiki/Higher-order_abstract_syntax">Higher
Order Abstract Syntax</a> which relies on the highly optimized Haskell
runtime system for evaluation. Of course individual BLC programs running
under the interpreter perform much worse than that same program written
in Haskell.</p>
<p>Our interpreter copes well with extra levels of interpretation:</p>
<div class="sourceCode" id="cb29"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> time cat primes.blc <span class="kw">|</span> <span class="ex">./tromp</span> <span class="at">-b</span> <span class="kw">|</span> <span class="fu">head</span> <span class="at">-c</span> 210 <span class="op">&gt;</span> /dev/null</span>
<span id="cb29-2"><a href="#cb29-2" aria-hidden="true" tabindex="-1"></a><span class="ex">real</span> 0m0.043s</span>
<span id="cb29-3"><a href="#cb29-3" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> time cat uni.blc primes.blc <span class="kw">|</span> <span class="ex">./tromp</span> <span class="at">-b</span> <span class="kw">|</span> <span class="fu">head</span> <span class="at">-c</span> 210 <span class="op">&gt;</span> /dev/null</span>
<span id="cb29-4"><a href="#cb29-4" aria-hidden="true" tabindex="-1"></a><span class="ex">real</span> 0m0.191s</span>
<span id="cb29-5"><a href="#cb29-5" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> time cat uni.blc uni.blc primes.blc <span class="kw">|</span> <span class="ex">./tromp</span> <span class="at">-b</span> <span class="kw">|</span> <span class="fu">head</span> <span class="at">-c</span> 210 <span class="op">&gt;</span> /dev/null</span>
<span id="cb29-6"><a href="#cb29-6" aria-hidden="true" tabindex="-1"></a><span class="ex">real</span> 0m1.919s</span>
<span id="cb29-7"><a href="#cb29-7" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> time cat uni.blc uni.blc uni.blc primes.blc <span class="kw">|</span> <span class="ex">./tromp</span> <span class="at">-b</span> <span class="kw">|</span> <span class="fu">head</span> <span class="at">-c</span> 210 <span class="op">&gt;</span> /dev/null</span>
<span id="cb29-8"><a href="#cb29-8" aria-hidden="true" tabindex="-1"></a><span class="ex">real</span> 0m23.514s</span>
<span id="cb29-9"><a href="#cb29-9" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> time cat uni.blc uni.blc uni.blc uni.blc primes.blc <span class="kw">|</span> <span class="ex">./tromp</span> <span class="at">-b</span> <span class="kw">|</span> <span class="fu">head</span> <span class="at">-c</span> 210 <span class="op">&gt;</span> /dev/null</span>
<span id="cb29-10"><a href="#cb29-10" aria-hidden="true" tabindex="-1"></a><span class="ex">real</span> 4m52.700s</span></code></pre></div>
<h3 id="obfuscation">Obfuscation</h3>
<p>Obfuscation is due entirely to conciseness. Some questions to
ponder:</p>
<p>Which of the term space codes <code>0</code>, <code>1</code>,
<code>2</code>, <code>3</code> serve multiple purposes?</p>
<p>Why is the environment pointer pointing into the term space?</p>
<p>What does the test <code>u+m&amp;1?</code> do?</p>
<p>How does the program reach exit code 0?</p>
<p>And how do any of those BLC programs work?</p>
<h3 id="portability">Portability</h3>
<p>The program freely (without casting) converts between
<code>int</code> and <code>int *</code>, causing many warnings;</p>
<pre><code> note: expected &#39;int *&#39; but argument is of type &#39;int&#39;
warning: assignment from incompatible pointer type
warning: assignment makes integer from pointer without a cast
warning: assignment makes pointer from integer without a cast
warning: incompatible implicit declaration of built-in function &#39;calloc&#39;
warning: incompatible implicit declaration of built-in function &#39;exit&#39;
warning: passing argument 1 of &#39;d&#39; makes pointer from integer without a cast
warning: passing argument 1 of &#39;p&#39; makes pointer from integer without a cast
warning: pointer/integer type mismatch in conditional expression</code></pre>
<p>Avoiding these would make the program substantially longer, and
detract from its single minded focus on conciseness.</p>
<p>It implicitly declares functions <code>read(2)</code>,
<code>write(2)</code>, <code>exit(3)</code> and <code>calloc(3)</code>,
the latter two incompatibly. 32 bit and 64 bit executables are separate
<a href="Makefile">Makefile</a> targets, involving a change from
<code>int</code> to <code>long</code> and from a hardcoded sizeof of 4
to 8.</p>
<p>The program has been tested to work correctly on Linux/Solaris/MacOSX
both in 32 and 64 bits.</p>
<h3 id="how-the-program-works">How the program works</h3>
<p>See the file <a href="how.md">how.md</a>.</p>
<h3 id="acknowledgements">Acknowledgements</h3>
<p>Christopher Hendrie, Bertram Felgenhauer, Alex Stangl, Seong-hoon
Kang, and <a href="/winners.html#Yusuke_Endoh">Yusuke Endoh</a> have
contributed ideas and suggestions for improvement.</p>
<h3 id="references">References</h3>
<p>Binary Lambda Calculus - <a
href="https://tromp.github.io/cl/Binary_lambda_calculus.html"
class="uri">https://tromp.github.io/cl/Binary_lambda_calculus.html</a></p>
<p>G J Chaitin, Algorithmic information theory, Volume I, Cambridge
Tracts in Theoretical Computer Science, Cambridge University Press,
October 1987. <a
href="https://web.archive.org/web/20121125233450/https://www.cs.auckland.ac.nz/~chaitin/cup.html"
class="uri">https://web.archive.org/web/20121125233450/https://www.cs.auckland.ac.nz/~chaitin/cup.html</a></p>
<p>Jean-Louis Krivine. 2007. A call-by-name lambda-calculus machine
Higher Order Symbol. Comput. 20, 3 (September 2007), 199-207. <a
href="http://www.pps.univ-paris-diderot.fr/~krivine/articles/lazymach.pdf"
class="uri">http://www.pps.univ-paris-diderot.fr/~krivine/articles/lazymach.pdf</a></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-2012tromp"><a name="inventory"></a>Inventory for
2012/tromp</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/2012/tromp/tromp.c">tromp.c</a>
- winning source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/tromp/Makefile">Makefile</a>
- winner Makefile</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/tromp/tromp.orig.c">tromp.orig.c</a>
- original source</li>
<li><a href="how.html">how.html</a> - author supplied spoiler</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/tromp/primes.pl">primes.pl</a>
- post process tromp output to print primes</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/tromp/try.sh">try.sh</a>
- how to run</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/tromp/hw.bf">hw.bf</a>
- bf source code</li>
<li><a href="2012_tromp.tar.bz2">2012_tromp.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/2012/tromp/.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/2012/tromp/.winner.json">.winner.json</a>
- description of winner in JSON</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/tromp/README.md">README.md</a>
- markdown source for index.html</li>
<li><a href="bf.Blc">bf.Blc</a> - sample input</li>
<li><a href="deflate.Blc">deflate.Blc</a> - sample input</li>
<li><a href="hilbert.Blc">hilbert.Blc</a> - sample input</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/tromp/how.md">how.md</a>
- markdown source for how.html</li>
<li><a href="inflate.Blc">inflate.Blc</a> - sample input</li>
<li><a href="oddindices.Blc">oddindices.Blc</a> - sample input</li>
<li><a href="parse.Blc">parse.Blc</a> - sample input</li>
<li><a href="primes.blc">primes.blc</a> - sample input</li>
<li><a href="symbolic.Blc">symbolic.Blc</a> - sample input</li>
<li><a href="uni.blc">uni.blc</a> - sample input</li>
<li><a href="uni8.Blc">uni8.Blc</a> - sample input</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%2F2012%2Ftromp%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 -->
+6 -6
View File
@@ -111,9 +111,9 @@ additional chunks are copied into the resulting image.
For some reason the chocolate image seems to have some special properties.
Apart from being quite big and a little bit noisy, it appears that when embedded
into another image and extracted, the bitmap data is also a valid
[brain$#@$](https://en.wikipedia.org/wiki/Brainfuck) program. It is of course
[brain\$#@\$](https://en.wikipedia.org/wiki/Brainfuck) program. It is of course
possible to get the bitmap data from the extracted image, and run it through any
of the previous winning brain$#@$ interpreters, but I thought it would be easier
of the previous winning brain\$#@\$ interpreters, but I thought it would be easier
to include an interpreter in the program to avoid the hassle:
```sh
@@ -122,7 +122,7 @@ to include an interpreter in the program to avoid the hassle:
```
It is of course also possible to embed a
[brain$#@$](https://en.wikipedia.org/wiki/Brainfuck) program as a text file
[brain\$#@\$](https://en.wikipedia.org/wiki/Brainfuck) program as a text file
(as explained above) and decode it, e.g.:
```sh
@@ -172,7 +172,7 @@ program to crash.
Since a lot of care was taken to keep the code simple, it turned out to be
quite easy to extend functionality. I did include a small
[brain$#@$](https://en.wikipedia.org/wiki/Brainfuck) after I
[brain\$#@\$](https://en.wikipedia.org/wiki/Brainfuck) after I
realized that the chocolate image had some interesting properties.
But there is more functionality I added that didn't fit within the size
@@ -181,9 +181,9 @@ format source code based on a PNG image. So the format of the program is
actually done by the program itself.
And to be honest, the chocolate image did not have a
[brain$#@$](https://en.wikipedia.org/wiki/Brainfuck) program
[brain\$#@\$](https://en.wikipedia.org/wiki/Brainfuck) program
embedded to begin with. I added functionality to the program to embed a
brain$#@$ into a PNG image and used it to create the image provided with
brain\$#@\$ into a PNG image and used it to create the image provided with
the entry.
I also added a method to analyze PNG images, to print the size and format,
+298 -13
View File
@@ -1,4 +1,6 @@
<!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 !!! -->
@@ -6,27 +8,310 @@
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- file: 2012/vik/index.html created by: fake.gen_index.sh version: 1.0.5 2023-10-31 -->
<html lang="en">
<!-- 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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2012 vik</title>
<meta name="description" content="IOCCC year: 2012 IOCCC winner: vik winner index page">
<meta name="keywords" content="IOCCC,2012,vik,winner index page">
<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>2012/vik</title>
<meta name="description" content="2012 IOCCC winner vik">
<meta name="keywords" content="IOCCC, 2012, IOCCC 2012, IOCCC winner, vik">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<h1>2012 vik</h1>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<p>XXX - fake content until readme2index is working - XXX</p>
<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>2012/vik</h2>
</div>
<hr style="width:50%;text-align:left;margin-left:0">
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.mid.html -->
<!-- Start Nu Html Checker -->
<p><a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2012%2Fvik%2Findex.html">Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/vik/index.html</a></p>
<!-- End Nu Html Checker -->
<div class="topnav">
<a class="Left" href="../tromp/index.html">&larr; tromp</a>
<a class="Left" href="../index.html">&uarr; 2012 &uarr;</a>
<a class="Left" href="../zeitak/index.html">zeitak &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#Daniel_Vik">Daniel Vik</a><br>
Location: <a href="/temp-test-ioccc/location.html#US">US</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>
<p>This entry requires <a href="https://www.zlib.net">Zlib</a>.</p>
<p>There is an alternate version which might work for Windows. See <a
href="#alternate-code">Alternate code</a> section below.</p>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
<p>For more detailed information see <a href="/bugs.md#2012-vik">2012
vik in bugs.md</a>.</p>
<h2 id="to-use">To use:</h2>
<p>To embed text (from file or command line):</p>
<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">./vik</span> e base.png filename <span class="op">&gt;</span> encodedimg.png</span></code></pre></div>
<p>or</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">./vik</span> e base.png SomeRandomText <span class="op">&gt;</span> encodedimg.png</span></code></pre></div>
<p>To extract the embedded text:</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">./vik</span> d encodedimg.png</span></code></pre></div>
<p>To embed a PNG into another:</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">./vik</span> e base.png source.png <span class="op">&gt;</span> encodedimg.png</span></code></pre></div>
<p>To extract the embedded PNG:</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">./vik</span> d encodedimg.png <span class="op">&gt;</span> restored.png</span></code></pre></div>
<h2 id="try">Try:</h2>
<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">./try.sh</span></span></code></pre></div>
<h2 id="alternate-code">Alternate code:</h2>
<p>For those few who might use Windows this alternate code might
work.</p>
<h3 id="alternate-build">Alternate build:</h3>
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> alt</span></code></pre></div>
<h3 id="alternate-use">Alternate use:</h3>
<p>Use <code>vik.alt</code> as you would <code>vik</code> above.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>References to chocolate had no effect on judging this entry. We
guarantee it.</p>
<p>Can you discern hidden pieces of chocolate in <a
href="chocolate-in-ioccc.png">chocolate-in-ioccc.png</a>?</p>
<figure>
<img src="chocolate-in-ioccc.png" title="Chocolate in IOCCC"
alt="chocolate in ioccc" />
<figcaption aria-hidden="true">chocolate in ioccc</figcaption>
</figure>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="introduction">Introduction</h3>
<p>This program is a <a
href="https://en.wikipedia.org/wiki/Steganography">steganography</a>
application for embedding an image or text into another image as well as
extracting the embedded image or text back. The program stores the
embedded image or text in the low bits of the RGB values.</p>
<p>The program supports any 8 bit true color PNG images (RGB, RGBA,
greyscale, and greyscale+alpha). The output image is always 8 bit RGB.
When embedding one image into another, the width and height needs to be
the same.</p>
<p>The program only updates the <code>IDAT</code> and <code>IHDR</code>
chunks of the source image. Any additional chunks are copied into the
resulting image.</p>
<h3 id="bonus-extractor">Bonus Extractor:</h3>
<p>For some reason the chocolate image seems to have some special
properties. Apart from being quite big and a little bit noisy, it
appears that when embedded into another image and extracted, the bitmap
data is also a valid <a
href="https://en.wikipedia.org/wiki/Brainfuck">brain$#@$</a> program. It
is of course possible to get the bitmap data from the extracted image,
and run it through any of the previous winning brain$#@$ interpreters,
but I thought it would be easier to include an interpreter in the
program to avoid the hassle:</p>
<div class="sourceCode" id="cb10"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./vik</span> e ioccc.png chocolate.png <span class="op">&gt;</span> encodedimg.png</span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./vik</span> b encodedimg.png</span></code></pre></div>
<p>It is of course also possible to embed a <a
href="https://en.wikipedia.org/wiki/Brainfuck">brain$#@$</a> program as
a text file (as explained above) and decode it, e.g.:</p>
<div class="sourceCode" id="cb11"><pre
class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./vik</span> e ioccc.png .+<span class="pp">[</span><span class="ss">.+</span><span class="pp">]</span> <span class="op">&gt;</span> encodedimg.png</span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./vik</span> b encodedimg.png</span></code></pre></div>
<h3 id="obfuscation">Obfuscation</h3>
<p>I really wanted to keep the program simple, so instead of adding
multiple macros or helper methods that can be confusing, I placed all
functionality in the <code>main()</code> function. <code>main()</code>
is called recursively and quite extensively, but it gives the benefit
that all invocations of the function have the same parameters,
<code>argv</code> and <code>argc</code>. This really helps readability,
as a programmer doesn’t need to remember several variable or function
names. I also tried to reduce the number of keywords, and the program
only has four <code>for</code> loops followed by a single
<code>return</code> statement. There is a little bit of use of the
ternary (<code>?:</code>) operator, but this is really there to keep the
program as simple as possible.</p>
<h3 id="portability">Portability</h3>
<p>The program is portable to most platforms that have <a
href="https://www.zlib.net">zlib</a> available. The only system
dependency is that the program relies on writing binary data to
<code>stdout</code>.</p>
<p>By default, Microsoft compilers adds carriage returns to new lines,
and to compile the program on this platform, the following line can be
added after the variable declarations in the main declaration in order
to run correctly:</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a>_setmode<span class="op">(</span>_fileno<span class="op">(</span>stdout<span class="op">),</span> <span class="bn">0x8000</span><span class="op">);</span></span></code></pre></div>
<p>NOTE: this is what the <a href="#alternate-code">Alternate code</a>
does.</p>
<h3 id="limitations">Limitations</h3>
<p>The program doesn’t have many error checks so passing in invalid
arguments or images of mismatching sizes, or unsupported pixel formats
will cause the program to crash.</p>
<h3 id="extendability">Extendability</h3>
<p>Since a lot of care was taken to keep the code simple, it turned out
to be quite easy to extend functionality. I did include a small <a
href="https://en.wikipedia.org/wiki/Brainfuck">brain$#@$</a> after I
realized that the chocolate image had some interesting properties.</p>
<p>But there is more functionality I added that didn’t fit within the
size limits and could not remain included. For example, I added a method
to format source code based on a PNG image. So the format of the program
is actually done by the program itself.</p>
<p>And to be honest, the chocolate image did not have a <a
href="https://en.wikipedia.org/wiki/Brainfuck">brain$#@$</a> program
embedded to begin with. I added functionality to the program to embed a
brain$#@$ into a PNG image and used it to create the image provided with
the entry.</p>
<p>I also added a method to analyze PNG images, to print the size and
format, as well as the scan line filters.</p>
<p>All these features were quite easy to add, much thanks to the
(actually pretty good) design of the code.</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-2012vik"><a name="inventory"></a>Inventory for
2012/vik</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/2012/vik/vik.c">vik.c</a>
- winning source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/vik/Makefile">Makefile</a>
- winner Makefile</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/vik/vik.alt.c">vik.alt.c</a>
- alternative source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/vik/vik.orig.c">vik.orig.c</a>
- original source</li>
<li><a href="chocolate.png">chocolate.png</a> - encoding image</li>
<li><a href="ioccc.png">ioccc.png</a> - encoding image</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/vik/try.sh">try.sh</a>
- how to run</li>
<li><a href="2012_vik.tar.bz2">2012_vik.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/2012/vik/.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/2012/vik/.winner.json">.winner.json</a>
- description of winner in JSON</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/vik/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%2F2012%2Fvik%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 -->
+308 -13
View File
@@ -1,4 +1,6 @@
<!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 !!! -->
@@ -6,27 +8,320 @@
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- file: 2012/zeitak/index.html created by: fake.gen_index.sh version: 1.0.5 2023-10-31 -->
<html lang="en">
<!-- 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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2012 zeitak</title>
<meta name="description" content="IOCCC year: 2012 IOCCC winner: zeitak winner index page">
<meta name="keywords" content="IOCCC,2012,zeitak,winner index page">
<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>2012/zeitak</title>
<meta name="description" content="2012 IOCCC winner zeitak">
<meta name="keywords" content="IOCCC, 2012, IOCCC 2012, IOCCC winner, zeitak">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<h1>2012 zeitak</h1>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<p>XXX - fake content until readme2index is working - XXX</p>
<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>2012/zeitak</h2>
</div>
<hr style="width:50%;text-align:left;margin-left:0">
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.last.html -->
<!-- Start Nu Html Checker -->
<p><a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2012%2Fzeitak%2Findex.html">Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/zeitak/index.html</a></p>
<!-- End Nu Html Checker -->
<div class="topnav">
<a class="Left" href="../vik/index.html">&larr; vik</a>
<a class="Left" href="../index.html">&uarr; 2012 &uarr;</a>
<a class="Left Disabled" href="#">last entry</a>
<a class="Right" href="#inventory">Inventory</a>
</div>
<!-- END: this line ends content from: inc/topnav.last.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#Adar_Zeitak">Adar Zeitak</a><br>
Location: <a href="/temp-test-ioccc/location.html#IL">IL</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>
<p>There is an alternate version that is slightly deobfuscated. See <a
href="#alternate-code">alternate code</a> below.</p>
<h2 id="to-use">To use:</h2>
<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">./zeitak</span> <span class="op">&lt;</span> file.c</span></code></pre></div>
<p>where <code>file.c</code> is the file to be checked for nesting
errors. For example, you may try <a href="incorrect.c">incorrect.c</a>
and the program itself.</p>
<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="fu">make</span> test</span></code></pre></div>
<p>NOTE: it prints an error and exits on the first nesting error so it
will not detect multiple issues!</p>
<h2 id="alternate-code">Alternate code:</h2>
<p>This version, <a href="zeitak.alt.c">zeitak.alt.c</a>, is a version
that has been slightly deobfuscated. You may find reading it helpful in
your attempt to understand this extremely subtle entry.</p>
<h3 id="alternate-build">Alternate build:</h3>
<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="fu">make</span> alt</span></code></pre></div>
<h3 id="alternate-use">Alternate use:</h3>
<p>Use <code>zeitak.alt</code> as you would <code>zeitak</code>
above.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>This is an extremely subtle and twisted piece of Gold award winning
code!</p>
<p>The judges had spent a considerable amount of time analyzing this
entry. At one point we spent <a
href="https://web.archive.org/web/20130925190722/https://twitter.com/ioccc/status/252162898800033792">18
minutes</a> just to understand 18 key characters of this code.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="nesting-errors-detector">Nesting Errors Detector</h3>
<h4 id="what-does-it-do">What does it do</h4>
<p>As you have probably understood by looking at the source*, this
program has something to do with parenthesis (and equality of opening
and closing parenthesis, if you look close enough). It goes over the
file given to it and checks that every opening <code>(</code>,
<code>[</code>, or <code>{</code> has a matching closing one and vice
versa. It also checks that every <code>"</code> or <code>'</code> is
closed.</p>
<p>If an error is detected, an error message will be printed. If the
problem is a superfluous closing bracket, it will even print a few
characters around it’s position.</p>
<p>* Make sure you view the source with 4 spaces tab width.</p>
<h4 id="features">Features</h4>
<ul>
<li>Ignores parenthesis inside strings or character constants, so no
errors will be detected in the following line:</li>
</ul>
<div class="sourceCode" id="cb5"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>printf<span class="op">(</span><span class="st">&quot;)&quot;</span><span class="op">);</span></span></code></pre></div>
<ul>
<li>Doesn’t get confused by the <a
href="/1984/anonymous/anonymous.c">1984/anonymous</a> entry!</li>
</ul>
<h4 id="mis-features">Mis-Features</h4>
<ul>
<li>Escapes (e.g. <code>\"</code>) are ignored, so the following line
will produce an error:</li>
</ul>
<div class="sourceCode" id="cb6"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>printf<span class="op">(</span><span class="st">&quot;</span><span class="sc">\&quot;</span><span class="st">&quot;</span><span class="op">);</span></span></code></pre></div>
<h4 id="obfuscation">Obfuscation</h4>
<p><a href="/years.html">IOCCC winners</a> already contain entries
without digits, control-flow keywords and certain operators in their
source. This entry has an even more limited source, that is:</p>
<ul>
<li>Without any digits.</li>
<li>Without any character constants.</li>
<li>Without using functions from headers other than
<code>stdio</code>.</li>
<li>Without any control-flow keywords (not even the <code>?:</code>
operator).</li>
<li>Without any arithmetic or logic operators!</li>
</ul>
<p>So, what’s left? Parenthesis, and lots of them, as looking at the
source will reveal immediately. The main obfuscation is building the
whole algorithm using only function calls, typecasts, array lookups and
pointer operators.</p>
<h4 id="additional-obfuscations-include">Additional obfuscations
include:</h4>
<ul>
<li>Extensive reuse of identifiers: Macros share names with variables,
inner curly braces scopes contain variables with names identical to
those in the outer scopes and some of the variables have different uses
in different parts of the program. Even the large array has more than
one use.</li>
<li>A complicated data structure with “unused” fields.</li>
<li>Mostly one-letter identifiers.</li>
<li>Complex recursion: A function might call itself once, twice, or not
at all.</li>
</ul>
<h4
id="compilationportabilityrunning-notes">Compilation/Portability/Running
Notes</h4>
<ul>
<li><p>The program requires <code>char</code> to be one byte and
pointers to be at least two bytes long.</p></li>
<li><p>The program was tested on the following platforms:</p>
<ul>
<li>Ubuntu 9.04 32-bit with GCC</li>
<li>Windows 7 32-bit with GCC</li>
<li>Windows 7 32-bit with OpenWatcom</li>
</ul></li>
</ul>
<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-2012zeitak"><a name="inventory"></a>Inventory for
2012/zeitak</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/2012/zeitak/zeitak.c">zeitak.c</a>
- winning source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/zeitak/Makefile">Makefile</a>
- winner Makefile</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/zeitak/anonymous.alt.c">anonymous.alt.c</a>
- alternative source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/zeitak/anonymous.c">anonymous.c</a>
- 1984/anonymous source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/zeitak/zeitak.alt.c">zeitak.alt.c</a>
- alternative source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/zeitak/zeitak.orig.c">zeitak.orig.c</a>
- original source</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/zeitak/test.sh">test.sh</a>
- test tool</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/zeitak/incorrect.1.quote.c">incorrect.1.quote.c</a>
- example source with incorrect quote</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/zeitak/incorrect.3.quotes.c">incorrect.3.quotes.c</a>
- example source with incorrect quote</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/zeitak/incorrect.brace.c">incorrect.brace.c</a>
- example source with incorrect brace</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/zeitak/incorrect.bracket.c">incorrect.bracket.c</a>
- example source with incorrect bracket</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/zeitak/incorrect.paren.c">incorrect.paren.c</a>
- example source with incorrect parenthesis</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/zeitak/incorrect.quote-esc.c">incorrect.quote-esc.c</a>
- example source with incorrect quote escape</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/zeitak/incorrect.single.quote.c">incorrect.single.quote.c</a>
- example source with incorrect single quote</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/zeitak/incorrect.txt">incorrect.txt</a>
- example source with incorrect text</li>
<li><a href="2012_zeitak.tar.bz2">2012_zeitak.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/2012/zeitak/.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/2012/zeitak/.winner.json">.winner.json</a>
- description of winner in JSON</li>
<li><a
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2012/zeitak/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%2F2012%2Fzeitak%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 -->