add hack-a-round for language specified markdown code blocks

When language is specified in a markdown code block such as:

````
```c
    printf("Hello, world!\n");
```
````

is used, the resulting HTML as produced by `pandoc(1)` combined
with our revised `ioccc.css` is not intent the code block well.

A temporary "_hack-a-round_" is to turn the "markdown code language
specifier" into an HTML comment.  For example:

````
```<!---c-->
    printf("Hello, world!\n");
```
````

This commits turns off existing markdown code language specifiers
for now, while preserving our ability to restore them in the future
when a better  "_hack-a-round_" to the "markdown code language
specifier" problem is found.

The HTML impact if this "_hack-a-round_" is to produce HTML that
looks like this:

```
<pre class="&lt;!---c--&gt;"><code> .. </code></pre>
```

We might be able to create a complex set of classes for each markdown
code language (there won't be very many) in `ioccc.css`, or we might
find a more general CSS (or maybe `pandoc(1)`?) solution.

For now, this hack-a-round will have to do.
This commit is contained in:
Landon Curt Noll committed 2024-04-04 14:50:38 -07:00
1 parent 3919df50fb
commit b66c79254a
700 files changed
+7052 -7056

No files matched your search

+5 -5
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -18,14 +18,14 @@ For more detailed information see [2012 blakely bugs](../../bugs.html#2012_blake
## To use:
```sh
```<!---sh-->
./blakely "RPN formula" resolution > output.gif
```
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -59,7 +59,7 @@ output to `stdout`.
The program should be run as:
```sh
```<!---sh-->
./blakely xy* 32 > pic.gif
```
@@ -105,7 +105,7 @@ resolution of `ripple.gif`
to 250 took ~35 minutes to render on an [i7
processor](https://en.wikipedia.org/wiki/Intel_Core#Core_i7).
```sh
```<!---sh-->
./blakely xy* 32 > saddle.gif
./blakely xx*yy*1++d5*ct/ 64 > ripple.gif
+7 -7
View File
@@ -141,15 +141,15 @@ Location: <a href="../../location.html#GB">GB</a> - <em>United Kingdom of Great
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<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.html#2012_blakely">2012 blakely bugs</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>
<pre class="&lt;!---sh--&gt;"><code> ./blakely &quot;RPN formula&quot; resolution &gt; output.gif</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<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
@@ -169,7 +169,7 @@ 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>
<pre class="&lt;!---sh--&gt;"><code> ./blakely xy* 32 &gt; pic.gif</code></pre>
<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
@@ -201,9 +201,9 @@ 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>
<pre class="&lt;!---sh--&gt;"><code> ./blakely xy* 32 &gt; saddle.gif
./blakely xx*yy*1++d5*ct/ 64 &gt; ripple.gif</code></pre>
<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
+7 -7
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -18,14 +18,14 @@ For more detailed information see [2012 deckmyn bugs](../../bugs.html#2012_deckm
## To use:
```sh
```<!---sh-->
./deckmyn "$(cat deckmyn.c)" "$(cat musicfile.txt)" > sheetmusic.pbm
```
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -59,13 +59,13 @@ 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 [.pbm bitmap
format](https://en.wikipedia.org/wiki/Netpbm) images.
```sh
```<!---sh-->
./deckmyn "`cat deckmyn.c`" "`cat example_greensleeves`" > greensleeves.pbm
```
If you have macOS you can open the image like:
```sh
```<!---sh-->
open greensleeves.pbm
```
@@ -73,13 +73,13 @@ If you have macOS you can open the image like:
normally open an image.
```sh
```<!---sh-->
./deckmyn "`cat deckmyn.c`" "KF m44c4 c4 g4 g4 : a4 a4 g2 :; " > short_bass.pbm
```
If you have macOS you can open the image like:
```sh
```<!---sh-->
open short_bass.pbm
```
+2 -2
View File
@@ -124,7 +124,7 @@
<h1 id="user-manual">USER MANUAL</h1>
<h2 id="calling-the-program">Calling the program</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="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> musicfile<span class="kw">`</span><span class="st">&quot;</span> <span class="op">&gt;</span> output.pbm</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./deckmyn &quot;`cat deckmyn.c`&quot; &quot;`cat musicfile`&quot; &gt; output.pbm</code></pre>
<p>Then display <code>output.pbm</code>.</p>
<p>This minimalistic music notator expects two command line arguments. The first is
the font description embedded in the source code. Notice that you don’t pass the
@@ -186,7 +186,7 @@ clef. <code>"K"</code> followed by any other letter will just default to a stand
</ol>
<h2 id="examples">Examples</h2>
<p>Blank music paper (with G clef):</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">./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;sz sa x s1 x s1 x s1 x s1 x s1 &quot;</span><span class="op">&gt;</span> blank.pbm</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./deckmyn &quot;`cat deckmyn.c`&quot; &quot;sz sa x s1 x s1 x s1 x s1 x s1 &quot;&gt; blank.pbm</code></pre>
<p>With an F clef:</p>
<pre><code> ./deckmyn &quot;`cat deckmyn.c`&quot; &quot;KF sz sa x s1 x s1 x s1 x s1 x s1 &quot;&gt; blank.pbm</code></pre>
<p>Notice how only the first staff (or any staff) needs to have the full length.</p>
+2 -2
View File
@@ -3,7 +3,7 @@
## Calling the program
```sh
```<!---sh-->
./deckmyn "`cat deckmyn.c`" "`cat musicfile`" > output.pbm
```
@@ -85,7 +85,7 @@ musical element of a line is only 2 characters!
Blank music paper (with G clef):
```sh
```<!---sh-->
./deckmyn "`cat deckmyn.c`" "sz sa x s1 x s1 x s1 x s1 x s1 "> blank.pbm
```
+7 -7
View File
@@ -141,15 +141,15 @@ Location: <a href="../../location.html#BE">BE</a> - <em>Kingdom of Belgium</em>
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<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.html#2012_deckmyn">2012 deckmyn bugs</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>
<pre class="&lt;!---sh--&gt;"><code> ./deckmyn &quot;$(cat deckmyn.c)&quot; &quot;$(cat musicfile.txt)&quot; &gt; sheetmusic.pbm</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<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>
@@ -168,14 +168,14 @@ is not done in the author’s remarks, however.</p>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./deckmyn &quot;`cat deckmyn.c`&quot; &quot;`cat example_greensleeves`&quot; &gt; greensleeves.pbm</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> open greensleeves.pbm</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./deckmyn &quot;`cat deckmyn.c`&quot; &quot;KF m44c4 c4 g4 g4 : a4 a4 g2 :; &quot; &gt; short_bass.pbm</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> open short_bass.pbm</code></pre>
<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>
+3 -3
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -18,14 +18,14 @@ For more detailed information see [2012 dlowe bugs](../../bugs.html#2012_dlowe).
## To use:
```sh
```<!---sh-->
./dlowe
```
## Try:
```sh
```<!---sh-->
./dlowe
```
+3 -3
View File
@@ -141,15 +141,15 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<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.html#2012_dlowe">2012 dlowe bugs</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>
<pre class="&lt;!---sh--&gt;"><code> ./dlowe</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./dlowe</code></pre>
<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>
+15 -15
View File
@@ -1,5 +1,5 @@
```sh
```<!---sh-->
make
```
@@ -14,7 +14,7 @@ section below for more details.
## To use:
```sh
```<!---sh-->
./endoh1 < file
```
@@ -25,7 +25,7 @@ see what this looks like not going so fast then you might wish to try the
## Try:
```sh
```<!---sh-->
./try.bw.sh endoh1.c
./try.sh endoh1.c
@@ -50,7 +50,7 @@ the fluid and change the behaviour of the fluid. The file
For the default values, try:
```sh
```<!---sh-->
make alt
```
@@ -59,13 +59,13 @@ one can more easily go through the list of files to see them all in succession,
for fun. That is controlled by the variable `TIMER` at compilation.
For instance if you wish to change the value to 5:
```sh
```<!---sh-->
make clobber TIMER=5 alt
```
If you want to disable the alarm time, set it to 0:
```sh
```<!---sh-->
make clobber TIMER=0 alt
```
@@ -76,7 +76,7 @@ see and to not flash too quickly. The code protects against a value < 0 and
defaults to 12321 but you can change it to. For instance to slow it down you
could increase the sleep time from `12321` to `50000`:
```sh
```<!---sh-->
make clobber SLEEP=50000 alt
```
@@ -84,7 +84,7 @@ could increase the sleep time from `12321` to `50000`:
If you wish to speed it up you might decrease the sleep time from `12321` to
`9999`:
```sh
```<!---sh-->
make clobber SLEEP=9999 alt
```
@@ -97,7 +97,7 @@ viscosity factor, you should redefine the values `GRAVITY`, `PRESSURE` and/or
`VISCOSITY` macros, respectively. For instance if you wish to change the
viscosity and pressure factors but leave the other values alone:
```sh
```<!---sh-->
make clobber VISCOSITY=X PRESSURE=Y alt
```
@@ -111,13 +111,13 @@ You might also wish to try redefining the macros `G`, `P` and/or `V`. For
instance:
```sh
```<!---sh-->
make clobber GRAVITY=5 PRESSURE=5 VISCOSITY=5 alt
```
You might try even:
```sh
```<!---sh-->
make clobber GRAVITY=I alt
```
@@ -141,7 +141,7 @@ and `endoh1_color` above.
To see two different ways run on the source file and each of the text files,
try:
```sh
```<!---sh-->
./try.alt.sh
```
@@ -149,7 +149,7 @@ The second run of each will be with the gravity factor set to `I`.
To see the same thing but in the original uncoloured version, try:
```sh
```<!---sh-->
./try.alt.bw.sh
```
@@ -178,7 +178,7 @@ entry](https://web.archive.org/web/20230711134609/https://whatif.xkcd.com/6/).
**DO NOT FORGET** `-DG=1 -DP=4 -DV=8` and make your terminal window larger
than 80 x 25.
```sh
```<!---sh-->
cc endoh1.c -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -o endoh1 -lm
./endoh1 < endoh1.c
./endoh1 < logo.txt
@@ -246,7 +246,7 @@ to build with no warning. Under these conditions, it should be portable.
At least, recent compilers with `-std=c99 -Wall -W -Wextra -pedantic` say
nothing.
```sh
```<!---sh-->
gcc -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -std=c99 -Wall -W -Wextra -pedantic endoh1.c
clang -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -std=c99 -Wall -W -Wextra -pedantic endoh1.c
+29 -29
View File
@@ -140,7 +140,7 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
<!-- END: this line ends content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<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
@@ -149,19 +149,19 @@ judges at the time of the contest). Another version is the deobfuscated version
provided by the author as well. See the <a href="#alternate-code">Alternate code</a>
section 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> file</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./endoh1 &lt; file</code></pre>
<p>WARNING: if you’re sensitive to/don’t like flashing colours/text or just want to
see what this looks like not going so fast then you might wish to try the
<a href="#alternate-code">Alternate code</a> instead.</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.bw.sh</span> endoh1.c</span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span> endoh1.c</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.bw.sh</span> pour-out.txt</span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span> pour-out.txt</span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.bw.sh</span> fountain.txt</span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span> fountain.txt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.bw.sh endoh1.c
./try.sh endoh1.c
./try.bw.sh pour-out.txt
./try.sh pour-out.txt
./try.bw.sh fountain.txt
./try.sh fountain.txt</code></pre>
<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
@@ -170,39 +170,39 @@ 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</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make alt</code></pre>
<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>TIMER</code> at compilation.
For instance if you wish to change the value to 5:</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 TIMER=5 alt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make clobber TIMER=5 alt</code></pre>
<p>If you want to disable the alarm time, set it to 0:</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 TIMER=0 alt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make clobber TIMER=0 alt</code></pre>
<p>It cannot be &lt; 0 or &gt; 60 (arbitrarily selected).</p>
<p>The <code>SLEEP</code> variable is to delay the time between updates to make it easier to
see and to not flash too quickly. The code protects against a value &lt; 0 and
defaults to 12321 but you can change it to. For instance to slow it down you
could increase the sleep time from <code>12321</code> to <code>50000</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="fu">make</span> clobber SLEEP=50000 alt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make clobber SLEEP=50000 alt</code></pre>
<p>If you wish to speed it up you might decrease the sleep time from <code>12321</code> to
<code>9999</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=9999 alt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make clobber SLEEP=9999 alt</code></pre>
<p>WARNING: the lower the value the faster it will flash so be careful if you’re
sensitive to this.</p>
<p>If you wish to change the gravity factor, pressure factor and/or
viscosity factor, you should redefine the values <code>GRAVITY</code>, <code>PRESSURE</code> and/or
<code>VISCOSITY</code> macros, respectively. For instance if you wish to change the
viscosity and pressure factors but leave the other values alone:</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 VISCOSITY=X PRESSURE=Y alt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make clobber VISCOSITY=X PRESSURE=Y alt</code></pre>
<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. There is no attempt to check the value or type
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>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>
<pre class="&lt;!---sh--&gt;"><code> make clobber GRAVITY=5 PRESSURE=5 VISCOSITY=5 alt</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> make clobber GRAVITY=I alt</code></pre>
<p>See the author’s remarks for details on these macros where:</p>
<pre><code> G = GRAVITY
P = PRESSURE
@@ -213,10 +213,10 @@ 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="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">./try.alt.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.alt.sh</code></pre>
<p>The second run of each will be with the gravity factor set to <code>I</code>.</p>
<p>To see the same thing but in the original uncoloured version, try:</p>
<div class="sourceCode" id="cb14"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.alt.bw.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.alt.bw.sh</code></pre>
<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.
@@ -231,12 +231,12 @@ entry</a>.</p>
<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="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">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="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh1</span> <span class="op">&lt;</span> endoh1.c</span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh1</span> <span class="op">&lt;</span> logo.txt</span>
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh1</span> <span class="op">&lt;</span> column.txt</span>
<span id="cb15-5"><a href="#cb15-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh1</span> <span class="op">&lt;</span> pour-out.txt</span>
<span id="cb15-6"><a href="#cb15-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh1</span> <span class="op">&lt;</span> tanada.txt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> cc endoh1.c -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -o endoh1 -lm
./endoh1 &lt; endoh1.c
./endoh1 &lt; logo.txt
./endoh1 &lt; column.txt
./endoh1 &lt; pour-out.txt
./endoh1 &lt; tanada.txt</code></pre>
<h3 id="what-it-is">What it is</h3>
<pre><code> ,___. ,. ,. ,. ,___. ,. ,. ,.
|/--&#39; || `&#39; || |/--&#39; `&#39; || |\_.
@@ -284,9 +284,9 @@ comments. It also uses <code>usleep(3)</code>, which may require <code>-D_BSD_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="cb17"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-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="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-3"><a href="#cb17-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>
<pre class="&lt;!---sh--&gt;"><code> gcc -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -std=c99 -Wall -W -Wextra -pedantic endoh1.c
clang -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -std=c99 -Wall -W -Wextra -pedantic endoh1.c</code></pre>
<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)
+6 -6
View File
@@ -1,13 +1,13 @@
## To build:
```sh
```<!---sh-->
make
```
## To use:
```sh
```<!---sh-->
./endoh2 > pi.c
gcc -o pi pi.c
./pi > 314.c
@@ -15,7 +15,7 @@
and:
```sh
```<!---sh-->
./endoh2 e > e.c\
gcc -o e e.c
./e > 271.c
@@ -26,7 +26,7 @@ and:
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -112,7 +112,7 @@ characters and not requiring a return in `main()`. In fact, recent compilers
with `-std=c99 -Wall -W -Wextra -pedantic` would say nothing.
```sh
```<!---sh-->
gcc -std=c99 -Wall -W -Wextra -pedantic spigot.c
clang -std=c99 -Wall -W -Wextra -pedantic spigot.c
```
@@ -123,7 +123,7 @@ and gcc-4.5.3 and clang-3.1 on Cygwin.
### Synopsis
```sh
```<!---sh-->
cc endoh2.c -o endoh2
./endoh2 > pi.c
+31 -31
View File
@@ -141,18 +141,18 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./endoh2 &gt; pi.c
gcc -o pi pi.c
./pi &gt; 314.c</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./endoh2 e &gt; e.c\
gcc -o e e.c
./e &gt; 271.c</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<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>
@@ -213,32 +213,32 @@ willy-nilly.</p>
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>
<pre class="&lt;!---sh--&gt;"><code> gcc -std=c99 -Wall -W -Wextra -pedantic spigot.c
clang -std=c99 -Wall -W -Wextra -pedantic spigot.c</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> cc endoh2.c -o endoh2
./endoh2 &gt; pi.c
cat pi.c
cc pi.c -o pi ; ./pi &gt; 314.c ; cat 314.c
cc 314.c -o 314 ; ./314 &gt; 3141.c ; cat 3141.c
cc 3141.c -o 3141 ; ./3141 &gt; 31415.c ; cat 31415.c
cc 31415.c -o 31415 ; ./31415 &gt; 314159.c ; cat 314159.c
cc 314159.c -o 314159 ; ./314159 &gt; 3141592.c ; cat 3141592.c
etc...
./endoh2 e &gt; e.c
cat e.c
cc e.c -o e ; ./e &gt; 271.c ; cat 271.c
cc 271.c -o 271 ; ./271 &gt; 2718.c ; cat 2718.c
cc 2718.c -o 2718 ; ./2718 &gt; 27182.c ; cat 27182.c
cc 27182.c -o 27182 ; ./27182 &gt; 271828.c ; cat 271828.c
cc 271828.c -o 271828 ; ./271828 &gt; 2718281.c ; cat 2718281.c
etc...</code></pre>
<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>
+6 -6
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -9,7 +9,7 @@
To create a shared secret shared among `M` people with `N+1` needed to reconstruct:
```sh
```<!---sh-->
./grothe -secret 1-/dev/urandom 2-/dev/urandom ... \
N-/dev/urandom 1+shared1 2+shared2 ... M+sharedM
```
@@ -17,14 +17,14 @@ To create a shared secret shared among `M` people with `N+1` needed to reconstru
To reconstruct the original (an arbitrary combination of `N+1` or
more shared files with their proper numbers):
```sh
```<!---sh-->
./grothe I-sharedI J-sharedJ K-sharedK ... +reconstructed
```
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -75,7 +75,7 @@ To share a secret. For example:
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:
```sh
```<!---sh-->
./grothe \
-cookie_recipe.txt\
1-/dev/urandom 2-/dev/urandom\
@@ -84,7 +84,7 @@ this case the cookie recipe) back:
To put the recipe back together using the first, second and fourth pieces:
```sh
```<!---sh-->
./grothe \
1-cookie_piece1.dat 2-cookie_piece2.dat 4-cookie_piece4.dat
+cookie_recipe_restore.txt
+12 -12
View File
@@ -144,16 +144,16 @@ Location: <a href="../../location.html#FR">FR</a> - <em>French Republic</em> (<e
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./grothe -secret 1-/dev/urandom 2-/dev/urandom ... \
N-/dev/urandom 1+shared1 2+shared2 ... M+sharedM</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./grothe I-sharedI J-sharedJ K-sharedK ... +reconstructed</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<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
@@ -184,14 +184,14 @@ into 3 parts and require two of them be available to extract the original recipe
<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>
<pre class="&lt;!---sh--&gt;"><code> ./grothe \
-cookie_recipe.txt\
1-/dev/urandom 2-/dev/urandom\
1+cookie_piece1.dat 2+cookie_piece2.dat 3+cookie_piece3.dat 4+cookie_piece4.dat</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./grothe \
1-cookie_piece1.dat 2-cookie_piece2.dat 4-cookie_piece4.dat
+cookie_recipe_restore.txt</code></pre>
<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>
+5 -5
View File
@@ -1,20 +1,20 @@
## To build:
```sh
```<!---sh-->
make
```
## To use:
```sh
```<!---sh-->
./hamano < textfile > output.pdf
```
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -30,7 +30,7 @@ README.md!
That procedure looks like:
```sh
```<!---sh-->
./hamano < README.md > hint.pdf
cc -xc hint.pdf -o hint
./hint
@@ -40,7 +40,7 @@ Another PDF generated is an obfuscated `Hello World!` program (obfuscated inside
the PDF). Once this is done it will compile the PDF as if it was C (itself!). It
will look like:
```sh
```<!---sh-->
echo 'int main(){puts("Hello World!");}' | ./hamano > hello.pdf
cc -xc hello.pdf -o hello
./hello | cc -Wno-implicit-function-declaration -xc - -o ./hello2
+11 -11
View File
@@ -141,11 +141,11 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./hamano &lt; textfile &gt; output.pdf</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<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
@@ -155,17 +155,17 @@ directly instead.</p>
the PDF file will then be compiled as C (itself!) and executed so that it shows
README.md!</p>
<p>That procedure looks 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="ex">./hamano</span> <span class="op">&lt;</span> README.md <span class="op">&gt;</span> hint.pdf</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">cc</span> <span class="at">-xc</span> hint.pdf <span class="at">-o</span> hint</span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./hint</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./hamano &lt; README.md &gt; hint.pdf
cc -xc hint.pdf -o hint
./hint</code></pre>
<p>Another PDF generated is an obfuscated <code>Hello World!</code> program (obfuscated inside
the PDF). Once this is done it will compile the PDF as if it was C (itself!). It
will look like:</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="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="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">cc</span> <span class="at">-xc</span> hello.pdf <span class="at">-o</span> hello</span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./hello</span> <span class="kw">|</span> <span class="fu">cc</span> <span class="at">-Wno-implicit-function-declaration</span> <span class="at">-xc</span> <span class="at">-</span> <span class="at">-o</span> ./hello2</span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">./hello2</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> echo &#39;int main(){puts(&quot;Hello World!&quot;);}&#39; | ./hamano &gt; hello.pdf
cc -xc hello.pdf -o hello
./hello | cc -Wno-implicit-function-declaration -xc - -o ./hello2
./hello2</code></pre>
<p>although the <code>CFLAGS</code> will be what is in the Makefile as it uses the helper
rules <code>hint.pdf</code>, <code>hint</code>, <code>hello.pdf</code> and <code>hello</code> to do this.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
+5 -5
View File
@@ -1,20 +1,20 @@
## To build:
```sh
```<!---sh-->
make
```
## To use:
```sh
```<!---sh-->
./hou syntax-file file-to-process
```
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -80,7 +80,7 @@ The following regular expression operators are supported:
For example, one can use the following expression to match a certain declaration
statement in [hou.c](hou.c):
```re
```<!---re-->
"char"[ *]*[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_ ]*\]))?[ ]*)*;
```
@@ -89,7 +89,7 @@ The regex engine is also algorithmically efficient. To illustrate the point,
hang for the competing Perl engine while matching itself. Try to compare these
two engines:
```sh
```<!---sh-->
./hou ansi.txt ansi.txt
perl patho.pl < ansi.txt
```
+5 -5
View File
@@ -124,9 +124,9 @@
<h2 id="judges-comments">Judges’ comments:</h2>
<h3 id="to-build">To build:</h3>
<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> hou</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make hou</code></pre>
<h3 id="to-run">To run:</h3>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./hou syntax-file file-to-process</code></pre>
<h3 id="try-unix">Try (Unix):</h3>
<p>The results are best viewed in a 80x25 console with ANSI colors.</p>
<pre><code> less hou.c
@@ -170,12 +170,12 @@ in the regular expression by escaping it with [] or ““.</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 hou.c:</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="st">&quot;char&quot;</span><span class="op">[</span> <span class="op">*]*[</span>a<span class="op">-</span>zA<span class="op">-</span>Z_<span class="op">][</span><span class="dv">0</span><span class="op">-</span><span class="dv">9</span><span class="er">a</span><span class="op">-</span>zA<span class="op">-</span>Z_<span class="op">]*[</span> <span class="op">]*((=[</span><span class="dv">0</span><span class="op">-</span><span class="dv">9</span><span class="er">a</span><span class="op">-</span>zA<span class="op">-</span>Z_ <span class="op">]+)|(</span>\<span class="op">[[</span><span class="dv">0</span><span class="op">-</span><span class="dv">9</span><span class="er">a</span><span class="op">-</span><span class="at">zA</span><span class="op">-</span><span class="at">Z_ </span><span class="op">]*</span><span class="at">\</span><span class="op">]))?[</span><span class="at"> </span><span class="op">]*(,[</span><span class="at"> </span><span class="op">*]*[</span><span class="at">a</span><span class="op">-</span><span class="at">zA</span><span class="op">-</span><span class="at">Z_</span><span class="op">][</span><span class="dv">0</span><span class="op">-</span><span class="dv">9</span><span class="er">a</span><span class="op">-</span><span class="at">zA</span><span class="op">-</span><span class="at">Z_</span><span class="op">]*[</span><span class="at"> </span><span class="op">]*((=[</span><span class="dv">0</span><span class="op">-</span><span class="dv">9</span><span class="er">a</span><span class="op">-</span><span class="at">zA</span><span class="op">-</span><span class="at">Z_ </span><span class="op">]+)|(</span><span class="at">\</span><span class="op">[[</span><span class="dv">0</span><span class="op">-</span><span class="dv">9</span><span class="er">a</span><span class="op">-</span><span class="at">zA</span><span class="op">-</span><span class="at">Z_ </span><span class="op">]*</span><span class="at">\</span><span class="op">]))?[</span><span class="at"> </span><span class="op">]*)*;</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><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,
ansi.txt contains a pathological expression [2] 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>
<pre class="&lt;!---sh--&gt;"><code> ./hou ansi.txt ansi.txt
perl patho.pl &lt; ansi.txt</code></pre>
<p>Finally, there are a few limitations…</p>
<ul>
<li>The only escape sequence supported is and it doesn’t work in [].</li>
+4 -4
View File
@@ -2,13 +2,13 @@
### To build:
```sh
```<!---sh-->
make hou
```
### To run:
```sh
```<!---sh-->
./hou syntax-file file-to-process
```
@@ -81,7 +81,7 @@ The following regular expression operators are supported:
For example, one can use the following expression to match a certain declaration statement in hou.c:
```c
```<!---c-->
"char"[ *]*[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_ ]*\]))?[ ]*)*;
```
@@ -89,7 +89,7 @@ The regex engine is also algorithmically efficient. To illustrate the point,
ansi.txt contains a pathological expression [2] that guarantees a hang for the
competing Perl engine while matching itself. Try to compare these two engines:
```sh
```<!---sh-->
./hou ansi.txt ansi.txt
perl patho.pl < ansi.txt
```
+6 -6
View File
@@ -141,11 +141,11 @@ Location: <a href="../../location.html#CN">CN</a> - <em>People’s Republic of C
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./hou syntax-file file-to-process</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<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>
@@ -183,13 +183,13 @@ in the regular expression by escaping it with <code>[]</code> or <code>""</code>
<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>
<pre class="&lt;!---re--&gt;"><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>
<pre class="&lt;!---sh--&gt;"><code> ./hou ansi.txt ansi.txt
perl patho.pl &lt; ansi.txt</code></pre>
<h3 id="limitations">Limitations</h3>
<p>Finally, there are a few limitations…</p>
<ul>
+8 -8
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -10,14 +10,14 @@ See [Alternate code](#alternate-code) below for the (fun) rationale here.
## To use:
```sh
```<!---sh-->
echo "full spelling of an English cardinal numeral less than a quadrillion" | ./kang
```
## Try:
```sh
```<!---sh-->
./try.sh # try various languages
./en.sh # English 0 through 13
@@ -43,14 +43,14 @@ subtlety of this entry even more.
### Alternate build:
```sh
```<!---sh-->
make alt
```
### Alternate use:
```sh
```<!---sh-->
echo "full spelling of an English cardinal numeral less than a quadrillion" | ./kang.alt
echo vier | ./kang.alt
@@ -61,7 +61,7 @@ subtlety of this entry even more.
### Alternate try:
```sh
```<!---sh-->
./try.alt.sh # try various languages
./en.alt.sh # English 0 through 13
@@ -88,13 +88,13 @@ We've added a linefeed to the print format for convenience.
Can you explain why:
```sh
```<!---sh-->
echo f hundr|./kang
```
correctly reports 500 but:
```sh
```<!---sh-->
echo hundr|./kang
```
+20 -20
View File
@@ -141,17 +141,17 @@ Location: <a href="../../location.html#KR">KR</a> - <em>Republic of Korea</em> (
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> echo &quot;full spelling of an English cardinal numeral less than a quadrillion&quot; | ./kang</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh # try various languages
./en.sh # English 0 through 13
./de.sh # German 0 through 13 with both umlauts and without (additional &#39;e&#39;)</code></pre>
<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>
@@ -164,19 +164,19 @@ deal with it :-) It also breaks other words too and this happens only for one
letter change. With this one should hopefully be able to really appreciate the
subtlety of this 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>
<pre class="&lt;!---sh--&gt;"><code> make alt</code></pre>
<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> <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.alt</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-3"><a href="#cb5-3" 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-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-5"><a href="#cb5-5" 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>
<pre class="&lt;!---sh--&gt;"><code> echo &quot;full spelling of an English cardinal numeral less than a quadrillion&quot; | ./kang.alt
echo vier | ./kang.alt
echo uno | ./kang.alt</code></pre>
<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">./try.alt.sh</span> <span class="co"># try various languages</span></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">./en.alt.sh</span> <span class="co"># English 0 through 13</span></span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">./de.alt.sh</span> <span class="co"># German 0 through 13 with both umlauts and without (additional &#39;e&#39;)</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.alt.sh # try various languages
./en.alt.sh # English 0 through 13
./de.alt.sh # German 0 through 13 with both umlauts and without (additional &#39;e&#39;)</code></pre>
<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 wrong what it gets wrong?</p>
@@ -188,9 +188,9 @@ German, Italian, Russian, and Spanish numerals.</p>
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>
<pre class="&lt;!---sh--&gt;"><code> echo f hundr|./kang</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> echo hundr|./kang</code></pre>
<p>does not report 100, instead printing 0?</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="synopsis">Synopsis</h3>
+7 -7
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -10,14 +10,14 @@ code](#alternate-code) below.
## To use:
```sh
```<!---sh-->
./konno N
```
## Try:
```sh
```<!---sh-->
./try.sh
# you can also specify numbers to try before the random and preselected ones:
@@ -36,7 +36,7 @@ This alternate code is an unobfuscated version of the winning code.
### Alternate build:
```sh
```<!---sh-->
make alt
```
@@ -64,7 +64,7 @@ patterns.
Try:
```sh
```<!---sh-->
./konno 30
./konno 90
./konno 102
@@ -79,13 +79,13 @@ There are 256 (from 0 through 255) possible rules.
This program uses bit operations. I think
```c
```<!---c-->
7&O<<!o>>!o+29
```
is an interesting operation. This isn't equal to
```c
```<!---c-->
7&O>>29
```
+14 -14
View File
@@ -141,23 +141,23 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./konno N</code></pre>
<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>
<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="co"># you can also specify numbers to try before the random and preselected ones:</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span> 111 222 333 444 555 666 777 888 999</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh
# you can also specify numbers to try before the random and preselected ones:
./try.sh 111 222 333 444 555 666 777 888 999</code></pre>
<p>Try running <a href="try.sh">try.sh</a> a number of times as the first part randomly
selects ten numbers to try.</p>
<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>
<pre class="&lt;!---sh--&gt;"><code> make alt</code></pre>
<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>
@@ -170,17 +170,17 @@ This alternate code is an unobfuscated version of the winning code.</p>
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>
<pre class="&lt;!---sh--&gt;"><code> ./konno 30
./konno 90
./konno 102
./konno 109
./konno 165</code></pre>
<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>
<pre class="&lt;!---c--&gt;"><code> 7&amp;O&lt;&lt;!o&gt;&gt;!o+29</code></pre>
<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>
<pre class="&lt;!---c--&gt;"><code> 7&amp;O&gt;&gt;29</code></pre>
<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>
+10 -10
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -12,7 +12,7 @@ theoretically work with Windows which distinguishes binary and text. See
## To use:
```sh
```<!---sh-->
./nyaruko [seed.txt] < original.bin > output.c
bash output.c > key.c
perl output.c > data.c
@@ -30,7 +30,7 @@ binary itself.
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -53,13 +53,13 @@ binary mode on `stdin` and `stdout`.
For the first version:
```sh
```<!---sh-->
make alt
```
For the second version:
```sh
```<!---sh-->
make alt2
```
@@ -73,7 +73,7 @@ Use `nyaruko.alt` or `nyaruko.alt2` as you would `nyaruko` above.
For the first alternate version:
```sh
```<!---sh-->
./try.alt.sh
```
@@ -93,7 +93,7 @@ The judges have nothing to add that has not already been written about in the
`Nyaruko` is a binary to text filter. Given some input on `stdin`,
`Nyaruko` will produce C code that reproduces this input on `stdout`:
```sh
```<!---sh-->
./nyaruko < original.bin > output.c
gcc output.c -o output
./output > regenerated.bin
@@ -102,7 +102,7 @@ The judges have nothing to add that has not already been written about in the
Output is encrypted, but both key and data are included in the output.
To separate the key from the data, run these commands:
```sh
```<!---sh-->
bash output.c > key.c
perl output.c > data.c
```
@@ -114,7 +114,7 @@ why the code is formatted the way it is.
To combine the key and data, concatenate them together in either
order:
```sh
```<!---sh-->
cat key.c data.c > output.c
cat data.c key.c > output.c
```
@@ -123,7 +123,7 @@ By default, `Nyaruko` generates a unique random key for every message,
using `/dev/urandom` as the seed. If given an extra command line
argument, `Nyaruko` will seed using that file instead of `/dev/urandom`:
```sh
```<!---sh-->
./nyaruko seed.txt < input.bin > output.c
```
+21 -21
View File
@@ -141,25 +141,25 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./nyaruko [seed.txt] &lt; original.bin &gt; output.c
bash output.c &gt; key.c
perl output.c &gt; data.c
cat key.c data.c &gt; output.c
cc output.c -o output
./output &gt; regenerated.bin</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<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>
@@ -171,14 +171,14 @@ 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>
<pre class="&lt;!---sh--&gt;"><code> make alt</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> make alt2</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./try.alt.sh</code></pre>
<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
@@ -187,24 +187,24 @@ binary mode on <code>stdin</code> and <code>stdout</code>.</p>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./nyaruko &lt; original.bin &gt; output.c
gcc output.c -o output
./output &gt; regenerated.bin</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> bash output.c &gt; key.c
perl output.c &gt; data.c</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> cat key.c data.c &gt; output.c
cat data.c key.c &gt; output.c</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./nyaruko seed.txt &lt; input.bin &gt; output.c</code></pre>
<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
+19 -19
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make all # On a 64-bit machine (default)
make tromp32 # On a 32-bit machine
@@ -20,7 +20,7 @@ For more detailed information see [2012 tromp bugs](../../bugs.html#2012_tromp).
## To use:
```sh
```<!---sh-->
./tromp [-b]
```
@@ -29,7 +29,7 @@ Use `./tromp32` as you would `./tromp` if on a 32-bit machine.
## To use:
```sh
```<!---sh-->
cat ascii-prog.blc data | ./tromp -b
cat binary-prog.Blc data | ./tromp
```
@@ -37,7 +37,7 @@ Use `./tromp32` as you would `./tromp` if on a 32-bit machine.
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -113,7 +113,7 @@ identity function. When its encoding `0010` 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:
```sh
```<!---sh-->
$ echo " Hello, world" | ./tromp
Hello, world
```
@@ -122,7 +122,7 @@ 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
(`/`) will do, e.g.:
```sh
```<!---sh-->
$ echo "*Hello, world" | ./tromp
Hello, world
```
@@ -134,7 +134,7 @@ 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:
```sh
```<!---sh-->
echo -n "U" | ./tromp
```
@@ -143,7 +143,7 @@ closed, that is, variable `n` can only appear within at least `n` enclosing
lambdas. For instance, here the term `\ 5` is not closed, causing the
interpreter to crash when looking into a null-pointer environment:
```sh
```<!---sh-->
echo ">Hello, world" | ./tromp
```
@@ -200,7 +200,7 @@ The byte oriented BLC8 version weighs in at 43 bytes (shown in hexadecimal).
```
```sh
```<!---sh-->
$ (cat uni8.Blc; echo " Ni hao") | ./tromp
Ni hao
```
@@ -225,7 +225,7 @@ Even shorter than the self-interpreter is this prime number sieve in 167 bits
The `n`th bit in the output indicates whether n is prime:
```sh
```<!---sh-->
$ cat primes.blc | ./tromp -b | head -c 70
0011010100010100010100010000010100000100010100010000010000010100000100
```
@@ -265,7 +265,7 @@ The program `hilbert.Blc`, at 143 bytes, is a very twisty "one-liner" (shown in
It expects `n` arbitrary characters of input, and draws a space filling [Hilbert
curve](https://en.wikipedia.org/wiki/Hilbert_curve) of order `n`:
```sh
```<!---sh-->
$ (cat hilbert.Blc; echo -n "1") | ./tromp
_
| |
@@ -344,7 +344,7 @@ Writing BLC programs can be made slightly less painful with this parser that
translates single-letter-variable lambda calculus into BLC:
```sh
```<!---sh-->
$ echo "\f\x f (f (f x))" > three
$ cat parse.Blc three | ./tromp
000001110011100111010
@@ -358,21 +358,21 @@ into BLC8:
So we could assemble an input reversing program as
```sh
```<!---sh-->
echo "\a a ((\b b b) (\b \c \d \e d (b b) (\f f c e))) (\b \c c)" > reverse
cat parse.Blc reverse | ./tromp > reverse.blc
```
and change it to BLC8 with
```sh
```<!---sh-->
$ cat deflate.Blc reverse.blc | ./tromp > rev.Blc
$ wc rev.Blc
0 1 9 rev.Blc
```
and then try it out with:
```sh
```<!---sh-->
$ cat rev.Blc - | ./tromp
Hello, world!
^D
@@ -384,7 +384,7 @@ and then try it out with:
BLC8 program `symbolic.Blc` shows individual reduction steps on symbolic lambda terms.
Here it is used to show the calculation of 2^3 in Church numerals:
```sh
```<!---sh-->
$ echo "(\f\x f (f (f x))) (\f\x f (f x))" > threetwo
$ cat parse.Blc threetwo | ./tromp > threetwo.blc
$ cat symbolic.Blc threetwo.blc | ./tromp
@@ -412,7 +412,7 @@ 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:
```sh
```<!---sh-->
$ cat symbolic.Blc primes.blc | ./tromp | head -1
\a (\b b (b ((\c c c) (\c \d \e e (\f \g g) ((\f c c f ((\g g g) (\g f (g g)))) (\f \g \h \i i g (h (d f))))) (\c \d \e b (e c))))) (\b \c c (\d \e d) b)
```
@@ -421,7 +421,7 @@ Hardly any less obfuscated...
The last line of
```sh
```<!---sh-->
cat symbolic.Blc primes.blc | ./tromp | head -16
```
@@ -459,7 +459,7 @@ under the interpreter perform much worse than that same program written in Haske
Our interpreter copes well with extra levels of interpretation:
```sh
```<!---sh-->
$ time cat primes.blc | ./tromp -b | head -c 210 > /dev/null
real 0m0.043s
$ time cat uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
+97 -97
View File
@@ -141,21 +141,21 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.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>
<pre class="&lt;!---sh--&gt;"><code> make all # On a 64-bit machine (default)
make tromp32 # On a 32-bit machine</code></pre>
<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.html#2012_tromp">2012 tromp bugs</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>
<pre class="&lt;!---sh--&gt;"><code> ./tromp [-b]</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> cat ascii-prog.blc data | ./tromp -b
cat binary-prog.Blc data | ./tromp</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<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>
@@ -206,23 +206,23 @@ 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>
<pre class="&lt;!---sh--&gt;"><code> $ echo &quot; Hello, world&quot; | ./tromp
Hello, world</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> $ echo &quot;*Hello, world&quot; | ./tromp
Hello, world</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> echo -n &quot;U&quot; | ./tromp</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> echo &quot;&gt;Hello, world&quot; | ./tromp</code></pre>
<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,
@@ -265,8 +265,8 @@ as a self interpreter in BLC it is downright minuscule at 232 bits (29 bytes):</
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>
<pre class="&lt;!---sh--&gt;"><code> $ (cat uni8.Blc; echo &quot; Ni hao&quot;) | ./tromp
Ni hao</code></pre>
<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>
@@ -281,8 +281,8 @@ as a self interpreter in BLC it is downright minuscule at 232 bits (29 bytes):</
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>
<pre class="&lt;!---sh--&gt;"><code> $ cat primes.blc | ./tromp -b | head -c 70
0011010100010100010100010000010100000100010100010000010000010100000100</code></pre>
<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)
@@ -308,43 +308,43 @@ separated by a given character:</p>
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>
<pre class="&lt;!---sh--&gt;"><code> $ (cat hilbert.Blc; echo -n &quot;1&quot;) | ./tromp
_
| |
$ (cat hilbert.Blc; echo -n &quot;12&quot;) | ./tromp
_ _
| |_| |
|_ _|
_| |_
$ (cat hilbert.Blc; echo -n &quot;123&quot;) | ./tromp
_ _ _ _
| |_| | | |_| |
|_ _| |_ _|
_| |_____| |_
| ___ ___ |
|_| _| |_ |_|
_ |_ _| _
| |___| |___| |
$ (cat hilbert.Blc; echo -n &quot;1234&quot;) | ./tromp
_ _ _ _ _ _ _ _
| |_| | | |_| | | |_| | | |_| |
|_ _| |_ _| |_ _| |_ _|
_| |_____| |_ _| |_____| |_
| ___ ___ | | ___ ___ |
|_| _| |_ |_| |_| _| |_ |_|
_ |_ _| _ _ |_ _| _
| |___| |___| |_| |___| |___| |
|_ ___ ___ ___ ___ _|
_| |_ |_| _| |_ |_| _| |_
| _ | _ |_ _| _ | _ |
|_| |_| | |___| |___| | |_| |_|
_ _ | ___ ___ | _ _
| |_| | |_| _| |_ |_| | |_| |
|_ _| _ |_ _| _ |_ _|
_| |___| |___| |___| |___| |_</code></pre>
<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>,
@@ -370,56 +370,56 @@ followed by a <code>]</code>, followed by the input for the Brainfuck program.</
<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>
<pre class="&lt;!---sh--&gt;"><code> $ echo &quot;\f\x f (f (f x))&quot; &gt; three
$ cat parse.Blc three | ./tromp
000001110011100111010</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> echo &quot;\a a ((\b b b) (\b \c \d \e d (b b) (\f f c e))) (\b \c c)&quot; &gt; reverse
cat parse.Blc reverse | ./tromp &gt; reverse.blc</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> $ cat deflate.Blc reverse.blc | ./tromp &gt; rev.Blc
$ wc rev.Blc
0 1 9 rev.Blc</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> $ cat rev.Blc - | ./tromp
Hello, world!
^D
!dlrow ,olleH</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> $ echo &quot;(\f\x f (f (f x))) (\f\x f (f x))&quot; &gt; threetwo
$ cat parse.Blc threetwo | ./tromp &gt; threetwo.blc
$ cat symbolic.Blc threetwo.blc | ./tromp
(\a \b a (a (a b))) (\a \b a (a b))
\a (\b \c b (b c)) ((\b \c b (b c)) ((\b \c b (b c)) a))
\a \b (\c \d c (c d)) ((\c \d c (c d)) a) ((\c \d c (c d)) ((\c \d c (c d)) a) b)
\a \b (\c (\d \e d (d e)) a ((\d \e d (d e)) a c)) ((\c \d c (c d)) ((\c \d c (c d)) a) b)
\a \b (\c \d c (c d)) a ((\c \d c (c d)) a ((\c \d c (c d)) ((\c \d c (c d)) a) b))
\a \b (\c a (a c)) ((\c \d c (c d)) a ((\c \d c (c d)) ((\c \d c (c d)) a) b))
\a \b a (a ((\c \d c (c d)) a ((\c \d c (c d)) ((\c \d c (c d)) a) b)))
\a \b a (a ((\c a (a c)) ((\c \d c (c d)) ((\c \d c (c d)) a) b)))
\a \b a (a (a (a ((\c \d c (c d)) ((\c \d c (c d)) a) b))))
\a \b a (a (a (a ((\c (\d \e d (d e)) a ((\d \e d (d e)) a c)) b))))
\a \b a (a (a (a ((\c \d c (c d)) a ((\c \d c (c d)) a b)))))
\a \b a (a (a (a ((\c a (a c)) ((\c \d c (c d)) a b)))))
\a \b a (a (a (a (a (a ((\c \d c (c d)) a b))))))
\a \b a (a (a (a (a (a ((\c a (a c)) b))))))
\a \b a (a (a (a (a (a (a (a b)))))))</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> $ cat symbolic.Blc primes.blc | ./tromp | head -1
\a (\b b (b ((\c c c) (\c \d \e e (\f \g g) ((\f c c f ((\g g g) (\g f (g g)))) (\f \g \h \i i g (h (d f))))) (\c \d \e b (e c))))) (\b \c c (\d \e d) b)</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> cat symbolic.Blc primes.blc | ./tromp | head -16</code></pre>
<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
@@ -444,16 +444,16 @@ 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>
<pre class="&lt;!---sh--&gt;"><code> $ time cat primes.blc | ./tromp -b | head -c 210 &gt; /dev/null
real 0m0.043s
$ time cat uni.blc primes.blc | ./tromp -b | head -c 210 &gt; /dev/null
real 0m0.191s
$ time cat uni.blc uni.blc primes.blc | ./tromp -b | head -c 210 &gt; /dev/null
real 0m1.919s
$ time cat uni.blc uni.blc uni.blc primes.blc | ./tromp -b | head -c 210 &gt; /dev/null
real 0m23.514s
$ time cat uni.blc uni.blc uni.blc uni.blc primes.blc | ./tromp -b | head -c 210 &gt; /dev/null
real 4m52.700s</code></pre>
<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>
+11 -11
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -25,38 +25,38 @@ For more detailed information see [2012 vik bugs](../../bugs.html#2012_vik).
To embed text (from file or command line):
```sh
```<!---sh-->
./vik e base.png filename > encodedimg.png
```
or
```sh
```<!---sh-->
./vik e base.png SomeRandomText > encodedimg.png
```
To extract the embedded text:
```sh
```<!---sh-->
./vik d encodedimg.png
```
To embed a PNG into another:
```sh
```<!---sh-->
./vik e base.png source.png > encodedimg.png
```
To extract the embedded PNG:
```sh
```<!---sh-->
./vik d encodedimg.png > restored.png
```
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -68,7 +68,7 @@ For those few who might use Windows this alternate code might work.
### Alternate build:
```sh
```<!---sh-->
make alt
```
@@ -116,7 +116,7 @@ possible to get the bitmap data from the extracted image, and run it through any
of the previous winning brainfuck interpreters, but I thought it would be easier
to include an interpreter in the program to avoid the hassle:
```sh
```<!---sh-->
./vik e ioccc.png chocolate.png > encodedimg.png
./vik b encodedimg.png
```
@@ -125,7 +125,7 @@ It is of course also possible to embed a
[brainfuck](https://en.wikipedia.org/wiki/Brainfuck) program as a text file
(as explained above) and decode it, e.g.:
```sh
```<!---sh-->
./vik e ioccc.png .+[.+] > encodedimg.png
./vik b encodedimg.png
```
@@ -154,7 +154,7 @@ 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:
```c
```<!---c-->
_setmode(_fileno(stdout), 0x8000);
```
+13 -13
View File
@@ -141,7 +141,7 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<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>
@@ -151,21 +151,21 @@ code</a> section below.</p>
<p>For more detailed information see <a href="../../bugs.html#2012_vik">2012 vik bugs</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>
<pre class="&lt;!---sh--&gt;"><code> ./vik e base.png filename &gt; encodedimg.png</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./vik e base.png SomeRandomText &gt; encodedimg.png</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./vik d encodedimg.png</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./vik e base.png source.png &gt; encodedimg.png</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./vik d encodedimg.png &gt; restored.png</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> make alt</code></pre>
<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>
@@ -196,13 +196,13 @@ into another image and extracted, the bitmap data is also a valid
possible to get the bitmap data from the extracted image, and run it through any
of the previous winning brainfuck 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>
<pre class="&lt;!---sh--&gt;"><code> ./vik e ioccc.png chocolate.png &gt; encodedimg.png
./vik b encodedimg.png</code></pre>
<p>It is of course also possible to embed a
<a href="https://en.wikipedia.org/wiki/Brainfuck">brainfuck</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>
<pre class="&lt;!---sh--&gt;"><code> ./vik e ioccc.png .+[.+] &gt; encodedimg.png
./vik b encodedimg.png</code></pre>
<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
@@ -221,7 +221,7 @@ binary data to <code>stdout</code>.</p>
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>
<pre class="&lt;!---c--&gt;"><code> _setmode(_fileno(stdout), 0x8000);</code></pre>
<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
+6 -6
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -10,7 +10,7 @@ code](#alternate-code) below.
## To use:
```sh
```<!---sh-->
./zeitak < file
```
@@ -21,7 +21,7 @@ text files that are not code.
## Try:
```sh
```<!---sh-->
make test
```
@@ -38,7 +38,7 @@ understand this extremely subtle entry.
### Alternate build:
```sh
```<!---sh-->
make alt
```
@@ -92,7 +92,7 @@ around it's position.
* Ignores parenthesis inside strings or character constants, so no errors
will be detected in the following line:
```c
```<!---c-->
printf(")");
```
@@ -104,7 +104,7 @@ around it's position.
* Escapes (e.g. `\"`) are ignored, so the following line will produce
an error:
```c
```<!---c-->
printf("\"");
```
+6 -6
View File
@@ -141,16 +141,16 @@ Location: <a href="../../location.html#IL">IL</a> - <em>State of Israel</em> (<e
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<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</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./zeitak &lt; file</code></pre>
<p>where <code>file</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. You may also run it on
text files that are not code.</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>
<pre class="&lt;!---sh--&gt;"><code> make test</code></pre>
<p>NOTE: the program 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>
@@ -158,7 +158,7 @@ will not detect multiple issues.</p>
deobfuscated by the author. 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>
<pre class="&lt;!---sh--&gt;"><code> make alt</code></pre>
<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>
@@ -188,7 +188,7 @@ around it’s position.</p>
<li>Ignores parenthesis inside strings or character constants, so no errors
will be detected in the following line:</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;)&quot;</span><span class="op">);</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> printf(&quot;)&quot;);</code></pre>
<ul>
<li>Doesn’t get confused by the <a href="../../1984/anonymous/index.html">1984/anonymous</a> entry!</li>
</ul>
@@ -197,7 +197,7 @@ will be detected in the following line:</li>
<li>Escapes (e.g. <code>\"</code>) are ignored, so the following line will produce
an error:</li>
</ul>
<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> 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>
<pre class="&lt;!---c--&gt;"><code> printf(&quot;\&quot;&quot;);</code></pre>
<h4 id="obfuscation">Obfuscation</h4>
<p><a href="../../years.html">IOCCC entries</a> already contain entries without digits, control-flow
keywords and certain operators in their source. This entry has an