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

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

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

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

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

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

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

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

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

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

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

No files matched your search

+7 -7
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -18,14 +18,14 @@ For more detailed information see [2019 adamovsky bugs](../../bugs.html#2019_ada
## To use:
```sh
```<!---sh-->
./prog file.unl
```
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -47,7 +47,7 @@ Functional programming is not a panacea against core dumps, after all.
This can be demonstrated by:
```sh
```<!---sh-->
./prog crash.unl
```
@@ -84,7 +84,7 @@ by the sheer length of the dividing line and totally overlooks the rest of the p
When built directly using
```sh
```<!---sh-->
make
```
@@ -92,7 +92,7 @@ the program (`prog`) accepts a single parameter with the name of an Unlambda pro
download the [Colossal Cave Adventure][1] (the [advent.unl](advent.unl) file)
and run it like this:
```sh
```<!---sh-->
./prog advent.unl
```
@@ -105,7 +105,7 @@ entries from [quine contest][4].
There is an alternative build path that requires the 2018 IOCCC size tool to complete. Put the tool
source [iocccsize_2018.c](iocccsize_2018.c) in the project directory and call
```sh
```<!---sh-->
make identify
```
+7 -7
View File
@@ -141,15 +141,15 @@ 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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
<p>For more detailed information see <a href="../../bugs.html#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>
<pre class="&lt;!---sh--&gt;"><code> ./prog file.unl</code></pre>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>Even after pre-processing and indenting, the C code of this entry it
is about as understandable as the Unlambda code.</p>
@@ -159,7 +159,7 @@ bytes which crashed it:</p>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog crash.unl</code></pre>
<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>
@@ -181,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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog advent.unl</code></pre>
<blockquote>
<p>NOTE: the file was added to the entry so there is no need to download it.</p>
</blockquote>
@@ -194,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>
<pre class="&lt;!---sh--&gt;"><code> make identify</code></pre>
<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>
+6 -6
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -18,7 +18,7 @@ For more detailed information see [2019 burton bugs](../../bugs.html#2019_burton
## To use:
```sh
```<!---sh-->
./prog < file
./cow file
@@ -27,7 +27,7 @@ For more detailed information see [2019 burton bugs](../../bugs.html#2019_burton
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -51,7 +51,7 @@ The output should look familiar.
Compiles cleanly with:
```sh
```<!---sh-->
WARN="-Wno-implicit-int -Wno-missing-variable-declarations -Wno-parentheses"
cc -Wall -Wextra -Weverything -pedantic $WARN -include stdio.h -o prog prog.c
```
@@ -63,7 +63,7 @@ programs, it is silent upon success; any output demonstrates an error. Instead
of checking correctness, the [check.sh](check.sh) script can simply output the
results: (The Makefile contains the spoiler):
```sh
```<!---sh-->
out=cat ./check.sh ./prog
```
@@ -97,7 +97,7 @@ interface.
Included is a version without compilation warnings:
```sh
```<!---sh-->
cc -Wall -Wextra -Weverything -pedantic -include stdio.h -o prog.clean prog.clean.c
```
+9 -9
View File
@@ -141,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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
<p>For more detailed information see <a href="../../bugs.html#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>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog &lt; file
./cow file</code></pre>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>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
@@ -163,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>
<pre class="&lt;!---sh--&gt;"><code> WARN=&quot;-Wno-implicit-int -Wno-missing-variable-declarations -Wno-parentheses&quot;
cc -Wall -Wextra -Weverything -pedantic $WARN -include stdio.h -o prog prog.c</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> out=cat ./check.sh ./prog</code></pre>
<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
@@ -189,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>
<pre class="&lt;!---sh--&gt;"><code> cc -Wall -Wextra -Weverything -pedantic -include stdio.h -o prog.clean prog.clean.c</code></pre>
<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>
+6 -6
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -22,14 +22,14 @@ For more detailed information see [2019 ciura bugs](../../bugs.html#2019_ciura).
## To use:
```sh
```<!---sh-->
./getwords.sh en | grep .. | ./prog string
```
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -42,7 +42,7 @@ newline. See the Author's remarks for more information.
### Alternate build:
```sh
```<!---sh-->
make alt
```
@@ -54,7 +54,7 @@ Use `prog.alt` as you would `prog` above.
### Alternate try:
```sh
```<!---sh-->
./try.alt.sh
```
@@ -83,7 +83,7 @@ of the alphabet exactly once.
#### Example execution:
```sh
```<!---sh-->
$ grep .. /usr/share/dict/words | ./prog abcdefghijklmnopqrstuvwxyz
qualm fjord wiz pyx vs beg kc nth
quartz jinx vs fed kc womb glyph
+22 -22
View File
@@ -141,7 +141,7 @@ 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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<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>
@@ -149,18 +149,18 @@ below.</p>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./getwords.sh en | grep .. | ./prog string</code></pre>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<h2 id="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>
<pre class="&lt;!---sh--&gt;"><code> make alt</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./try.alt.sh</code></pre>
<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>
@@ -176,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>
<pre class="&lt;!---sh--&gt;"><code> $ 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</code></pre>
<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>)
+6 -6
View File
@@ -1,20 +1,20 @@
## To build:
```sh
```<!---sh-->
make
```
## To use:
```sh
```<!---sh-->
./prog < file > file.Z
```
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -37,19 +37,19 @@ compresses differently? The judges know. :)
#### Usage:
```sh
```<!---sh-->
./prog < input.txt > input.txt.Z
```
#### Example:
```sh
```<!---sh-->
./prog < guidelines.txt > guidelines.txt.Z
```
#### Check for correctness:
```sh
```<!---sh-->
zcat guidelines.txt.Z > guidelines2.txt
diff -s guidelines.txt guidelines2.txt
```
+7 -7
View File
@@ -141,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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<h2 id="to-use">To use:</h2>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> <span class="op">&lt;</span> file <span class="op">&gt;</span> file.Z</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./prog &lt; file &gt; file.Z</code></pre>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<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
@@ -157,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>
<pre class="&lt;!---sh--&gt;"><code> ./prog &lt; input.txt &gt; input.txt.Z</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog &lt; guidelines.txt &gt; guidelines.txt.Z</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> zcat guidelines.txt.Z &gt; guidelines2.txt
diff -s guidelines.txt guidelines2.txt</code></pre>
<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
+4 -4
View File
@@ -1,20 +1,20 @@
## To build:
```sh
```<!---sh-->
make
```
## To use:
```sh
```<!---sh-->
./prog
```
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -33,7 +33,7 @@ that you are dreaming? Or is it, wake up from the simulation?
This program prints its own SHA-512 hash. To verify, run:
```sh
```<!---sh-->
$ sha512sum prog.c; ./prog
43bd0c4381a5078d2850fca9ae5e0647596bcc03cd67d8d973ad02ff35c316c728e7b347ca70abe6c74e745e63646cc7643cb0cffcd3d9a969cbf31a7ce5bf68 prog.c
43bd0c4381a5078d2850fca9ae5e0647596bcc03cd67d8d973ad02ff35c316c728e7b347ca70abe6c74e745e63646cc7643cb0cffcd3d9a969cbf31a7ce5bf68
+6 -6
View File
@@ -141,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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<h2 id="to-use">To use:</h2>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./prog</code></pre>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<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
@@ -153,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>
<pre class="&lt;!---sh--&gt;"><code> $ sha512sum prog.c; ./prog
43bd0c4381a5078d2850fca9ae5e0647596bcc03cd67d8d973ad02ff35c316c728e7b347ca70abe6c74e745e63646cc7643cb0cffcd3d9a969cbf31a7ce5bf68 prog.c
43bd0c4381a5078d2850fca9ae5e0647596bcc03cd67d8d973ad02ff35c316c728e7b347ca70abe6c74e745e63646cc7643cb0cffcd3d9a969cbf31a7ce5bf68</code></pre>
<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
+5 -5
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -18,14 +18,14 @@ For more detailed information see [2019 dogon bugs](../../bugs.html#2019_dogon).
## To use:
```sh
```<!---sh-->
./prog < pattern.mc
```
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -247,13 +247,13 @@ 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 `8*8` leaf:
````c
```<!---`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); }
````
```<!---`-->
This uses only 19 bitwise operations and six shifts to calculate the inner 6x6
next generation bits of the input 8x8 !
+4 -8
View File
@@ -141,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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<pre><code> STATUS: 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>
<pre class="&lt;!---sh--&gt;"><code> ./prog &lt; pattern.mc</code></pre>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<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>
@@ -321,11 +321,7 @@ 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>
<p><code>&lt;!---`c--&gt; unsigned long life8x8(long a) { unsigned long aw = a &lt;&lt; 1, ae = a &gt;&gt; 1, s0 = aw ^ ae, s1 = aw &amp; ae, hs0 = s0 ^ a, hs1 = (s0 &amp; a) | s1, hs0w8 = hs0 &gt;&gt; 8, hs0e8 = hs0 &lt;&lt; 8, hs1w8 = hs1 &gt;&gt; 8, hs1e8 = hs1 &lt;&lt; 8, ts0 = hs0w8 ^ hs0e8, ts1 = (hs0w8 &amp; hs0e8) | (ts0 &amp; s0); return (hs1w8 ^ hs1e8 ^ ts1 ^ s1) &amp; ((hs1w8 | hs1e8) ^ (ts1 | s1)) &amp; ((ts0 ^ s0) | a); }</code><!---`--></p>
<p>This uses only 19 bitwise operations and six shifts to calculate the inner 6x6
next generation bits of the input 8x8 !</p>
<!--
+10 -10
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -21,20 +21,20 @@ For more detailed information see [2019 duble bugs](../../bugs.html#2019_duble).
## To use:
```sh
```<!---sh-->
./prog file
```
## Try:
```sh
```<!---sh-->
./prog /tmp/drawing
```
Open another window / terminal.
```sh
```<!---sh-->
./prog /tmp/drawing
```
@@ -42,13 +42,13 @@ Open more terminals and repeat...
You might also wish to try a full screen size. For this try:
```sh
```<!---sh-->
make clobber fullscreen
```
Alternatively, if you want to change the size, do something like:
```sh
```<!---sh-->
make clobber LINES=20 COLUMNS=20 all
```
@@ -69,7 +69,7 @@ the editor.
After editing the file and quitting, try:
```sh
```<!---sh-->
/tmp/drawing
```
@@ -97,7 +97,7 @@ alternate code might not work as well in macOS.
### Alternate build:
```sh
```<!---sh-->
make alt
```
@@ -132,7 +132,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
```<!---sh-->
./prog /tmp/drawing
```
@@ -216,7 +216,7 @@ Note: the drawing files `prog` generates are probably even more portable than
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
```<!---sh-->
make clobber fullscreen
```
+10 -10
View File
@@ -141,7 +141,7 @@ Location: <a href="../../location.html#FR">FR</a> - <em>French Republic</em> (<e
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<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>
@@ -149,16 +149,16 @@ See <a href="#alternate-code">Alternate code</a> below if you are curious.</p>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog file</code></pre>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> /tmp/drawing</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./prog /tmp/drawing</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog /tmp/drawing</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> make clobber fullscreen</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> make clobber LINES=20 COLUMNS=20 all</code></pre>
<p>The author provided us with the following table for use:</p>
<hr />
<ul>
@@ -173,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>
<pre class="&lt;!---sh--&gt;"><code> /tmp/drawing</code></pre>
<p>i.e. execute the file.</p>
<hr />
<p>WARNING: if the file is deleted it might lock any session still in use. These
@@ -188,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>
<pre class="&lt;!---sh--&gt;"><code> make alt</code></pre>
<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>
@@ -204,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>
<pre class="&lt;!---sh--&gt;"><code> ./prog /tmp/drawing</code></pre>
<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
@@ -264,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>
<pre class="&lt;!---sh--&gt;"><code> make clobber fullscreen</code></pre>
<p>IMPORTANT NOTES:</p>
<ul>
<li><strong>The program compiled with a given size will fail to reload a drawing file
+8 -8
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -21,7 +21,7 @@ For more detailed information see [2019 endoh bugs](../../bugs.html#2019_endoh).
## To use:
```sh
```<!---sh-->
./prog
```
@@ -30,7 +30,7 @@ For more detailed information see [2019 endoh bugs](../../bugs.html#2019_endoh).
If you have `gdb(1)` installed:
```sh
```<!---sh-->
./try.sh
```
@@ -40,7 +40,7 @@ only been tested with linux.
You might also wish to try:
```sh
```<!---sh-->
gdb ./prog || lldb ./prog
```
@@ -59,20 +59,20 @@ ascii` when debugging it to reveal its purpose.
Compile prog.c with no optimization.
```sh
```<!---sh-->
cc -g -O0 -o prog prog.c
```
Then, run it. You will see a segmentation fault.
```sh
```<!---sh-->
$ ./prog
Segmentation fault (core dumped)
```
Let's debug. As usual, run it under gdb.
```sh
```<!---sh-->
$ gdb ./prog
(gdb) run
Starting program: /home/.../prog
@@ -132,7 +132,7 @@ The original program can be used as a GDB command file.
By using this, you can confirm that it is actually a quine.
```sh
```<!---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
```
+15 -15
View File
@@ -141,7 +141,7 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<p>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>
@@ -149,32 +149,32 @@ this entry because it is SUPPOSED to crash and it needs debugging symbols.</p>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> gdb ./prog || lldb ./prog</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> cc -g -O0 -o prog prog.c</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> $ ./prog
Segmentation fault (core dumped)</code></pre>
<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>
<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>
<pre class="&lt;!---sh--&gt;"><code> $ gdb ./prog
(gdb) run
Starting program: /home/.../prog
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()</code></pre>
<p>Okay, check the backtrace.</p>
<pre><code> (gdb) backtrace
#0 0x0000000000000000 in ?? ()
@@ -212,8 +212,8 @@ only been tested with linux.</p>
#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>
<pre class="&lt;!---sh--&gt;"><code> gdb -q -x prog.c ./prog | sed -n -r &#39;s/#.*:([0-9]+)/\1/p&#39; | awk &#39;{printf &quot;%c&quot;,$1}&#39; &gt; prog2.c
diff prog.c prog2.c</code></pre>
<!--
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
+5 -5
View File
@@ -1,20 +1,20 @@
## To build:
```sh
```<!---sh-->
make
```
## To use:
```sh
```<!---sh-->
./prog infile.wav outfile.wav
```
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -62,7 +62,7 @@ Interesting fact: The size of the program from `./iocccsize -i` is 2019.
#### How to use:
```sh
```<!---sh-->
./prog input [output [size [dry [wet [damping]]]]]
prog.exe input [output [size [dry [wet [damping]]]]]
```
@@ -87,7 +87,7 @@ 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:
```sh
```<!---sh-->
./prog in.wav out.wav 1.8 80% 15%
```
+6 -6
View File
@@ -141,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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<h2 id="to-use">To use:</h2>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> infile.wav outfile.wav</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./prog infile.wav outfile.wav</code></pre>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<p>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>
@@ -175,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>
<pre class="&lt;!---sh--&gt;"><code> ./prog input [output [size [dry [wet [damping]]]]]
prog.exe input [output [size [dry [wet [damping]]]]]</code></pre>
<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>
@@ -196,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>
<pre class="&lt;!---sh--&gt;"><code> ./prog in.wav out.wav 1.8 80% 15%</code></pre>
<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
+8 -8
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -21,13 +21,13 @@ For more detailed information see [2019 karns bugs](../../bugs.html#2019_karns).
## To use:
```sh
```<!---sh-->
./prog < textfile_that_fits_on_the_screen
```
You might want to type:
```sh
```<!---sh-->
reset
```
@@ -36,13 +36,13 @@ after running the program to restore the terminal to its previous state.
## Try:
```sh
```<!---sh-->
./try.sh
```
If you have more time you might want to try:
```sh
```<!---sh-->
./prog < README.md
```
@@ -82,7 +82,7 @@ connected with anything.
This program usually compiles under both GCC and clang. Build with:
```sh
```<!---sh-->
$(CC) -std=c99 -o tbfs prog.c
```
@@ -90,13 +90,13 @@ where `$(CC)` is cc, gcc, clang, or some other C compiler.
You can then run it with:
```sh
```<!---sh-->
cat <input file> | ./tbfs
```
Examples:
```sh
```<!---sh-->
./tbfs < maze
./tbfs < prog.c
```
+9 -9
View File
@@ -141,7 +141,7 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<p>NOTE: we disable the optimiser because this program has problems with it
enabled.</p>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
@@ -149,14 +149,14 @@ enabled.</p>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog &lt; textfile_that_fits_on_the_screen</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> reset</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog &lt; README.md</code></pre>
<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
@@ -179,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>
<pre class="&lt;!---sh--&gt;"><code> $(CC) -std=c99 -o tbfs prog.c</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> cat &lt;input file&gt; | ./tbfs</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./tbfs &lt; maze
./tbfs &lt; prog.c</code></pre>
<h3 id="issues">Issues</h3>
<ul>
<li>The program must be ran in a terminal that supports ANSI escape codes for
+11 -11
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -18,14 +18,14 @@ For more detailed information see [2019 lynn bugs](../../bugs.html#2019_lynn).
## To use:
```sh
```<!---sh-->
./prog
```
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -62,7 +62,7 @@ typeclasses. Just pass dictionaries explicitly.
Build the compiler:
```sh
```<!---sh-->
cc -o prog prog.c
```
@@ -72,7 +72,7 @@ Build the compiler:
Test the compiler on [fib.hs](fib.hs):
```sh
```<!---sh-->
(./prog < fib.hs ; cat prog.c) > fib.c
```
@@ -81,7 +81,7 @@ Compiling the output produces a binary that prints the 30th Fibonacci number.
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
```<!---sh-->
ghc ghcfib.hs
```
@@ -93,7 +93,7 @@ instead provide [hint.hs](hint.hs), 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:
```sh
```<!---sh-->
(./prog < hint.hs ; cat prog.c) > hint.c
make hint
./hint
@@ -116,7 +116,7 @@ languages"](https://www.cs.dartmouth.edu/~doug/nfa.pdf). We exercise it by
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
```<!---sh-->
(./prog < lol.hs ; cat prog.c) > lol.c
make lol
./lol
@@ -124,7 +124,7 @@ of the characters `a` and `b` that contain an even number of `a`s.
A GHC wrapper is provided:
```sh
```<!---sh-->
ghc ghclol.hs
```
@@ -135,14 +135,14 @@ See [scc.hs](scc.hs) (and its GHC wrapper [ghcscc.hs](ghcscc.hs)) for an elegant
way to print the strongly-connected components of a graph in reverse topological
order.
```sh
```<!---sh-->
(./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
```<!---sh-->
make scc
./scc < example-1.txt
./scc < example-2.txt
+17 -17
View File
@@ -141,15 +141,15 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
<p>For more detailed information see <a href="../../bugs.html#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>
<pre class="&lt;!---sh--&gt;"><code> ./prog</code></pre>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>A fully functional compiler. The example prints out the 30th <a href="https://en.wikipedia.org/wiki/Fibonacci_sequence">Fibonacci
number</a>.</p>
@@ -171,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>
<pre class="&lt;!---sh--&gt;"><code> cc -o prog prog.c</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> (./prog &lt; fib.hs ; cat prog.c) &gt; fib.c</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ghc ghcfib.hs</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> (./prog &lt; hint.hs ; cat prog.c) &gt; hint.c
make hint
./hint</code></pre>
<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
@@ -200,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>
<pre class="&lt;!---sh--&gt;"><code> (./prog &lt; lol.hs ; cat prog.c) &gt; lol.c
make lol
./lol</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ghc ghclol.hs</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> (./prog &lt; scc.hs ; cat prog.c) &gt; scc.c</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> make scc
./scc &lt; example-1.txt
./scc &lt; example-2.txt</code></pre>
<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>
+22 -22
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -18,7 +18,7 @@ For more detailed information see [2019 mills bugs](../../bugs.html#2019_mills).
## To use:
```sh
```<!---sh-->
make cpclean
# Let this run for about about an hour and then kill it:
./prog Shakespeare.txt
@@ -27,7 +27,7 @@ For more detailed information see [2019 mills bugs](../../bugs.html#2019_mills).
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -92,19 +92,19 @@ OMLET has three operating modes:
For your first OMLET experiment, we will try training a simple single-level
RNN to write some [Shakespeare][5] plays. Start by typing
```sh
```<!---sh-->
make
```
After it builds, train it using
```sh
```<!---sh-->
./prog Shakespere.txt
```
This will immediately start outputting gibberish to the output, e.g.
```sh
```<!---sh-->
./prog Shakespere.txt
```
@@ -259,7 +259,7 @@ doing `Control-C`.
You can continue training from a previous checkpoint by providing the
checkpoint file name as the second parameter, for example:
```sh
```<!---sh-->
./prog Shakespeare.txt cp01_1.970
```
@@ -275,7 +275,7 @@ parameters to generate data. Inference mode takes the checkpoint file as
*standard input* (not on the command line) and hence must be run with a
command like
```sh
```<!---sh-->
./prog < cp55_1.807
```
@@ -294,7 +294,7 @@ The default network for OMLET (the one you get if you type `make` with the
executable name `prog`) is the simplest recurrent neural network. It looks
like
```c
```<!---c-->
h = tanh(Wxh * x + Whh * h' + Bh)
y = Why * h + By
```
@@ -317,26 +317,26 @@ 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
```sh
```<!---sh-->
make lin1
```
OMLET will create an [ADALINE][10] network that does
```c
```<!---c-->
y = Wxy * x + By
```
This is a simple [linear][11] [feed-forward network][12]. You can run it with
```sh
```<!---sh-->
./lin1 Shakespeare.txt
```
The linear network won't be able to get past the gibberish stage, because it
lacks history:
```sh
```<!---sh-->
./lin1 Shakespeare.txt
```
@@ -388,7 +388,7 @@ the language but `per` with the digit 1).
We can try to improve the RNN's performance by stacking RNN modules atop each
other:
```c
```<!---c-->
h1 = RNN(h1', x)
h2 = RNN(h2', h1)
y = Why * h2 + By
@@ -414,13 +414,13 @@ the hard limit with `limit -h stacksize` and set it with
You can try the deeper network by doing
```sh
```<!---sh-->
make rnn2
```
(or even `make rnn3` if you want a three-layer RNN) and train it with
```sh
```<!---sh-->
./rnn2 Shakespeare.txt
```
@@ -444,13 +444,13 @@ gradient, worsening the exploding and vanishing gradient problem.
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
```<!---sh-->
make lstm2
```
and train with it with
```sh
```<!---sh-->
./lstm2 Shakespeare.txt
```
@@ -464,7 +464,7 @@ its hidden state via "gates". These gates are called
The basic LSTM equations are
```c
```<!---c-->
f = sigmoid(Wxf * x + Whf * h' + Bf)
i = sigmoid(Wxi * x + Whi * h' + Bi)
o = sigmoid(Wxo * x + Who * h' + Bo)
@@ -496,7 +496,7 @@ 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
```sh
```<!---sh-->
make gru2
```
@@ -510,7 +510,7 @@ compiler's command-line by using `-D` directives. The network is defined by
a `-DNW='...'` command which consists of a series of comma-separated
assignments. For example, the simple one-layer RNN could be defined like
```make
```<!---make-->
-DNW=' x = I(n), hp = I(128), \
h = C(hp, T(A(L(128, x), L(128, hp)))), \
y = L(n, h)'
@@ -555,7 +555,7 @@ training mode, this is used to generate the loss which is backpropagated.
As an example of a more complicated network, we can look at a two-layer
GRU network:
```make
```<!---make-->
-DHS=128, \
-DNW=' x = I(n), \
y = L(n, MD(MD(x)))' \
+31 -31
View File
@@ -141,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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
<p>For more detailed information see <a href="../../bugs.html#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>
<pre class="&lt;!---sh--&gt;"><code> make cpclean
# Let this run for about about an hour and then kill it:
./prog Shakespeare.txt</code></pre>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<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>
@@ -200,11 +200,11 @@ 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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog Shakespere.txt</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog Shakespere.txt</code></pre>
<p>produces:</p>
<pre><code> sins ohennAu
T-teooclelp tiThoWy
@@ -331,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>
<pre class="&lt;!---sh--&gt;"><code> ./prog Shakespeare.txt cp01_1.970</code></pre>
<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
@@ -342,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>
<pre class="&lt;!---sh--&gt;"><code> ./prog &lt; cp55_1.807</code></pre>
<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
@@ -353,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>
<pre class="&lt;!---c--&gt;"><code> h = tanh(Wxh * x + Whh * h&#39; + Bh)
y = Why * h + By</code></pre>
<p>where</p>
<ul>
<li><code>x</code> is the <em>input vector</em></li>
@@ -371,14 +371,14 @@ 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>
<pre class="&lt;!---sh--&gt;"><code> make lin1</code></pre>
<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>
<pre class="&lt;!---c--&gt;"><code> y = Wxy * x + By</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./lin1 Shakespeare.txt</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./lin1 Shakespeare.txt</code></pre>
<p>produces:</p>
<pre><code> UERond w,
@@ -418,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>
<pre class="&lt;!---c--&gt;"><code> h1 = RNN(h1&#39;, x)
h2 = RNN(h2&#39;, h1)
y = Why * h2 + By</code></pre>
<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>
@@ -436,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>
<pre class="&lt;!---sh--&gt;"><code> make rnn2</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./rnn2 Shakespeare.txt</code></pre>
<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
@@ -454,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>
<pre class="&lt;!---sh--&gt;"><code> make lstm2</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./lstm2 Shakespeare.txt</code></pre>
<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>
@@ -466,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>
<pre class="&lt;!---c--&gt;"><code> f = sigmoid(Wxf * x + Whf * h&#39; + Bf)
i = sigmoid(Wxi * x + Whi * h&#39; + Bi)
o = sigmoid(Wxo * x + Who * h&#39; + Bo)
c = f * c&#39; + i * tanh(Wxc * x + Whc * h&#39; + Bc)
h = o * tanh(c)</code></pre>
<p>Where</p>
<ul>
<li><code>x</code> is the input vector</li>
@@ -494,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>
<pre class="&lt;!---sh--&gt;"><code> make gru2</code></pre>
<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
@@ -503,7 +503,7 @@ 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), \
<pre class="&lt;!---make--&gt;"><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
@@ -538,7 +538,7 @@ 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, \
<pre class="&lt;!---make--&gt;"><code> -DHS=128, \
-DNW=&#39; x = I(n), \
y = L(n, MD(MD(x)))&#39; \
-DBK=&#39; hp = I(HS), \
+10 -10
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -26,7 +26,7 @@ For more detailed information see [2019 poikola bugs](../../bugs.html#2019_poiko
## To use:
```sh
```<!---sh-->
./prog 512 ./prog
sleep 86400; make clobber prog
@@ -38,7 +38,7 @@ For more detailed information see [2019 poikola bugs](../../bugs.html#2019_poiko
If you wish for some documentation:
```sh
```<!---sh-->
make docs
```
@@ -49,7 +49,7 @@ This will create the file `poikola.pdf` for your enjoyment.
If you don't have a few days, try:
```sh
```<!---sh-->
./try.sh
```
@@ -65,7 +65,7 @@ what can be done with the original entry.
### Alternate build:
```sh
```<!---sh-->
make alt
```
@@ -77,7 +77,7 @@ Use `prog.alt` as you would `prog` above.
### Alternate try:
```sh
```<!---sh-->
./try.alt.sh
```
@@ -103,19 +103,19 @@ Nyk&auml;nen](https://en.wikipedia.org/wiki/Matti_Nyk%C3%A4nen).
### How to build:
```sh
```<!---sh-->
gcc -O0 -o prog prog.c
```
or
```sh
```<!---sh-->
clang -O[0123s] -o prog prog.c
```
e.g.:
```sh
```<!---sh-->
clang -O1 -o prog prog.c
```
@@ -166,7 +166,7 @@ unnecessary checks, but either fails or gets stuck if invoked erroneously. The
program is invoked in this way:
```sh
```<!---sh-->
./prog <integer> <file>
```
+16 -16
View File
@@ -141,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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<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
@@ -153,30 +153,30 @@ forcing <code>-std=gnu11</code>.</p>
<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>
<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-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>
<pre class="&lt;!---sh--&gt;"><code> ./prog 512 ./prog
sleep 86400; make clobber prog
./prog 512 ./prog
sleep 86400; make clobber prog
./prog 512 ./prog</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> make docs</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> make alt</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./try.alt.sh</code></pre>
<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>
@@ -191,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>
<pre class="&lt;!---sh--&gt;"><code> gcc -O0 -o prog prog.c</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> clang -O[0123s] -o prog prog.c</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> clang -O1 -o prog prog.c</code></pre>
<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
@@ -231,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>
<pre class="&lt;!---sh--&gt;"><code> ./prog &lt;integer&gt; &lt;file&gt;</code></pre>
<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
+15 -15
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -18,7 +18,7 @@ For more detailed information see [2019 yang bugs](../../bugs.html#2019_yang).
## To use:
```sh
```<!---sh-->
./prog sample_input.txt a b c d
cat a
@@ -35,7 +35,7 @@ For more detailed information see [2019 yang bugs](../../bugs.html#2019_yang).
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -52,7 +52,7 @@ output again.
Scramble/unscramble to single file:
```sh
```<!---sh-->
./prog original.txt > scrambled.txt
./prog < scrambled.txt > unscrambled.txt
@@ -60,7 +60,7 @@ Scramble/unscramble to single file:
Scramble/unscramble to multiple files:
```sh
```<!---sh-->
./prog input.txt output1.txt output2.txt ...
cat output1.txt output2.txt ... | ./prog > unscrambled.txt
@@ -68,7 +68,7 @@ Scramble/unscramble to multiple files:
Re-scramble:
```sh
```<!---sh-->
./prog original.txt | ./prog - > scrambled1.txt
./prog original.txt | ./prog - | ./prog - > scrambled2.txt
./prog original.txt | ./prog - | ./prog - | ... > scrambled3.txt
@@ -76,7 +76,7 @@ Re-scramble:
Scramble slowly:
```sh
```<!---sh-->
./prog input.txt | ruby prog.c
```
@@ -87,14 +87,14 @@ Input must be in UTF-8 encoding.
This is a text scrambling utility. To scramble text, specify input file name as
the first argument:
```sh
```<!---sh-->
./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
```<!---sh-->
cat output.txt
```
@@ -106,7 +106,7 @@ 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:
```sh
```<!---sh-->
./prog input.txt | ruby prog.c
```
@@ -114,14 +114,14 @@ Scrambling order is deterministic, but you can reshuffle the output by
piping it through the same utility again, by specifying `-` as the
first argument:
```sh
```<!---sh-->
./prog input.txt | ./prog - | ./prog - | ...
```
You can also split the input to multiple files, each getting a subset
of the original input characters:
```sh
```<!---sh-->
./prog input.txt output1.txt output2.txt ...
cat output1.txt output2.txt ... > unscrambled.txt
```
@@ -138,7 +138,7 @@ positions to be misaligned. But fear not, this utility also includes
unscrambling functionality. If no argument is specified, input will
be read through `stdin` and unscrambled to `stdout`:
```sh
```<!---sh-->
./prog < scrambled.txt > unscrambled.txt
```
@@ -146,7 +146,7 @@ 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.
```sh
```<!---sh-->
./prog input.txt output1.txt output2.txt output3.txt
./prog < output1.txt > layer1.txt
./prog < output2.txt > layer2.txt
@@ -159,7 +159,7 @@ In other words, this is a utility for facilitating
This utility can also be used just for removing trailing whitespaces
and expanding tabs to 8 spaces.
```sh
```<!---sh-->
./prog input.txt | ./prog
```
+35 -35
View File
@@ -141,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>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
<p>For more detailed information see <a href="../../bugs.html#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>
<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-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-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-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-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>
<pre class="&lt;!---sh--&gt;"><code> ./prog sample_input.txt a b c d
cat a
cat b
cat c
cat d
cat a b c d | ./prog</code></pre>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>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>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog original.txt &gt; scrambled.txt
./prog &lt; scrambled.txt &gt; unscrambled.txt</code></pre>
<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>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog input.txt output1.txt output2.txt ...
cat output1.txt output2.txt ... | ./prog &gt; unscrambled.txt</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog original.txt | ./prog - &gt; scrambled1.txt
./prog original.txt | ./prog - | ./prog - &gt; scrambled2.txt
./prog original.txt | ./prog - | ./prog - | ... &gt; scrambled3.txt</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog input.txt | ruby prog.c</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog input.txt &gt; output.txt</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> cat output.txt</code></pre>
<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
@@ -194,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>
<pre class="&lt;!---sh--&gt;"><code> ./prog input.txt | ruby prog.c</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog input.txt | ./prog - | ./prog - | ...</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog input.txt output1.txt output2.txt ...
cat output1.txt output2.txt ... &gt; unscrambled.txt</code></pre>
<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
@@ -213,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>
<pre class="&lt;!---sh--&gt;"><code> ./prog &lt; scrambled.txt &gt; unscrambled.txt</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog input.txt output1.txt output2.txt output3.txt
./prog &lt; output1.txt &gt; layer1.txt
./prog &lt; output2.txt &gt; layer2.txt
./prog &lt; output3.txt &gt; layer3.txt</code></pre>
<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>
<pre class="&lt;!---sh--&gt;"><code> ./prog input.txt | ./prog</code></pre>
<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