improved indentation and whitespace for markdown code blocks
All code blocks in markdown have been intended by at least 4 spaces. We add `--tab-stop=8` to all `pandoc(1)` executions in order to set a better tab stop indentation, especially for tab intended code blocks. Changed `bin/pandoc-wrapper.sh` VERSION from "1.5.3 2024-03-26" to "1.6 2024-03-31". Fixed `1991/brnstnd/sorta.README.md` so that the sorta code is code blocks. Removed unneeded paragraph group in copyright in `inc/footer.default.html`. Fixed excess whitespace after list Author on entry `index.html` page. Changed `bin/output-index-author.sh` VERSION from "1.5.2 2024-03-26" to "1.6 2024-03-31". Performed `make www` to perform the above and test under macOS. TODO: Fix the problem of the initial line of code being extra intended. TODO: Fix excess whitespace around code that is inline.
This commit is contained in:
1 parent
b84c27ce02
commit
a996f8d2b8
734 files changed
+16723
-16963
No files matched your search
+16
-16
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ make
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2012 blakely bugs](../../bugs.html#2012_blakely).
|
||||
@@ -19,14 +19,14 @@ For more detailed information see [2012 blakely bugs](../../bugs.html#2012_blake
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./blakely "RPN formula" resolution > output.gif
|
||||
./blakely "RPN formula" resolution > output.gif
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ output to `stdout`.
|
||||
The program should be run as:
|
||||
|
||||
```sh
|
||||
./blakely xy* 32 > pic.gif
|
||||
./blakely xy* 32 > pic.gif
|
||||
```
|
||||
|
||||
where the first parameter is a
|
||||
@@ -73,15 +73,15 @@ Notation](https://en.wikipedia.org/wiki/Reverse_Polish_notation) with the
|
||||
following characters recognised:
|
||||
|
||||
```
|
||||
+, -, *, / - usual arithmetic operations
|
||||
^ - Exponentiation; valid for constant exponent only
|
||||
s - sin
|
||||
c - cos
|
||||
0-9 - single digit integers
|
||||
d - duplicate number on stack
|
||||
t - transpose top two elements on stack
|
||||
x - x coordinate value
|
||||
y - y coordinate value
|
||||
+, -, *, / - usual arithmetic operations
|
||||
^ - Exponentiation; valid for constant exponent only
|
||||
s - sin
|
||||
c - cos
|
||||
0-9 - single digit integers
|
||||
d - duplicate number on stack
|
||||
t - transpose top two elements on stack
|
||||
x - x coordinate value
|
||||
y - y coordinate value
|
||||
```
|
||||
|
||||
NB: all arithmetic is done in double precision, so `23/` is two-thirds, rather
|
||||
@@ -106,9 +106,9 @@ to 250 took ~35 minutes to render on an [i7
|
||||
processor](https://en.wikipedia.org/wiki/Intel_Core#Core_i7).
|
||||
|
||||
```sh
|
||||
./blakely xy* 32 > saddle.gif
|
||||
./blakely xy* 32 > saddle.gif
|
||||
|
||||
./blakely xx*yy*1++d5*ct/ 64 > ripple.gif
|
||||
./blakely xx*yy*1++d5*ct/ 64 > ripple.gif
|
||||
```
|
||||
|
||||
|
||||
|
||||
+17
-18
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Philip_Blakely">Philip Blakely</a><br>
|
||||
Location: <a href="../../location.html#GB">GB</a> - <em>United Kingdom of Great Britain and Northern Ireland</em> (<em>United Kingdom</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#GB">GB</a> - <em>United Kingdom of Great Britain and Northern Ireland</em> (<em>United Kingdom</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,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>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<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">"RPN formula"</span> resolution <span class="op">></span> output.gif</span></code></pre></div>
|
||||
<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">"RPN formula"</span> resolution <span class="op">></span> output.gif</span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>Several IOCCC themes (<a href="https://en.wikipedia.org/wiki/Reverse_Polish_notation">RPN
|
||||
calculator</a>, animated
|
||||
@@ -170,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">></span> pic.gif</span></code></pre></div>
|
||||
<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">></span> pic.gif</span></code></pre></div>
|
||||
<p>where the first parameter is a
|
||||
<a href="https://en.wikipedia.org/wiki/Reverse_Polish_notation">RPN</a> expression, and the
|
||||
second is the width of the required <a href="https://en.wikipedia.org/wiki/GIF">GIF</a>, up
|
||||
@@ -178,15 +177,15 @@ to a maximum of 250.</p>
|
||||
<p>The expressions are written in <a href="https://en.wikipedia.org/wiki/Reverse_Polish_notation">Reverse Polish
|
||||
Notation</a> with the
|
||||
following characters recognised:</p>
|
||||
<pre><code>+, -, *, / - usual arithmetic operations
|
||||
^ - Exponentiation; valid for constant exponent only
|
||||
s - sin
|
||||
c - cos
|
||||
0-9 - single digit integers
|
||||
d - duplicate number on stack
|
||||
t - transpose top two elements on stack
|
||||
x - x coordinate value
|
||||
y - y coordinate value</code></pre>
|
||||
<pre><code> +, -, *, / - usual arithmetic operations
|
||||
^ - Exponentiation; valid for constant exponent only
|
||||
s - sin
|
||||
c - cos
|
||||
0-9 - single digit integers
|
||||
d - duplicate number on stack
|
||||
t - transpose top two elements on stack
|
||||
x - x coordinate value
|
||||
y - y coordinate value</code></pre>
|
||||
<p>NB: all arithmetic is done in double precision, so <code>23/</code> is two-thirds, rather
|
||||
than 0.</p>
|
||||
<p>The surface plotted corresponds to <code>-1 <= x,y <= 1</code> and for best results, the
|
||||
@@ -202,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">></span> saddle.gif</span>
|
||||
<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">></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">></span> ripple.gif</span></code></pre></div>
|
||||
<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">></span> ripple.gif</span></code></pre></div>
|
||||
<h3 id="algorithm">Algorithm</h3>
|
||||
<p>A generic root-finding algorithm to find the point of intersection between a ray
|
||||
and the surface is done using a simple forward search from the eye. In order to
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ make
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2012 deckmyn bugs](../../bugs.html#2012_deckmyn).
|
||||
@@ -19,14 +19,14 @@ For more detailed information see [2012 deckmyn bugs](../../bugs.html#2012_deckm
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./deckmyn "$(cat deckmyn.c)" "$(cat musicfile.txt)" > sheetmusic.pbm
|
||||
./deckmyn "$(cat deckmyn.c)" "$(cat musicfile.txt)" > sheetmusic.pbm
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -60,13 +60,13 @@ manual input as below) ready and a program capable of showing [.pbm bitmap
|
||||
format](https://en.wikipedia.org/wiki/Netpbm) images.
|
||||
|
||||
```sh
|
||||
./deckmyn "`cat deckmyn.c`" "`cat example_greensleeves`" > greensleeves.pbm
|
||||
./deckmyn "`cat deckmyn.c`" "`cat example_greensleeves`" > greensleeves.pbm
|
||||
```
|
||||
|
||||
If you have macOS you can open the image like:
|
||||
|
||||
```sh
|
||||
open greensleeves.pbm
|
||||
open greensleeves.pbm
|
||||
```
|
||||
|
||||
... otherwise, you'll have to open it in your viewer of choice how you would
|
||||
@@ -74,13 +74,13 @@ normally open an image.
|
||||
|
||||
|
||||
```sh
|
||||
./deckmyn "`cat deckmyn.c`" "KF m44c4 c4 g4 g4 : a4 a4 g2 :; " > short_bass.pbm
|
||||
./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
|
||||
open short_bass.pbm
|
||||
open short_bass.pbm
|
||||
```
|
||||
|
||||
... otherwise, you'll have to open it in your viewer of choice how you would
|
||||
|
||||
@@ -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">"</span><span class="kw">`</span><span class="fu">cat</span> deckmyn.c<span class="kw">`</span><span class="st">"</span> <span class="st">"</span><span class="kw">`</span><span class="fu">cat</span> musicfile<span class="kw">`</span><span class="st">"</span> <span class="op">></span> output.pbm</span></code></pre></div>
|
||||
<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">"</span><span class="kw">`</span><span class="fu">cat</span> deckmyn.c<span class="kw">`</span><span class="st">"</span> <span class="st">"</span><span class="kw">`</span><span class="fu">cat</span> musicfile<span class="kw">`</span><span class="st">"</span> <span class="op">></span> output.pbm</span></code></pre></div>
|
||||
<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,9 +186,9 @@ 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">"</span><span class="kw">`</span><span class="fu">cat</span> deckmyn.c<span class="kw">`</span><span class="st">"</span> <span class="st">"sz sa x s1 x s1 x s1 x s1 x s1 "</span><span class="op">></span> blank.pbm</span></code></pre></div>
|
||||
<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">"</span><span class="kw">`</span><span class="fu">cat</span> deckmyn.c<span class="kw">`</span><span class="st">"</span> <span class="st">"sz sa x s1 x s1 x s1 x s1 x s1 "</span><span class="op">></span> blank.pbm</span></code></pre></div>
|
||||
<p>With an F clef:</p>
|
||||
<pre><code>./deckmyn "`cat deckmyn.c`" "KF sz sa x s1 x s1 x s1 x s1 x s1 "> blank.pbm</code></pre>
|
||||
<pre><code> ./deckmyn "`cat deckmyn.c`" "KF sz sa x s1 x s1 x s1 x s1 x s1 "> blank.pbm</code></pre>
|
||||
<p>Notice how only the first staff (or any staff) needs to have the full length.</p>
|
||||
<p>Some files with well-known melodies are included as examples.</p>
|
||||
<!--
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
## Calling the program
|
||||
|
||||
```sh
|
||||
./deckmyn "`cat deckmyn.c`" "`cat musicfile`" > output.pbm
|
||||
./deckmyn "`cat deckmyn.c`" "`cat musicfile`" > output.pbm
|
||||
```
|
||||
|
||||
Then display `output.pbm`.
|
||||
@@ -86,13 +86,13 @@ musical element of a line is only 2 characters!
|
||||
Blank music paper (with G clef):
|
||||
|
||||
```sh
|
||||
./deckmyn "`cat deckmyn.c`" "sz sa x s1 x s1 x s1 x s1 x s1 "> blank.pbm
|
||||
./deckmyn "`cat deckmyn.c`" "sz sa x s1 x s1 x s1 x s1 x s1 "> blank.pbm
|
||||
```
|
||||
|
||||
With an F clef:
|
||||
|
||||
```
|
||||
./deckmyn "`cat deckmyn.c`" "KF sz sa x s1 x s1 x s1 x s1 x s1 "> blank.pbm
|
||||
./deckmyn "`cat deckmyn.c`" "KF sz sa x s1 x s1 x s1 x s1 x s1 "> blank.pbm
|
||||
```
|
||||
|
||||
Notice how only the first staff (or any staff) needs to have the full length.
|
||||
|
||||
+9
-10
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Alex_Deckmyn">Alex Deckmyn</a><br>
|
||||
Location: <a href="../../location.html#BE">BE</a> - <em>Kingdom of Belgium</em> (<em>Belgium</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#BE">BE</a> - <em>Kingdom of Belgium</em> (<em>Belgium</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,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>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<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">"</span><span class="va">$(</span><span class="fu">cat</span> deckmyn.c<span class="va">)</span><span class="st">"</span> <span class="st">"</span><span class="va">$(</span><span class="fu">cat</span> musicfile.txt<span class="va">)</span><span class="st">"</span> <span class="op">></span> sheetmusic.pbm</span></code></pre></div>
|
||||
<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">"</span><span class="va">$(</span><span class="fu">cat</span> deckmyn.c<span class="va">)</span><span class="st">"</span> <span class="st">"</span><span class="va">$(</span><span class="fu">cat</span> musicfile.txt<span class="va">)</span><span class="st">"</span> <span class="op">></span> sheetmusic.pbm</span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>The C of this entry is definitely sharp. The program cleverly uses its own
|
||||
source at runtime to define the notes, time signature and accidental bitmaps.</p>
|
||||
@@ -169,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">"</span><span class="kw">`</span><span class="fu">cat</span> deckmyn.c<span class="kw">`</span><span class="st">"</span> <span class="st">"</span><span class="kw">`</span><span class="fu">cat</span> example_greensleeves<span class="kw">`</span><span class="st">"</span> <span class="op">></span> greensleeves.pbm</span></code></pre></div>
|
||||
<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">"</span><span class="kw">`</span><span class="fu">cat</span> deckmyn.c<span class="kw">`</span><span class="st">"</span> <span class="st">"</span><span class="kw">`</span><span class="fu">cat</span> example_greensleeves<span class="kw">`</span><span class="st">"</span> <span class="op">></span> greensleeves.pbm</span></code></pre></div>
|
||||
<p>If you have macOS you can open the image like:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ex">open</span> greensleeves.pbm</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">open</span> greensleeves.pbm</span></code></pre></div>
|
||||
<p>… otherwise, you’ll have to open it in your viewer of choice how you would
|
||||
normally open an image.</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./deckmyn</span> <span class="st">"</span><span class="kw">`</span><span class="fu">cat</span> deckmyn.c<span class="kw">`</span><span class="st">"</span> <span class="st">"KF m44c4 c4 g4 g4 : a4 a4 g2 :; "</span> <span class="op">></span> short_bass.pbm</span></code></pre></div>
|
||||
<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">"</span><span class="kw">`</span><span class="fu">cat</span> deckmyn.c<span class="kw">`</span><span class="st">"</span> <span class="st">"KF m44c4 c4 g4 g4 : a4 a4 g2 :; "</span> <span class="op">></span> short_bass.pbm</span></code></pre></div>
|
||||
<p>If you have macOS you can open the image like:</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">open</span> short_bass.pbm</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">open</span> short_bass.pbm</span></code></pre></div>
|
||||
<p>… otherwise, you’ll have to open it in your viewer of choice how you would
|
||||
normally open an image.</p>
|
||||
<h3 id="description">Description</h3>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ make
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2012 dlowe bugs](../../bugs.html#2012_dlowe).
|
||||
@@ -19,14 +19,14 @@ For more detailed information see [2012 dlowe bugs](../../bugs.html#2012_dlowe).
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./dlowe
|
||||
./dlowe
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./dlowe
|
||||
./dlowe
|
||||
```
|
||||
|
||||
Watch for a while if you like, then press a key within the window.
|
||||
|
||||
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#J_David_Lowe">J. David Lowe</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,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>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<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>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./dlowe</span></span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./dlowe</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./dlowe</span></span></code></pre></div>
|
||||
<p>Watch for a while if you like, then press a key within the window.</p>
|
||||
<p>Use up and down keys to escape death.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
|
||||
+29
-29
@@ -1,6 +1,6 @@
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
There are two alt versions that let you control the compile time variables that
|
||||
@@ -15,7 +15,7 @@ section below for more details.
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./endoh1 < file
|
||||
./endoh1 < file
|
||||
```
|
||||
|
||||
WARNING: if you're sensitive to/don't like flashing colours/text or just want to
|
||||
@@ -26,14 +26,14 @@ see what this looks like not going so fast then you might wish to try the
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.bw.sh endoh1.c
|
||||
./try.sh endoh1.c
|
||||
./try.bw.sh endoh1.c
|
||||
./try.sh endoh1.c
|
||||
|
||||
./try.bw.sh pour-out.txt
|
||||
./try.sh pour-out.txt
|
||||
./try.bw.sh pour-out.txt
|
||||
./try.sh pour-out.txt
|
||||
|
||||
./try.bw.sh fountain.txt
|
||||
./try.sh fountain.txt
|
||||
./try.bw.sh fountain.txt
|
||||
./try.sh fountain.txt
|
||||
```
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ the fluid and change the behaviour of the fluid. The file
|
||||
For the default values, try:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
make alt
|
||||
```
|
||||
|
||||
In the `alt` versions a default time of 10 seconds is set as an alarm so that
|
||||
@@ -60,13 +60,13 @@ for fun. That is controlled by the variable `TIMER` at compilation.
|
||||
For instance if you wish to change the value to 5:
|
||||
|
||||
```sh
|
||||
make clobber TIMER=5 alt
|
||||
make clobber TIMER=5 alt
|
||||
```
|
||||
|
||||
If you want to disable the alarm time, set it to 0:
|
||||
|
||||
```sh
|
||||
make clobber TIMER=0 alt
|
||||
make clobber TIMER=0 alt
|
||||
```
|
||||
|
||||
It cannot be < 0 or > 60 (arbitrarily selected).
|
||||
@@ -77,7 +77,7 @@ 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
|
||||
make clobber SLEEP=50000 alt
|
||||
make clobber SLEEP=50000 alt
|
||||
```
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ If you wish to speed it up you might decrease the sleep time from `12321` to
|
||||
`9999`:
|
||||
|
||||
```sh
|
||||
make clobber SLEEP=9999 alt
|
||||
make clobber SLEEP=9999 alt
|
||||
```
|
||||
|
||||
WARNING: the lower the value the faster it will flash so be careful if you're
|
||||
@@ -98,7 +98,7 @@ viscosity factor, you should redefine the values `GRAVITY`, `PRESSURE` and/or
|
||||
viscosity and pressure factors but leave the other values alone:
|
||||
|
||||
```sh
|
||||
make clobber VISCOSITY=X PRESSURE=Y alt
|
||||
make clobber VISCOSITY=X PRESSURE=Y alt
|
||||
```
|
||||
|
||||
where `X` and `Y` are numbers or the letter `I` and which are, respectively, the
|
||||
@@ -112,21 +112,21 @@ instance:
|
||||
|
||||
|
||||
```sh
|
||||
make clobber GRAVITY=5 PRESSURE=5 VISCOSITY=5 alt
|
||||
make clobber GRAVITY=5 PRESSURE=5 VISCOSITY=5 alt
|
||||
```
|
||||
|
||||
You might try even:
|
||||
|
||||
```sh
|
||||
make clobber GRAVITY=I alt
|
||||
make clobber GRAVITY=I alt
|
||||
```
|
||||
|
||||
See the author's remarks for details on these macros where:
|
||||
|
||||
```
|
||||
G = GRAVITY
|
||||
P = PRESSURE
|
||||
V = VISCOSITY
|
||||
G = GRAVITY
|
||||
P = PRESSURE
|
||||
V = VISCOSITY
|
||||
```
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ To see two different ways run on the source file and each of the text files,
|
||||
try:
|
||||
|
||||
```sh
|
||||
./try.alt.sh
|
||||
./try.alt.sh
|
||||
```
|
||||
|
||||
The second run of each will be with the gravity factor set to `I`.
|
||||
@@ -150,7 +150,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
|
||||
./try.alt.bw.sh
|
||||
./try.alt.bw.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -179,12 +179,12 @@ entry](https://web.archive.org/web/20230711134609/https://whatif.xkcd.com/6/).
|
||||
than 80 x 25.
|
||||
|
||||
```sh
|
||||
cc endoh1.c -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -o endoh1 -lm
|
||||
./endoh1 < endoh1.c
|
||||
./endoh1 < logo.txt
|
||||
./endoh1 < column.txt
|
||||
./endoh1 < pour-out.txt
|
||||
./endoh1 < tanada.txt
|
||||
cc endoh1.c -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -o endoh1 -lm
|
||||
./endoh1 < endoh1.c
|
||||
./endoh1 < logo.txt
|
||||
./endoh1 < column.txt
|
||||
./endoh1 < pour-out.txt
|
||||
./endoh1 < tanada.txt
|
||||
```
|
||||
|
||||
### What it is
|
||||
@@ -247,9 +247,9 @@ At least, recent compilers with `-std=c99 -Wall -W -Wextra -pedantic` say
|
||||
nothing.
|
||||
|
||||
```sh
|
||||
gcc -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -std=c99 -Wall -W -Wextra -pedantic endoh1.c
|
||||
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
|
||||
clang -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -std=c99 -Wall -W -Wextra -pedantic endoh1.c
|
||||
```
|
||||
|
||||
I expect it to work in any Unix-like environment. VTxxx/ANSI sequences are
|
||||
|
||||
+30
-31
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Yusuke_Endoh">Yusuke Endoh</a><br>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -141,7 +140,7 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<!-- 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>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<p>There are two alt versions that let you control the compile time variables that
|
||||
control the fluid behaviour and the added variables to speed up or slow down the
|
||||
fluid as well as setting a timeout (if not 0): one for the original black and
|
||||
@@ -150,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"><</span> file</span></code></pre></div>
|
||||
<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"><</span> file</span></code></pre></div>
|
||||
<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>
|
||||
<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-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>
|
||||
<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>
|
||||
<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
|
||||
@@ -171,53 +170,53 @@ 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>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
|
||||
<p>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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<p>It cannot be < 0 or > 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 < 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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> clobber GRAVITY=5 PRESSURE=5 VISCOSITY=5 alt</span></code></pre></div>
|
||||
<p>You might try even:</p>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> clobber GRAVITY=I alt</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> clobber GRAVITY=I alt</span></code></pre></div>
|
||||
<p>See the author’s remarks for details on these macros where:</p>
|
||||
<pre><code>G = GRAVITY
|
||||
P = PRESSURE
|
||||
V = VISCOSITY</code></pre>
|
||||
<pre><code> G = GRAVITY
|
||||
P = PRESSURE
|
||||
V = VISCOSITY</code></pre>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<p>Use <code>endoh1.alt</code>, <code>endoh1_color.alt</code> and <code>endoh1.alt2</code> as you would <code>endoh1</code>
|
||||
and <code>endoh1_color</code> above.</p>
|
||||
<h3 id="alternate-try">Alternate try:</h3>
|
||||
<p>To see two different ways run on the source file and each of the text files,
|
||||
try:</p>
|
||||
<div class="sourceCode" id="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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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.
|
||||
@@ -232,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"><</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"><</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"><</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"><</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"><</span> tanada.txt</span></code></pre></div>
|
||||
<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"><</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"><</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"><</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"><</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"><</span> tanada.txt</span></code></pre></div>
|
||||
<h3 id="what-it-is">What it is</h3>
|
||||
<pre><code> ,___. ,. ,. ,. ,___. ,. ,. ,.
|
||||
|/--' || `' || |/--' `' || |\_.
|
||||
@@ -285,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>
|
||||
<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>
|
||||
<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>
|
||||
<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)
|
||||
|
||||
+27
-27
@@ -1,24 +1,24 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./endoh2 > pi.c
|
||||
gcc -o pi pi.c
|
||||
./pi > 314.c
|
||||
./endoh2 > pi.c
|
||||
gcc -o pi pi.c
|
||||
./pi > 314.c
|
||||
```
|
||||
|
||||
and:
|
||||
|
||||
```sh
|
||||
./endoh2 e > e.c\
|
||||
gcc -o e e.c
|
||||
./e > 271.c
|
||||
./endoh2 e > e.c\
|
||||
gcc -o e e.c
|
||||
./e > 271.c
|
||||
```
|
||||
|
||||
...
|
||||
@@ -27,7 +27,7 @@ gcc -o e e.c
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -113,8 +113,8 @@ with `-std=c99 -Wall -W -Wextra -pedantic` would say nothing.
|
||||
|
||||
|
||||
```sh
|
||||
gcc -std=c99 -Wall -W -Wextra -pedantic spigot.c
|
||||
clang -std=c99 -Wall -W -Wextra -pedantic spigot.c
|
||||
gcc -std=c99 -Wall -W -Wextra -pedantic spigot.c
|
||||
clang -std=c99 -Wall -W -Wextra -pedantic spigot.c
|
||||
```
|
||||
|
||||
I've tested with gcc-4.6.3 and clang-3.0 on Linux (Ubuntu 12.04)
|
||||
@@ -124,27 +124,27 @@ and gcc-4.5.3 and clang-3.1 on Cygwin.
|
||||
### Synopsis
|
||||
|
||||
```sh
|
||||
cc endoh2.c -o endoh2
|
||||
cc endoh2.c -o endoh2
|
||||
|
||||
./endoh2 > pi.c
|
||||
cat pi.c
|
||||
./endoh2 > pi.c
|
||||
cat pi.c
|
||||
|
||||
cc pi.c -o pi ; ./pi > 314.c ; cat 314.c
|
||||
cc 314.c -o 314 ; ./314 > 3141.c ; cat 3141.c
|
||||
cc 3141.c -o 3141 ; ./3141 > 31415.c ; cat 31415.c
|
||||
cc 31415.c -o 31415 ; ./31415 > 314159.c ; cat 314159.c
|
||||
cc 314159.c -o 314159 ; ./314159 > 3141592.c ; cat 3141592.c
|
||||
etc...
|
||||
cc pi.c -o pi ; ./pi > 314.c ; cat 314.c
|
||||
cc 314.c -o 314 ; ./314 > 3141.c ; cat 3141.c
|
||||
cc 3141.c -o 3141 ; ./3141 > 31415.c ; cat 31415.c
|
||||
cc 31415.c -o 31415 ; ./31415 > 314159.c ; cat 314159.c
|
||||
cc 314159.c -o 314159 ; ./314159 > 3141592.c ; cat 3141592.c
|
||||
etc...
|
||||
|
||||
./endoh2 e > e.c
|
||||
cat e.c
|
||||
./endoh2 e > e.c
|
||||
cat e.c
|
||||
|
||||
cc e.c -o e ; ./e > 271.c ; cat 271.c
|
||||
cc 271.c -o 271 ; ./271 > 2718.c ; cat 2718.c
|
||||
cc 2718.c -o 2718 ; ./2718 > 27182.c ; cat 27182.c
|
||||
cc 27182.c -o 27182 ; ./27182 > 271828.c ; cat 271828.c
|
||||
cc 271828.c -o 271828 ; ./271828 > 2718281.c ; cat 2718281.c
|
||||
etc...
|
||||
cc e.c -o e ; ./e > 271.c ; cat 271.c
|
||||
cc 271.c -o 271 ; ./271 > 2718.c ; cat 2718.c
|
||||
cc 2718.c -o 2718 ; ./2718 > 27182.c ; cat 27182.c
|
||||
cc 27182.c -o 27182 ; ./27182 > 271828.c ; cat 271828.c
|
||||
cc 271828.c -o 271828 ; ./271828 > 2718281.c ; cat 2718281.c
|
||||
etc...
|
||||
```
|
||||
|
||||
You can do `make everything` for the process (with no `cat`).
|
||||
|
||||
+28
-29
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Yusuke_Endoh">Yusuke Endoh</a><br>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,18 +141,18 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</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>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./endoh2</span> <span class="op">></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">></span> 314.c</span></code></pre></div>
|
||||
<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">></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">></span> 314.c</span></code></pre></div>
|
||||
<p>and:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./endoh2</span> e <span class="op">></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">></span> 271.c</span></code></pre></div>
|
||||
<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">></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">></span> 271.c</span></code></pre></div>
|
||||
<p>…</p>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>A
|
||||
<a href="https://en.wikipedia.org/wiki/Pi">pi</a>/<a href="https://en.wikipedia.org/wiki/E_(mathematical_constant)">e</a>
|
||||
@@ -214,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>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> <span class="at">-std</span><span class="op">=</span>c99 <span class="at">-Wall</span> <span class="at">-W</span> <span class="at">-Wextra</span> <span class="at">-pedantic</span> spigot.c</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">clang</span> <span class="at">-std</span><span class="op">=</span>c99 <span class="at">-Wall</span> <span class="at">-W</span> <span class="at">-Wextra</span> <span class="at">-pedantic</span> spigot.c</span></code></pre></div>
|
||||
<p>I’ve tested with gcc-4.6.3 and clang-3.0 on Linux (Ubuntu 12.04)
|
||||
and gcc-4.5.3 and clang-3.1 on Cygwin.</p>
|
||||
<h3 id="synopsis">Synopsis</h3>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> endoh2.c <span class="at">-o</span> endoh2</span>
|
||||
<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">></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-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh2</span> <span class="op">></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">></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">></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">></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">></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">></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-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">></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">></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">></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">></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">></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">></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-13"><a href="#cb6-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh2</span> e <span class="op">></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">></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">></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">></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">></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">></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>
|
||||
<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">></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">></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">></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">></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">></span> 2718281.c <span class="kw">;</span> <span class="fu">cat</span> 2718281.c</span>
|
||||
<span id="cb6-21"><a href="#cb6-21" aria-hidden="true" tabindex="-1"></a> <span class="ex">etc...</span></span></code></pre></div>
|
||||
<p>You can do <code>make everything</code> for the process (with no <code>cat</code>).</p>
|
||||
<p>Note: The executable may return a failure (non-zero) exit status
|
||||
unless <code>-std=c99</code> option is given.</p>
|
||||
|
||||
+12
-12
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
@@ -10,22 +10,22 @@ make
|
||||
To create a shared secret shared among `M` people with `N+1` needed to reconstruct:
|
||||
|
||||
```sh
|
||||
./grothe -secret 1-/dev/urandom 2-/dev/urandom ... \
|
||||
N-/dev/urandom 1+shared1 2+shared2 ... M+sharedM
|
||||
./grothe -secret 1-/dev/urandom 2-/dev/urandom ... \
|
||||
N-/dev/urandom 1+shared1 2+shared2 ... M+sharedM
|
||||
```
|
||||
|
||||
To reconstruct the original (an arbitrary combination of `N+1` or
|
||||
more shared files with their proper numbers):
|
||||
|
||||
```sh
|
||||
./grothe I-sharedI J-sharedJ K-sharedK ... +reconstructed
|
||||
./grothe I-sharedI J-sharedJ K-sharedK ... +reconstructed
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -76,18 +76,18 @@ 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
|
||||
./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
|
||||
./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
|
||||
```
|
||||
|
||||
To put the recipe back together using the first, second and fourth pieces:
|
||||
|
||||
```sh
|
||||
./grothe \
|
||||
1-cookie_piece1.dat 2-cookie_piece2.dat 4-cookie_piece4.dat
|
||||
+cookie_recipe_restore.txt
|
||||
./grothe \
|
||||
1-cookie_piece1.dat 2-cookie_piece2.dat 4-cookie_piece4.dat
|
||||
+cookie_recipe_restore.txt
|
||||
```
|
||||
|
||||
|
||||
|
||||
+13
-14
@@ -135,8 +135,7 @@
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
<li>Name: <a href="../../authors.html#David_Madore">David Madore</a><br>
|
||||
Location: <a href="../../location.html#FR">FR</a> - <em>French Republic</em> (<em>France</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#FR">FR</a> - <em>French Republic</em> (<em>France</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -145,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>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<p>To create a shared secret shared among <code>M</code> people with <code>N+1</code> needed to reconstruct:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./grothe</span> <span class="at">-secret</span> 1-/dev/urandom 2-/dev/urandom ... <span class="dt">\</span></span>
|
||||
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> N-/dev/urandom 1+shared1 2+shared2 ... M+sharedM</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./grothe</span> <span class="at">-secret</span> 1-/dev/urandom 2-/dev/urandom ... <span class="dt">\</span></span>
|
||||
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> N-/dev/urandom 1+shared1 2+shared2 ... M+sharedM</span></code></pre></div>
|
||||
<p>To reconstruct the original (an arbitrary combination of <code>N+1</code> or
|
||||
more shared files with their proper numbers):</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./grothe</span> I-sharedI J-sharedJ K-sharedK ... +reconstructed</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./grothe</span> I-sharedI J-sharedJ K-sharedK ... +reconstructed</span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>Also known as ‘Best abuse of the judging process’.</p>
|
||||
<p>The IOCCC 2012 submission page didn’t enforce the 2048 meaningful character
|
||||
@@ -185,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>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./grothe</span> <span class="dt">\</span></span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="at">-cookie_recipe.txt</span><span class="dt">\</span></span>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> 1-/dev/urandom 2-/dev/urandom<span class="dt">\</span></span>
|
||||
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> 1+cookie_piece1.dat 2+cookie_piece2.dat 3+cookie_piece3.dat 4+cookie_piece4.dat</span></code></pre></div>
|
||||
<p>To put the recipe back together using the first, second and fourth pieces:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./grothe</span> <span class="dt">\</span></span>
|
||||
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> 1-cookie_piece1.dat 2-cookie_piece2.dat 4-cookie_piece4.dat</span>
|
||||
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">+cookie_recipe_restore.txt</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./grothe</span> <span class="dt">\</span></span>
|
||||
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> 1-cookie_piece1.dat 2-cookie_piece2.dat 4-cookie_piece4.dat</span>
|
||||
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">+cookie_recipe_restore.txt</span></span></code></pre></div>
|
||||
<h3 id="limitations">Limitations</h3>
|
||||
<p>The program is limited to 256 input and output files and will slow down
|
||||
dramatically when you get past 20-50 inputs and outputs.</p>
|
||||
|
||||
+10
-10
@@ -1,21 +1,21 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./hamano < textfile > output.pdf
|
||||
./hamano < textfile > output.pdf
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
The script will generate a number of PDF files and it will suggest you look at
|
||||
@@ -31,9 +31,9 @@ README.md!
|
||||
That procedure looks like:
|
||||
|
||||
```sh
|
||||
./hamano < README.md > hint.pdf
|
||||
cc -xc hint.pdf -o hint
|
||||
./hint
|
||||
./hamano < README.md > hint.pdf
|
||||
cc -xc hint.pdf -o hint
|
||||
./hint
|
||||
```
|
||||
|
||||
Another PDF generated is an obfuscated `Hello World!` program (obfuscated inside
|
||||
@@ -41,11 +41,11 @@ the PDF). Once this is done it will compile the PDF as if it was C (itself!). It
|
||||
will look like:
|
||||
|
||||
```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
|
||||
echo 'int main(){puts("Hello World!");}' | ./hamano > hello.pdf
|
||||
cc -xc hello.pdf -o hello
|
||||
./hello | cc -Wno-implicit-function-declaration -xc - -o ./hello2
|
||||
|
||||
./hello2
|
||||
./hello2
|
||||
```
|
||||
|
||||
although the `CFLAGS` will be what is in the Makefile as it uses the helper
|
||||
|
||||
+11
-12
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Tsukasa_Hamano">Tsukasa Hamano</a><br>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,11 +141,11 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</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>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./hamano</span> <span class="op"><</span> textfile <span class="op">></span> output.pdf</span></code></pre></div>
|
||||
<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"><</span> textfile <span class="op">></span> output.pdf</span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<p>The script will generate a number of PDF files and it will suggest you look at
|
||||
them as well. You can read <code>hint.pdf</code> with a PDF reader like <code>acroread hint.pdf</code>
|
||||
or <code>evince hint.pdf</code>. With macOS you can do <code>open hint.pdf</code> which by default
|
||||
@@ -156,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"><</span> README.md <span class="op">></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>
|
||||
<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"><</span> README.md <span class="op">></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>
|
||||
<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">'int main(){puts("Hello World!");}'</span> <span class="kw">|</span> <span class="ex">./hamano</span> <span class="op">></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>
|
||||
<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">'int main(){puts("Hello World!");}'</span> <span class="kw">|</span> <span class="ex">./hamano</span> <span class="op">></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>
|
||||
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">./hello2</span></span></code></pre></div>
|
||||
<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>
|
||||
|
||||
+11
-11
@@ -1,21 +1,21 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./hou syntax-file file-to-process
|
||||
./hou syntax-file file-to-process
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
View the `remarks.htm` file in your web browser.
|
||||
@@ -26,9 +26,9 @@ The result is best viewed in a 80x25 console with ANSI colors.
|
||||
## Try (Windows):
|
||||
|
||||
```
|
||||
copy header.htm hou.htm /y
|
||||
hou html.txt hou.c >> hou.htm
|
||||
start hou.htm
|
||||
copy header.htm hou.htm /y
|
||||
hou html.txt hou.c >> hou.htm
|
||||
start hou.htm
|
||||
```
|
||||
|
||||
|
||||
@@ -74,15 +74,15 @@ in the regular expression by escaping it with `[]` or `""`.
|
||||
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
|
||||
"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_ ]*\]))?[ ]*)*;
|
||||
```
|
||||
"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_ ]*\]))?[ ]*)*;
|
||||
```
|
||||
|
||||
The regex engine is also algorithmically efficient. To illustrate the point,
|
||||
[ansi.txt](ansi.txt) contains a pathological expression [^2] that guarantees a
|
||||
@@ -90,8 +90,8 @@ hang for the competing Perl engine while matching itself. Try to compare these
|
||||
two engines:
|
||||
|
||||
```sh
|
||||
./hou ansi.txt ansi.txt
|
||||
perl patho.pl < ansi.txt
|
||||
./hou ansi.txt ansi.txt
|
||||
perl patho.pl < ansi.txt
|
||||
```
|
||||
|
||||
|
||||
|
||||
+17
-14
@@ -124,20 +124,23 @@
|
||||
|
||||
<h2 id="judges-comments">Judges’ comments:</h2>
|
||||
<h3 id="to-build">To build:</h3>
|
||||
<p>make hou</p>
|
||||
<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>
|
||||
<h3 id="to-run">To run:</h3>
|
||||
<p>./hou syntax-file file-to-process</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">./hou</span> syntax-file file-to-process</span></code></pre></div>
|
||||
<h3 id="try-unix">Try (Unix):</h3>
|
||||
<p>The results are best viewed in a 80x25 console with ANSI colors.</p>
|
||||
<p>less hou.c</p>
|
||||
<p>./hou ansi.txt hou.c | less -r</p>
|
||||
<p>./hou chk.txt hou.c | wc</p>
|
||||
<p>./hou markdown.txt remarks.markdown > remarks.htm
|
||||
your-browser remarks.htm</p>
|
||||
<pre><code> less hou.c
|
||||
|
||||
./hou ansi.txt hou.c | less -r
|
||||
|
||||
./hou chk.txt hou.c | wc
|
||||
|
||||
./hou markdown.txt remarks.markdown > remarks.htm
|
||||
your-browser remarks.htm</code></pre>
|
||||
<h3 id="try-windows">Try (Windows):</h3>
|
||||
<p>copy header.htm hou.htm /y
|
||||
hou html.txt hou.c >> hou.htm
|
||||
start hou.htm</p>
|
||||
<pre><code> copy header.htm hou.htm /y
|
||||
hou html.txt hou.c >> hou.htm
|
||||
start hou.htm</code></pre>
|
||||
<h3 id="selected-judges-remarks">Selected Judges Remarks:</h3>
|
||||
<p>What a versatile entry! It can be used to check the size of IOCCC entries <em>and</em> to publish them as HTML.</p>
|
||||
<p>For extra credit: what is the meaning of the number 2321237?</p>
|
||||
@@ -165,14 +168,14 @@ original text in the format string using “%s”. Other “%” characters in t
|
||||
format string must be escaped with another “%”. The space character can be used
|
||||
in the regular expression by escaping it with [] or ““.</p>
|
||||
<p>The following regular expression operators are supported:</p>
|
||||
<p>() [] * + ? | “”</p>
|
||||
<pre><code> () [] * + ? | ""</code></pre>
|
||||
<p>For example, one can use the following expression to match a certain declaration statement in hou.c:</p>
|
||||
<p>“char”[ *]<em>[a-zA-Z_][0-9a-zA-Z_]</em>[ ]<em>((=[0-9a-zA-Z_ ]+)|([[0-9a-zA-Z_ ]</em>]))?[ ]<em>(,[ *]</em>[a-zA-Z_][0-9a-zA-Z_]<em>[ ]</em>((=[0-9a-zA-Z_ ]+)|([[0-9a-zA-Z_ ]<em>]))?[ ]</em>)*;</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">"char"</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>
|
||||
<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>
|
||||
<p>./hou ansi.txt ansi.txt
|
||||
perl patho.pl < ansi.txt</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"><</span> ansi.txt</span></code></pre></div>
|
||||
<p>Finally, there are a few limitations…</p>
|
||||
<ul>
|
||||
<li>The only escape sequence supported is and it doesn’t work in [].</li>
|
||||
|
||||
@@ -2,16 +2,21 @@
|
||||
|
||||
### To build:
|
||||
|
||||
```sh
|
||||
make hou
|
||||
```
|
||||
|
||||
### To run:
|
||||
|
||||
```sh
|
||||
./hou syntax-file file-to-process
|
||||
```
|
||||
|
||||
### Try (Unix):
|
||||
|
||||
The results are best viewed in a 80x25 console with ANSI colors.
|
||||
|
||||
```
|
||||
less hou.c
|
||||
|
||||
./hou ansi.txt hou.c | less -r
|
||||
@@ -20,12 +25,15 @@ The results are best viewed in a 80x25 console with ANSI colors.
|
||||
|
||||
./hou markdown.txt remarks.markdown > remarks.htm
|
||||
your-browser remarks.htm
|
||||
```
|
||||
|
||||
### Try (Windows):
|
||||
|
||||
```
|
||||
copy header.htm hou.htm /y
|
||||
hou html.txt hou.c >> hou.htm
|
||||
start hou.htm
|
||||
```
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
@@ -67,18 +75,24 @@ in the regular expression by escaping it with [] or "".
|
||||
|
||||
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
|
||||
"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_ ]*\]))?[ ]*)*;
|
||||
```
|
||||
|
||||
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
|
||||
./hou ansi.txt ansi.txt
|
||||
perl patho.pl < ansi.txt
|
||||
```
|
||||
|
||||
Finally, there are a few limitations...
|
||||
|
||||
|
||||
+11
-12
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Qiming_HOU">Qiming HOU</a><br>
|
||||
Location: <a href="../../location.html#CN">CN</a> - <em>People’s Republic of China</em> (<em>China</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#CN">CN</a> - <em>People’s Republic of China</em> (<em>China</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,17 +141,17 @@ 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>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./hou</span> syntax-file file-to-process</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./hou</span> syntax-file file-to-process</span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<p>View the <code>remarks.htm</code> file in your web browser.</p>
|
||||
<p>The result is best viewed in a 80x25 console with ANSI colors.</p>
|
||||
<h2 id="try-windows">Try (Windows):</h2>
|
||||
<pre><code>copy header.htm hou.htm /y
|
||||
hou html.txt hou.c >> hou.htm
|
||||
start hou.htm</code></pre>
|
||||
<pre><code> copy header.htm hou.htm /y
|
||||
hou html.txt hou.c >> hou.htm
|
||||
start hou.htm</code></pre>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>What a versatile entry! It can be used to check the size of IOCCC entries <em>and</em>
|
||||
to publish them as HTML.</p>
|
||||
@@ -181,16 +180,16 @@ original text in the format string using <code>%s</code>. Other <code>%</code> c
|
||||
format string must be escaped with another <code>%</code>. The space character can be used
|
||||
in the regular expression by escaping it with <code>[]</code> or <code>""</code>.</p>
|
||||
<p>The following regular expression operators are supported:</p>
|
||||
<pre><code>() [] * + ? | ""</code></pre>
|
||||
<pre><code> () [] * + ? | ""</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> "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_ ]*\]))?[ ]*)*;</code></pre>
|
||||
<pre class="re"><code> "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_ ]*\]))?[ ]*)*;</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"><</span> ansi.txt</span></code></pre></div>
|
||||
<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"><</span> ansi.txt</span></code></pre></div>
|
||||
<h3 id="limitations">Limitations</h3>
|
||||
<p>Finally, there are a few limitations…</p>
|
||||
<ul>
|
||||
|
||||
+22
-22
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
There is alternate code which fixes some German at the expense of other German.
|
||||
@@ -11,18 +11,18 @@ See [Alternate code](#alternate-code) below for the (fun) rationale here.
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
echo "full spelling of an English cardinal numeral less than a quadrillion" | ./kang
|
||||
echo "full spelling of an English cardinal numeral less than a quadrillion" | ./kang
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh # try various languages
|
||||
./try.sh # try various languages
|
||||
|
||||
./en.sh # English 0 through 13
|
||||
./en.sh # English 0 through 13
|
||||
|
||||
./de.sh # German 0 through 13 with both umlauts and without (additional 'e')
|
||||
./de.sh # German 0 through 13 with both umlauts and without (additional 'e')
|
||||
```
|
||||
|
||||
How does it have no `u` or `o` in a string in the source code and yet it gets
|
||||
@@ -44,29 +44,29 @@ subtlety of this entry even more.
|
||||
### Alternate build:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
make alt
|
||||
```
|
||||
|
||||
|
||||
### Alternate use:
|
||||
|
||||
```sh
|
||||
echo "full spelling of an English cardinal numeral less than a quadrillion" | ./kang.alt
|
||||
echo "full spelling of an English cardinal numeral less than a quadrillion" | ./kang.alt
|
||||
|
||||
echo vier | ./kang.alt
|
||||
echo vier | ./kang.alt
|
||||
|
||||
echo uno | ./kang.alt
|
||||
echo uno | ./kang.alt
|
||||
```
|
||||
|
||||
|
||||
### Alternate try:
|
||||
|
||||
```sh
|
||||
./try.alt.sh # try various languages
|
||||
./try.alt.sh # try various languages
|
||||
|
||||
./en.alt.sh # English 0 through 13
|
||||
./en.alt.sh # English 0 through 13
|
||||
|
||||
./de.alt.sh # German 0 through 13 with both umlauts and without (additional 'e')
|
||||
./de.alt.sh # German 0 through 13 with both umlauts and without (additional 'e')
|
||||
```
|
||||
|
||||
What does it get right? What does it get wrong? How does it compare to the
|
||||
@@ -89,13 +89,13 @@ We've added a linefeed to the print format for convenience.
|
||||
Can you explain why:
|
||||
|
||||
```sh
|
||||
echo f hundr|./kang
|
||||
echo f hundr|./kang
|
||||
```
|
||||
|
||||
correctly reports 500 but:
|
||||
|
||||
```sh
|
||||
echo hundr|./kang
|
||||
echo hundr|./kang
|
||||
```
|
||||
|
||||
does not report 100, instead printing 0?
|
||||
@@ -184,19 +184,19 @@ But the most important obfuscation is the clever construction of lookup table.
|
||||
The program uses 11 different characters required for recognizing 22 lexemes:
|
||||
|
||||
```
|
||||
zero one tw- th(i)r- fo(u)r- fi- six-
|
||||
seven- eigh- nin- ten eleven twelve
|
||||
hundred(s) thousand(s) million(s) billion(s) trillion(s)
|
||||
a and -teen -ty
|
||||
zero one tw- th(i)r- fo(u)r- fi- six-
|
||||
seven- eigh- nin- ten eleven twelve
|
||||
hundred(s) thousand(s) million(s) billion(s) trillion(s)
|
||||
a and -teen -ty
|
||||
```
|
||||
|
||||
So that they are internally represented as like:
|
||||
|
||||
```
|
||||
r n tw- tr- fr- f- s-
|
||||
sn- g- nn- tn ln twl
|
||||
nr(s) tsan(s) lln(s) blln(s) trlln(s)
|
||||
a an -tn -ty
|
||||
r n tw- tr- fr- f- s-
|
||||
sn- g- nn- tn ln twl
|
||||
nr(s) tsan(s) lln(s) blln(s) trlln(s)
|
||||
a an -tn -ty
|
||||
```
|
||||
|
||||
The stemmer recognizes the longest matching prefix, so every lexeme can be
|
||||
|
||||
+23
-24
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Seonghoon_Kang">Seonghoon Kang</a><br>
|
||||
Location: <a href="../../location.html#KR">KR</a> - <em>Republic of Korea</em> (<em>South Korea</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#KR">KR</a> - <em>Republic of Korea</em> (<em>South Korea</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,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>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<p>There is alternate code which fixes some German at the expense of other German.
|
||||
See <a href="#alternate-code">Alternate code</a> below for the (fun) rationale here.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">"full spelling of an English cardinal numeral less than a quadrillion"</span> <span class="kw">|</span> <span class="ex">./kang</span></span></code></pre></div>
|
||||
<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">"full spelling of an English cardinal numeral less than a quadrillion"</span> <span class="kw">|</span> <span class="ex">./kang</span></span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span> <span class="co"># try various languages</span></span>
|
||||
<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-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 'e')</span></span></code></pre></div>
|
||||
<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 'e')</span></span></code></pre></div>
|
||||
<p>How does it have no <code>u</code> or <code>o</code> in a string in the source code and yet it gets
|
||||
<code>uno</code> right?</p>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
@@ -165,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>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">"full spelling of an English cardinal numeral less than a quadrillion"</span> <span class="kw">|</span> <span class="ex">./kang.alt</span></span>
|
||||
<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">"full spelling of an English cardinal numeral less than a quadrillion"</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-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>
|
||||
<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>
|
||||
<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>
|
||||
<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-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 'e')</span></span></code></pre></div>
|
||||
<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 'e')</span></span></code></pre></div>
|
||||
<p>What does it get right? What does it get wrong? How does it compare to the
|
||||
original entry without the change of <code>f</code> to <code>v</code>?</p>
|
||||
<p>Finally why does it get wrong what it gets wrong?</p>
|
||||
@@ -189,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>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> f hundr<span class="kw">|</span><span class="ex">./kang</span></span></code></pre></div>
|
||||
<p>correctly reports 500 but:</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> hundr<span class="kw">|</span><span class="ex">./kang</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> hundr<span class="kw">|</span><span class="ex">./kang</span></span></code></pre></div>
|
||||
<p>does not report 100, instead printing 0?</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<h3 id="synopsis">Synopsis</h3>
|
||||
@@ -261,15 +260,15 @@ including the final NUL character are used.</li>
|
||||
</ul>
|
||||
<p>But the most important obfuscation is the clever construction of lookup table.
|
||||
The program uses 11 different characters required for recognizing 22 lexemes:</p>
|
||||
<pre><code>zero one tw- th(i)r- fo(u)r- fi- six-
|
||||
seven- eigh- nin- ten eleven twelve
|
||||
hundred(s) thousand(s) million(s) billion(s) trillion(s)
|
||||
a and -teen -ty</code></pre>
|
||||
<pre><code> zero one tw- th(i)r- fo(u)r- fi- six-
|
||||
seven- eigh- nin- ten eleven twelve
|
||||
hundred(s) thousand(s) million(s) billion(s) trillion(s)
|
||||
a and -teen -ty</code></pre>
|
||||
<p>So that they are internally represented as like:</p>
|
||||
<pre><code>r n tw- tr- fr- f- s-
|
||||
sn- g- nn- tn ln twl
|
||||
nr(s) tsan(s) lln(s) blln(s) trlln(s)
|
||||
a an -tn -ty</code></pre>
|
||||
<pre><code> r n tw- tr- fr- f- s-
|
||||
sn- g- nn- tn ln twl
|
||||
nr(s) tsan(s) lln(s) blln(s) trlln(s)
|
||||
a an -tn -ty</code></pre>
|
||||
<p>The stemmer recognizes the longest matching prefix, so every lexeme can be
|
||||
recognized by at most three characters (e.g. <code>trl</code> instead of <code>trlln</code>). This is
|
||||
also handy for ignoring plurals. But that would make it so that the table does not fit
|
||||
|
||||
+13
-13
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
There is an unobfuscated version of this entry. See [Alternate
|
||||
@@ -11,17 +11,17 @@ code](#alternate-code) below.
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./konno N
|
||||
./konno N
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./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
|
||||
# you can also specify numbers to try before the random and preselected ones:
|
||||
./try.sh 111 222 333 444 555 666 777 888 999
|
||||
```
|
||||
|
||||
Try running [try.sh](try.sh) a number of times as the first part randomly
|
||||
@@ -37,7 +37,7 @@ This alternate code is an unobfuscated version of the winning code.
|
||||
### Alternate build:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
make alt
|
||||
```
|
||||
|
||||
|
||||
@@ -65,11 +65,11 @@ patterns.
|
||||
Try:
|
||||
|
||||
```sh
|
||||
./konno 30
|
||||
./konno 90
|
||||
./konno 102
|
||||
./konno 109
|
||||
./konno 165
|
||||
./konno 30
|
||||
./konno 90
|
||||
./konno 102
|
||||
./konno 109
|
||||
./konno 165
|
||||
```
|
||||
|
||||
There are 256 (from 0 through 255) possible rules.
|
||||
@@ -80,13 +80,13 @@ There are 256 (from 0 through 255) possible rules.
|
||||
This program uses bit operations. I think
|
||||
|
||||
```c
|
||||
7&O<<!o>>!o+29
|
||||
7&O<<!o>>!o+29
|
||||
```
|
||||
|
||||
is an interesting operation. This isn't equal to
|
||||
|
||||
```c
|
||||
7&O>>29
|
||||
7&O>>29
|
||||
```
|
||||
|
||||
operation. What is the operation doing?
|
||||
|
||||
+14
-15
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Taketo_Konno">Taketo Konno</a><br>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,23 +141,23 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</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>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<p>There is an unobfuscated version of this entry. See <a href="#alternate-code">Alternate
|
||||
code</a> below.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./konno</span> N</span></code></pre></div>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<p>Use <code>konno.alt</code> as you would <code>konno</code> above.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
@@ -171,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>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./konno</span> 30</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./konno</span> 90</span>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./konno</span> 102</span>
|
||||
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">./konno</span> 109</span>
|
||||
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">./konno</span> 165</span></code></pre></div>
|
||||
<p>There are 256 (from 0 through 255) possible rules.</p>
|
||||
<h3 id="obfuscation">Obfuscation</h3>
|
||||
<p>This program uses bit operations. I think</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="dv">7</span><span class="op">&</span>O<span class="op"><<!</span>o<span class="op">>>!</span>o<span class="op">+</span><span class="dv">29</span></span></code></pre></div>
|
||||
<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">&</span>O<span class="op"><<!</span>o<span class="op">>>!</span>o<span class="op">+</span><span class="dv">29</span></span></code></pre></div>
|
||||
<p>is an interesting operation. This isn’t equal to</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="dv">7</span><span class="op">&</span>O<span class="op">>></span><span class="dv">29</span></span></code></pre></div>
|
||||
<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">&</span>O<span class="op">>></span><span class="dv">29</span></span></code></pre></div>
|
||||
<p>operation. What is the operation doing?</p>
|
||||
<h3 id="limitation">Limitation</h3>
|
||||
<p>This program assumes that the size of <code>int</code> is 4.</p>
|
||||
|
||||
+19
-19
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
There is an alternate version that will read from the compiled file itself, in
|
||||
@@ -13,14 +13,14 @@ theoretically work with Windows which distinguishes binary and text. See
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./nyaruko [seed.txt] < original.bin > output.c
|
||||
bash output.c > key.c
|
||||
perl output.c > data.c
|
||||
./nyaruko [seed.txt] < original.bin > output.c
|
||||
bash output.c > key.c
|
||||
perl output.c > data.c
|
||||
|
||||
cat key.c data.c > output.c
|
||||
cat key.c data.c > output.c
|
||||
|
||||
cc output.c -o output
|
||||
./output > regenerated.bin
|
||||
cc output.c -o output
|
||||
./output > regenerated.bin
|
||||
```
|
||||
|
||||
NOTE: if your OS does not have `/dev/urandom` then you should specify a seed
|
||||
@@ -31,7 +31,7 @@ binary itself.
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
The script [try.sh](try.sh) will check if you have perl before trying to use the
|
||||
@@ -54,13 +54,13 @@ For the first version:
|
||||
|
||||
|
||||
```sh
|
||||
make alt
|
||||
make alt
|
||||
```
|
||||
|
||||
For the second version:
|
||||
|
||||
```sh
|
||||
make alt2
|
||||
make alt2
|
||||
```
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ Use `nyaruko.alt` or `nyaruko.alt2` as you would `nyaruko` above.
|
||||
For the first alternate version:
|
||||
|
||||
```sh
|
||||
./try.alt.sh
|
||||
./try.alt.sh
|
||||
```
|
||||
|
||||
We have no way to test the second version, sorry (tm Canada :-) )!
|
||||
@@ -94,17 +94,17 @@ The judges have nothing to add that has not already been written about in the
|
||||
`Nyaruko` will produce C code that reproduces this input on `stdout`:
|
||||
|
||||
```sh
|
||||
./nyaruko < original.bin > output.c
|
||||
gcc output.c -o output
|
||||
./output > regenerated.bin
|
||||
./nyaruko < original.bin > output.c
|
||||
gcc output.c -o output
|
||||
./output > regenerated.bin
|
||||
```
|
||||
|
||||
Output is encrypted, but both key and data are included in the output.
|
||||
To separate the key from the data, run these commands:
|
||||
|
||||
```sh
|
||||
bash output.c > key.c
|
||||
perl output.c > data.c
|
||||
bash output.c > key.c
|
||||
perl output.c > data.c
|
||||
```
|
||||
|
||||
The key-less `data.c` still compiles, but produces a different message
|
||||
@@ -115,8 +115,8 @@ To combine the key and data, concatenate them together in either
|
||||
order:
|
||||
|
||||
```sh
|
||||
cat key.c data.c > output.c
|
||||
cat data.c key.c > output.c
|
||||
cat key.c data.c > output.c
|
||||
cat data.c key.c > output.c
|
||||
```
|
||||
|
||||
By default, `Nyaruko` generates a unique random key for every message,
|
||||
@@ -124,7 +124,7 @@ using `/dev/urandom` as the seed. If given an extra command line
|
||||
argument, `Nyaruko` will seed using that file instead of `/dev/urandom`:
|
||||
|
||||
```sh
|
||||
./nyaruko seed.txt < input.bin > output.c
|
||||
./nyaruko seed.txt < input.bin > output.c
|
||||
```
|
||||
|
||||
This makes the output key deterministic, allowing the same key to be shared
|
||||
|
||||
+20
-21
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Don_Yang">Don Yang</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,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>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<p>There is an alternate version that will read from the compiled file itself, in
|
||||
case you don’t have a <code>/dev/urandom</code> file. There is also a version that should
|
||||
theoretically work with Windows which distinguishes binary and text. See
|
||||
<a href="#alternate-code">alternate code</a> below.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./nyaruko</span> <span class="pp">[</span><span class="ss">seed.txt</span><span class="pp">]</span> <span class="op"><</span> original.bin <span class="op">></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">></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">></span> data.c</span>
|
||||
<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"><</span> original.bin <span class="op">></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">></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">></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">></span> output.c</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">></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">></span> regenerated.bin</span></code></pre></div>
|
||||
<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">></span> regenerated.bin</span></code></pre></div>
|
||||
<p>NOTE: if your OS does not have <code>/dev/urandom</code> then you should specify a seed
|
||||
file or use the <a href="#alternate-code">alternate version</a> which reads in the compiled
|
||||
binary itself.</p>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<p>The script <a href="try.sh">try.sh</a> will check if you have perl before trying to use the
|
||||
perl parts of the script.</p>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
@@ -172,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>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
|
||||
<p>For the second version:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> alt2</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt2</span></code></pre></div>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<p>Use <code>nyaruko.alt</code> or <code>nyaruko.alt2</code> as you would <code>nyaruko</code> above.</p>
|
||||
<h3 id="alternate-try">Alternate try:</h3>
|
||||
<p>For the first alternate version:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.alt.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.alt.sh</span></span></code></pre></div>
|
||||
<p>We have no way to test the second version, sorry (tm Canada :-) )!</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>The judges have nothing to add that has not already been written about in the
|
||||
@@ -188,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"><</span> original.bin <span class="op">></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">></span> regenerated.bin</span></code></pre></div>
|
||||
<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"><</span> original.bin <span class="op">></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">></span> regenerated.bin</span></code></pre></div>
|
||||
<p>Output is encrypted, but both key and data are included in the output.
|
||||
To separate the key from the data, run these commands:</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="fu">bash</span> output.c <span class="op">></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">></span> data.c</span></code></pre></div>
|
||||
<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">></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">></span> data.c</span></code></pre></div>
|
||||
<p>The key-less <code>data.c</code> still compiles, but produces a different message
|
||||
on <code>stdout</code> instead of the original input. This message is a hint to
|
||||
why the code is formatted the way it is.</p>
|
||||
<p>To combine the key and data, concatenate them together in either
|
||||
order:</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> key.c data.c <span class="op">></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">></span> output.c</span></code></pre></div>
|
||||
<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">></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">></span> output.c</span></code></pre></div>
|
||||
<p>By default, <code>Nyaruko</code> generates a unique random key for every message,
|
||||
using <code>/dev/urandom</code> as the seed. If given an extra command line
|
||||
argument, <code>Nyaruko</code> will seed using that file instead of <code>/dev/urandom</code>:</p>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./nyaruko</span> seed.txt <span class="op"><</span> input.bin <span class="op">></span> output.c</span></code></pre></div>
|
||||
<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"><</span> input.bin <span class="op">></span> output.c</span></code></pre></div>
|
||||
<p>This makes the output key deterministic, allowing the same key to be shared
|
||||
across different files. On operating systems that do not have <code>/dev/urandom</code>,
|
||||
users should always specify this extra seed argument to avoid indeterministic
|
||||
|
||||
+123
-125
@@ -1,9 +1,9 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make all # On a 64-bit machine (default)
|
||||
make all # On a 64-bit machine (default)
|
||||
|
||||
make tromp32 # On a 32-bit machine
|
||||
make tromp32 # On a 32-bit machine
|
||||
```
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ make tromp32 # On a 32-bit machine
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2012 tromp bugs](../../bugs.html#2012_tromp).
|
||||
@@ -21,7 +21,7 @@ For more detailed information see [2012 tromp bugs](../../bugs.html#2012_tromp).
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./tromp [-b]
|
||||
./tromp [-b]
|
||||
```
|
||||
|
||||
Use `./tromp32` as you would `./tromp` if on a 32-bit machine.
|
||||
@@ -30,15 +30,15 @@ Use `./tromp32` as you would `./tromp` if on a 32-bit machine.
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
cat ascii-prog.blc data | ./tromp -b
|
||||
cat binary-prog.Blc data | ./tromp
|
||||
cat ascii-prog.blc data | ./tromp -b
|
||||
cat binary-prog.Blc data | ./tromp
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -96,10 +96,10 @@ bit of input, and using characters `0` and `1` for output.
|
||||
The program uses the following exit codes:
|
||||
|
||||
```
|
||||
0: OK; result is a finite list
|
||||
5: Out of term space
|
||||
6: Out of memory
|
||||
1,2,3,4,8,9: result not in list form
|
||||
0: OK; result is a finite list
|
||||
5: Out of term space
|
||||
6: Out of memory
|
||||
1,2,3,4,8,9: result not in list form
|
||||
```
|
||||
|
||||
The size of the term space is fixed at compile time with `-DA`.
|
||||
@@ -114,8 +114,8 @@ 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
|
||||
$ echo " Hello, world" | ./tromp
|
||||
Hello, world
|
||||
$ echo " Hello, world" | ./tromp
|
||||
Hello, world
|
||||
```
|
||||
|
||||
Since the least significant 4 bits of the first byte are just arbitrary padding
|
||||
@@ -123,8 +123,8 @@ that is ignored by the program, any character from ASCII 32 (space) through 47
|
||||
(`/`) will do, e.g.:
|
||||
|
||||
```sh
|
||||
$ echo "*Hello, world" | ./tromp
|
||||
Hello, world
|
||||
$ echo "*Hello, world" | ./tromp
|
||||
Hello, world
|
||||
```
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ if the interpreter reaches end-of-file during program parsing,
|
||||
it will crash in some way. E.g. the following might dump core:
|
||||
|
||||
```sh
|
||||
echo -n "U" | ./tromp
|
||||
echo -n "U" | ./tromp
|
||||
```
|
||||
|
||||
Furthermore, the interpreter requires the initial encoded lambda term to be
|
||||
@@ -144,7 +144,7 @@ lambdas. For instance, here the term `\ 5` is not closed, causing the
|
||||
interpreter to crash when looking into a null-pointer environment:
|
||||
|
||||
```sh
|
||||
echo ">Hello, world" | ./tromp
|
||||
echo ">Hello, world" | ./tromp
|
||||
```
|
||||
|
||||
will likely dump core.
|
||||
@@ -201,8 +201,8 @@ The byte oriented BLC8 version weighs in at 43 bytes (shown in hexadecimal).
|
||||
```
|
||||
|
||||
```sh
|
||||
$ (cat uni8.Blc; echo " Ni hao") | ./tromp
|
||||
Ni hao
|
||||
$ (cat uni8.Blc; echo " Ni hao") | ./tromp
|
||||
Ni hao
|
||||
```
|
||||
|
||||
### A prime number sieve
|
||||
@@ -226,8 +226,8 @@ 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
|
||||
$ cat primes.blc | ./tromp -b | head -c 70
|
||||
0011010100010100010100010000010100000100010100010000010000010100000100
|
||||
$ cat primes.blc | ./tromp -b | head -c 70
|
||||
0011010100010100010100010000010100000100010100010000010000010100000100
|
||||
```
|
||||
|
||||
For those who prefer to digest their primes in decimal, there is `oddindices.Blc`,
|
||||
@@ -236,8 +236,8 @@ which will print the indices of all odd characters (with
|
||||
separated by a given character:
|
||||
|
||||
```
|
||||
$ (cat oddindices.Blc; echo -n " "; cat primes.blc | ./tromp -b) | ./tromp | head -c 70
|
||||
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
|
||||
$ (cat oddindices.Blc; echo -n " "; cat primes.blc | ./tromp -b) | ./tromp | head -c 70
|
||||
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
|
||||
```
|
||||
|
||||
### A Space filling program
|
||||
@@ -266,44 +266,43 @@ 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
|
||||
$ (cat hilbert.Blc; echo -n "1") | ./tromp
|
||||
_
|
||||
| |
|
||||
$ (cat hilbert.Blc; echo -n "1") | ./tromp
|
||||
_
|
||||
| |
|
||||
|
||||
$ (cat hilbert.Blc; echo -n "12") | ./tromp
|
||||
_ _
|
||||
| |_| |
|
||||
|_ _|
|
||||
_| |_
|
||||
$ (cat hilbert.Blc; echo -n "12") | ./tromp
|
||||
_ _
|
||||
| |_| |
|
||||
|_ _|
|
||||
_| |_
|
||||
|
||||
$ (cat hilbert.Blc; echo -n "123") | ./tromp
|
||||
_ _ _ _
|
||||
| |_| | | |_| |
|
||||
|_ _| |_ _|
|
||||
_| |_____| |_
|
||||
| ___ ___ |
|
||||
|_| _| |_ |_|
|
||||
_ |_ _| _
|
||||
| |___| |___| |
|
||||
|
||||
$ (cat hilbert.Blc; echo -n "1234") | ./tromp
|
||||
_ _ _ _ _ _ _ _
|
||||
| |_| | | |_| | | |_| | | |_| |
|
||||
|_ _| |_ _| |_ _| |_ _|
|
||||
_| |_____| |_ _| |_____| |_
|
||||
| ___ ___ | | ___ ___ |
|
||||
|_| _| |_ |_| |_| _| |_ |_|
|
||||
_ |_ _| _ _ |_ _| _
|
||||
| |___| |___| |_| |___| |___| |
|
||||
|_ ___ ___ ___ ___ _|
|
||||
_| |_ |_| _| |_ |_| _| |_
|
||||
| _ | _ |_ _| _ | _ |
|
||||
|_| |_| | |___| |___| | |_| |_|
|
||||
_ _ | ___ ___ | _ _
|
||||
| |_| | |_| _| |_ |_| | |_| |
|
||||
|_ _| _ |_ _| _ |_ _|
|
||||
_| |___| |___| |___| |___| |_
|
||||
$ (cat hilbert.Blc; echo -n "123") | ./tromp
|
||||
_ _ _ _
|
||||
| |_| | | |_| |
|
||||
|_ _| |_ _|
|
||||
_| |_____| |_
|
||||
| ___ ___ |
|
||||
|_| _| |_ |_|
|
||||
_ |_ _| _
|
||||
| |___| |___| |
|
||||
|
||||
$ (cat hilbert.Blc; echo -n "1234") | ./tromp
|
||||
_ _ _ _ _ _ _ _
|
||||
| |_| | | |_| | | |_| | | |_| |
|
||||
|_ _| |_ _| |_ _| |_ _|
|
||||
_| |_____| |_ _| |_____| |_
|
||||
| ___ ___ | | ___ ___ |
|
||||
|_| _| |_ |_| |_| _| |_ |_|
|
||||
_ |_ _| _ _ |_ _| _
|
||||
| |___| |___| |_| |___| |___| |
|
||||
|_ ___ ___ ___ ___ _|
|
||||
_| |_ |_| _| |_ |_| _| |_
|
||||
| _ | _ |_ _| _ | _ |
|
||||
|_| |_| | |___| |___| | |_| |_|
|
||||
_ _ | ___ ___ | _ _
|
||||
| |_| | |_| _| |_ |_| | |_| |
|
||||
|_ _| _ |_ _| _ |_ _|
|
||||
_| |___| |___| |___| |___| |_
|
||||
```
|
||||
|
||||
### A [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck) interpreter
|
||||
@@ -313,15 +312,15 @@ The smallest known BF interpreter is written in... you guessed it,
|
||||
coming in at 112 bytes (including 3 bits of padding):
|
||||
|
||||
```
|
||||
$ od -t x4 bf.Blc
|
||||
0000000 01a15144 02d55584 223070b7 00f032ff
|
||||
0000020 7f85f9bf 956fe15e c0ee7d7f 006854e5
|
||||
0000040 fbfd5558 fd5745e0 b6f0fbeb 07d62ff0
|
||||
0000060 d7736fe1 c0bc14f1 1f2eff0b 17666fa1
|
||||
0000100 2fef5be8 ff13ffcf 2034cae1 0bd0c80a
|
||||
0000120 e51fee99 6a5a7fff ff0fff1f d0049d87
|
||||
0000140 db0500ab 3bb74023 b0c0cc28 10740e6c
|
||||
0000160
|
||||
$ od -t x4 bf.Blc
|
||||
0000000 01a15144 02d55584 223070b7 00f032ff
|
||||
0000020 7f85f9bf 956fe15e c0ee7d7f 006854e5
|
||||
0000040 fbfd5558 fd5745e0 b6f0fbeb 07d62ff0
|
||||
0000060 d7736fe1 c0bc14f1 1f2eff0b 17666fa1
|
||||
0000100 2fef5be8 ff13ffcf 2034cae1 0bd0c80a
|
||||
0000120 e51fee99 6a5a7fff ff0fff1f d0049d87
|
||||
0000140 db0500ab 3bb74023 b0c0cc28 10740e6c
|
||||
0000160
|
||||
```
|
||||
|
||||
It expects its input to consist of a
|
||||
@@ -330,10 +329,10 @@ It expects its input to consist of a
|
||||
followed by a `]`, followed by the input for the Brainfuck program.
|
||||
|
||||
```
|
||||
$ more hw.bf
|
||||
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.]
|
||||
$ cat bf.Blc hw.bf | ./tromp
|
||||
Hello World!
|
||||
$ more hw.bf
|
||||
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.]
|
||||
$ cat bf.Blc hw.bf | ./tromp
|
||||
Hello World!
|
||||
```
|
||||
|
||||
Curiously, the interpreter `bf.Blc` is the exact same size as `hw.bf`.
|
||||
@@ -346,10 +345,9 @@ translates single-letter-variable lambda calculus into BLC:
|
||||
|
||||
|
||||
```sh
|
||||
$ echo "\f\x f (f (f x))" > three
|
||||
$ cat parse.Blc three | ./tromp
|
||||
000001110011100111010
|
||||
|
||||
$ echo "\f\x f (f (f x))" > three
|
||||
$ cat parse.Blc three | ./tromp
|
||||
000001110011100111010
|
||||
```
|
||||
|
||||
### Converting between bits and bytes
|
||||
@@ -361,24 +359,24 @@ into BLC8:
|
||||
So we could assemble an input reversing program as
|
||||
|
||||
```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
|
||||
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
|
||||
$ cat deflate.Blc reverse.blc | ./tromp > rev.Blc
|
||||
$ wc rev.Blc
|
||||
0 1 9 rev.Blc
|
||||
$ cat deflate.Blc reverse.blc | ./tromp > rev.Blc
|
||||
$ wc rev.Blc
|
||||
0 1 9 rev.Blc
|
||||
```
|
||||
and then try it out with:
|
||||
|
||||
```sh
|
||||
$ cat rev.Blc - | ./tromp
|
||||
Hello, world!
|
||||
^D
|
||||
!dlrow ,olleH
|
||||
$ cat rev.Blc - | ./tromp
|
||||
Hello, world!
|
||||
^D
|
||||
!dlrow ,olleH
|
||||
```
|
||||
|
||||
### Symbolic Lambda Calculus reduction
|
||||
@@ -387,24 +385,24 @@ BLC8 program `symbolic.Blc` shows individual reduction steps on symbolic lambda
|
||||
Here it is used to show the calculation of 2^3 in Church numerals:
|
||||
|
||||
```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
|
||||
(\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)))))))
|
||||
$ 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
|
||||
(\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)))))))
|
||||
```
|
||||
|
||||
As expected, the resulting normal form is [Church
|
||||
@@ -415,8 +413,8 @@ exact inverse of the above assembler. The prime number sieve disassembles as
|
||||
follows:
|
||||
|
||||
```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)
|
||||
$ 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)
|
||||
```
|
||||
|
||||
Hardly any less obfuscated...
|
||||
@@ -424,13 +422,13 @@ Hardly any less obfuscated...
|
||||
The last line of
|
||||
|
||||
```sh
|
||||
cat symbolic.Blc primes.blc | ./tromp | head -16
|
||||
cat symbolic.Blc primes.blc | ./tromp | head -16
|
||||
```
|
||||
|
||||
starts out as
|
||||
|
||||
```
|
||||
\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
|
||||
\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
|
||||
```
|
||||
|
||||
The `\a` is for ignoring the rest of the input (to which the universal machine
|
||||
@@ -462,16 +460,16 @@ under the interpreter perform much worse than that same program written in Haske
|
||||
Our interpreter copes well with extra levels of interpretation:
|
||||
|
||||
```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
|
||||
real 0m0.191s
|
||||
$ time cat uni.blc uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
|
||||
real 0m1.919s
|
||||
$ time cat uni.blc uni.blc uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
|
||||
real 0m23.514s
|
||||
$ time cat uni.blc uni.blc uni.blc uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
|
||||
real 4m52.700s
|
||||
$ 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
|
||||
real 0m0.191s
|
||||
$ time cat uni.blc uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
|
||||
real 0m1.919s
|
||||
$ time cat uni.blc uni.blc uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
|
||||
real 0m23.514s
|
||||
$ time cat uni.blc uni.blc uni.blc uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
|
||||
real 4m52.700s
|
||||
```
|
||||
|
||||
### Obfuscation
|
||||
@@ -495,15 +493,15 @@ The program freely (without casting) converts between `int` and `int *`, causing
|
||||
many warnings;
|
||||
|
||||
```
|
||||
note: expected 'int *' but argument is of type 'int'
|
||||
warning: assignment from incompatible pointer type
|
||||
warning: assignment makes integer from pointer without a cast
|
||||
warning: assignment makes pointer from integer without a cast
|
||||
warning: incompatible implicit declaration of built-in function 'calloc'
|
||||
warning: incompatible implicit declaration of built-in function 'exit'
|
||||
warning: passing argument 1 of 'd' makes pointer from integer without a cast
|
||||
warning: passing argument 1 of 'p' makes pointer from integer without a cast
|
||||
warning: pointer/integer type mismatch in conditional expression
|
||||
note: expected 'int *' but argument is of type 'int'
|
||||
warning: assignment from incompatible pointer type
|
||||
warning: assignment makes integer from pointer without a cast
|
||||
warning: assignment makes pointer from integer without a cast
|
||||
warning: incompatible implicit declaration of built-in function 'calloc'
|
||||
warning: incompatible implicit declaration of built-in function 'exit'
|
||||
warning: passing argument 1 of 'd' makes pointer from integer without a cast
|
||||
warning: passing argument 1 of 'p' makes pointer from integer without a cast
|
||||
warning: pointer/integer type mismatch in conditional expression
|
||||
```
|
||||
|
||||
Avoiding these would make the program substantially longer,
|
||||
|
||||
+23
-23
@@ -133,10 +133,10 @@ continuations (see the 3rd reference for details).</p>
|
||||
<p>The term space holds <a href="https://en.wikipedia.org/wiki/Lambda_calculus">lambda
|
||||
calculus</a> terms in the following
|
||||
format. 0 denotes some form of I/O; the only four occurrences are at:</p>
|
||||
<pre><code> C=13: recognizes end of a byte
|
||||
C=20: recognize output of 0 bit
|
||||
C=21: recognize output of 1 bit
|
||||
C=end: input list, expanded lazily</code></pre>
|
||||
<pre><code> C=13: recognizes end of a byte
|
||||
C=20: recognize output of 0 bit
|
||||
C=21: recognize output of 1 bit
|
||||
C=end: input list, expanded lazily</code></pre>
|
||||
<p><code>1</code> denotes a variable, with the next entry its <a href="https://en.wikipedia.org/wiki/De_Bruijn_index">de Bruijn
|
||||
index</a>.</p>
|
||||
<p><code>2</code> denotes application with the next entry the size of the term being applied.</p>
|
||||
@@ -150,26 +150,26 @@ free list.</li>
|
||||
<li>lambda term (index in term space).</li>
|
||||
</ol>
|
||||
<p>Here’s what each variable does:</p>
|
||||
<pre><code>L Lambda term space
|
||||
m mode: 0 for bits and 7 for bytes
|
||||
b bits remaining unread in I, -1 on EOF
|
||||
D Desirable temporary
|
||||
c continuation context
|
||||
a active environment pointer
|
||||
C Current term index
|
||||
U Ultimate term pointer
|
||||
u utility entry
|
||||
B Born to be free-list of closures
|
||||
I Input character
|
||||
O Output character
|
||||
e entry of current term</code></pre>
|
||||
<pre><code> L Lambda term space
|
||||
m mode: 0 for bits and 7 for bytes
|
||||
b bits remaining unread in I, -1 on EOF
|
||||
D Desirable temporary
|
||||
c continuation context
|
||||
a active environment pointer
|
||||
C Current term index
|
||||
U Ultimate term pointer
|
||||
u utility entry
|
||||
B Born to be free-list of closures
|
||||
I Input character
|
||||
O Output character
|
||||
e entry of current term</code></pre>
|
||||
<p>Here’s what each of the 6 auxiliary functions do:</p>
|
||||
<pre><code>s variable lookup in active environment with de Bruijn index u
|
||||
S gets one bit of input, setting b to -1 on EOF or to remaining number of bits in current byte
|
||||
k copy fragment from string literal holding lambda terms xor 46 into current end of term space
|
||||
x expand input, adding 11 (resp. 99) entries to term space for bit (resp. byte) mode
|
||||
p parses BLC-encoded lambda term using S(), stores results in term space and returns length
|
||||
d decrease reference counter, add record to free list on reaching zero</code></pre>
|
||||
<pre><code> s variable lookup in active environment with de Bruijn index u
|
||||
S gets one bit of input, setting b to -1 on EOF or to remaining number of bits in current byte
|
||||
k copy fragment from string literal holding lambda terms xor 46 into current end of term space
|
||||
x expand input, adding 11 (resp. 99) entries to term space for bit (resp. byte) mode
|
||||
p parses BLC-encoded lambda term using S(), stores results in term space and returns length
|
||||
d decrease reference counter, add record to free list on reaching zero</code></pre>
|
||||
<!--
|
||||
|
||||
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
|
||||
|
||||
+23
-23
@@ -13,10 +13,10 @@ calculus](https://en.wikipedia.org/wiki/Lambda_calculus) terms in the following
|
||||
format. 0 denotes some form of I/O; the only four occurrences are at:
|
||||
|
||||
```
|
||||
C=13: recognizes end of a byte
|
||||
C=20: recognize output of 0 bit
|
||||
C=21: recognize output of 1 bit
|
||||
C=end: input list, expanded lazily
|
||||
C=13: recognizes end of a byte
|
||||
C=20: recognize output of 0 bit
|
||||
C=21: recognize output of 1 bit
|
||||
C=end: input list, expanded lazily
|
||||
```
|
||||
|
||||
`1` denotes a variable, with the next entry its [de Bruijn
|
||||
@@ -38,30 +38,30 @@ free list.
|
||||
Here's what each variable does:
|
||||
|
||||
```
|
||||
L Lambda term space
|
||||
m mode: 0 for bits and 7 for bytes
|
||||
b bits remaining unread in I, -1 on EOF
|
||||
D Desirable temporary
|
||||
c continuation context
|
||||
a active environment pointer
|
||||
C Current term index
|
||||
U Ultimate term pointer
|
||||
u utility entry
|
||||
B Born to be free-list of closures
|
||||
I Input character
|
||||
O Output character
|
||||
e entry of current term
|
||||
L Lambda term space
|
||||
m mode: 0 for bits and 7 for bytes
|
||||
b bits remaining unread in I, -1 on EOF
|
||||
D Desirable temporary
|
||||
c continuation context
|
||||
a active environment pointer
|
||||
C Current term index
|
||||
U Ultimate term pointer
|
||||
u utility entry
|
||||
B Born to be free-list of closures
|
||||
I Input character
|
||||
O Output character
|
||||
e entry of current term
|
||||
```
|
||||
|
||||
Here's what each of the 6 auxiliary functions do:
|
||||
|
||||
```
|
||||
s variable lookup in active environment with de Bruijn index u
|
||||
S gets one bit of input, setting b to -1 on EOF or to remaining number of bits in current byte
|
||||
k copy fragment from string literal holding lambda terms xor 46 into current end of term space
|
||||
x expand input, adding 11 (resp. 99) entries to term space for bit (resp. byte) mode
|
||||
p parses BLC-encoded lambda term using S(), stores results in term space and returns length
|
||||
d decrease reference counter, add record to free list on reaching zero
|
||||
s variable lookup in active environment with de Bruijn index u
|
||||
S gets one bit of input, setting b to -1 on EOF or to remaining number of bits in current byte
|
||||
k copy fragment from string literal holding lambda terms xor 46 into current end of term space
|
||||
x expand input, adding 11 (resp. 99) entries to term space for bit (resp. byte) mode
|
||||
p parses BLC-encoded lambda term using S(), stores results in term space and returns length
|
||||
d decrease reference counter, add record to free list on reaching zero
|
||||
```
|
||||
|
||||
|
||||
|
||||
+124
-125
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#John_Tromp">John Tromp</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,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>
|
||||
<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>
|
||||
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> tromp32 <span class="co"># On a 32-bit machine</span></span></code></pre></div>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<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>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./tromp</span> <span class="pp">[-</span><span class="ss">b</span><span class="pp">]</span></span></code></pre></div>
|
||||
<p>Use <code>./tromp32</code> as you would <code>./tromp</code> if on a 32-bit machine.</p>
|
||||
<h2 id="to-use-1">To use:</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> ascii-prog.blc data <span class="kw">|</span> <span class="ex">./tromp</span> <span class="at">-b</span></span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> binary-prog.Blc data <span class="kw">|</span> <span class="ex">./tromp</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> ascii-prog.blc data <span class="kw">|</span> <span class="ex">./tromp</span> <span class="at">-b</span></span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> binary-prog.Blc data <span class="kw">|</span> <span class="ex">./tromp</span></span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>The judges dare to say that the data files this entry is processing
|
||||
are more obfuscated than the entry itself.</p>
|
||||
@@ -196,10 +195,10 @@ under 6K in size.</p>
|
||||
With one (arbitrary) argument, it runs in bit mode, using only the least significant
|
||||
bit of input, and using characters <code>0</code> and <code>1</code> for output.</p>
|
||||
<p>The program uses the following exit codes:</p>
|
||||
<pre><code>0: OK; result is a finite list
|
||||
5: Out of term space
|
||||
6: Out of memory
|
||||
1,2,3,4,8,9: result not in list form</code></pre>
|
||||
<pre><code> 0: OK; result is a finite list
|
||||
5: Out of term space
|
||||
6: Out of memory
|
||||
1,2,3,4,8,9: result not in list form</code></pre>
|
||||
<p>The size of the term space is fixed at compile time with <code>-DA</code>.</p>
|
||||
<h3 id="a-half-byte-cat">A half byte <code>cat</code></h3>
|
||||
<p>The shortest (closed) lambda calculus term is <code>\x x (\ 1</code> in <a href="https://en.wikipedia.org/wiki/De_Bruijn_notation">De Bruijn
|
||||
@@ -207,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">" Hello, world"</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>
|
||||
<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">" Hello, world"</span> <span class="kw">|</span> <span class="ex">./tromp</span></span>
|
||||
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">Hello,</span> world</span></code></pre></div>
|
||||
<p>Since the least significant 4 bits of the first byte are just arbitrary padding
|
||||
that is ignored by the program, any character from ASCII 32 (space) through 47
|
||||
(<code>/</code>) will do, e.g.:</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo <span class="st">"*Hello, world"</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>
|
||||
<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">"*Hello, world"</span> <span class="kw">|</span> <span class="ex">./tromp</span></span>
|
||||
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">Hello,</span> world</span></code></pre></div>
|
||||
<h3 id="bad-programs">Bad programs</h3>
|
||||
<p>If the input doesn’t start with a valid program, that is,
|
||||
if the interpreter reaches end-of-file during program parsing,
|
||||
it will crash in some way. E.g. the following might dump core:</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="at">-n</span> <span class="st">"U"</span> <span class="kw">|</span> <span class="ex">./tromp</span></span></code></pre></div>
|
||||
<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">"U"</span> <span class="kw">|</span> <span class="ex">./tromp</span></span></code></pre></div>
|
||||
<p>Furthermore, the interpreter requires the initial encoded lambda term to be
|
||||
closed, that is, variable <code>n</code> can only appear within at least <code>n</code> enclosing
|
||||
lambdas. For instance, here the term <code>\ 5</code> is not closed, causing the
|
||||
interpreter to crash when looking into a null-pointer environment:</p>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">">Hello, world"</span> <span class="kw">|</span> <span class="ex">./tromp</span></span></code></pre></div>
|
||||
<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">">Hello, world"</span> <span class="kw">|</span> <span class="ex">./tromp</span></span></code></pre></div>
|
||||
<p>will likely dump core.</p>
|
||||
<p>Since these properties can be checked when creating
|
||||
<a href="https://tromp.github.io/cl/Binary_lambda_calculus.html">BLC</a> programs,
|
||||
@@ -266,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">" Ni hao"</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>
|
||||
<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">" Ni hao"</span><span class="kw">)</span> <span class="kw">|</span> <span class="ex">./tromp</span></span>
|
||||
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">Ni</span> hao</span></code></pre></div>
|
||||
<h3 id="a-prime-number-sieve">A prime number sieve</h3>
|
||||
<p>Even shorter than the self-interpreter is this prime number sieve in 167 bits
|
||||
(under 21 bytes):</p>
|
||||
@@ -282,14 +281,14 @@ 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>
|
||||
<div class="sourceCode" id="cb15"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> cat primes.blc <span class="kw">|</span> <span class="ex">./tromp</span> <span class="at">-b</span> <span class="kw">|</span> <span class="fu">head</span> <span class="at">-c</span> 70</span>
|
||||
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">0011010100010100010100010000010100000100010100010000010000010100000100</span></span></code></pre></div>
|
||||
<p>For those who prefer to digest their primes in decimal, there is <code>oddindices.Blc</code>,
|
||||
which will print the indices of all odd characters (with
|
||||
<a href="https://en.wikipedia.org/wiki/Bit_numbering">LSB</a> = 1)
|
||||
separated by a given character:</p>
|
||||
<pre><code>$ (cat oddindices.Blc; echo -n " "; cat primes.blc | ./tromp -b) | ./tromp | head -c 70
|
||||
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97</code></pre>
|
||||
<pre><code> $ (cat oddindices.Blc; echo -n " "; cat primes.blc | ./tromp -b) | ./tromp | head -c 70
|
||||
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97</code></pre>
|
||||
<h3 id="a-space-filling-program">A Space filling program</h3>
|
||||
<p>The program <code>hilbert.Blc</code>, at 143 bytes, is a very twisty “one-liner” (shown in hexadecimal):</p>
|
||||
<pre><code> 1818181 8111154 6806041 55ff041
|
||||
@@ -309,120 +308,120 @@ 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">"1"</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>
|
||||
<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">"1"</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">"12"</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-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">"12"</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">"123"</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-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">"123"</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">"1234"</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>
|
||||
<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">"1234"</span><span class="kw">)</span> <span class="kw">|</span> <span class="ex">./tromp</span></span>
|
||||
<span id="cb18-22"><a href="#cb18-22" aria-hidden="true" tabindex="-1"></a> <span class="ex">_</span> _ _ _ _ _ _ _</span>
|
||||
<span id="cb18-23"><a href="#cb18-23" aria-hidden="true" tabindex="-1"></a> <span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span></span>
|
||||
<span id="cb18-24"><a href="#cb18-24" aria-hidden="true" tabindex="-1"></a> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span></span>
|
||||
<span id="cb18-25"><a href="#cb18-25" aria-hidden="true" tabindex="-1"></a> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_____</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="kw">|</span><span class="ex">_____</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span></span>
|
||||
<span id="cb18-26"><a href="#cb18-26" aria-hidden="true" tabindex="-1"></a> <span class="kw">|</span> <span class="ex">___</span> ___ <span class="kw">|</span> <span class="kw">|</span> <span class="ex">___</span> ___ <span class="kw">|</span></span>
|
||||
<span id="cb18-27"><a href="#cb18-27" aria-hidden="true" tabindex="-1"></a> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span></span>
|
||||
<span id="cb18-28"><a href="#cb18-28" aria-hidden="true" tabindex="-1"></a> <span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="ex">_</span> _ <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="ex">_</span></span>
|
||||
<span id="cb18-29"><a href="#cb18-29" aria-hidden="true" tabindex="-1"></a> <span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span></span>
|
||||
<span id="cb18-30"><a href="#cb18-30" aria-hidden="true" tabindex="-1"></a> <span class="kw">|</span><span class="ex">_</span> ___ ___ ___ ___ _<span class="kw">|</span></span>
|
||||
<span id="cb18-31"><a href="#cb18-31" aria-hidden="true" tabindex="-1"></a> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span></span>
|
||||
<span id="cb18-32"><a href="#cb18-32" aria-hidden="true" tabindex="-1"></a> <span class="kw">|</span> <span class="ex">_</span> <span class="kw">|</span> <span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="ex">_</span> <span class="kw">|</span> <span class="ex">_</span> <span class="kw">|</span></span>
|
||||
<span id="cb18-33"><a href="#cb18-33" aria-hidden="true" tabindex="-1"></a> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span></span>
|
||||
<span id="cb18-34"><a href="#cb18-34" aria-hidden="true" tabindex="-1"></a> <span class="ex">_</span> _ <span class="kw">|</span> <span class="ex">___</span> ___ <span class="kw">|</span> <span class="ex">_</span> _</span>
|
||||
<span id="cb18-35"><a href="#cb18-35" aria-hidden="true" tabindex="-1"></a> <span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span></span>
|
||||
<span id="cb18-36"><a href="#cb18-36" aria-hidden="true" tabindex="-1"></a> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span> <span class="ex">_</span> <span class="kw">|</span><span class="ex">_</span> _<span class="kw">|</span></span>
|
||||
<span id="cb18-37"><a href="#cb18-37" aria-hidden="true" tabindex="-1"></a> <span class="ex">_</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">___</span><span class="kw">|</span> <span class="kw">|</span><span class="ex">_</span></span></code></pre></div>
|
||||
<h3 id="a-brainfuck-interpreter">A <a href="https://en.wikipedia.org/wiki/Brainfuck">Brainfuck</a> interpreter</h3>
|
||||
<p>The smallest known BF interpreter is written in… you guessed it,
|
||||
<a href="https://tromp.github.io/cl/Binary_lambda_calculus.html">BLC</a>,
|
||||
coming in at 112 bytes (including 3 bits of padding):</p>
|
||||
<pre><code>$ od -t x4 bf.Blc
|
||||
0000000 01a15144 02d55584 223070b7 00f032ff
|
||||
0000020 7f85f9bf 956fe15e c0ee7d7f 006854e5
|
||||
0000040 fbfd5558 fd5745e0 b6f0fbeb 07d62ff0
|
||||
0000060 d7736fe1 c0bc14f1 1f2eff0b 17666fa1
|
||||
0000100 2fef5be8 ff13ffcf 2034cae1 0bd0c80a
|
||||
0000120 e51fee99 6a5a7fff ff0fff1f d0049d87
|
||||
0000140 db0500ab 3bb74023 b0c0cc28 10740e6c
|
||||
0000160</code></pre>
|
||||
<pre><code> $ od -t x4 bf.Blc
|
||||
0000000 01a15144 02d55584 223070b7 00f032ff
|
||||
0000020 7f85f9bf 956fe15e c0ee7d7f 006854e5
|
||||
0000040 fbfd5558 fd5745e0 b6f0fbeb 07d62ff0
|
||||
0000060 d7736fe1 c0bc14f1 1f2eff0b 17666fa1
|
||||
0000100 2fef5be8 ff13ffcf 2034cae1 0bd0c80a
|
||||
0000120 e51fee99 6a5a7fff ff0fff1f d0049d87
|
||||
0000140 db0500ab 3bb74023 b0c0cc28 10740e6c
|
||||
0000160</code></pre>
|
||||
<p>It expects its input to consist of a
|
||||
<a href="https://en.wikipedia.org/wiki/Brainfuck">Brainfuck</a> program
|
||||
(looking only at bits <code>0</code>, <code>1</code> and <code>4</code> to distinguish among <code>,-.+<>][</code>)
|
||||
followed by a <code>]</code>, followed by the input for the Brainfuck program.</p>
|
||||
<pre><code>$ more hw.bf
|
||||
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.]
|
||||
$ cat bf.Blc hw.bf | ./tromp
|
||||
Hello World!</code></pre>
|
||||
<pre><code> $ more hw.bf
|
||||
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.]
|
||||
$ cat bf.Blc hw.bf | ./tromp
|
||||
Hello World!</code></pre>
|
||||
<p>Curiously, the interpreter <code>bf.Blc</code> is the exact same size as <code>hw.bf</code>.</p>
|
||||
<h3 id="a-blc-assembler">A BLC assembler</h3>
|
||||
<p>Writing BLC programs can be made slightly less painful with this parser that
|
||||
translates single-letter-variable lambda calculus into BLC:</p>
|
||||
<div class="sourceCode" id="cb21"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo <span class="st">"\f\x f (f (f x))"</span> <span class="op">></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>
|
||||
<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">"\f\x f (f (f x))"</span> <span class="op">></span> three</span>
|
||||
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> cat parse.Blc three <span class="kw">|</span> <span class="ex">./tromp</span></span>
|
||||
<span id="cb21-3"><a href="#cb21-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">000001110011100111010</span></span></code></pre></div>
|
||||
<h3 id="converting-between-bits-and-bytes">Converting between bits and bytes</h3>
|
||||
<p>The program <code>inflate.Blc</code> and its inverse <code>deflate.Blc</code> allow us to translate between
|
||||
BLC and BLC8. If you assemble a byte oriented program, you’ll need to compact it
|
||||
into BLC8:</p>
|
||||
<p>So we could assemble an input reversing program as</p>
|
||||
<div class="sourceCode" id="cb22"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">"\a a ((\b b b) (\b \c \d \e d (b b) (\f f c e))) (\b \c c)"</span> <span class="op">></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">></span> reverse.blc</span></code></pre></div>
|
||||
<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">"\a a ((\b b b) (\b \c \d \e d (b b) (\f f c e))) (\b \c c)"</span> <span class="op">></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">></span> reverse.blc</span></code></pre></div>
|
||||
<p>and change it to BLC8 with</p>
|
||||
<div class="sourceCode" id="cb23"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat deflate.Blc reverse.blc <span class="kw">|</span> <span class="ex">./tromp</span> <span class="op">></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>
|
||||
<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">></span> rev.Blc</span>
|
||||
<span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> wc rev.Blc</span>
|
||||
<span id="cb23-3"><a href="#cb23-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">0</span> 1 9 rev.Blc</span></code></pre></div>
|
||||
<p>and then try it out with:</p>
|
||||
<div class="sourceCode" id="cb24"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat rev.Blc <span class="at">-</span> <span class="kw">|</span> <span class="ex">./tromp</span></span>
|
||||
<span id="cb24-2"><a href="#cb24-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Hello,</span> world!</span>
|
||||
<span id="cb24-3"><a href="#cb24-3" aria-hidden="true" tabindex="-1"></a><span class="ex">^D</span></span>
|
||||
<span id="cb24-4"><a href="#cb24-4" aria-hidden="true" tabindex="-1"></a><span class="ex">!dlrow</span> ,olleH</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb24"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> cat rev.Blc <span class="at">-</span> <span class="kw">|</span> <span class="ex">./tromp</span></span>
|
||||
<span id="cb24-2"><a href="#cb24-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">Hello,</span> world!</span>
|
||||
<span id="cb24-3"><a href="#cb24-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">^D</span></span>
|
||||
<span id="cb24-4"><a href="#cb24-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">!dlrow</span> ,olleH</span></code></pre></div>
|
||||
<h3 id="symbolic-lambda-calculus-reduction">Symbolic Lambda Calculus reduction</h3>
|
||||
<p>BLC8 program <code>symbolic.Blc</code> shows individual reduction steps on symbolic lambda terms.
|
||||
Here it is used to show the calculation of 2^3 in Church numerals:</p>
|
||||
<div class="sourceCode" id="cb25"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo <span class="st">"(\f\x f (f (f x))) (\f\x f (f x))"</span> <span class="op">></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">></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>
|
||||
<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">"(\f\x f (f (f x))) (\f\x f (f x))"</span> <span class="op">></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">></span> threetwo.blc</span>
|
||||
<span id="cb25-3"><a href="#cb25-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> cat symbolic.Blc threetwo.blc <span class="kw">|</span> <span class="ex">./tromp</span></span>
|
||||
<span id="cb25-4"><a href="#cb25-4" aria-hidden="true" tabindex="-1"></a> <span class="kw">(</span><span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> b<span class="kw">)))</span> <span class="kw">(</span><span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> b<span class="kw">))</span></span>
|
||||
<span id="cb25-5"><a href="#cb25-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">\a</span> <span class="er">(</span><span class="ex">\b</span> <span class="dt">\c</span> b <span class="er">(</span><span class="ex">b</span> c<span class="kw">))</span> <span class="kw">((</span><span class="ex">\b</span> <span class="dt">\c</span> b <span class="er">(</span><span class="ex">b</span> c<span class="kw">))</span> <span class="kw">((</span><span class="ex">\b</span> <span class="dt">\c</span> b <span class="er">(</span><span class="ex">b</span> c<span class="kw">))</span> <span class="ex">a</span><span class="kw">))</span></span>
|
||||
<span id="cb25-6"><a href="#cb25-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">\a</span> <span class="dt">\b</span> <span class="er">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span><span class="kw">)</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span><span class="kw">)</span> <span class="ex">b</span><span class="kw">)</span></span>
|
||||
<span id="cb25-7"><a href="#cb25-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">\a</span> <span class="dt">\b</span> <span class="er">(</span><span class="ex">\c</span> <span class="er">(</span><span class="ex">\d</span> <span class="dt">\e</span> d <span class="er">(</span><span class="ex">d</span> e<span class="kw">))</span> <span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\d</span> <span class="dt">\e</span> d <span class="er">(</span><span class="ex">d</span> e<span class="kw">))</span> <span class="ex">a</span> c<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span><span class="kw">)</span> <span class="ex">b</span><span class="kw">)</span></span>
|
||||
<span id="cb25-8"><a href="#cb25-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">\a</span> <span class="dt">\b</span> <span class="er">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span><span class="kw">)</span> <span class="ex">b</span><span class="kw">))</span></span>
|
||||
<span id="cb25-9"><a href="#cb25-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">\a</span> <span class="dt">\b</span> <span class="er">(</span><span class="ex">\c</span> a <span class="er">(</span><span class="ex">a</span> c<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span><span class="kw">)</span> <span class="ex">b</span><span class="kw">))</span></span>
|
||||
<span id="cb25-10"><a href="#cb25-10" aria-hidden="true" tabindex="-1"></a> <span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span><span class="kw">)</span> <span class="ex">b</span><span class="kw">)))</span></span>
|
||||
<span id="cb25-11"><a href="#cb25-11" aria-hidden="true" tabindex="-1"></a> <span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> a <span class="er">(</span><span class="ex">a</span> c<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span><span class="kw">)</span> <span class="ex">b</span><span class="kw">)))</span></span>
|
||||
<span id="cb25-12"><a href="#cb25-12" aria-hidden="true" tabindex="-1"></a> <span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span><span class="kw">)</span> <span class="ex">b</span><span class="kw">))))</span></span>
|
||||
<span id="cb25-13"><a href="#cb25-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="er">(</span><span class="ex">\d</span> <span class="dt">\e</span> d <span class="er">(</span><span class="ex">d</span> e<span class="kw">))</span> <span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\d</span> <span class="dt">\e</span> d <span class="er">(</span><span class="ex">d</span> e<span class="kw">))</span> <span class="ex">a</span> c<span class="kw">))</span> <span class="ex">b</span><span class="kw">))))</span></span>
|
||||
<span id="cb25-14"><a href="#cb25-14" aria-hidden="true" tabindex="-1"></a> <span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span> b<span class="kw">)))))</span></span>
|
||||
<span id="cb25-15"><a href="#cb25-15" aria-hidden="true" tabindex="-1"></a> <span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> a <span class="er">(</span><span class="ex">a</span> c<span class="kw">))</span> <span class="kw">((</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span> b<span class="kw">)))))</span></span>
|
||||
<span id="cb25-16"><a href="#cb25-16" aria-hidden="true" tabindex="-1"></a> <span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> c <span class="er">(</span><span class="ex">c</span> d<span class="kw">))</span> <span class="ex">a</span> b<span class="kw">))))))</span></span>
|
||||
<span id="cb25-17"><a href="#cb25-17" aria-hidden="true" tabindex="-1"></a> <span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> a <span class="er">(</span><span class="ex">a</span> c<span class="kw">))</span> <span class="ex">b</span><span class="kw">))))))</span></span>
|
||||
<span id="cb25-18"><a href="#cb25-18" aria-hidden="true" tabindex="-1"></a> <span class="ex">\a</span> <span class="dt">\b</span> a <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> <span class="er">(</span><span class="ex">a</span> b<span class="kw">)))))))</span></span></code></pre></div>
|
||||
<p>As expected, the resulting normal form is <a href="https://en.wikipedia.org/wiki/Church_encoding">Church
|
||||
numeral</a> 8.</p>
|
||||
<p>Taking only the first line of output gives us a sort of BLC disassembler, an
|
||||
exact inverse of the above assembler. The prime number sieve disassembles as
|
||||
follows:</p>
|
||||
<div class="sourceCode" id="cb26"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat symbolic.Blc primes.blc <span class="kw">|</span> <span class="ex">./tromp</span> <span class="kw">|</span> <span class="fu">head</span> <span class="at">-1</span></span>
|
||||
<span id="cb26-2"><a href="#cb26-2" aria-hidden="true" tabindex="-1"></a><span class="ex">\a</span> <span class="er">(</span><span class="ex">\b</span> b <span class="er">(</span><span class="ex">b</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> c c<span class="kw">)</span> <span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> <span class="dt">\e</span> e <span class="er">(</span><span class="ex">\f</span> <span class="dt">\g</span> g<span class="kw">)</span> <span class="kw">((</span><span class="ex">\f</span> c c f <span class="er">(</span><span class="kw">(</span><span class="ex">\g</span> g g<span class="kw">)</span> <span class="kw">(</span><span class="ex">\g</span> f <span class="er">(</span><span class="ex">g</span> g<span class="kw">))))</span> <span class="kw">(</span><span class="ex">\f</span> <span class="dt">\g</span> <span class="dt">\h</span> <span class="dt">\i</span> i g <span class="er">(</span><span class="ex">h</span> <span class="er">(</span><span class="ex">d</span> f<span class="kw">)))))</span> <span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> <span class="dt">\e</span> b <span class="er">(</span><span class="ex">e</span> c<span class="kw">)))))</span> <span class="kw">(</span><span class="ex">\b</span> <span class="dt">\c</span> c <span class="er">(</span><span class="ex">\d</span> <span class="dt">\e</span> d<span class="kw">)</span> <span class="ex">b</span><span class="kw">)</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb26"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> cat symbolic.Blc primes.blc <span class="kw">|</span> <span class="ex">./tromp</span> <span class="kw">|</span> <span class="fu">head</span> <span class="at">-1</span></span>
|
||||
<span id="cb26-2"><a href="#cb26-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">\a</span> <span class="er">(</span><span class="ex">\b</span> b <span class="er">(</span><span class="ex">b</span> <span class="er">(</span><span class="kw">(</span><span class="ex">\c</span> c c<span class="kw">)</span> <span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> <span class="dt">\e</span> e <span class="er">(</span><span class="ex">\f</span> <span class="dt">\g</span> g<span class="kw">)</span> <span class="kw">((</span><span class="ex">\f</span> c c f <span class="er">(</span><span class="kw">(</span><span class="ex">\g</span> g g<span class="kw">)</span> <span class="kw">(</span><span class="ex">\g</span> f <span class="er">(</span><span class="ex">g</span> g<span class="kw">))))</span> <span class="kw">(</span><span class="ex">\f</span> <span class="dt">\g</span> <span class="dt">\h</span> <span class="dt">\i</span> i g <span class="er">(</span><span class="ex">h</span> <span class="er">(</span><span class="ex">d</span> f<span class="kw">)))))</span> <span class="kw">(</span><span class="ex">\c</span> <span class="dt">\d</span> <span class="dt">\e</span> b <span class="er">(</span><span class="ex">e</span> c<span class="kw">)))))</span> <span class="kw">(</span><span class="ex">\b</span> <span class="dt">\c</span> c <span class="er">(</span><span class="ex">\d</span> <span class="dt">\e</span> d<span class="kw">)</span> <span class="ex">b</span><span class="kw">)</span></span></code></pre></div>
|
||||
<p>Hardly any less obfuscated…</p>
|
||||
<p>The last line of</p>
|
||||
<div class="sourceCode" id="cb27"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> symbolic.Blc primes.blc <span class="kw">|</span> <span class="ex">./tromp</span> <span class="kw">|</span> <span class="fu">head</span> <span class="at">-16</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb27"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> symbolic.Blc primes.blc <span class="kw">|</span> <span class="ex">./tromp</span> <span class="kw">|</span> <span class="fu">head</span> <span class="at">-16</span></span></code></pre></div>
|
||||
<p>starts out as</p>
|
||||
<pre><code>\a \b b (\c \d c) (\c c (\d \e d) (\d d (\e \f f) (\e e (\f \g g) ((\f (\g \h \i</code></pre>
|
||||
<pre><code> \a \b b (\c \d c) (\c c (\d \e d) (\d d (\e \f f) (\e e (\f \g g) ((\f (\g \h \i</code></pre>
|
||||
<p>The <code>\a</code> is for ignoring the rest of the input (to which the universal machine
|
||||
applies the decoded lambda term). The <code>\b b (..) (...)</code> is the list constructor,
|
||||
usually called <code>cons</code>, applied to a head (a list element) and a tail (another list).
|
||||
@@ -445,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">></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">></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">></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">></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">></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>
|
||||
<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">></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">></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">></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">></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">></span> /dev/null</span>
|
||||
<span id="cb29-10"><a href="#cb29-10" aria-hidden="true" tabindex="-1"></a> <span class="ex">real</span> 4m52.700s</span></code></pre></div>
|
||||
<h3 id="obfuscation">Obfuscation</h3>
|
||||
<p>Obfuscation is due entirely to conciseness. Some questions to ponder:</p>
|
||||
<p>Which of the term space codes <code>0</code>, <code>1</code>, <code>2</code>, <code>3</code> serve multiple purposes?</p>
|
||||
@@ -465,15 +464,15 @@ under the interpreter perform much worse than that same program written in Haske
|
||||
<h3 id="portability">Portability</h3>
|
||||
<p>The program freely (without casting) converts between <code>int</code> and <code>int *</code>, causing
|
||||
many warnings;</p>
|
||||
<pre><code> note: expected 'int *' but argument is of type 'int'
|
||||
warning: assignment from incompatible pointer type
|
||||
warning: assignment makes integer from pointer without a cast
|
||||
warning: assignment makes pointer from integer without a cast
|
||||
warning: incompatible implicit declaration of built-in function 'calloc'
|
||||
warning: incompatible implicit declaration of built-in function 'exit'
|
||||
warning: passing argument 1 of 'd' makes pointer from integer without a cast
|
||||
warning: passing argument 1 of 'p' makes pointer from integer without a cast
|
||||
warning: pointer/integer type mismatch in conditional expression</code></pre>
|
||||
<pre><code> note: expected 'int *' but argument is of type 'int'
|
||||
warning: assignment from incompatible pointer type
|
||||
warning: assignment makes integer from pointer without a cast
|
||||
warning: assignment makes pointer from integer without a cast
|
||||
warning: incompatible implicit declaration of built-in function 'calloc'
|
||||
warning: incompatible implicit declaration of built-in function 'exit'
|
||||
warning: passing argument 1 of 'd' makes pointer from integer without a cast
|
||||
warning: passing argument 1 of 'p' makes pointer from integer without a cast
|
||||
warning: pointer/integer type mismatch in conditional expression</code></pre>
|
||||
<p>Avoiding these would make the program substantially longer,
|
||||
and detract from its single minded focus on conciseness.</p>
|
||||
<p>It implicitly declares functions <code>read(2)</code>, <code>write(2)</code>, <code>exit(3)</code> and
|
||||
|
||||
+14
-14
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
This entry requires [Zlib](https://www.zlib.net).
|
||||
@@ -15,7 +15,7 @@ code](#alternate-code) section below.
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2012 vik bugs](../../bugs.html#2012_vik).
|
||||
@@ -26,38 +26,38 @@ For more detailed information see [2012 vik bugs](../../bugs.html#2012_vik).
|
||||
To embed text (from file or command line):
|
||||
|
||||
```sh
|
||||
./vik e base.png filename > encodedimg.png
|
||||
./vik e base.png filename > encodedimg.png
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```sh
|
||||
./vik e base.png SomeRandomText > encodedimg.png
|
||||
./vik e base.png SomeRandomText > encodedimg.png
|
||||
```
|
||||
|
||||
To extract the embedded text:
|
||||
|
||||
```sh
|
||||
./vik d encodedimg.png
|
||||
./vik d encodedimg.png
|
||||
```
|
||||
|
||||
To embed a PNG into another:
|
||||
|
||||
```sh
|
||||
./vik e base.png source.png > encodedimg.png
|
||||
./vik e base.png source.png > encodedimg.png
|
||||
```
|
||||
|
||||
To extract the embedded PNG:
|
||||
|
||||
```sh
|
||||
./vik d encodedimg.png > restored.png
|
||||
./vik d encodedimg.png > restored.png
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ For those few who might use Windows this alternate code might work.
|
||||
### Alternate build:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
make alt
|
||||
```
|
||||
|
||||
|
||||
@@ -117,8 +117,8 @@ 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
|
||||
./vik e ioccc.png chocolate.png > encodedimg.png
|
||||
./vik b encodedimg.png
|
||||
./vik e ioccc.png chocolate.png > encodedimg.png
|
||||
./vik b encodedimg.png
|
||||
```
|
||||
|
||||
It is of course also possible to embed a
|
||||
@@ -126,8 +126,8 @@ It is of course also possible to embed a
|
||||
(as explained above) and decode it, e.g.:
|
||||
|
||||
```sh
|
||||
./vik e ioccc.png .+[.+] > encodedimg.png
|
||||
./vik b encodedimg.png
|
||||
./vik e ioccc.png .+[.+] > encodedimg.png
|
||||
./vik b encodedimg.png
|
||||
```
|
||||
|
||||
### Obfuscation
|
||||
@@ -155,7 +155,7 @@ the variable declarations in the main declaration in order to run
|
||||
correctly:
|
||||
|
||||
```c
|
||||
_setmode(_fileno(stdout), 0x8000);
|
||||
_setmode(_fileno(stdout), 0x8000);
|
||||
```
|
||||
|
||||
NOTE: this is what the [Alternate code](#alternate-code) does.
|
||||
|
||||
+15
-16
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Daniel_Vik">Daniel Vik</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,31 +141,31 @@ 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>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<p>This entry requires <a href="https://www.zlib.net">Zlib</a>.</p>
|
||||
<p>There is an alternate version which might work for Windows. See <a href="#alternate-code">Alternate
|
||||
code</a> section below.</p>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<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">></span> encodedimg.png</span></code></pre></div>
|
||||
<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">></span> encodedimg.png</span></code></pre></div>
|
||||
<p>or</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./vik</span> e base.png SomeRandomText <span class="op">></span> encodedimg.png</span></code></pre></div>
|
||||
<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">></span> encodedimg.png</span></code></pre></div>
|
||||
<p>To extract the embedded text:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./vik</span> d encodedimg.png</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vik</span> d encodedimg.png</span></code></pre></div>
|
||||
<p>To embed a PNG into another:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./vik</span> e base.png source.png <span class="op">></span> encodedimg.png</span></code></pre></div>
|
||||
<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">></span> encodedimg.png</span></code></pre></div>
|
||||
<p>To extract the embedded PNG:</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./vik</span> d encodedimg.png <span class="op">></span> restored.png</span></code></pre></div>
|
||||
<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">></span> restored.png</span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<p>For those few who might use Windows this alternate code might work.</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> alt</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<p>Use <code>vik.alt</code> as you would <code>vik</code> above.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
@@ -197,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">></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>
|
||||
<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">></span> encodedimg.png</span>
|
||||
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vik</span> b encodedimg.png</span></code></pre></div>
|
||||
<p>It is of course also possible to embed a
|
||||
<a href="https://en.wikipedia.org/wiki/Brainfuck">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">></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>
|
||||
<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">></span> encodedimg.png</span>
|
||||
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vik</span> b encodedimg.png</span></code></pre></div>
|
||||
<h3 id="obfuscation">Obfuscation</h3>
|
||||
<p>I really wanted to keep the program simple, so instead of adding multiple macros
|
||||
or helper methods that can be confusing, I placed all functionality in the
|
||||
@@ -222,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>
|
||||
<div class="sourceCode" id="cb12"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a> _setmode<span class="op">(</span>_fileno<span class="op">(</span>stdout<span class="op">),</span> <span class="bn">0x8000</span><span class="op">);</span></span></code></pre></div>
|
||||
<p>NOTE: this is what the <a href="#alternate-code">Alternate code</a> does.</p>
|
||||
<h3 id="limitations">Limitations</h3>
|
||||
<p>The program doesn’t have many error checks so passing in invalid arguments
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
There is an alternate version that is slightly deobfuscated. See [alternate
|
||||
@@ -11,7 +11,7 @@ code](#alternate-code) below.
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./zeitak < file
|
||||
./zeitak < file
|
||||
```
|
||||
|
||||
where `file` is the file to be checked for nesting errors. For example, you may
|
||||
@@ -22,7 +22,7 @@ text files that are not code.
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
make test
|
||||
make test
|
||||
```
|
||||
|
||||
NOTE: the program prints an error and exits on the first nesting error so it
|
||||
@@ -39,7 +39,7 @@ understand this extremely subtle entry.
|
||||
### Alternate build:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
make alt
|
||||
```
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ just to understand _18 key **characters**_ of this code.
|
||||
NOTE: if you use vim to view the code, make sure to do:
|
||||
|
||||
```
|
||||
:set tabstop=4
|
||||
:set tabstop=4
|
||||
```
|
||||
|
||||
in command mode, before looking at the code, to see the correct layout.
|
||||
@@ -93,7 +93,7 @@ around it's position.
|
||||
will be detected in the following line:
|
||||
|
||||
```c
|
||||
printf(")");
|
||||
printf(")");
|
||||
```
|
||||
|
||||
* Doesn't get confused by the [1984/anonymous](../../1984/anonymous/index.html) entry!
|
||||
@@ -105,7 +105,7 @@ printf(")");
|
||||
an error:
|
||||
|
||||
```c
|
||||
printf("\"");
|
||||
printf("\"");
|
||||
```
|
||||
|
||||
#### Obfuscation
|
||||
|
||||
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Adar_Zeitak">Adar Zeitak</a><br>
|
||||
Location: <a href="../../location.html#IL">IL</a> - <em>State of Israel</em> (<em>Israel</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#IL">IL</a> - <em>State of Israel</em> (<em>Israel</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,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>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<p>There is an alternate version that is slightly deobfuscated. See <a href="#alternate-code">alternate
|
||||
code</a> below.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./zeitak</span> <span class="op"><</span> file</span></code></pre></div>
|
||||
<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"><</span> file</span></code></pre></div>
|
||||
<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>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> test</span></code></pre></div>
|
||||
<p>NOTE: 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>
|
||||
@@ -159,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>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<p>Use <code>zeitak.alt</code> as you would <code>zeitak</code> above.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
@@ -170,7 +169,7 @@ At one point we spent
|
||||
minutes</a>
|
||||
just to understand <em>18 key <strong>characters</strong></em> of this code.</p>
|
||||
<p>NOTE: if you use vim to view the code, make sure to do:</p>
|
||||
<pre><code>:set tabstop=4</code></pre>
|
||||
<pre><code> :set tabstop=4</code></pre>
|
||||
<p>in command mode, before looking at the code, to see the correct layout.</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<h3 id="nesting-errors-detector">Nesting Errors Detector</h3>
|
||||
@@ -189,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">")"</span><span class="op">);</span></span></code></pre></div>
|
||||
<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">")"</span><span class="op">);</span></span></code></pre></div>
|
||||
<ul>
|
||||
<li>Doesn’t get confused by the <a href="../../1984/anonymous/index.html">1984/anonymous</a> entry!</li>
|
||||
</ul>
|
||||
@@ -198,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">"</span><span class="sc">\"</span><span class="st">"</span><span class="op">);</span></span></code></pre></div>
|
||||
<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">"</span><span class="sc">\"</span><span class="st">"</span><span class="op">);</span></span></code></pre></div>
|
||||
<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
|
||||
|
||||
Reference in new issue
Block a user