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:
Landon Curt Noll committed 2024-04-01 04:48:48 -07:00
1 parent b84c27ce02
commit a996f8d2b8
734 files changed
+16723 -16963

No files matched your search

+3 -3
View File
@@ -40,9 +40,9 @@ There are again nods to entries of the years:
These nods to not run afoul of the guideline:
```
We tend to dislike programs that:
...
are rather similar to previous entries
We tend to dislike programs that:
...
are rather similar to previous entries
```
because the entry [2019/dogon](2019/dogon/index.html) appropriately pays homage
+9 -9
View File
@@ -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 [2019 adamovsky bugs](../../bugs.html#2019_adamovsky).
@@ -19,14 +19,14 @@ For more detailed information see [2019 adamovsky bugs](../../bugs.html#2019_ada
## To use:
```sh
./prog file.unl
./prog file.unl
```
## Try:
```sh
./try.sh
./try.sh
```
@@ -40,7 +40,7 @@ better way to understand the entry but to fuzz it, we stumbled on a string of
bytes which crashed it:
```
````.0`.0`.0`c.0``sssss
````.0`.0`.0`c.0``sssss
```
Functional programming is not a panacea against core dumps, after all.
@@ -48,7 +48,7 @@ Functional programming is not a panacea against core dumps, after all.
This can be demonstrated by:
```sh
./prog crash.unl
./prog crash.unl
```
@@ -85,7 +85,7 @@ by the sheer length of the dividing line and totally overlooks the rest of the p
When built directly using
```sh
make
make
```
the program (`prog`) accepts a single parameter with the name of an Unlambda program. You can
@@ -93,7 +93,7 @@ download the [Colossal Cave Adventure][1] (the [advent.unl](advent.unl) file)
and run it like this:
```sh
./prog advent.unl
./prog advent.unl
```
> NOTE: the file was added to the entry so there is no need to download it.
@@ -106,7 +106,7 @@ There is an alternative build path that requires the 2018 IOCCC size tool to com
source [iocccsize_2018.c](iocccsize_2018.c) in the project directory and call
```sh
make identify
make identify
```
It will build the tool and use it to build an alternative program `prog2`, which in turn will
+10 -11
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Ondrej_Adamovsky">Ondřej Adamovský</a><br>
Location: <a href="../../location.html#CZ">CZ</a> - <em>Czech Republic</em> (<em>Czechia</em>)
<br><br></li>
Location: <a href="../../location.html#CZ">CZ</a> - <em>Czech Republic</em> (<em>Czechia</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,25 +141,25 @@ Location: <a href="../../location.html#CZ">CZ</a> - <em>Czech Republic</em> (<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#2019_adamovsky">2019 adamovsky 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">./prog</span> file.unl</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">./prog</span> file.unl</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>Even after pre-processing and indenting, the C code of this entry it
is about as understandable as the Unlambda code.</p>
<p>Pretending that we don’t know a bit of functional programming :) and lacking a
better way to understand the entry but to fuzz it, we stumbled on a string of
bytes which crashed it:</p>
<pre><code>````.0`.0`.0`c.0``sssss</code></pre>
<pre><code> ````.0`.0`.0`c.0``sssss</code></pre>
<p>Functional programming is not a panacea against core dumps, after all.</p>
<p>This can be demonstrated by:</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">./prog</span> crash.unl</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">./prog</span> crash.unl</span></code></pre></div>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="a-highly-structured-state-state-machine">A highly structured state state machine</h3>
<h3 id="purpose">Purpose:</h3>
@@ -182,11 +181,11 @@ actually a <code>one-liner</code>. It certainly was for me. I like to think the
by the sheer length of the dividing line and totally overlooks the rest of the program.</p>
<h3 id="usage">Usage:</h3>
<p>When built directly using</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></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></span></code></pre></div>
<p>the program (<code>prog</code>) accepts a single parameter with the name of an Unlambda program. You can
download the <a href="https://github.com/irori/advent-unlambda" title="Adventure">Colossal Cave Adventure</a> (the <a href="advent.unl">advent.unl</a> file)
and run it like this:</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">./prog</span> advent.unl</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">./prog</span> advent.unl</span></code></pre></div>
<blockquote>
<p>NOTE: the file was added to the entry so there is no need to download it.</p>
</blockquote>
@@ -195,7 +194,7 @@ and run it like this:</p>
entries from <a href="http://www.madore.org/~david/programs/unlambda/#quine" title="Unlambda quine contest">quine contest</a>.</p>
<p>There is an alternative build path that requires the 2018 IOCCC size tool to complete. Put the tool
source <a href="iocccsize_2018.c">iocccsize_2018.c</a> in the project directory and call</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> identify</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> identify</span></code></pre></div>
<p>It will build the tool and use it to build an alternative program <code>prog2</code>, which in turn will
produce an Unlambda program <code>identify.unl</code>. <code>make identify</code> runs this program to identify
itself.</p>
+9 -9
View File
@@ -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 [2019 burton bugs](../../bugs.html#2019_burton).
@@ -19,16 +19,16 @@ For more detailed information see [2019 burton bugs](../../bugs.html#2019_burton
## To use:
```sh
./prog < file
./prog < file
./cow file
./cow file
```
## Try:
```sh
./try.sh
./try.sh
```
@@ -52,8 +52,8 @@ The output should look familiar.
Compiles cleanly with:
```sh
WARN="-Wno-implicit-int -Wno-missing-variable-declarations -Wno-parentheses"
cc -Wall -Wextra -Weverything -pedantic $WARN -include stdio.h -o prog prog.c
WARN="-Wno-implicit-int -Wno-missing-variable-declarations -Wno-parentheses"
cc -Wall -Wextra -Weverything -pedantic $WARN -include stdio.h -o prog prog.c
```
### Description:
@@ -64,7 +64,7 @@ of checking correctness, the [check.sh](check.sh) script can simply output the
results: (The Makefile contains the spoiler):
```sh
out=cat ./check.sh ./prog
out=cat ./check.sh ./prog
```
Interestingly, and a spoiler here: macOS and FreeBSD implement the common
@@ -98,7 +98,7 @@ interface.
Included is a version without compilation warnings:
```sh
cc -Wall -Wextra -Weverything -pedantic -include stdio.h -o prog.clean prog.clean.c
cc -Wall -Wextra -Weverything -pedantic -include stdio.h -o prog.clean prog.clean.c
```
### Bugs
+10 -11
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Dave_Burton">Dave Burton</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,17 +141,17 @@ 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#2019_burton">2019 burton 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">./prog</span> <span class="op">&lt;</span> file</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">./prog</span> <span class="op">&lt;</span> file</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">./cow</span> file</span></code></pre></div>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cow</span> file</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>A tiny, but punctually correct way of POSIX counting for text files. This one
line, one word, 127 character beauty continues to expand the number of classic
@@ -164,14 +163,14 @@ interesting.</p>
<p>Feed it anything on <code>stdin</code>.
The output should look familiar.</p>
<p>Compiles cleanly with:</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="va">WARN</span><span class="op">=</span><span class="st">&quot;-Wno-implicit-int -Wno-missing-variable-declarations -Wno-parentheses&quot;</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> <span class="at">-Wall</span> <span class="at">-Wextra</span> <span class="at">-Weverything</span> <span class="at">-pedantic</span> <span class="va">$WARN</span> <span class="at">-include</span> stdio.h <span class="at">-o</span> prog prog.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="va">WARN</span><span class="op">=</span><span class="st">&quot;-Wno-implicit-int -Wno-missing-variable-declarations -Wno-parentheses&quot;</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">cc</span> <span class="at">-Wall</span> <span class="at">-Wextra</span> <span class="at">-Weverything</span> <span class="at">-pedantic</span> <span class="va">$WARN</span> <span class="at">-include</span> stdio.h <span class="at">-o</span> prog prog.c</span></code></pre></div>
<h3 id="description">Description:</h3>
<p>Included is a test script, useful for the corner cases. As in all good Unix
programs, it is silent upon success; any output demonstrates an error. Instead
of checking correctness, the <a href="check.sh">check.sh</a> script can simply output the
results: (The Makefile contains the spoiler):</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="va">out</span><span class="op">=</span>cat <span class="ex">./check.sh</span> ./prog</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="va">out</span><span class="op">=</span>cat <span class="ex">./check.sh</span> ./prog</span></code></pre></div>
<p>Interestingly, and a spoiler here: macOS and FreeBSD implement the common
utility “correctly”. CentOS and Ubuntu both share a “flawed” utility that
changes output format based upon input redirection or pipeline(!). As well, the
@@ -190,7 +189,7 @@ All your base belong to us, but the constants seem a bit … off?</p>
<p>The script <a href="cow.sh">cow.sh</a> provides a closer analog, and perhaps a more useful
interface.</p>
<p>Included is a version without compilation warnings:</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">cc</span> <span class="at">-Wall</span> <span class="at">-Wextra</span> <span class="at">-Weverything</span> <span class="at">-pedantic</span> <span class="at">-include</span> stdio.h <span class="at">-o</span> prog.clean prog.clean.c</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">cc</span> <span class="at">-Wall</span> <span class="at">-Wextra</span> <span class="at">-Weverything</span> <span class="at">-pedantic</span> <span class="at">-include</span> stdio.h <span class="at">-o</span> prog.clean prog.clean.c</span></code></pre></div>
<h3 id="bugs">Bugs</h3>
<p>The flags are not supported. Although they could easily be added into <code>cow.sh</code>.
This exercise left to the reader.</p>
+23 -23
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make
make
```
@@ -14,7 +14,7 @@ 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 [2019 ciura bugs](../../bugs.html#2019_ciura).
@@ -23,14 +23,14 @@ For more detailed information see [2019 ciura bugs](../../bugs.html#2019_ciura).
## To use:
```sh
./getwords.sh en | grep .. | ./prog string
./getwords.sh en | grep .. | ./prog string
```
## Try:
```sh
./try.sh
./try.sh
```
@@ -43,7 +43,7 @@ newline. See the Author's remarks for more information.
### Alternate build:
```sh
make alt
make alt
```
@@ -55,7 +55,7 @@ Use `prog.alt` as you would `prog` above.
### Alternate try:
```sh
./try.alt.sh
./try.alt.sh
```
@@ -84,23 +84,23 @@ of the alphabet exactly once.
#### Example execution:
```sh
$ grep .. /usr/share/dict/words | ./prog abcdefghijklmnopqrstuvwxyz
qualm fjord wiz pyx vs beg kc nth
quartz jinx vs fed kc womb glyph
quid jamb fez vs pyx kc growl nth
quiz fjord pyx vs bag kc mewl nth
quiz fjord pyx vs gab kc mewl nth
quiz fjord pyx vs gem bawl kc nth
quiz fjord pyx vs meg bawl kc nth
quiz fjord vex bawl kc gyp ms nth
quiz jamb flex vs kc gyp word nth
quiz jamb pyx vs kc flog drew nth
quiz jamb pyx vs kc frog lewd nth
quiz jamb pyx vs kc frog weld nth
quiz jamb pyx vs kc golf drew nth
quiz jamb pyx vs kc grew fold nth
quiz jamb pyx vs kc grow nth fled
quiz jamb pyx vs kc growl fed nth
$ grep .. /usr/share/dict/words | ./prog abcdefghijklmnopqrstuvwxyz
qualm fjord wiz pyx vs beg kc nth
quartz jinx vs fed kc womb glyph
quid jamb fez vs pyx kc growl nth
quiz fjord pyx vs bag kc mewl nth
quiz fjord pyx vs gab kc mewl nth
quiz fjord pyx vs gem bawl kc nth
quiz fjord pyx vs meg bawl kc nth
quiz fjord vex bawl kc gyp ms nth
quiz jamb flex vs kc gyp word nth
quiz jamb pyx vs kc flog drew nth
quiz jamb pyx vs kc frog lewd nth
quiz jamb pyx vs kc frog weld nth
quiz jamb pyx vs kc golf drew nth
quiz jamb pyx vs kc grew fold nth
quiz jamb pyx vs kc grow nth fled
quiz jamb pyx vs kc growl fed nth
```
Rearranging the words into more or less meaningful expressions is the
+24 -25
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Marcin_Ciura">Marcin Ciura</a><br>
Location: <a href="../../location.html#PL">PL</a> - <em>Republic of Poland</em> (<em>Poland</em>)
<br><br></li>
Location: <a href="../../location.html#PL">PL</a> - <em>Republic of Poland</em> (<em>Poland</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,26 +141,26 @@ Location: <a href="../../location.html#PL">PL</a> - <em>Republic of Poland</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 alternate version available. See <a href="#alternate-code">Alternate code</a>
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#2019_ciura">2019 ciura 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">./getwords.sh</span> en <span class="kw">|</span> <span class="fu">grep</span> .. <span class="kw">|</span> <span class="ex">./prog</span> string</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">./getwords.sh</span> en <span class="kw">|</span> <span class="fu">grep</span> .. <span class="kw">|</span> <span class="ex">./prog</span> string</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="alternate-code">Alternate code:</h2>
<p>There is an alternate version of this code that flushes <code>stdout</code> after writing a
newline. See the Author’s remarks for more information.</p>
<h3 id="alternate-build">Alternate build:</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="fu">make</span> 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> alt</span></code></pre></div>
<h3 id="alternate-use">Alternate use:</h3>
<p>Use <code>prog.alt</code> as you would <code>prog</code> above.</p>
<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></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>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>A few letters, one at a time, with no repeats. How many different ways can this
be done?</p>
@@ -177,23 +176,23 @@ written with an alphabet and outputs perfect pangrams composed of these
words. A perfect pangram is a series of words that contains every letter
of the alphabet exactly once.</p>
<h4 id="example-execution">Example execution:</h4>
<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> grep .. /usr/share/dict/words <span class="kw">|</span> <span class="ex">./prog</span> abcdefghijklmnopqrstuvwxyz</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="ex">qualm</span> fjord wiz pyx vs beg kc nth</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="ex">quartz</span> jinx vs fed kc womb glyph</span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="ex">quid</span> jamb fez vs pyx kc growl nth</span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a><span class="ex">quiz</span> fjord pyx vs bag kc mewl nth</span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a><span class="ex">quiz</span> fjord pyx vs gab kc mewl nth</span>
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a><span class="ex">quiz</span> fjord pyx vs gem bawl kc nth</span>
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a><span class="ex">quiz</span> fjord pyx vs meg bawl kc nth</span>
<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a><span class="ex">quiz</span> fjord vex bawl kc gyp ms nth</span>
<span id="cb7-10"><a href="#cb7-10" aria-hidden="true" tabindex="-1"></a><span class="ex">quiz</span> jamb flex vs kc gyp word nth</span>
<span id="cb7-11"><a href="#cb7-11" aria-hidden="true" tabindex="-1"></a><span class="ex">quiz</span> jamb pyx vs kc flog drew nth</span>
<span id="cb7-12"><a href="#cb7-12" aria-hidden="true" tabindex="-1"></a><span class="ex">quiz</span> jamb pyx vs kc frog lewd nth</span>
<span id="cb7-13"><a href="#cb7-13" aria-hidden="true" tabindex="-1"></a><span class="ex">quiz</span> jamb pyx vs kc frog weld nth</span>
<span id="cb7-14"><a href="#cb7-14" aria-hidden="true" tabindex="-1"></a><span class="ex">quiz</span> jamb pyx vs kc golf drew nth</span>
<span id="cb7-15"><a href="#cb7-15" aria-hidden="true" tabindex="-1"></a><span class="ex">quiz</span> jamb pyx vs kc grew fold nth</span>
<span id="cb7-16"><a href="#cb7-16" aria-hidden="true" tabindex="-1"></a><span class="ex">quiz</span> jamb pyx vs kc grow nth fled</span>
<span id="cb7-17"><a href="#cb7-17" aria-hidden="true" tabindex="-1"></a><span class="ex">quiz</span> jamb pyx vs kc growl fed nth</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> grep .. /usr/share/dict/words <span class="kw">|</span> <span class="ex">./prog</span> abcdefghijklmnopqrstuvwxyz</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">qualm</span> fjord wiz pyx vs beg kc nth</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">quartz</span> jinx vs fed kc womb glyph</span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">quid</span> jamb fez vs pyx kc growl nth</span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">quiz</span> fjord pyx vs bag kc mewl nth</span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">quiz</span> fjord pyx vs gab kc mewl nth</span>
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">quiz</span> fjord pyx vs gem bawl kc nth</span>
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">quiz</span> fjord pyx vs meg bawl kc nth</span>
<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">quiz</span> fjord vex bawl kc gyp ms nth</span>
<span id="cb7-10"><a href="#cb7-10" aria-hidden="true" tabindex="-1"></a> <span class="ex">quiz</span> jamb flex vs kc gyp word nth</span>
<span id="cb7-11"><a href="#cb7-11" aria-hidden="true" tabindex="-1"></a> <span class="ex">quiz</span> jamb pyx vs kc flog drew nth</span>
<span id="cb7-12"><a href="#cb7-12" aria-hidden="true" tabindex="-1"></a> <span class="ex">quiz</span> jamb pyx vs kc frog lewd nth</span>
<span id="cb7-13"><a href="#cb7-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">quiz</span> jamb pyx vs kc frog weld nth</span>
<span id="cb7-14"><a href="#cb7-14" aria-hidden="true" tabindex="-1"></a> <span class="ex">quiz</span> jamb pyx vs kc golf drew nth</span>
<span id="cb7-15"><a href="#cb7-15" aria-hidden="true" tabindex="-1"></a> <span class="ex">quiz</span> jamb pyx vs kc grew fold nth</span>
<span id="cb7-16"><a href="#cb7-16" aria-hidden="true" tabindex="-1"></a> <span class="ex">quiz</span> jamb pyx vs kc grow nth fled</span>
<span id="cb7-17"><a href="#cb7-17" aria-hidden="true" tabindex="-1"></a> <span class="ex">quiz</span> jamb pyx vs kc growl fed nth</span></code></pre></div>
<p>Rearranging the words into more or less meaningful expressions is the
user’s duty.</p>
<p>This entry implements Algorithm X (<em>Exact cover via dancing links</em>)
+7 -7
View File
@@ -1,21 +1,21 @@
## To build:
```sh
make
make
```
## To use:
```sh
./prog < file > file.Z
./prog < file > file.Z
```
## Try:
```sh
./try.sh
./try.sh
```
@@ -38,20 +38,20 @@ compresses differently? The judges know. :)
#### Usage:
```sh
./prog < input.txt > input.txt.Z
./prog < input.txt > input.txt.Z
```
#### Example:
```sh
./prog < guidelines.txt > guidelines.txt.Z
./prog < guidelines.txt > guidelines.txt.Z
```
#### Check for correctness:
```sh
zcat guidelines.txt.Z > guidelines2.txt
diff -s guidelines.txt guidelines2.txt
zcat guidelines.txt.Z > guidelines2.txt
diff -s guidelines.txt guidelines2.txt
```
Of course you can also use [2015/mills2](../../2015/mills2/mills2.c) instead of
+8 -9
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Volker_Diels-Grabsch">Volker Diels-Grabsch</a><br>
Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germany</em> (<em>Germany</em>)
<br><br></li>
Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germany</em> (<em>Germany</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,11 +141,11 @@ Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germ
<!-- 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">./prog</span> <span class="op">&lt;</span> file <span class="op">&gt;</span> file.Z</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">./prog</span> <span class="op">&lt;</span> file <span class="op">&gt;</span> file.Z</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>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>Finally, IOCCC now has its own text compression program, and it is short enough
to qualify for the Best Short Program award! That said, can you compress it down
@@ -158,12 +157,12 @@ compresses differently? The judges know. :)</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="a-tiny-compress-tool">A tiny “compress” tool:</h3>
<h4 id="usage">Usage:</h4>
<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">./prog</span> <span class="op">&lt;</span> input.txt <span class="op">&gt;</span> input.txt.Z</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">./prog</span> <span class="op">&lt;</span> input.txt <span class="op">&gt;</span> input.txt.Z</span></code></pre></div>
<h4 id="example">Example:</h4>
<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">./prog</span> <span class="op">&lt;</span> guidelines.txt <span class="op">&gt;</span> guidelines.txt.Z</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">./prog</span> <span class="op">&lt;</span> guidelines.txt <span class="op">&gt;</span> guidelines.txt.Z</span></code></pre></div>
<h4 id="check-for-correctness">Check for correctness:</h4>
<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">zcat</span> guidelines.txt.Z <span class="op">&gt;</span> guidelines2.txt</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="fu">diff</span> <span class="at">-s</span> guidelines.txt guidelines2.txt</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">zcat</span> guidelines.txt.Z <span class="op">&gt;</span> guidelines2.txt</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">diff</span> <span class="at">-s</span> guidelines.txt guidelines2.txt</span></code></pre></div>
<p>Of course you can also use <a href="../../2015/mills2/mills2.c">2015/mills2</a> instead of
<code>zcat</code> to verify the output file. The achieved compression ratio roughly matches
that of the classic Unix <code>compress(1)</code> tool. And the source code is very
+7 -7
View File
@@ -1,21 +1,21 @@
## To build:
```sh
make
make
```
## To use:
```sh
./prog
./prog
```
## Try:
```sh
./try.sh
./try.sh
```
@@ -34,9 +34,9 @@ that you are dreaming? Or is it, wake up from the simulation?
This program prints its own SHA-512 hash. To verify, run:
```sh
$ sha512sum prog.c; ./prog
43bd0c4381a5078d2850fca9ae5e0647596bcc03cd67d8d973ad02ff35c316c728e7b347ca70abe6c74e745e63646cc7643cb0cffcd3d9a969cbf31a7ce5bf68 prog.c
43bd0c4381a5078d2850fca9ae5e0647596bcc03cd67d8d973ad02ff35c316c728e7b347ca70abe6c74e745e63646cc7643cb0cffcd3d9a969cbf31a7ce5bf68
$ sha512sum prog.c; ./prog
43bd0c4381a5078d2850fca9ae5e0647596bcc03cd67d8d973ad02ff35c316c728e7b347ca70abe6c74e745e63646cc7643cb0cffcd3d9a969cbf31a7ce5bf68 prog.c
43bd0c4381a5078d2850fca9ae5e0647596bcc03cd67d8d973ad02ff35c316c728e7b347ca70abe6c74e745e63646cc7643cb0cffcd3d9a969cbf31a7ce5bf68
```
It started as a complicated "hello world" program that prints some random hex
@@ -70,7 +70,7 @@ are step 1 and step 2 achieved then?
Regarding step 1, note that the large string literal
```
"`x{bh}ndbq..."
"`x{bh}ndbq..."
```
in the last line doesn't look like C code. Moreover, it is too short
+8 -9
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Volker_Diels-Grabsch">Volker Diels-Grabsch</a><br>
Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germany</em> (<em>Germany</em>)
<br><br></li>
Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germany</em> (<em>Germany</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,11 +141,11 @@ Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germ
<!-- 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">./prog</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="ex">./prog</span></span></code></pre></div>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>Before running this one, stay calm. Chill out, have a cup of tea. Is this bad?</p>
<p>To understand what is going on here, please check if you are dreaming, or are you dreaming
@@ -154,9 +153,9 @@ that you are dreaming? Or is it, wake up from the simulation?</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="almost-a-hash-collision">Almost a hash collision:</h3>
<p>This program prints its own SHA-512 hash. To verify, run:</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">$</span> sha512sum prog.c<span class="kw">;</span> <span class="ex">./prog</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="ex">43bd0c4381a5078d2850fca9ae5e0647596bcc03cd67d8d973ad02ff35c316c728e7b347ca70abe6c74e745e63646cc7643cb0cffcd3d9a969cbf31a7ce5bf68</span> prog.c</span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="ex">43bd0c4381a5078d2850fca9ae5e0647596bcc03cd67d8d973ad02ff35c316c728e7b347ca70abe6c74e745e63646cc7643cb0cffcd3d9a969cbf31a7ce5bf68</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">$</span> sha512sum prog.c<span class="kw">;</span> <span class="ex">./prog</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">43bd0c4381a5078d2850fca9ae5e0647596bcc03cd67d8d973ad02ff35c316c728e7b347ca70abe6c74e745e63646cc7643cb0cffcd3d9a969cbf31a7ce5bf68</span> prog.c</span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">43bd0c4381a5078d2850fca9ae5e0647596bcc03cd67d8d973ad02ff35c316c728e7b347ca70abe6c74e745e63646cc7643cb0cffcd3d9a969cbf31a7ce5bf68</span></span></code></pre></div>
<p>It started as a complicated “hello world” program that prints some random hex
digits instead of “hello world”. Then, the digits were adjusted until the
resulting program matched its own SHA-512 hash, via brute force through all
@@ -181,7 +180,7 @@ the <code>#define</code>s are only used to shorten redundant parts of the code,
they are not meant to obfuscate much. Having that out of the way, how
are step 1 and step 2 achieved then?</p>
<p>Regarding step 1, note that the large string literal</p>
<pre><code>&quot;`x{bh}ndbq...&quot;</code></pre>
<pre><code> &quot;`x{bh}ndbq...&quot;</code></pre>
<p>in the last line doesn’t look like C code. Moreover, it is too short
to contain even a compressed representation of all preceding and
subsequent code. Instead, the preceding code including the <code>"</code>
+9 -9
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make
make
```
@@ -10,7 +10,7 @@ make
The current status of this entry is:
```
STATUS: uses gets() - change to fgets() if possible
STATUS: uses gets() - change to fgets() if possible
```
For more detailed information see [2019 dogon bugs](../../bugs.html#2019_dogon).
@@ -19,14 +19,14 @@ For more detailed information see [2019 dogon bugs](../../bugs.html#2019_dogon).
## To use:
```sh
./prog < pattern.mc
./prog < pattern.mc
```
## Try:
```sh
./try.sh
./try.sh
```
Make sure that you keep focus of windows in mind when going back and forth to
@@ -248,11 +248,11 @@ Tom has allowed me to show his code which is probably the most efficient yet
most obfuscated way of calculating the GOL function on a 64 bits `8*8` leaf:
````c
unsigned long life8x8(long a) { unsigned long aw = a << 1, ae = a >> 1, s0 = aw
^ ae, s1 = aw & ae, hs0 = s0 ^ a, hs1 = (s0 & a) | s1, hs0w8 = hs0 >> 8, hs0e8 =
hs0 << 8, hs1w8 = hs1 >> 8, hs1e8 = hs1 << 8, ts0 = hs0w8 ^ hs0e8, ts1 = (hs0w8
& hs0e8) | (ts0 & s0); return (hs1w8 ^ hs1e8 ^ ts1 ^ s1) & ((hs1w8 | hs1e8) ^
(ts1 | s1)) & ((ts0 ^ s0) | a); }
unsigned long life8x8(long a) { unsigned long aw = a << 1, ae = a >> 1, s0 = aw
^ ae, s1 = aw & ae, hs0 = s0 ^ a, hs1 = (s0 & a) | s1, hs0w8 = hs0 >> 8, hs0e8 =
hs0 << 8, hs1w8 = hs1 >> 8, hs1e8 = hs1 << 8, ts0 = hs0w8 ^ hs0e8, ts1 = (hs0w8
& hs0e8) | (ts0 & s0); return (hs1w8 ^ hs1e8 ^ ts1 ^ s1) & ((hs1w8 | hs1e8) ^
(ts1 | s1)) & ((ts0 ^ s0) | a); }
````
This uses only 19 bitwise operations and six shifts to calculate the inner 6x6
+10 -11
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Gil_Dogon">Gil Dogon</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,15 +141,15 @@ 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>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<pre><code>STATUS: uses gets() - change to fgets() if possible</code></pre>
<pre><code> STATUS: uses gets() - change to fgets() if possible</code></pre>
<p>For more detailed information see <a href="../../bugs.html#2019_dogon">2019 dogon 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">./prog</span> <span class="op">&lt;</span> pattern.mc</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">./prog</span> <span class="op">&lt;</span> pattern.mc</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>
<p>Make sure that you keep focus of windows in mind when going back and forth to
the program and the script.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
@@ -322,11 +321,11 @@ master, who reviewed some earlier versions of the entry and freely shared some
of his vast knowledge regarding GOL programming and hashlife. As a free bonus,
Tom has allowed me to show his code which is probably the most efficient yet
most obfuscated way of calculating the GOL function on a 64 bits <code>8*8</code> leaf:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="dt">unsigned</span> <span class="dt">long</span> life8x8<span class="op">(</span><span class="dt">long</span> a<span class="op">)</span> <span class="op">{</span> <span class="dt">unsigned</span> <span class="dt">long</span> aw <span class="op">=</span> a <span class="op">&lt;&lt;</span> <span class="dv">1</span><span class="op">,</span> ae <span class="op">=</span> a <span class="op">&gt;&gt;</span> <span class="dv">1</span><span class="op">,</span> s0 <span class="op">=</span> aw</span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="op">^</span> ae<span class="op">,</span> s1 <span class="op">=</span> aw <span class="op">&amp;</span> ae<span class="op">,</span> hs0 <span class="op">=</span> s0 <span class="op">^</span> a<span class="op">,</span> hs1 <span class="op">=</span> <span class="op">(</span>s0 <span class="op">&amp;</span> a<span class="op">)</span> <span class="op">|</span> s1<span class="op">,</span> hs0w8 <span class="op">=</span> hs0 <span class="op">&gt;&gt;</span> <span class="dv">8</span><span class="op">,</span> hs0e8 <span class="op">=</span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a>hs0 <span class="op">&lt;&lt;</span> <span class="dv">8</span><span class="op">,</span> hs1w8 <span class="op">=</span> hs1 <span class="op">&gt;&gt;</span> <span class="dv">8</span><span class="op">,</span> hs1e8 <span class="op">=</span> hs1 <span class="op">&lt;&lt;</span> <span class="dv">8</span><span class="op">,</span> ts0 <span class="op">=</span> hs0w8 <span class="op">^</span> hs0e8<span class="op">,</span> ts1 <span class="op">=</span> <span class="op">(</span>hs0w8</span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a><span class="op">&amp;</span> hs0e8<span class="op">)</span> <span class="op">|</span> <span class="op">(</span>ts0 <span class="op">&amp;</span> s0<span class="op">);</span> <span class="cf">return</span> <span class="op">(</span>hs1w8 <span class="op">^</span> hs1e8 <span class="op">^</span> ts1 <span class="op">^</span> s1<span class="op">)</span> <span class="op">&amp;</span> <span class="op">((</span>hs1w8 <span class="op">|</span> hs1e8<span class="op">)</span> <span class="op">^</span></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="op">(</span>ts1 <span class="op">|</span> s1<span class="op">))</span> <span class="op">&amp;</span> <span class="op">((</span>ts0 <span class="op">^</span> s0<span class="op">)</span> <span class="op">|</span> a<span class="op">);</span> <span class="op">}</span></span></code></pre></div>
<div class="sourceCode" id="cb5"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="dt">unsigned</span> <span class="dt">long</span> life8x8<span class="op">(</span><span class="dt">long</span> a<span class="op">)</span> <span class="op">{</span> <span class="dt">unsigned</span> <span class="dt">long</span> aw <span class="op">=</span> a <span class="op">&lt;&lt;</span> <span class="dv">1</span><span class="op">,</span> ae <span class="op">=</span> a <span class="op">&gt;&gt;</span> <span class="dv">1</span><span class="op">,</span> s0 <span class="op">=</span> aw</span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="op">^</span> ae<span class="op">,</span> s1 <span class="op">=</span> aw <span class="op">&amp;</span> ae<span class="op">,</span> hs0 <span class="op">=</span> s0 <span class="op">^</span> a<span class="op">,</span> hs1 <span class="op">=</span> <span class="op">(</span>s0 <span class="op">&amp;</span> a<span class="op">)</span> <span class="op">|</span> s1<span class="op">,</span> hs0w8 <span class="op">=</span> hs0 <span class="op">&gt;&gt;</span> <span class="dv">8</span><span class="op">,</span> hs0e8 <span class="op">=</span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> hs0 <span class="op">&lt;&lt;</span> <span class="dv">8</span><span class="op">,</span> hs1w8 <span class="op">=</span> hs1 <span class="op">&gt;&gt;</span> <span class="dv">8</span><span class="op">,</span> hs1e8 <span class="op">=</span> hs1 <span class="op">&lt;&lt;</span> <span class="dv">8</span><span class="op">,</span> ts0 <span class="op">=</span> hs0w8 <span class="op">^</span> hs0e8<span class="op">,</span> ts1 <span class="op">=</span> <span class="op">(</span>hs0w8</span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> <span class="op">&amp;</span> hs0e8<span class="op">)</span> <span class="op">|</span> <span class="op">(</span>ts0 <span class="op">&amp;</span> s0<span class="op">);</span> <span class="cf">return</span> <span class="op">(</span>hs1w8 <span class="op">^</span> hs1e8 <span class="op">^</span> ts1 <span class="op">^</span> s1<span class="op">)</span> <span class="op">&amp;</span> <span class="op">((</span>hs1w8 <span class="op">|</span> hs1e8<span class="op">)</span> <span class="op">^</span></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> <span class="op">(</span>ts1 <span class="op">|</span> s1<span class="op">))</span> <span class="op">&amp;</span> <span class="op">((</span>ts0 <span class="op">^</span> s0<span class="op">)</span> <span class="op">|</span> a<span class="op">);</span> <span class="op">}</span></span></code></pre></div>
<p>This uses only 19 bitwise operations and six shifts to calculate the inner 6x6
next generation bits of the input 8x8 !</p>
<!--
+11 -11
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make
make
```
There is an alternate version, the original, which does not work well in macOS.
@@ -13,7 +13,7 @@ See [Alternate code](#alternate-code) below if you are curious.
The current status of this entry is:
```
STATUS: INABIAF - please **DO NOT** fix
STATUS: INABIAF - please **DO NOT** fix
```
For more detailed information see [2019 duble bugs](../../bugs.html#2019_duble).
@@ -22,20 +22,20 @@ For more detailed information see [2019 duble bugs](../../bugs.html#2019_duble).
## To use:
```sh
./prog file
./prog file
```
## Try:
```sh
./prog /tmp/drawing
./prog /tmp/drawing
```
Open another window / terminal.
```sh
./prog /tmp/drawing
./prog /tmp/drawing
```
Open more terminals and repeat...
@@ -43,13 +43,13 @@ Open more terminals and repeat...
You might also wish to try a full screen size. For this try:
```sh
make clobber fullscreen
make clobber fullscreen
```
Alternatively, if you want to change the size, do something like:
```sh
make clobber LINES=20 COLUMNS=20 all
make clobber LINES=20 COLUMNS=20 all
```
The author provided us with the following table for use:
@@ -70,7 +70,7 @@ the editor.
After editing the file and quitting, try:
```sh
/tmp/drawing
/tmp/drawing
```
i.e. execute the file.
@@ -98,7 +98,7 @@ alternate code might not work as well in macOS.
### Alternate build:
```sh
make alt
make alt
```
@@ -133,7 +133,7 @@ To build, type `make` (assuming gcc) or `make CC=clang`.
Then you can start the program. It expects a file path as its first argument:
```sh
./prog /tmp/drawing
./prog /tmp/drawing
```
(If not started this way, with a file, `prog` will refuse to start.)
@@ -217,7 +217,7 @@ The default size is the one of my xterm (see top of Makefile).
You may set it to the full size of your terminal window by typing:
```sh
make clobber fullscreen
make clobber fullscreen
```
IMPORTANT NOTES:
+12 -13
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Etienne_Duble">Etienne Duble</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 -->
@@ -142,24 +141,24 @@ 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>
<p>There is an alternate version, the original, which does not work well in macOS.
See <a href="#alternate-code">Alternate code</a> below if you are curious.</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#2019_duble">2019 duble 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">./prog</span> file</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">./prog</span> file</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">./prog</span> /tmp/drawing</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">./prog</span> /tmp/drawing</span></code></pre></div>
<p>Open another window / terminal.</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">./prog</span> /tmp/drawing</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">./prog</span> /tmp/drawing</span></code></pre></div>
<p>Open more terminals and repeat…</p>
<p>You might also wish to try a full screen size. For this try:</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 fullscreen</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 fullscreen</span></code></pre></div>
<p>Alternatively, if you want to change the size, do something like:</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 LINES=20 COLUMNS=20 all</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 LINES=20 COLUMNS=20 all</span></code></pre></div>
<p>The author provided us with the following table for use:</p>
<hr />
<ul>
@@ -174,7 +173,7 @@ to the <em>move</em> mode).</li>
<p>The mode and current color is indicated at the bottom left corner of
the editor.</p>
<p>After editing the file and quitting, try:</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">/tmp/drawing</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">/tmp/drawing</span></span></code></pre></div>
<p>i.e. execute the file.</p>
<hr />
<p>WARNING: if the file is deleted it might lock any session still in use. These
@@ -189,7 +188,7 @@ directory which you’ll have to delete manually. This is also discussed in
<p>An alternate version of this entry, <a href="prog.alt.c">prog.alt.c</a>, is provided. This
alternate code might not work as well in macOS.</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>prog.alt</code> as you would <code>prog</code> above.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
@@ -205,7 +204,7 @@ of someone else by just opening the same file!</p>
See section <a href="#limits-portability">Limits, Portability</a> for more info.</p>
<p>To build, type <code>make</code> (assuming gcc) or <code>make CC=clang</code>.</p>
<p>Then you can start the program. It expects a file path as its first argument:</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">./prog</span> /tmp/drawing</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">./prog</span> /tmp/drawing</span></code></pre></div>
<p>(If not started this way, with a file, <code>prog</code> will refuse to start.)</p>
<p>If the file does not exist, you will start with a blank drawing.</p>
<p>If someone else (or another <em>instance of yourself</em>, maybe?) is already
@@ -265,7 +264,7 @@ inverse video mode, and movement escape codes, e.g. <code>xterm</code>, <code>g
<h4 id="the-drawing-area-size-is-set-at-compilation-time">The drawing area size is set at compilation time:</h4>
<p>The default size is the one of my xterm (see top of Makefile).
You may set it to the full size of your terminal window by typing:</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 fullscreen</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 fullscreen</span></code></pre></div>
<p>IMPORTANT NOTES:</p>
<ul>
<li><strong>The program compiled with a given size will fail to reload a drawing file
+46 -46
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make
make
```
NOTE: the use of the C compiler optimiser was disabled and `-g` was enabled for
@@ -13,7 +13,7 @@ this entry because it is SUPPOSED to crash and it needs debugging symbols.
The current status of this entry is:
```
STATUS: INABIAF - please **DO NOT** fix
STATUS: INABIAF - please **DO NOT** fix
```
For more detailed information see [2019 endoh bugs](../../bugs.html#2019_endoh).
@@ -22,7 +22,7 @@ For more detailed information see [2019 endoh bugs](../../bugs.html#2019_endoh).
## To use:
```sh
./prog
./prog
```
@@ -31,7 +31,7 @@ For more detailed information see [2019 endoh bugs](../../bugs.html#2019_endoh).
If you have `gdb(1)` installed:
```sh
./try.sh
./try.sh
```
Note that in macOS installing `gdb(1)` takes multiple steps - it's not just a
@@ -41,7 +41,7 @@ only been tested with linux.
You might also wish to try:
```sh
gdb ./prog || lldb ./prog
gdb ./prog || lldb ./prog
```
and then type in `r` (to run program) and then `bt` (for backtrace).
@@ -60,53 +60,53 @@ ascii` when debugging it to reveal its purpose.
Compile prog.c with no optimization.
```sh
cc -g -O0 -o prog prog.c
cc -g -O0 -o prog prog.c
```
Then, run it. You will see a segmentation fault.
```sh
$ ./prog
Segmentation fault (core dumped)
$ ./prog
Segmentation fault (core dumped)
```
Let's debug. As usual, run it under gdb.
```sh
$ gdb ./prog
(gdb) run
Starting program: /home/.../prog
$ gdb ./prog
(gdb) run
Starting program: /home/.../prog
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
```
Okay, check the backtrace.
```
(gdb) backtrace
#0 0x0000000000000000 in ?? ()
#1 0x0000555555555201 in x23 () at prog.c:35
#2 0x000055555555571a in x64 () at prog.c:100
#3 0x0000555555555747 in x65 () at prog.c:101
#4 0x0000555555555774 in x66 () at prog.c:102
#5 0x00005555555557ce in x69 () at prog.c:105
#6 0x0000555555555828 in x6e () at prog.c:110
#7 0x0000555555555747 in x65 () at prog.c:101
...
(gdb) backtrace
#0 0x0000000000000000 in ?? ()
#1 0x0000555555555201 in x23 () at prog.c:35
#2 0x000055555555571a in x64 () at prog.c:100
#3 0x0000555555555747 in x65 () at prog.c:101
#4 0x0000555555555774 in x66 () at prog.c:102
#5 0x00005555555557ce in x69 () at prog.c:105
#6 0x0000555555555828 in x6e () at prog.c:110
#7 0x0000555555555747 in x65 () at prog.c:101
...
```
See the line numbers and lookup the ASCII table.
```
35 = '#'
100 = 'd'
101 = 'e'
102 = 'f'
105 = 'i'
110 = 'n'
101 = 'e'
...
35 = '#'
100 = 'd'
101 = 'e'
102 = 'f'
105 = 'i'
110 = 'n'
101 = 'e'
...
```
### One more thing:
@@ -114,27 +114,27 @@ See the line numbers and lookup the ASCII table.
The original program can be used as a GDB command file.
```
gdb -q -x prog.c ./prog | cat
Reading symbols from ./prog...done.
gdb -q -x prog.c ./prog | cat
Reading symbols from ./prog...done.
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
#0 0x0000000000000000 in ?? ()
#1 0x0000555555555201 in x23 () at prog.c:35
#2 0x000055555555571a in x64 () at prog.c:100
#3 0x0000555555555747 in x65 () at prog.c:101
#4 0x0000555555555774 in x66 () at prog.c:102
#5 0x00005555555557ce in x69 () at prog.c:105
#6 0x0000555555555828 in x6e () at prog.c:110
#7 0x0000555555555747 in x65 () at prog.c:101
...
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
#0 0x0000000000000000 in ?? ()
#1 0x0000555555555201 in x23 () at prog.c:35
#2 0x000055555555571a in x64 () at prog.c:100
#3 0x0000555555555747 in x65 () at prog.c:101
#4 0x0000555555555774 in x66 () at prog.c:102
#5 0x00005555555557ce in x69 () at prog.c:105
#6 0x0000555555555828 in x6e () at prog.c:110
#7 0x0000555555555747 in x65 () at prog.c:101
...
```
By using this, you can confirm that it is actually a quine.
```sh
gdb -q -x prog.c ./prog | sed -n -r 's/#.*:([0-9]+)/\1/p' | awk '{printf "%c",$1}' > prog2.c
diff prog.c prog2.c
gdb -q -x prog.c ./prog | sed -n -r 's/#.*:([0-9]+)/\1/p' | awk '{printf "%c",$1}' > prog2.c
diff prog.c prog2.c
```
<!--
+47 -48
View File
@@ -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,79 +141,79 @@ 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>NOTE: the use of the C compiler optimiser was disabled and <code>-g</code> was enabled for
this entry because it is SUPPOSED to crash and it needs debugging symbols.</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#2019_endoh">2019 endoh 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">./prog</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">./prog</span></span></code></pre></div>
<h2 id="try">Try:</h2>
<p>If you have <code>gdb(1)</code> installed:</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">./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>
<p>Note that in macOS installing <code>gdb(1)</code> takes multiple steps - it’s not just a
matter of installing <code>gdb(1)</code> and that’s that. The <a href="try.sh">try.sh</a> script has
only been tested with linux.</p>
<p>You might also wish to 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="fu">gdb</span> ./prog <span class="kw">||</span> <span class="ex">lldb</span> ./prog</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">gdb</span> ./prog <span class="kw">||</span> <span class="ex">lldb</span> ./prog</span></code></pre></div>
<p>and then type in <code>r</code> (to run program) and then <code>bt</code> (for backtrace).</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>The purpose of this program is to crash. You’ll want to have memorized <code>man 7 ascii</code> when debugging it to reveal its purpose.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="backtrace-quine">backtrace quine:</h3>
<p>Compile prog.c with no optimization.</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">cc</span> <span class="at">-g</span> <span class="at">-O0</span> <span class="at">-o</span> prog prog.c</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">cc</span> <span class="at">-g</span> <span class="at">-O0</span> <span class="at">-o</span> prog prog.c</span></code></pre></div>
<p>Then, run it. You will see a segmentation fault.</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> ./prog</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Segmentation</span> fault <span class="er">(</span><span class="ex">core</span> dumped<span class="kw">)</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="ex">$</span> ./prog</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">Segmentation</span> fault <span class="er">(</span><span class="ex">core</span> dumped<span class="kw">)</span></span></code></pre></div>
<p>Let’s debug. As usual, run it under gdb.</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> gdb ./prog</span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="kw">(</span><span class="fu">gdb</span><span class="kw">)</span> <span class="ex">run</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="ex">Starting</span> program: /home/.../prog</span>
<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> gdb ./prog</span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="kw">(</span><span class="fu">gdb</span><span class="kw">)</span> <span class="ex">run</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">Starting</span> program: /home/.../prog</span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a><span class="ex">Program</span> received signal SIGSEGV, Segmentation fault.</span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a><span class="ex">0x0000000000000000</span> in <span class="pp">??</span> <span class="er">(</span><span class="kw">)</span></span></code></pre></div>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">Program</span> received signal SIGSEGV, Segmentation fault.</span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">0x0000000000000000</span> in <span class="pp">??</span> <span class="er">(</span><span class="kw">)</span></span></code></pre></div>
<p>Okay, check the backtrace.</p>
<pre><code>(gdb) backtrace
#0 0x0000000000000000 in ?? ()
#1 0x0000555555555201 in x23 () at prog.c:35
#2 0x000055555555571a in x64 () at prog.c:100
#3 0x0000555555555747 in x65 () at prog.c:101
#4 0x0000555555555774 in x66 () at prog.c:102
#5 0x00005555555557ce in x69 () at prog.c:105
#6 0x0000555555555828 in x6e () at prog.c:110
#7 0x0000555555555747 in x65 () at prog.c:101
...</code></pre>
<pre><code> (gdb) backtrace
#0 0x0000000000000000 in ?? ()
#1 0x0000555555555201 in x23 () at prog.c:35
#2 0x000055555555571a in x64 () at prog.c:100
#3 0x0000555555555747 in x65 () at prog.c:101
#4 0x0000555555555774 in x66 () at prog.c:102
#5 0x00005555555557ce in x69 () at prog.c:105
#6 0x0000555555555828 in x6e () at prog.c:110
#7 0x0000555555555747 in x65 () at prog.c:101
...</code></pre>
<p>See the line numbers and lookup the ASCII table.</p>
<pre><code> 35 = &#39;#&#39;
100 = &#39;d&#39;
101 = &#39;e&#39;
102 = &#39;f&#39;
105 = &#39;i&#39;
110 = &#39;n&#39;
101 = &#39;e&#39;
...</code></pre>
<pre><code> 35 = &#39;#&#39;
100 = &#39;d&#39;
101 = &#39;e&#39;
102 = &#39;f&#39;
105 = &#39;i&#39;
110 = &#39;n&#39;
101 = &#39;e&#39;
...</code></pre>
<h3 id="one-more-thing">One more thing:</h3>
<p>The original program can be used as a GDB command file.</p>
<pre><code>gdb -q -x prog.c ./prog | cat
Reading symbols from ./prog...done.
<pre><code> gdb -q -x prog.c ./prog | cat
Reading symbols from ./prog...done.
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
#0 0x0000000000000000 in ?? ()
#1 0x0000555555555201 in x23 () at prog.c:35
#2 0x000055555555571a in x64 () at prog.c:100
#3 0x0000555555555747 in x65 () at prog.c:101
#4 0x0000555555555774 in x66 () at prog.c:102
#5 0x00005555555557ce in x69 () at prog.c:105
#6 0x0000555555555828 in x6e () at prog.c:110
#7 0x0000555555555747 in x65 () at prog.c:101
...</code></pre>
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
#0 0x0000000000000000 in ?? ()
#1 0x0000555555555201 in x23 () at prog.c:35
#2 0x000055555555571a in x64 () at prog.c:100
#3 0x0000555555555747 in x65 () at prog.c:101
#4 0x0000555555555774 in x66 () at prog.c:102
#5 0x00005555555557ce in x69 () at prog.c:105
#6 0x0000555555555828 in x6e () at prog.c:110
#7 0x0000555555555747 in x65 () at prog.c:101
...</code></pre>
<p>By using this, you can confirm that it is actually a quine.</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="fu">gdb</span> <span class="at">-q</span> <span class="at">-x</span> prog.c ./prog <span class="kw">|</span> <span class="fu">sed</span> <span class="at">-n</span> <span class="at">-r</span> <span class="st">&#39;s/#.*:([0-9]+)/\1/p&#39;</span> <span class="kw">|</span> <span class="fu">awk</span> <span class="st">&#39;{printf &quot;%c&quot;,$1}&#39;</span> <span class="op">&gt;</span> prog2.c</span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a><span class="fu">diff</span> prog.c prog2.c</span></code></pre></div>
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">gdb</span> <span class="at">-q</span> <span class="at">-x</span> prog.c ./prog <span class="kw">|</span> <span class="fu">sed</span> <span class="at">-n</span> <span class="at">-r</span> <span class="st">&#39;s/#.*:([0-9]+)/\1/p&#39;</span> <span class="kw">|</span> <span class="fu">awk</span> <span class="st">&#39;{printf &quot;%c&quot;,$1}&#39;</span> <span class="op">&gt;</span> prog2.c</span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">diff</span> prog.c prog2.c</span></code></pre></div>
<!--
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
+6 -6
View File
@@ -1,21 +1,21 @@
## To build:
```sh
make
make
```
## To use:
```sh
./prog infile.wav outfile.wav
./prog infile.wav outfile.wav
```
## Try:
```sh
./try.sh
./try.sh
```
@@ -63,8 +63,8 @@ Interesting fact: The size of the program from `./iocccsize -i` is 2019.
#### How to use:
```sh
./prog input [output [size [dry [wet [damping]]]]]
prog.exe input [output [size [dry [wet [damping]]]]]
./prog input [output [size [dry [wet [damping]]]]]
prog.exe input [output [size [dry [wet [damping]]]]]
```
* `input`: The path to the input file. Required.
@@ -88,7 +88,7 @@ so it may be a good idea to adjust the ratio of "dry" to "wet", to give a more
pleasant result:
```sh
./prog in.wav out.wav 1.8 80% 15%
./prog in.wav out.wav 1.8 80% 15%
```
The program only supports WAV files, and only mostly. Other audio formats, such
+7 -8
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Edward_Giles">Edward Giles</a><br>
Location: <a href="../../location.html#AU">AU</a> - <em>Commonwealth of Australia</em> (<em>Australia</em>)
<br><br></li>
Location: <a href="../../location.html#AU">AU</a> - <em>Commonwealth of Australia</em> (<em>Australia</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,11 +141,11 @@ Location: <a href="../../location.html#AU">AU</a> - <em>Commonwealth of Australi
<!-- 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">./prog</span> infile.wav outfile.wav</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">./prog</span> infile.wav outfile.wav</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>NOTE: <code>play</code>, which <a href="try.sh">try.sh</a> uses, comes from SoX, the Swiss Army Knife
of sound processing programs. If you don’t have this installed, see <a href="../../faq.html#sox">FAQ 3.10:
How do I compile and use an IOCCC entry that requires sound</a>.</p>
@@ -176,8 +175,8 @@ the latter reports warnings about loss of information when converting <code>floa
and that <code>void (*)()</code> and <code>void (*)(void)</code> are not the same thing.</p>
<p>Interesting fact: The size of the program from <code>./iocccsize -i</code> is 2019.</p>
<h4 id="how-to-use">How to use:</h4>
<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">./prog</span> input [output [size [dry [wet <span class="pp">[</span><span class="ss">damping</span><span class="pp">]</span>]]]]</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="ex">prog.exe</span> input [output [size [dry [wet <span class="pp">[</span><span class="ss">damping</span><span class="pp">]</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">./prog</span> input [output [size [dry [wet <span class="pp">[</span><span class="ss">damping</span><span class="pp">]</span>]]]]</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">prog.exe</span> input [output [size [dry [wet <span class="pp">[</span><span class="ss">damping</span><span class="pp">]</span>]]]]</span></code></pre></div>
<ul>
<li><code>input</code>: The path to the input file. Required.</li>
<li><code>output</code>: The path to the output file. Optional, defaults to <code>out.wav</code>.</li>
@@ -197,7 +196,7 @@ decimal numbers (e.g. 0.35) or as percentages (e.g. 35%).</p>
<p>The default settings are designed to make the effect obvious rather than subtle,
so it may be a good idea to adjust the ratio of “dry” to “wet”, to give a more
pleasant result:</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">./prog</span> in.wav out.wav 1.8 80% 15%</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">./prog</span> in.wav out.wav 1.8 80% 15%</span></code></pre></div>
<p>The program only supports WAV files, and only mostly. Other audio formats, such
as MP3, are not supported because they are difficult to decode, but there are
free programs such as <code>ffmpeg</code> that can perform the conversion. Some of the
+3 -3
View File
@@ -150,9 +150,9 @@ vocabulary!</p>
<pre><code>[1991/davidguy](../years.html#1991_davidguy)
[2011/blakely](../years.html#2011_blakely)</code></pre>
<p>These nods to not run afoul of the guideline:</p>
<pre><code>We tend to dislike programs that:
...
are rather similar to previous entries</code></pre>
<pre><code> We tend to dislike programs that:
...
are rather similar to previous entries</code></pre>
<p>because the entry <a href="2019/dogon/index.html">2019/dogon</a> appropriately pays homage
to past entries without blatantly reusing their code.</p>
<p>…We’ll stop spouting spoilers now. Have fun exploring all the entries!</p>
+10 -10
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make
make
```
NOTE: we disable the optimiser because this program has problems with it
@@ -13,7 +13,7 @@ enabled.
The current status of this entry is:
```
STATUS: INABIAF - please **DO NOT** fix
STATUS: INABIAF - please **DO NOT** fix
```
For more detailed information see [2019 karns bugs](../../bugs.html#2019_karns).
@@ -22,13 +22,13 @@ For more detailed information see [2019 karns bugs](../../bugs.html#2019_karns).
## To use:
```sh
./prog < textfile_that_fits_on_the_screen
./prog < textfile_that_fits_on_the_screen
```
You might want to type:
```sh
reset
reset
```
after running the program to restore the terminal to its previous state.
@@ -37,13 +37,13 @@ after running the program to restore the terminal to its previous state.
## Try:
```sh
./try.sh
./try.sh
```
If you have more time you might want to try:
```sh
./prog < README.md
./prog < README.md
```
@@ -83,7 +83,7 @@ connected with anything.
This program usually compiles under both GCC and clang. Build with:
```sh
$(CC) -std=c99 -o tbfs prog.c
$(CC) -std=c99 -o tbfs prog.c
```
where `$(CC)` is cc, gcc, clang, or some other C compiler.
@@ -91,14 +91,14 @@ where `$(CC)` is cc, gcc, clang, or some other C compiler.
You can then run it with:
```sh
cat <input file> | ./tbfs
cat <input file> | ./tbfs
```
Examples:
```sh
./tbfs < maze
./tbfs < prog.c
./tbfs < maze
./tbfs < prog.c
```
### Issues
+11 -12
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Joshua_Karns">Joshua Karns</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,22 +141,22 @@ 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>NOTE: we disable the optimiser because this program has problems with it
enabled.</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#2019_karns">2019 karns 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">./prog</span> <span class="op">&lt;</span> textfile_that_fits_on_the_screen</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">./prog</span> <span class="op">&lt;</span> textfile_that_fits_on_the_screen</span></code></pre></div>
<p>You might want to type:</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">reset</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">reset</span></span></code></pre></div>
<p>after running the program to restore the terminal to its previous state.</p>
<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>
<p>If you have more time you might want to try:</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">./prog</span> <span class="op">&lt;</span> README.md</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">./prog</span> <span class="op">&lt;</span> README.md</span></code></pre></div>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>If you typically get lost in mazes, watching this program run might – or might
not, YMMV – teach you how to find your way in a maze. The algorithm is
@@ -180,13 +179,13 @@ adjacent nodes that are also spaces. Nodes that aren’t spaces are not
connected with anything.</p>
<h3 id="compiling-and-running">Compiling and Running:</h3>
<p>This program usually compiles under both GCC and clang. Build with:</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="va">$(</span><span class="ex">CC</span><span class="va">)</span> <span class="at">-std</span><span class="op">=</span>c99 <span class="at">-o</span> tbfs prog.c</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="va">$(</span><span class="ex">CC</span><span class="va">)</span> <span class="at">-std</span><span class="op">=</span>c99 <span class="at">-o</span> tbfs prog.c</span></code></pre></div>
<p>where <code>$(CC)</code> is cc, gcc, clang, or some other C compiler.</p>
<p>You can then run it with:</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">cat</span> <span class="op">&lt;</span>input file<span class="op">&gt;</span> <span class="kw">|</span> <span class="ex">./tbfs</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="fu">cat</span> <span class="op">&lt;</span>input file<span class="op">&gt;</span> <span class="kw">|</span> <span class="ex">./tbfs</span></span></code></pre></div>
<p>Examples:</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="ex">./tbfs</span> <span class="op">&lt;</span> maze</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./tbfs</span> <span class="op">&lt;</span> prog.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="ex">./tbfs</span> <span class="op">&lt;</span> maze</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./tbfs</span> <span class="op">&lt;</span> prog.c</span></code></pre></div>
<h3 id="issues">Issues</h3>
<ul>
<li>The program must be ran in a terminal that supports ANSI escape codes for
+26 -26
View File
@@ -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 [2019 lynn bugs](../../bugs.html#2019_lynn).
@@ -19,14 +19,14 @@ For more detailed information see [2019 lynn bugs](../../bugs.html#2019_lynn).
## To use:
```sh
./prog
./prog
```
## Try:
```sh
./try.sh
./try.sh
```
@@ -63,7 +63,7 @@ typeclasses. Just pass dictionaries explicitly.
Build the compiler:
```sh
cc -o prog prog.c
cc -o prog prog.c
```
### Demos:
@@ -73,7 +73,7 @@ cc -o prog prog.c
Test the compiler on [fib.hs](fib.hs):
```sh
(./prog < fib.hs ; cat prog.c) > fib.c
(./prog < fib.hs ; cat prog.c) > fib.c
```
Compiling the output produces a binary that prints the 30th Fibonacci number.
@@ -82,7 +82,7 @@ The file [ghcfib.hs](ghcfib.hs) includes [fib.hs](fib.hs) with some glue code,
and shows GHC also accepts our subset of Haskell:
```sh
ghc ghcfib.hs
ghc ghcfib.hs
```
@@ -94,9 +94,9 @@ compiler when run on itself. This intermediate output is hopefully difficult to
understand, yet is accepted by our compiler:
```sh
(./prog < hint.hs ; cat prog.c) > hint.c
make hint
./hint
(./prog < hint.hs ; cat prog.c) > hint.c
make hint
./hint
```
The output program behaves like the compiler itself.
@@ -117,15 +117,15 @@ showing the first entries of the length-ordered list of all strings consisting
of the characters `a` and `b` that contain an even number of `a`s.
```sh
(./prog < lol.hs ; cat prog.c) > lol.c
make lol
./lol
(./prog < lol.hs ; cat prog.c) > lol.c
make lol
./lol
```
A GHC wrapper is provided:
```sh
ghc ghclol.hs
ghc ghclol.hs
```
@@ -136,16 +136,16 @@ way to print the strongly-connected components of a graph in reverse topological
order.
```sh
(./prog < scc.hs ; cat prog.c) > scc.c
(./prog < scc.hs ; cat prog.c) > scc.c
```
It expects the input to be in a similar format as a previous entry
(2018 vokes). For example:
```sh
make scc
./scc < example-1.txt
./scc < example-2.txt
make scc
./scc < example-1.txt
./scc < example-2.txt
```
The output should agree, though our program omits line numbers and does not
@@ -162,7 +162,7 @@ disabling layout-based rules, making every operator left-associative with same
precedence, and only defining 6 primitive functions:
```
: + - * / <=
: + - * / <=
```
The arithmetic operations behave as they do in C on `unsigned int`s, and `(:)` is
@@ -195,7 +195,7 @@ function, and the result is printed to standard output.
`Bool` must be defined as:
```
data Bool = True | False;
data Bool = True | False;
```
so that it matches the Scott-encoded booleans internally used by the primitive
@@ -205,17 +205,17 @@ The alternatives in a `case` expressions must list every data constructor in
the order they are defined. For example, if we have:
```
data Foo a b = Bar a | Baz | Qux Int [b]
data Foo a b = Bar a | Baz | Qux Int [b]
```
then a `case` expression that examines a term of this type must have the form:
```
case x of
{ Bar a -> ...
; Baz -> ...
; Qux n bs -> ...
}
case x of
{ Bar a -> ...
; Baz -> ...
; Qux n bs -> ...
}
```
We stress braces and semicolons are required. Our fussy parser treats
+27 -28
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Ben_Lynn">Ben Lynn</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#2019_lynn">2019 lynn 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">./prog</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">./prog</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">./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 fully functional compiler. The example prints out the 30th <a href="https://en.wikipedia.org/wiki/Fibonacci_sequence">Fibonacci
number</a>.</p>
@@ -172,23 +171,23 @@ trace of those scary <code>unsafeThisAndThat</code> functions. All functions mus
</ul>
<h3 id="building">Building:</h3>
<p>Build the compiler:</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">cc</span> <span class="at">-o</span> prog prog.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">cc</span> <span class="at">-o</span> prog prog.c</span></code></pre></div>
<h3 id="demos">Demos:</h3>
<h4 id="fibonacci-numbers">Fibonacci numbers:</h4>
<p>Test the compiler on <a href="fib.hs">fib.hs</a>:</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="kw">(</span><span class="ex">./prog</span> <span class="op">&lt;</span> fib.hs <span class="kw">;</span> <span class="fu">cat</span> prog.c<span class="kw">)</span> <span class="op">&gt;</span> fib.c</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="kw">(</span><span class="ex">./prog</span> <span class="op">&lt;</span> fib.hs <span class="kw">;</span> <span class="fu">cat</span> prog.c<span class="kw">)</span> <span class="op">&gt;</span> fib.c</span></code></pre></div>
<p>Compiling the output produces a binary that prints the 30th Fibonacci number.</p>
<p>The file <a href="ghcfib.hs">ghcfib.hs</a> includes <a href="fib.hs">fib.hs</a> with some glue code,
and shows GHC also accepts our subset of Haskell:</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">ghc</span> ghcfib.hs</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">ghc</span> ghcfib.hs</span></code></pre></div>
<h4 id="self-hosting-compiler">Self-hosting compiler:</h4>
<p>To avoid spoiling this entry by revealing the original Haskell source, we
instead provide <a href="hint.hs">hint.hs</a>, the output of a certain stage of the
compiler when run on itself. This intermediate output is hopefully difficult to
understand, yet is accepted by our compiler:</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="kw">(</span><span class="ex">./prog</span> <span class="op">&lt;</span> hint.hs <span class="kw">;</span> <span class="fu">cat</span> prog.c<span class="kw">)</span> <span class="op">&gt;</span> hint.c</span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> hint</span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./hint</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="kw">(</span><span class="ex">./prog</span> <span class="op">&lt;</span> hint.hs <span class="kw">;</span> <span class="fu">cat</span> prog.c<span class="kw">)</span> <span class="op">&gt;</span> hint.c</span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> hint</span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./hint</span></span></code></pre></div>
<p>The output program behaves like the compiler itself.</p>
<p>Unlike the original source from which it is derived, GHC fails to compile
<a href="hint.hs">hint.hs</a>. This is because values have been replaced with their <a href="https://en.wikipedia.org/wiki/Mogensen-Scott_encoding">Scott
@@ -201,21 +200,21 @@ it to work.</p>
languages”</a>. We exercise it by
showing the first entries of the length-ordered list of all strings consisting
of the characters <code>a</code> and <code>b</code> that contain an even number of <code>a</code>s.</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="kw">(</span><span class="ex">./prog</span> <span class="op">&lt;</span> lol.hs <span class="kw">;</span> <span class="fu">cat</span> prog.c<span class="kw">)</span> <span class="op">&gt;</span> lol.c</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> lol</span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./lol</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="kw">(</span><span class="ex">./prog</span> <span class="op">&lt;</span> lol.hs <span class="kw">;</span> <span class="fu">cat</span> prog.c<span class="kw">)</span> <span class="op">&gt;</span> lol.c</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> lol</span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./lol</span></span></code></pre></div>
<p>A GHC wrapper is provided:</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">ghc</span> ghclol.hs</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">ghc</span> ghclol.hs</span></code></pre></div>
<h3 id="strongly-connected-components">Strongly-connected components:</h3>
<p>See <a href="scc.hs">scc.hs</a> (and its GHC wrapper <a href="ghcscc.hs">ghcscc.hs</a>) for an elegant
way to print the strongly-connected components of a graph in reverse topological
order.</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="kw">(</span><span class="ex">./prog</span> <span class="op">&lt;</span> scc.hs <span class="kw">;</span> <span class="fu">cat</span> prog.c<span class="kw">)</span> <span class="op">&gt;</span> scc.c</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="kw">(</span><span class="ex">./prog</span> <span class="op">&lt;</span> scc.hs <span class="kw">;</span> <span class="fu">cat</span> prog.c<span class="kw">)</span> <span class="op">&gt;</span> scc.c</span></code></pre></div>
<p>It expects the input to be in a similar format as a previous entry
(2018 vokes). For example:</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> scc</span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./scc</span> <span class="op">&lt;</span> example-1.txt</span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./scc</span> <span class="op">&lt;</span> example-2.txt</span></code></pre></div>
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> scc</span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./scc</span> <span class="op">&lt;</span> example-1.txt</span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./scc</span> <span class="op">&lt;</span> example-2.txt</span></code></pre></div>
<p>The output should agree, though our program omits line numbers and does not
sort entries within a line. (Also, our program only treats spaces as
whitespace, and supports any non-space character in a vertex name.)</p>
@@ -225,7 +224,7 @@ optional. Some complain about a zoo of twisty little operators, all alike. Our
compiler addresses such concerns by making braces and semicolons compulsory,
disabling layout-based rules, making every operator left-associative with same
precedence, and only defining 6 primitive functions:</p>
<pre><code>: + - * / &lt;=</code></pre>
<pre><code> : + - * / &lt;=</code></pre>
<p>The arithmetic operations behave as they do in C on <code>unsigned int</code>s, and <code>(:)</code> is
Haskell’s <code>cons</code> function. Like Haskell and unlike C, <code>(&lt;=)</code> returns a <code>Bool</code>
(which are Church booleans behind the scenes) and not an <code>Int</code>.</p>
@@ -246,18 +245,18 @@ type <code>[Int] -&gt; [Int]</code>, and our compiler treats this like the funct
into <code>Prelude.interact</code>, that is, the entire standard input is passed to this
function, and the result is printed to standard output.</p>
<p><code>Bool</code> must be defined as:</p>
<pre><code>data Bool = True | False;</code></pre>
<pre><code> data Bool = True | False;</code></pre>
<p>so that it matches the Scott-encoded booleans internally used by the primitive
function <code>(&lt;=)</code>.</p>
<p>The alternatives in a <code>case</code> expressions must list every data constructor in
the order they are defined. For example, if we have:</p>
<pre><code>data Foo a b = Bar a | Baz | Qux Int [b]</code></pre>
<pre><code> data Foo a b = Bar a | Baz | Qux Int [b]</code></pre>
<p>then a <code>case</code> expression that examines a term of this type must have the form:</p>
<pre><code>case x of
{ Bar a -&gt; ...
; Baz -&gt; ...
; Qux n bs -&gt; ...
}</code></pre>
<pre><code> case x of
{ Bar a -&gt; ...
; Baz -&gt; ...
; Qux n bs -&gt; ...
}</code></pre>
<p>We stress braces and semicolons are required. Our fussy parser treats
semicolons as separators, not terminators.</p>
<p>The effect of erroneous input is undefined. It may be best to develop with GHC,
+141 -141
View File
@@ -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 [2019 mills bugs](../../bugs.html#2019_mills).
@@ -19,16 +19,16 @@ For more detailed information see [2019 mills bugs](../../bugs.html#2019_mills).
## To use:
```sh
make cpclean
# Let this run for about about an hour and then kill it:
./prog Shakespeare.txt
make cpclean
# Let this run for about about an hour and then kill it:
./prog Shakespeare.txt
```
## Try:
```sh
./try.sh
./try.sh
```
However, as the binary model files used to produce the output are in an
@@ -93,56 +93,56 @@ For your first OMLET experiment, we will try training a simple single-level
RNN to write some [Shakespeare][5] plays. Start by typing
```sh
make
make
```
After it builds, train it using
```sh
./prog Shakespere.txt
./prog Shakespere.txt
```
This will immediately start outputting gibberish to the output, e.g.
```sh
./prog Shakespere.txt
./prog Shakespere.txt
```
produces:
```
sins ohennAu
T-teooclelp tiThoWy
sins ohennAu
T-teooclelp tiThoWy
g
nlakuafy
e
sselW usnsofueB Aoee pasfUsuslhe ooM ot Wou moy
me neltAl -no IoyI mhuyakse inT-l chu ghenn ffo? fnsoe yhyye
ue nnfrlass heUthole saounlcesyee pee
t,
T0:0% 3.210888
o',,vU
An ,hTf lnm Far rur:s moilt WoEgrv wonds mith Aog thernw
Rni So
co Nnd :
For an bImy pgafoun:
Wf'r hom wortiverita
int fod mous Eheledet,
Tho he theket nonS wnu-ang dorlaMSp
nrocWiSe tflg 'o.
T0:0% 2.995950
d whecedhencrysesil yr bn,
we hh y thiwt
g
nlakuafy
e
sselW usnsofueB Aoee pasfUsuslhe ooM ot Wou moy
me neltAl -no IoyI mhuyakse inT-l chu ghenn ffo? fnsoe yhyye
ue nnfrlass heUthole saounlcesyee pee
t,
T0:0% 3.210888
o',,vU
An ,hTf lnm Far rur:s moilt WoEgrv wonds mith Aog thernw
Rni So
co Nnd :
For an bImy pgafoun:
Wf'r hom wortiverita
int fod mous Eheledet,
Tho he theket nonS wnu-ang dorlaMSp
nrocWiSe tflg 'o.
T0:0% 2.995950
d whecedhencrysesil yr bn,
we hh y thiwt
hut fithlot,
Fmdy s he alt
Vh th no dh foud bobt werw:s Aotnf Fhwi't whe, eusu
hut fithlot,
Fmdy s he alt
Vh th no dh foud bobt werw:s Aotnf Fhwi't whe, eusu
lhh thele wewcond ary soupfy wind tDont couc ths:
er fucwald oncli hen bos, f
T0:1% 2.878945
lhh thele wewcond ary soupfy wind tDont couc ths:
er fucwald oncli hen bos, f
T0:1% 2.878945
```
The gibberish is the networks attempt to write a play. So far, it's not very
@@ -150,7 +150,7 @@ successful! Between the chunks of gibberish are training progress reports
that look like
```
T0:1% 2.878945
T0:1% 2.878945
```
This tells you that we are 1% through training epoch 0, and that the training
@@ -158,31 +158,31 @@ This tells you that we are 1% through training epoch 0, and that the training
reduce and the generated snippets will improve quickly:
```
ses, kuth
LAs of the wish,
As, I nos you,
Yov not to nalll,
Tr tot wonds.
ses, kuth
LAs of the wish,
As, I nos you,
Yov not to nalll,
Tr tot wonds.
First Sondy, llt lrte, our, tw.
First Sondy, llt lrte, our, tw.
First.
First.
BRUTUS:
Helsting the kith gops of hoch Whay, fars surd what to,
The cownens golt te.
T0:12% 2.259114
eplerrotrur tandans one wiok thy or thach and cullice ded yourssting
And wours:
Whed ur surt.
BRUTUS:
Helsting the kith gops of hoch Whay, fars surd what to,
The cownens golt te.
T0:12% 2.259114
eplerrotrur tandans one wiok thy or thach and cullice ded yourssting
And wours:
Whed ur surt.
SINENIUS:
On we lain bith
rerytund: tich lon hyivetetgor.
SINENIUS:
On we lain bith
rerytund: tich lon hyivetetgor.
VOLUONIA:
He brich nom dove worthan then wise,
T0:13% 2.254926
VOLUONIA:
He brich nom dove worthan then wise,
T0:13% 2.254926
```
It's already started to figure out things about Shakespeare plays -- how to
@@ -194,40 +194,40 @@ Eventually, we will finish with the training data set and move on to a
validation cycle:
```
y fath onother,
I sucess,
For I me the west crare.
y fath onother,
I sucess,
For I me the west crare.
TRANIO:
Whow and'd have not to had you you one in my lapteny she very ame come me a gut and shourd aghir you as ignested; shend to make I strem
To h
T0:99% 1.924063
notnce gaud and is nicked thou day, ha the dusing you disaid: in thim, you things in ere thee thus erile Iht that tare theme my hast thesp thou shay: thou not eaten-or-ho-bess resing: I the but had d
T0:99% 1.923128
V0:0% 1.678907
V0:9% 1.700527
V0:18% 1.733179
V0:27% 1.714891
V0:36% 1.716672
V0:45% 1.782946
V0:54% 1.835629
V0:63% 1.876108
V0:72% 1.906814
V0:81% 1.924096
V0:90% 1.954492
V0:99% 1.969287
serfs you'll alliencseard:
We
got you? before
I say.
TRANIO:
Whow and'd have not to had you you one in my lapteny she very ame come me a gut and shourd aghir you as ignested; shend to make I strem
To h
T0:99% 1.924063
notnce gaud and is nicked thou day, ha the dusing you disaid: in thim, you things in ere thee thus erile Iht that tare theme my hast thesp thou shay: thou not eaten-or-ho-bess resing: I the but had d
T0:99% 1.923128
V0:0% 1.678907
V0:9% 1.700527
V0:18% 1.733179
V0:27% 1.714891
V0:36% 1.716672
V0:45% 1.782946
V0:54% 1.835629
V0:63% 1.876108
V0:72% 1.906814
V0:81% 1.924096
V0:90% 1.954492
V0:99% 1.969287
serfs you'll alliencseard:
We
got you? before
I say.
Farstred dentlentecaly, sir, I it one bosticield
All me the backnour mino,
Whith capitaned mid! but stell the ifvemion
Willerity.
Farstred dentlentecaly, sir, I it one bosticield
All me the backnour mino,
Whith capitaned mid! but stell the ifvemion
Willerity.
First Cumfol of
T1:0% 1.885619
First Cumfol of
T1:0% 1.885619
```
Validation cycles are used to test the network to see if it has learned to
@@ -237,7 +237,7 @@ on the validation set is also displayed with a validation progress report that
looks like
```
V0:36% 1.716672
V0:36% 1.716672
```
which means we are 36% of the way through the validation for epoch 0, and the
@@ -260,7 +260,7 @@ You can continue training from a previous checkpoint by providing the
checkpoint file name as the second parameter, for example:
```sh
./prog Shakespeare.txt cp01_1.970
./prog Shakespeare.txt cp01_1.970
```
After the validation cycle finishes, OMLET begins the next epoch by restarting
@@ -276,7 +276,7 @@ parameters to generate data. Inference mode takes the checkpoint file as
command like
```sh
./prog < cp55_1.807
./prog < cp55_1.807
```
Running it produces an infinite amount of generated output, until you hit
@@ -295,8 +295,8 @@ executable name `prog`) is the simplest recurrent neural network. It looks
like
```c
h = tanh(Wxh * x + Whh * h' + Bh)
y = Why * h + By
h = tanh(Wxh * x + Whh * h' + Bh)
y = Why * h + By
```
where
@@ -318,53 +318,53 @@ It is the presence of the hidden state vector that allows the RNN to
state. If you type
```sh
make lin1
make lin1
```
OMLET will create an [ADALINE][10] network that does
```c
y = Wxy * x + By
y = Wxy * x + By
```
This is a simple [linear][11] [feed-forward network][12]. You can run it with
```sh
./lin1 Shakespeare.txt
./lin1 Shakespeare.txt
```
The linear network won't be able to get past the gibberish stage, because it
lacks history:
```sh
./lin1 Shakespeare.txt
./lin1 Shakespeare.txt
```
produces:
```
UERond w,
UERond w,
Gir:
KINof s, mesther s thouth.
E:
KINTret, at fu,
GOMy t, as sth kesewit sooos atse ang k, ck,
Sotheouserivesthecowhet been's, t he, h nre; t and, har wiread of pincer cedst sur has, ut:
Gir:
KINof s, mesther s thouth.
E:
KINTret, at fu,
GOMy t, as sth kesewit sooos atse ang k, ck,
Sotheouserivesthecowhet been's, t he, h nre; t and, har wiread of pincer cedst sur has, ut:
T14:67% 2.465115
UKESpan,
NGaromy soreate e m esewfoure pamitherarjulthengeoly tl.
NG s at e! w.
T14:67% 2.465115
UKESpan,
NGaromy soreate e m esewfoure pamitherarjulthengeoly tl.
NG s at e! w.
WAllinoully?
Wamisw ofilem:
I'delandinarrstath har aksubly s cath Whern t Is, weciss:
WAllinoully?
Wamisw ofilem:
I'delandinarrstath har aksubly s cath Whern t Is, weciss:
GLat s; llde.
Y aterit dsthence
T14:67% 2.465404
GLat s; llde.
Y aterit dsthence
T14:67% 2.465404
```
It is able to guess at what character is likely to follow the current one
@@ -389,9 +389,9 @@ We can try to improve the RNN's performance by stacking RNN modules atop each
other:
```c
h1 = RNN(h1', x)
h2 = RNN(h2', h1)
y = Why * h2 + By
h1 = RNN(h1', x)
h2 = RNN(h2', h1)
y = Why * h2 + By
```
with `RNN(h, x)` defined as above. Each RNN module has its own set of
@@ -415,13 +415,13 @@ the hard limit with `limit -h stacksize` and set it with
You can try the deeper network by doing
```sh
make rnn2
make rnn2
```
(or even `make rnn3` if you want a three-layer RNN) and train it with
```sh
./rnn2 Shakespeare.txt
./rnn2 Shakespeare.txt
```
The additional depth should allow the network to make better predictions (it
@@ -445,13 +445,13 @@ solve this problem. Christopher Olah gives a good description of them
at his [blog posting][20]. You can build a two-level LSTM by doing
```sh
make lstm2
make lstm2
```
and train with it with
```sh
./lstm2 Shakespeare.txt
./lstm2 Shakespeare.txt
```
The LSTM is much easier to train because it explicitly decides how to update
@@ -465,11 +465,11 @@ its hidden state via "gates". These gates are called
The basic LSTM equations are
```c
f = sigmoid(Wxf * x + Whf * h' + Bf)
i = sigmoid(Wxi * x + Whi * h' + Bi)
o = sigmoid(Wxo * x + Who * h' + Bo)
c = f * c' + i * tanh(Wxc * x + Whc * h' + Bc)
h = o * tanh(c)
f = sigmoid(Wxf * x + Whf * h' + Bf)
i = sigmoid(Wxi * x + Whi * h' + Bi)
o = sigmoid(Wxo * x + Who * h' + Bo)
c = f * c' + i * tanh(Wxc * x + Whc * h' + Bc)
h = o * tanh(c)
```
Where
@@ -497,7 +497,7 @@ require fewer learned parameters. This allows them to train faster than a
generic LSTM. You can build a two-layer GRU with
```sh
make gru2
make gru2
```
### Building your own networks
@@ -511,9 +511,9 @@ a `-DNW='...'` command which consists of a series of comma-separated
assignments. For example, the simple one-layer RNN could be defined like
```make
-DNW=' x = I(n), hp = I(128), \
h = C(hp, T(A(L(128, x), L(128, hp)))), \
y = L(n, h)'
-DNW=' x = I(n), hp = I(128), \
h = C(hp, T(A(L(128, x), L(128, hp)))), \
y = L(n, h)'
```
The network declares `x` as an input vector (there must be a declaration for
@@ -556,16 +556,16 @@ As an example of a more complicated network, we can look at a two-layer
GRU network:
```make
-DHS=128, \
-DNW=' x = I(n), \
y = L(n, MD(MD(x)))' \
-DBK=' hp = I(HS), \
z = S(A(L(HS, x), L(HS, hp))), \
r = S(A(L(HS, x), L(HS, hp))), \
c = T(A(L(HS, x), L(HS, hp))), \
zc = OG(1, -1, z), \
h = C(hp, A(M(zc, hp), M(z, c))), \
y = h'
-DHS=128, \
-DNW=' x = I(n), \
y = L(n, MD(MD(x)))' \
-DBK=' hp = I(HS), \
z = S(A(L(HS, x), L(HS, hp))), \
r = S(A(L(HS, x), L(HS, hp))), \
c = T(A(L(HS, x), L(HS, hp))), \
zc = OG(1, -1, z), \
h = C(hp, A(M(zc, hp), M(z, c))), \
y = h'
```
We are using a few new tricks here -- first, we are defining `HS` as the size
+142 -143
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Christopher_Mills">Christopher Mills</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,17 +141,17 @@ 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#2019_mills">2019 mills 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="fu">make</span> cpclean</span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="co"># Let this run for about about an hour and then kill it:</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> Shakespeare.txt</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> cpclean</span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="co"># Let this run for about about an hour and then kill it:</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> Shakespeare.txt</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>
<p>However, as the binary model files used to produce the output are in an
implementation-specific format, your mileage may vary.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
@@ -201,122 +200,122 @@ training, but you can have even more fun by downloading some larger datasets:</p
</ul>
<p>For your first OMLET experiment, we will try training a simple single-level
RNN to write some <a href="https://en.wikipedia.org/wiki/William_Shakespeare">Shakespeare</a> plays. Start by typing</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></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></span></code></pre></div>
<p>After it builds, train it using</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">./prog</span> Shakespere.txt</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">./prog</span> Shakespere.txt</span></code></pre></div>
<p>This will immediately start outputting gibberish to the output, e.g.</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">./prog</span> Shakespere.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">./prog</span> Shakespere.txt</span></code></pre></div>
<p>produces:</p>
<pre><code>sins ohennAu
T-teooclelp tiThoWy
<pre><code> sins ohennAu
T-teooclelp tiThoWy
g
nlakuafy
e
sselW usnsofueB Aoee pasfUsuslhe ooM ot Wou moy
me neltAl -no IoyI mhuyakse inT-l chu ghenn ffo? fnsoe yhyye
ue nnfrlass heUthole saounlcesyee pee
t,
T0:0% 3.210888
o&#39;,,vU
An ,hTf lnm Far rur:s moilt WoEgrv wonds mith Aog thernw
Rni So
co Nnd :
For an bImy pgafoun:
Wf&#39;r hom wortiverita
int fod mous Eheledet,
Tho he theket nonS wnu-ang dorlaMSp
nrocWiSe tflg &#39;o.
T0:0% 2.995950
d whecedhencrysesil yr bn,
we hh y thiwt
g
nlakuafy
e
sselW usnsofueB Aoee pasfUsuslhe ooM ot Wou moy
me neltAl -no IoyI mhuyakse inT-l chu ghenn ffo? fnsoe yhyye
ue nnfrlass heUthole saounlcesyee pee
t,
T0:0% 3.210888
o&#39;,,vU
An ,hTf lnm Far rur:s moilt WoEgrv wonds mith Aog thernw
Rni So
co Nnd :
For an bImy pgafoun:
Wf&#39;r hom wortiverita
int fod mous Eheledet,
Tho he theket nonS wnu-ang dorlaMSp
nrocWiSe tflg &#39;o.
T0:0% 2.995950
d whecedhencrysesil yr bn,
we hh y thiwt
hut fithlot,
Fmdy s he alt
Vh th no dh foud bobt werw:s Aotnf Fhwi&#39;t whe, eusu
hut fithlot,
Fmdy s he alt
Vh th no dh foud bobt werw:s Aotnf Fhwi&#39;t whe, eusu
lhh thele wewcond ary soupfy wind tDont couc ths:
er fucwald oncli hen bos, f
T0:1% 2.878945</code></pre>
lhh thele wewcond ary soupfy wind tDont couc ths:
er fucwald oncli hen bos, f
T0:1% 2.878945</code></pre>
<p>The gibberish is the networks attempt to write a play. So far, it’s not very
successful! Between the chunks of gibberish are training progress reports
that look like</p>
<pre><code>T0:1% 2.878945</code></pre>
<pre><code> T0:1% 2.878945</code></pre>
<p>This tells you that we are 1% through training epoch 0, and that the training
<a href="https://en.wikipedia.org/wiki/Loss_function">loss</a> is about 2.88. As the training continues, the training loss will
reduce and the generated snippets will improve quickly:</p>
<pre><code>ses, kuth
LAs of the wish,
As, I nos you,
Yov not to nalll,
Tr tot wonds.
<pre><code> ses, kuth
LAs of the wish,
As, I nos you,
Yov not to nalll,
Tr tot wonds.
First Sondy, llt lrte, our, tw.
First Sondy, llt lrte, our, tw.
First.
First.
BRUTUS:
Helsting the kith gops of hoch Whay, fars surd what to,
The cownens golt te.
T0:12% 2.259114
eplerrotrur tandans one wiok thy or thach and cullice ded yourssting
And wours:
Whed ur surt.
BRUTUS:
Helsting the kith gops of hoch Whay, fars surd what to,
The cownens golt te.
T0:12% 2.259114
eplerrotrur tandans one wiok thy or thach and cullice ded yourssting
And wours:
Whed ur surt.
SINENIUS:
On we lain bith
rerytund: tich lon hyivetetgor.
SINENIUS:
On we lain bith
rerytund: tich lon hyivetetgor.
VOLUONIA:
He brich nom dove worthan then wise,
T0:13% 2.254926</code></pre>
VOLUONIA:
He brich nom dove worthan then wise,
T0:13% 2.254926</code></pre>
<p>It’s already started to figure out things about Shakespeare plays – how to
spell short English words, how long lines tend to be, and that characters take
turns speaking with their names capitalized. The training loss has dropped to
2.25 and the improvement is noticeable.</p>
<p>Eventually, we will finish with the training data set and move on to a
validation cycle:</p>
<pre><code>y fath onother,
I sucess,
For I me the west crare.
<pre><code> y fath onother,
I sucess,
For I me the west crare.
TRANIO:
Whow and&#39;d have not to had you you one in my lapteny she very ame come me a gut and shourd aghir you as ignested; shend to make I strem
To h
T0:99% 1.924063
notnce gaud and is nicked thou day, ha the dusing you disaid: in thim, you things in ere thee thus erile Iht that tare theme my hast thesp thou shay: thou not eaten-or-ho-bess resing: I the but had d
T0:99% 1.923128
V0:0% 1.678907
V0:9% 1.700527
V0:18% 1.733179
V0:27% 1.714891
V0:36% 1.716672
V0:45% 1.782946
V0:54% 1.835629
V0:63% 1.876108
V0:72% 1.906814
V0:81% 1.924096
V0:90% 1.954492
V0:99% 1.969287
serfs you&#39;ll alliencseard:
We
got you? before
I say.
TRANIO:
Whow and&#39;d have not to had you you one in my lapteny she very ame come me a gut and shourd aghir you as ignested; shend to make I strem
To h
T0:99% 1.924063
notnce gaud and is nicked thou day, ha the dusing you disaid: in thim, you things in ere thee thus erile Iht that tare theme my hast thesp thou shay: thou not eaten-or-ho-bess resing: I the but had d
T0:99% 1.923128
V0:0% 1.678907
V0:9% 1.700527
V0:18% 1.733179
V0:27% 1.714891
V0:36% 1.716672
V0:45% 1.782946
V0:54% 1.835629
V0:63% 1.876108
V0:72% 1.906814
V0:81% 1.924096
V0:90% 1.954492
V0:99% 1.969287
serfs you&#39;ll alliencseard:
We
got you? before
I say.
Farstred dentlentecaly, sir, I it one bosticield
All me the backnour mino,
Whith capitaned mid! but stell the ifvemion
Willerity.
Farstred dentlentecaly, sir, I it one bosticield
All me the backnour mino,
Whith capitaned mid! but stell the ifvemion
Willerity.
First Cumfol of
T1:0% 1.885619</code></pre>
First Cumfol of
T1:0% 1.885619</code></pre>
<p>Validation cycles are used to test the network to see if it has learned to
generalize – how well it performs on data it hasn’t seen before (as opposed to
the training data that the network will see many times as it trains). Progress
on the validation set is also displayed with a validation progress report that
looks like</p>
<pre><code>V0:36% 1.716672</code></pre>
<pre><code> V0:36% 1.716672</code></pre>
<p>which means we are 36% of the way through the validation for epoch 0, and the
validation loss is about 1.72. Comparing the validation loss and the
training loss will give you an idea of how well the network is learning and
@@ -332,7 +331,7 @@ helpful if you need to stop and restart training. You can stop training by
doing <code>Control-C</code>.</p>
<p>You can continue training from a previous checkpoint by providing the
checkpoint file name as the second parameter, for example:</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">./prog</span> Shakespeare.txt cp01_1.970</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">./prog</span> Shakespeare.txt cp01_1.970</span></code></pre></div>
<p>After the validation cycle finishes, OMLET begins the next epoch by restarting
training at the beginning of the training set. Training continues forever,
until you quit it with <code>Control-C</code>. You should monitor the checkpoints to
@@ -343,7 +342,7 @@ OMLET to run the network in inference mode which uses the frozen checkpoint
parameters to generate data. Inference mode takes the checkpoint file as
<em>standard input</em> (not on the command line) and hence must be run with a
command like</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">./prog</span> <span class="op">&lt;</span> cp55_1.807</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">./prog</span> <span class="op">&lt;</span> cp55_1.807</span></code></pre></div>
<p>Running it produces an infinite amount of generated output, until you hit
<code>Control-C</code> to stop it.</p>
<p>Note that if you decide to change networks or use a different input file, you
@@ -354,8 +353,8 @@ cause a crash.</p>
<p>The default network for OMLET (the one you get if you type <code>make</code> with the
executable name <code>prog</code>) is the simplest recurrent neural network. It looks
like</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a>h <span class="op">=</span> tanh<span class="op">(</span>Wxh <span class="op">*</span> x <span class="op">+</span> Whh <span class="op">*</span> h<span class="ch">&#39; </span><span class="er">+ Bh)</span></span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a>y <span class="op">=</span> Why <span class="op">*</span> h <span class="op">+</span> By</span></code></pre></div>
<div class="sourceCode" id="cb15"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a> h <span class="op">=</span> tanh<span class="op">(</span>Wxh <span class="op">*</span> x <span class="op">+</span> Whh <span class="op">*</span> h<span class="ch">&#39; </span><span class="er">+ Bh)</span></span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a> y <span class="op">=</span> Why <span class="op">*</span> h <span class="op">+</span> By</span></code></pre></div>
<p>where</p>
<ul>
<li><code>x</code> is the <em>input vector</em></li>
@@ -372,37 +371,37 @@ the loss of the network across the training set.</p>
<p>It is the presence of the hidden state vector that allows the RNN to
“remember” the past. We can see what would happen if we removed this hidden
state. If you type</p>
<div class="sourceCode" id="cb16"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> lin1</span></code></pre></div>
<div class="sourceCode" id="cb16"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> lin1</span></code></pre></div>
<p>OMLET will create an <a href="https://en.wikipedia.org/wiki/ADALINE">ADALINE</a> network that does</p>
<div class="sourceCode" id="cb17"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a>y <span class="op">=</span> Wxy <span class="op">*</span> x <span class="op">+</span> By</span></code></pre></div>
<div class="sourceCode" id="cb17"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a> y <span class="op">=</span> Wxy <span class="op">*</span> x <span class="op">+</span> By</span></code></pre></div>
<p>This is a simple <a href="https://en.wikipedia.org/wiki/Linear_map">linear</a> <a href="https://en.wikipedia.org/wiki/Feedforward_neural_network">feed-forward network</a>. You can run it with</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">./lin1</span> Shakespeare.txt</span></code></pre></div>
<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">./lin1</span> Shakespeare.txt</span></code></pre></div>
<p>The linear network won’t be able to get past the gibberish stage, because it
lacks history:</p>
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./lin1</span> Shakespeare.txt</span></code></pre></div>
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./lin1</span> Shakespeare.txt</span></code></pre></div>
<p>produces:</p>
<pre><code>UERond w,
<pre><code> UERond w,
Gir:
KINof s, mesther s thouth.
E:
KINTret, at fu,
GOMy t, as sth kesewit sooos atse ang k, ck,
Sotheouserivesthecowhet been&#39;s, t he, h nre; t and, har wiread of pincer cedst sur has, ut:
Gir:
KINof s, mesther s thouth.
E:
KINTret, at fu,
GOMy t, as sth kesewit sooos atse ang k, ck,
Sotheouserivesthecowhet been&#39;s, t he, h nre; t and, har wiread of pincer cedst sur has, ut:
T14:67% 2.465115
UKESpan,
NGaromy soreate e m esewfoure pamitherarjulthengeoly tl.
NG s at e! w.
T14:67% 2.465115
UKESpan,
NGaromy soreate e m esewfoure pamitherarjulthengeoly tl.
NG s at e! w.
WAllinoully?
Wamisw ofilem:
I&#39;delandinarrstath har aksubly s cath Whern t Is, weciss:
WAllinoully?
Wamisw ofilem:
I&#39;delandinarrstath har aksubly s cath Whern t Is, weciss:
GLat s; llde.
Y aterit dsthence
T14:67% 2.465404</code></pre>
GLat s; llde.
Y aterit dsthence
T14:67% 2.465404</code></pre>
<p>It is able to guess at what character is likely to follow the current one
(by doing a <a href="https://en.wikipedia.org/wiki/Linear_regression">linear regression</a>), but it lacks any history beyond that to
guide it.</p>
@@ -419,9 +418,9 @@ the language but <code>per</code> with the digit 1).</p>
<h3 id="going-deeper">Going deeper:</h3>
<p>We can try to improve the RNN’s performance by stacking RNN modules atop each
other:</p>
<div class="sourceCode" id="cb21"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a>h1 <span class="op">=</span> RNN<span class="op">(</span>h1<span class="ch">&#39;,</span><span class="er"> x)</span></span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a>h2 <span class="op">=</span> RNN<span class="op">(</span>h2<span class="ch">&#39;,</span><span class="er"> h1)</span></span>
<span id="cb21-3"><a href="#cb21-3" aria-hidden="true" tabindex="-1"></a>y <span class="op">=</span> Why <span class="op">*</span> h2 <span class="op">+</span> By</span></code></pre></div>
<div class="sourceCode" id="cb21"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a> h1 <span class="op">=</span> RNN<span class="op">(</span>h1<span class="ch">&#39;,</span><span class="er"> x)</span></span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a> h2 <span class="op">=</span> RNN<span class="op">(</span>h2<span class="ch">&#39;,</span><span class="er"> h1)</span></span>
<span id="cb21-3"><a href="#cb21-3" aria-hidden="true" tabindex="-1"></a> y <span class="op">=</span> Why <span class="op">*</span> h2 <span class="op">+</span> By</span></code></pre></div>
<p>with <code>RNN(h, x)</code> defined as above. Each RNN module has its own set of
parameters and its own hidden state vector. This will improve the network’s
performance, at the cost of a much larger parameter space.</p>
@@ -437,9 +436,9 @@ the hard limit with <code>limit -h stacksize</code> and set it with
<code>limit stacksize 65532</code> (replacing <code>65532</code> with the actual hard limit).</p>
<hr />
<p>You can try the deeper network by doing</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="fu">make</span> rnn2</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="fu">make</span> rnn2</span></code></pre></div>
<p>(or even <code>make rnn3</code> if you want a three-layer RNN) and train it 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">./rnn2</span> Shakespeare.txt</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">./rnn2</span> Shakespeare.txt</span></code></pre></div>
<p>The additional depth should allow the network to make better predictions (it
can represent more complicated history), but it may take a long time to train
-- both because the network (being larger) now requires more time to train and
@@ -455,9 +454,9 @@ gradient, worsening the exploding and vanishing gradient problem.</p>
<p><a href="https://en.wikipedia.org/wiki/Long_short-term_memory">Long Short Term Memory</a> networks (also called LSTMs) were developed to
solve this problem. Christopher Olah gives a good description of them
at his <a href="http://colah.github.io/posts/2015-08-Understanding-LSTMs/">blog posting</a>. You can build a two-level LSTM by doing</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="fu">make</span> lstm2</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="fu">make</span> lstm2</span></code></pre></div>
<p>and train with it with</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">./lstm2</span> Shakespeare.txt</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">./lstm2</span> Shakespeare.txt</span></code></pre></div>
<p>The LSTM is much easier to train because it explicitly decides how to update
its hidden state via “gates”. These gates are called</p>
<ul>
@@ -467,11 +466,11 @@ its hidden state via “gates”. These gates are called</p>
produce the output</li>
</ul>
<p>The basic LSTM equations are</p>
<div class="sourceCode" id="cb26"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a>f <span class="op">=</span> sigmoid<span class="op">(</span>Wxf <span class="op">*</span> x <span class="op">+</span> Whf <span class="op">*</span> h<span class="ch">&#39; </span><span class="er">+ Bf)</span></span>
<span id="cb26-2"><a href="#cb26-2" aria-hidden="true" tabindex="-1"></a>i <span class="op">=</span> sigmoid<span class="op">(</span>Wxi <span class="op">*</span> x <span class="op">+</span> Whi <span class="op">*</span> h<span class="ch">&#39; </span><span class="er">+ Bi)</span></span>
<span id="cb26-3"><a href="#cb26-3" aria-hidden="true" tabindex="-1"></a>o <span class="op">=</span> sigmoid<span class="op">(</span>Wxo <span class="op">*</span> x <span class="op">+</span> Who <span class="op">*</span> h<span class="ch">&#39; </span><span class="er">+ Bo)</span></span>
<span id="cb26-4"><a href="#cb26-4" aria-hidden="true" tabindex="-1"></a>c <span class="op">=</span> f <span class="op">*</span> c<span class="ch">&#39; </span><span class="er">+ i * tanh(Wxc * x + Whc * h</span><span class="ch">&#39;</span> <span class="op">+</span> Bc<span class="op">)</span></span>
<span id="cb26-5"><a href="#cb26-5" aria-hidden="true" tabindex="-1"></a>h <span class="op">=</span> o <span class="op">*</span> tanh<span class="op">(</span>c<span class="op">)</span></span></code></pre></div>
<div class="sourceCode" id="cb26"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a> f <span class="op">=</span> sigmoid<span class="op">(</span>Wxf <span class="op">*</span> x <span class="op">+</span> Whf <span class="op">*</span> h<span class="ch">&#39; </span><span class="er">+ Bf)</span></span>
<span id="cb26-2"><a href="#cb26-2" aria-hidden="true" tabindex="-1"></a> i <span class="op">=</span> sigmoid<span class="op">(</span>Wxi <span class="op">*</span> x <span class="op">+</span> Whi <span class="op">*</span> h<span class="ch">&#39; </span><span class="er">+ Bi)</span></span>
<span id="cb26-3"><a href="#cb26-3" aria-hidden="true" tabindex="-1"></a> o <span class="op">=</span> sigmoid<span class="op">(</span>Wxo <span class="op">*</span> x <span class="op">+</span> Who <span class="op">*</span> h<span class="ch">&#39; </span><span class="er">+ Bo)</span></span>
<span id="cb26-4"><a href="#cb26-4" aria-hidden="true" tabindex="-1"></a> c <span class="op">=</span> f <span class="op">*</span> c<span class="ch">&#39; </span><span class="er">+ i * tanh(Wxc * x + Whc * h</span><span class="ch">&#39;</span> <span class="op">+</span> Bc<span class="op">)</span></span>
<span id="cb26-5"><a href="#cb26-5" aria-hidden="true" tabindex="-1"></a> h <span class="op">=</span> o <span class="op">*</span> tanh<span class="op">(</span>c<span class="op">)</span></span></code></pre></div>
<p>Where</p>
<ul>
<li><code>x</code> is the input vector</li>
@@ -495,7 +494,7 @@ examples). One important one is the <a href="https://en.wikipedia.org/wiki/Gated
simplified versions of an LSTM which combine the gates together, meaning they
require fewer learned parameters. This allows them to train faster than a
generic LSTM. You can build a two-layer GRU with</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">make</span> gru2</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">make</span> gru2</span></code></pre></div>
<h3 id="building-your-own-networks">Building your own networks</h3>
<p>The OMLET <code>Makefile</code> comes with one-, two- and three-layer RNNs, LSTMs and
GRUs, along with simpler feed-forward networks like multi-layer perceptrons and
@@ -504,9 +503,9 @@ own networks by modifying the <code>Makefile</code>. Networks are passed in on t
compiler’s command-line by using <code>-D</code> directives. The network is defined by
a <code>-DNW='...'</code> command which consists of a series of comma-separated
assignments. For example, the simple one-layer RNN could be defined like</p>
<pre class="make"><code>-DNW=&#39; x = I(n), hp = I(128), \
h = C(hp, T(A(L(128, x), L(128, hp)))), \
y = L(n, h)&#39;</code></pre>
<pre class="make"><code> -DNW=&#39; x = I(n), hp = I(128), \
h = C(hp, T(A(L(128, x), L(128, hp)))), \
y = L(n, h)&#39;</code></pre>
<p>The network declares <code>x</code> as an input vector (there must be a declaration for
<code>x</code>). It is declared as <code>I(n)</code>, which is an input vector of size <code>n</code>, which
is the number of characters of the input alphabet (OMLET computes this from
@@ -539,16 +538,16 @@ inference mode, this is used to select the next character to emit. In
training mode, this is used to generate the loss which is backpropagated.</p>
<p>As an example of a more complicated network, we can look at a two-layer
GRU network:</p>
<pre class="make"><code>-DHS=128, \
-DNW=&#39; x = I(n), \
y = L(n, MD(MD(x)))&#39; \
-DBK=&#39; hp = I(HS), \
z = S(A(L(HS, x), L(HS, hp))), \
r = S(A(L(HS, x), L(HS, hp))), \
c = T(A(L(HS, x), L(HS, hp))), \
zc = OG(1, -1, z), \
h = C(hp, A(M(zc, hp), M(z, c))), \
y = h&#39;</code></pre>
<pre class="make"><code> -DHS=128, \
-DNW=&#39; x = I(n), \
y = L(n, MD(MD(x)))&#39; \
-DBK=&#39; hp = I(HS), \
z = S(A(L(HS, x), L(HS, hp))), \
r = S(A(L(HS, x), L(HS, hp))), \
c = T(A(L(HS, x), L(HS, hp))), \
zc = OG(1, -1, z), \
h = C(hp, A(M(zc, hp), M(z, c))), \
y = h&#39;</code></pre>
<p>We are using a few new tricks here – first, we are defining <code>HS</code> as the size
of the hidden and cell vectors. There’s nothing special about this name, it’s
just convenient to specify it so we don’t have a bunch of constants in the
+15 -17
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make
make
```
There is an alternate version of this program which changes the way the output
@@ -18,7 +18,7 @@ forcing `-std=gnu11`.
The current status of this entry is:
```
STATUS: INABIAF - please **DO NOT** fix
STATUS: INABIAF - please **DO NOT** fix
```
For more detailed information see [2019 poikola bugs](../../bugs.html#2019_poikola).
@@ -27,20 +27,19 @@ For more detailed information see [2019 poikola bugs](../../bugs.html#2019_poiko
## To use:
```sh
./prog 512 ./prog
./prog 512 ./prog
sleep 86400; make clobber prog
./prog 512 ./prog
sleep 86400; make clobber prog
./prog 512 ./prog
sleep 86400; make clobber prog
./prog 512 ./prog
sleep 86400; make clobber prog
./prog 512 ./prog
```
If you wish for some documentation:
```sh
make docs
make docs
```
This will create the file `poikola.pdf` for your enjoyment.
@@ -51,7 +50,7 @@ This will create the file `poikola.pdf` for your enjoyment.
If you don't have a few days, try:
```sh
./try.sh
./try.sh
```
As the [2019 poikola bugs](../../bugs.html#2019_poikola) says, this program will not validate
@@ -67,7 +66,7 @@ what can be done with the original entry.
### Alternate build:
```sh
make alt
make alt
```
@@ -79,7 +78,7 @@ Use `prog.alt` as you would `prog` above.
### Alternate try:
```sh
./try.alt.sh
./try.alt.sh
```
@@ -105,19 +104,19 @@ Nyk&auml;nen](https://en.wikipedia.org/wiki/Matti_Nyk%C3%A4nen).
### How to build:
```sh
gcc -O0 -o prog prog.c
gcc -O0 -o prog prog.c
```
or
```sh
clang -O[0123s] -o prog prog.c
clang -O[0123s] -o prog prog.c
```
e.g.:
```sh
clang -O1 -o prog prog.c
clang -O1 -o prog prog.c
```
@@ -168,8 +167,7 @@ program is invoked in this way:
```sh
./prog <integer> <file>
./prog <integer> <file>
```
where `<integer>` is 224, 256, 384, 512 or even 1024. Yes, I know 1024 is not a
+16 -17
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Timo_Poikola">Timo Poikola</a><br>
Location: <a href="../../location.html#FI">FI</a> - <em>Republic of Finland </em> (<em>Finland</em>)
<br><br></li>
Location: <a href="../../location.html#FI">FI</a> - <em>Republic of Finland </em> (<em>Finland</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,7 +141,7 @@ Location: <a href="../../location.html#FI">FI</a> - <em>Republic of Finland </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 alternate version of this program which changes the way the output
is displayed. See <a href="#alternate-code">Alternate code</a> below.</p>
<p>NOTE: we disable the optimiser because the author stated that for GCC optimiser
@@ -151,33 +150,33 @@ might or might not work with GCC. Likewise, we do similar for the standard,
forcing <code>-std=gnu11</code>.</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#2019_poikola">2019 poikola 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">./prog</span> 512 ./prog</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">./prog</span> 512 ./prog</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="fu">sleep</span> 86400<span class="kw">;</span> <span class="fu">make</span> clobber prog</span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> 512 ./prog</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">sleep</span> 86400<span class="kw">;</span> <span class="fu">make</span> clobber prog</span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> 512 ./prog</span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a><span class="fu">sleep</span> 86400<span class="kw">;</span> <span class="fu">make</span> clobber prog</span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> 512 ./prog</span></code></pre></div>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">sleep</span> 86400<span class="kw">;</span> <span class="fu">make</span> clobber prog</span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> 512 ./prog</span></code></pre></div>
<p>If you wish for some documentation:</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> docs</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> docs</span></code></pre></div>
<p>This will create the file <code>poikola.pdf</code> for your enjoyment.</p>
<h2 id="try">Try:</h2>
<p>If you don’t have a few days, 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">./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>
<p>As the <a href="../../bugs.html#2019_poikola">2019 poikola bugs</a> says, this program will not validate
input so it might get stuck or fail if invoked erroneously.</p>
<h2 id="alternate-code">Alternate code:</h2>
<p>This version prints a newline after each number for parsing in other ways than
what can be done with the original entry.</p>
<h3 id="alternate-build">Alternate build:</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">make</span> 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> alt</span></code></pre></div>
<h3 id="alternate-use">Alternate use:</h3>
<p>Use <code>prog.alt</code> as you would <code>prog</code> above.</p>
<h3 id="alternate-try">Alternate try:</h3>
<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">./try.alt.sh</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="ex">./try.alt.sh</span></span></code></pre></div>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>Do you have the time to see what this program does? Think again, come back and
try again.</p>
@@ -192,11 +191,11 @@ accomplishments of <a href="https://en.wikipedia.org/wiki/Matti_Nyk%C3%A4nen">Ma
Nykänen</a>.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="how-to-build">How to build:</h3>
<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">gcc</span> <span class="at">-O0</span> <span class="at">-o</span> prog prog.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">gcc</span> <span class="at">-O0</span> <span class="at">-o</span> prog prog.c</span></code></pre></div>
<p>or</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">clang</span> <span class="at">-O</span><span class="pp">[</span><span class="ss">0123s</span><span class="pp">]</span> <span class="at">-o</span> prog prog.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">clang</span> <span class="at">-O</span><span class="pp">[</span><span class="ss">0123s</span><span class="pp">]</span> <span class="at">-o</span> prog prog.c</span></code></pre></div>
<p>e.g.:</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">clang</span> <span class="at">-O1</span> <span class="at">-o</span> prog prog.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="fu">clang</span> <span class="at">-O1</span> <span class="at">-o</span> prog prog.c</span></code></pre></div>
<h3 id="poster">Poster:</h3>
<p>You can generate an A3 sized poster by <code>make docs</code>. This command creates a pdf
file <code>poikola.pdf</code>. This requires the
@@ -232,7 +231,7 @@ three consecutive days.</p>
<p>As this is a contest for obfuscated code, the program does not perform
unnecessary checks, but either fails or gets stuck if invoked erroneously. The
program is invoked in this way:</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">./prog</span> <span class="op">&lt;</span>integer<span class="op">&gt;</span> <span class="op">&lt;</span>file<span class="op">&gt;</span></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">./prog</span> <span class="op">&lt;</span>integer<span class="op">&gt;</span> <span class="op">&lt;</span>file<span class="op">&gt;</span></span></code></pre></div>
<p>where <code>&lt;integer&gt;</code> is 224, 256, 384, 512 or even 1024. Yes, I know 1024 is not a
supported length of output, but as I said, the program does not validate its
input in any way. These same parameters should be given in calculating a
+29 -29
View File
@@ -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 [2019 yang bugs](../../bugs.html#2019_yang).
@@ -19,24 +19,24 @@ For more detailed information see [2019 yang bugs](../../bugs.html#2019_yang).
## To use:
```sh
./prog sample_input.txt a b c d
./prog sample_input.txt a b c d
cat a
cat a
cat b
cat b
cat c
cat c
cat d
cat d
cat a b c d | ./prog
cat a b c d | ./prog
```
## Try:
```sh
./try.sh
./try.sh
```
@@ -53,31 +53,31 @@ output again.
Scramble/unscramble to single file:
```sh
./prog original.txt > scrambled.txt
./prog original.txt > scrambled.txt
./prog < scrambled.txt > unscrambled.txt
./prog < scrambled.txt > unscrambled.txt
```
Scramble/unscramble to multiple files:
```sh
./prog input.txt output1.txt output2.txt ...
./prog input.txt output1.txt output2.txt ...
cat output1.txt output2.txt ... | ./prog > unscrambled.txt
cat output1.txt output2.txt ... | ./prog > unscrambled.txt
```
Re-scramble:
```sh
./prog original.txt | ./prog - > scrambled1.txt
./prog original.txt | ./prog - | ./prog - > scrambled2.txt
./prog original.txt | ./prog - | ./prog - | ... > scrambled3.txt
./prog original.txt | ./prog - > scrambled1.txt
./prog original.txt | ./prog - | ./prog - > scrambled2.txt
./prog original.txt | ./prog - | ./prog - | ... > scrambled3.txt
```
Scramble slowly:
```sh
./prog input.txt | ruby prog.c
./prog input.txt | ruby prog.c
```
Input must be in UTF-8 encoding.
@@ -88,14 +88,14 @@ This is a text scrambling utility. To scramble text, specify input file name as
the first argument:
```sh
./prog input.txt > output.txt
./prog input.txt > output.txt
```
If original input file was small enough to fit in your terminal, you
can simply use `cat` to unscramble the output text.
```sh
cat output.txt
cat output.txt
```
It might seem like nothing was scrambled, but you can try passing the output
@@ -107,7 +107,7 @@ printed. For convenience, a utility is included in the source to output
characters slowly:
```sh
./prog input.txt | ruby prog.c
./prog input.txt | ruby prog.c
```
Scrambling order is deterministic, but you can reshuffle the output by
@@ -115,15 +115,15 @@ piping it through the same utility again, by specifying `-` as the
first argument:
```sh
./prog input.txt | ./prog - | ./prog - | ...
./prog input.txt | ./prog - | ./prog - | ...
```
You can also split the input to multiple files, each getting a subset
of the original input characters:
```sh
./prog input.txt output1.txt output2.txt ...
cat output1.txt output2.txt ... > unscrambled.txt
./prog input.txt output1.txt output2.txt ...
cat output1.txt output2.txt ... > unscrambled.txt
```
You can only unscramble files with `cat` if the input fits in a single
@@ -139,7 +139,7 @@ unscrambling functionality. If no argument is specified, input will
be read through `stdin` and unscrambled to `stdout`:
```sh
./prog < scrambled.txt > unscrambled.txt
./prog < scrambled.txt > unscrambled.txt
```
Where this is useful is that if you scramble the input to multiple
@@ -147,10 +147,10 @@ files and unscramble each output file individually, those output
files can be printed on transparencies and distributed separately.
```sh
./prog input.txt output1.txt output2.txt output3.txt
./prog < output1.txt > layer1.txt
./prog < output2.txt > layer2.txt
./prog < output3.txt > layer3.txt
./prog input.txt output1.txt output2.txt output3.txt
./prog < output1.txt > layer1.txt
./prog < output2.txt > layer2.txt
./prog < output3.txt > layer3.txt
```
In other words, this is a utility for facilitating
@@ -160,7 +160,7 @@ This utility can also be used just for removing trailing whitespaces
and expanding tabs to 8 spaces.
```sh
./prog input.txt | ./prog
./prog input.txt | ./prog
```
### Features:
+30 -31
View File
@@ -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,52 +141,52 @@ 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#2019_yang">2019 yang 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">./prog</span> sample_input.txt a b c d</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">./prog</span> sample_input.txt a b c d</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="fu">cat</span> a</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> a</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="fu">cat</span> b</span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> b</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="fu">cat</span> c</span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> c</span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> d</span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> d</span>
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> a b c d <span class="kw">|</span> <span class="ex">./prog</span></span></code></pre></div>
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> a b c d <span class="kw">|</span> <span class="ex">./prog</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">./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>Do you understand how this program works? You may have to go over and over the
output again.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="summary">Summary:</h3>
<p>Scramble/unscramble to single file:</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">./prog</span> original.txt <span class="op">&gt;</span> scrambled.txt</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="ex">./prog</span> original.txt <span class="op">&gt;</span> scrambled.txt</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="ex">./prog</span> <span class="op">&lt;</span> scrambled.txt <span class="op">&gt;</span> unscrambled.txt</span></code></pre></div>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> <span class="op">&lt;</span> scrambled.txt <span class="op">&gt;</span> unscrambled.txt</span></code></pre></div>
<p>Scramble/unscramble to multiple files:</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">./prog</span> input.txt output1.txt output2.txt ...</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">./prog</span> input.txt output1.txt output2.txt ...</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="fu">cat</span> output1.txt output2.txt ... <span class="kw">|</span> <span class="ex">./prog</span> <span class="op">&gt;</span> unscrambled.txt</span></code></pre></div>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> output1.txt output2.txt ... <span class="kw">|</span> <span class="ex">./prog</span> <span class="op">&gt;</span> unscrambled.txt</span></code></pre></div>
<p>Re-scramble:</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">./prog</span> original.txt <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="op">&gt;</span> scrambled1.txt</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> original.txt <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="op">&gt;</span> scrambled2.txt</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> original.txt <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="kw">|</span> <span class="ex">...</span> <span class="op">&gt;</span> scrambled3.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">./prog</span> original.txt <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="op">&gt;</span> scrambled1.txt</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> original.txt <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="op">&gt;</span> scrambled2.txt</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> original.txt <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="kw">|</span> <span class="ex">...</span> <span class="op">&gt;</span> scrambled3.txt</span></code></pre></div>
<p>Scramble slowly:</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">./prog</span> input.txt <span class="kw">|</span> <span class="ex">ruby</span> prog.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="ex">./prog</span> input.txt <span class="kw">|</span> <span class="ex">ruby</span> prog.c</span></code></pre></div>
<p>Input must be in UTF-8 encoding.</p>
<h3 id="details">Details:</h3>
<p>This is a text scrambling utility. To scramble text, specify input file name as
the first argument:</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="ex">./prog</span> input.txt <span class="op">&gt;</span> output.txt</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="ex">./prog</span> input.txt <span class="op">&gt;</span> output.txt</span></code></pre></div>
<p>If original input file was small enough to fit in your terminal, you
can simply use <code>cat</code> to unscramble the output text.</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">cat</span> output.txt</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">cat</span> output.txt</span></code></pre></div>
<p>It might seem like nothing was scrambled, but you can try passing the output
through <code>strings(1)</code> and see that most of the original strings are gone. What
happened is that the original text has been shuffled with ANSI cursor
@@ -195,15 +194,15 @@ positioning codes inserted in such a way that characters are printed in random
order. This effect is more visible if there is a delay after each character is
printed. For convenience, a utility is included in the source to output
characters slowly:</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">./prog</span> input.txt <span class="kw">|</span> <span class="ex">ruby</span> prog.c</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">./prog</span> input.txt <span class="kw">|</span> <span class="ex">ruby</span> prog.c</span></code></pre></div>
<p>Scrambling order is deterministic, but you can reshuffle the output by
piping it through the same utility again, by specifying <code>-</code> as the
first argument:</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> input.txt <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="kw">|</span> <span class="ex">...</span></span></code></pre></div>
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> input.txt <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="kw">|</span> <span class="ex">./prog</span> <span class="at">-</span> <span class="kw">|</span> <span class="ex">...</span></span></code></pre></div>
<p>You can also split the input to multiple files, each getting a subset
of the original input characters:</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">./prog</span> input.txt output1.txt output2.txt ...</span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> output1.txt output2.txt ... <span class="op">&gt;</span> unscrambled.txt</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">./prog</span> input.txt output1.txt output2.txt ...</span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> output1.txt output2.txt ... <span class="op">&gt;</span> unscrambled.txt</span></code></pre></div>
<p>You can only unscramble files with <code>cat</code> if the input fits in a single
terminal screen. If you don’t know what will be the terminal size of
the recipient, note that <code>prog.c</code> will fit in a 80x25 terminal, so a
@@ -214,19 +213,19 @@ sufficient for unscrambling because any scrolling causes the character
positions to be misaligned. But fear not, this utility also includes
unscrambling functionality. If no argument is specified, input will
be read through <code>stdin</code> and unscrambled to <code>stdout</code>:</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">./prog</span> <span class="op">&lt;</span> scrambled.txt <span class="op">&gt;</span> unscrambled.txt</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">./prog</span> <span class="op">&lt;</span> scrambled.txt <span class="op">&gt;</span> unscrambled.txt</span></code></pre></div>
<p>Where this is useful is that if you scramble the input to multiple
files and unscramble each output file individually, those output
files can be printed on transparencies and distributed separately.</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">./prog</span> input.txt output1.txt output2.txt output3.txt</span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> <span class="op">&lt;</span> output1.txt <span class="op">&gt;</span> layer1.txt</span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> <span class="op">&lt;</span> output2.txt <span class="op">&gt;</span> layer2.txt</span>
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> <span class="op">&lt;</span> output3.txt <span class="op">&gt;</span> layer3.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="ex">./prog</span> input.txt output1.txt output2.txt output3.txt</span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> <span class="op">&lt;</span> output1.txt <span class="op">&gt;</span> layer1.txt</span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> <span class="op">&lt;</span> output2.txt <span class="op">&gt;</span> layer2.txt</span>
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> <span class="op">&lt;</span> output3.txt <span class="op">&gt;</span> layer3.txt</span></code></pre></div>
<p>In other words, this is a utility for facilitating
<a href="https://en.wikipedia.org/wiki/Visual_cryptography">visual cryptography</a>.</p>
<p>This utility can also be used just for removing trailing whitespaces
and expanding tabs to 8 spaces.</p>
<div class="sourceCode" id="cb16"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> input.txt <span class="kw">|</span> <span class="ex">./prog</span></span></code></pre></div>
<div class="sourceCode" id="cb16"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> input.txt <span class="kw">|</span> <span class="ex">./prog</span></span></code></pre></div>
<h3 id="features">Features:</h3>
<h4 id="utf-8-support">UTF-8 support:</h4>
<p>A simple text scrambling utility might not have required a screenful