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

+2 -2
View File
@@ -43,13 +43,13 @@ had to print a value 2053 or less when the `-i` flag was used.
Several people discovered an undocumented feature in that
certain comments such as:
```c
```<!---c-->
///*
```
or:
```c
```<!---c-->
*\
/
```
+11 -11
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make alt
```
@@ -11,7 +11,7 @@ version see the [original code](#original-code) section below.
## To use:
```sh
```<!---sh-->
./birken.alt < 17_columns_wide_paint_by_numbers_file
```
@@ -30,7 +30,7 @@ it should you wish (see below).
To see the program run on each text file, try:
```sh
```<!---sh-->
./try.alt.sh
```
@@ -44,7 +44,7 @@ other entries where this was made an alternate version it is configurable at
compile time. If you wish to speed it up by 100% you can instead do:
```sh
```<!---sh-->
make clobber SLEEP=7500 alt
```
@@ -55,7 +55,7 @@ If you wish to speed that up 200% (300% total) you can use instead try
ctrl-c to terminate the program early but note that the terminal is likely to be
messed up. In that case try:
```sh
```<!---sh-->
reset
```
@@ -70,7 +70,7 @@ hard to see the art of the entry but you may do so if you wish.
### Original build:
```sh
```<!---sh-->
make all
```
@@ -84,7 +84,7 @@ Use `birken` as you would `birken.alt` above.
To use the demo script with the original code, try:
```sh
```<!---sh-->
./try.sh
```
@@ -96,7 +96,7 @@ PLEASE be careful if you are sensitive to flashing colours!
This program also wins the "Most amusing abuse of the iocccsize tool" award;
although not the absolute best: it is possible to achieve 0 by writing:
```c
```<!---c-->
/* *\
/....
```
@@ -319,7 +319,7 @@ This program demonstrates how to exploit a bug in IOCCC size tool version
If that line is added to the top of any program, the tool will report a size of 8.
```sh
```<!---sh-->
$ ./iocccsize -i < prog.c
8
```
@@ -327,7 +327,7 @@ If that line is added to the top of any program, the tool will report a size of
When that line is deleted from this program, the tool properly reports the
secondary size limit of the program as 2048.
```sh
```<!---sh-->
$ ./iocccsize -i < birken.c
2048
```
@@ -357,7 +357,7 @@ Carefully selected variable names also yielded wonderful expressions like `l=0`,
`O=0`, `O=1` and `while(O)`. `"Tetris"` also makes a second appearance of
sorts:
```c
```<!---c-->
[T][e][t]--; while(R+i) { s
```
+14 -14
View File
@@ -141,12 +141,12 @@ 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> alt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make alt</code></pre>
<p>We recommend that you use the alt version first to see what this entry looked
like back in 2013 (with a configurable speed). If you wish to use the original
version see the <a href="#original-code">original code</a> section below.</p>
<h2 id="to-use">To use:</h2>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./birken.alt</span> <span class="op">&lt;</span> 17_columns_wide_paint_by_numbers_file</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./birken.alt &lt; 17_columns_wide_paint_by_numbers_file</code></pre>
<p>NOTE: if your terminal is messed up after running this (perhaps from exiting
before it finishes) try using <code>reset</code> to restore the terminal. This will clear
the screen.</p>
@@ -157,7 +157,7 @@ be problematic for some people, can be configured to different speeds by way of
the value used in <code>usleep(3)</code>. The default is <code>13500</code> but you can reconfigure
it should you wish (see below).</p>
<p>To see the program run on each text file, try:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.alt.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.alt.sh</code></pre>
<p>If you have perl installed it will also try a random run.</p>
<p>Finding the ‘right’ default value was a fine line; the default, 15000
microseconds (0.015 seconds), will take quite a while to finish but it allows
@@ -165,30 +165,30 @@ one to more easily see what is going on. Even easier to see would be 25000 but
these values make it quite slow and one could easily lose interest. Like some
other entries where this was made an alternate version it is configurable at
compile time. If you wish to speed it up by 100% you can instead do:</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> clobber SLEEP=7500 alt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make clobber SLEEP=7500 alt</code></pre>
<p>and then try <code>birken.alt</code> as above.</p>
<p>If you wish to speed that up 200% (300% total) you can use instead try
<code>SLEEP=3750</code>. Doing this you might find the right value to your liking; use
ctrl-c to terminate the program early but note that the terminal is likely to be
messed up. In that case 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">reset</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> reset</code></pre>
<p>to make it sane again (running to completion will do that for you).</p>
<h2 id="original-code">Original code:</h2>
<p>The original code will run faster with modern systems which is likely to make it
hard to see the art of the entry but you may do so if you wish.</p>
<h3 id="original-build">Original 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> all</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make all</code></pre>
<h3 id="original-use">Original use:</h3>
<p>Use <code>birken</code> as you would <code>birken.alt</code> above.</p>
<h3 id="original-try">Original try:</h3>
<p>To use the demo script with the original code, try:</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">./try.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<p>PLEASE be careful if you are sensitive to flashing colours!</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>This program also wins the “Most amusing abuse of the iocccsize tool” award;
although not the absolute best: it is possible to achieve 0 by writing:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="co">/* *\</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="co"> /....</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> /* *\
/....</code></pre>
<p>The game of Tetris had been used in many endeavors, from studying <a href="http://arxiv.org/abs/cs/0210020">algorithmic
complexity</a> to <a href="http://www.livescience.com/19894-tetris-treat-ptsd-flashbacks.html">treating
PTSD</a> and
@@ -346,12 +346,12 @@ call to <code>fflush(3)</code> (N.B: see <a href="birken.alt.c">birken.alt.c</a>
<code>2013-07-30-v17</code>. The first line of the program is reproduced below.</p>
<p>char<em>_ = “’”“/</em>”;</p>
<p>If that line is added to the top of any program, the tool will report a size of 8.</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">$</span> ./iocccsize <span class="at">-i</span> <span class="op">&lt;</span> prog.c</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">8</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> $ ./iocccsize -i &lt; prog.c
8</code></pre>
<p>When that line is deleted from this program, the tool properly reports the
secondary size limit of the program as 2048.</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">$</span> ./iocccsize <span class="at">-i</span> <span class="op">&lt;</span> birken.c</span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">2048</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> $ ./iocccsize -i &lt; birken.c
2048</code></pre>
<p>Although this bug provides an easy means of circumventing contest rule 2, as
demonstrated from the size value, this entry is not necessarily striving for a
‘worst abuse of the rules’ award.</p>
@@ -371,7 +371,7 @@ Pajitnov</a>’s original 1984
<p>Carefully selected variable names also yielded wonderful expressions like <code>l=0</code>,
<code>O=0</code>, <code>O=1</code> and <code>while(O)</code>. <code>"Tetris"</code> also makes a second appearance of
sorts:</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="op">[</span>T<span class="op">][</span>e<span class="op">][</span>t<span class="op">]--;</span> <span class="cf">while</span><span class="op">(</span>R<span class="op">+</span>i<span class="op">)</span> <span class="op">{</span> s</span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> [T][e][t]--; while(R+i) { s</code></pre>
<p>The source is formatted to resemble the
<a href="https://en.wikipedia.org/wiki/Tetris">Tetris</a> play-field mid-game. It is also
an homage to all the <a href="../../years.html">past IOCCC entries</a> formatted as a compact
+9 -9
View File
@@ -1,20 +1,20 @@
## To build:
```sh
```<!---sh-->
make
```
## To use:
```sh
```<!---sh-->
./cable1 name group1 group2
```
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -26,39 +26,39 @@ We need not limit ourselves to the two major political parties in the US today.
Let us consider:
```sh
```<!---sh-->
./cable1 Cooper Mac PC
```
Simon works for Apple, so you would expect Mac. :-)
Landon is a long time Mac user:
```sh
```<!---sh-->
./cable1 Noll Mac PC
```
That works too! Now Leo brings PCs to the IOCCC judging for cross-platform
testing:
```sh
```<!---sh-->
./cable1 Broukhis Mac PC
```
We can test other people. The late Steve Jobs:
```sh
```<!---sh-->
./cable1 Jobs Mac PC
```
That works! How about Bill?
```sh
```<!---sh-->
./cable1 Gates Mac PC
```
A PC guy as expected. What about that other Steve?
```sh
```<!---sh-->
./cable1 Ballmer Mac PC
```
+9 -9
View File
@@ -141,28 +141,28 @@ 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>
<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">./cable1</span> name group1 group2</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./cable1 name group1 group2</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>Partisan may be defined as a strong supporter of a cause, party or person.
We need not limit ourselves to the two major political parties in the US today.</p>
<p>Let us consider:</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">./cable1</span> Cooper Mac PC</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./cable1 Cooper Mac PC</code></pre>
<p>Simon works for Apple, so you would expect Mac. :-)
Landon is a long time Mac user:</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">./cable1</span> Noll Mac PC</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./cable1 Noll Mac PC</code></pre>
<p>That works too! Now Leo brings PCs to the IOCCC judging for cross-platform
testing:</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">./cable1</span> Broukhis Mac PC</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./cable1 Broukhis Mac PC</code></pre>
<p>We can test other people. The late Steve Jobs:</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">./cable1</span> Jobs Mac PC</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./cable1 Jobs Mac PC</code></pre>
<p>That works! How about Bill?</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">./cable1</span> Gates Mac PC</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./cable1 Gates Mac PC</code></pre>
<p>A PC guy as expected. What about that other Steve?</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">./cable1</span> Ballmer Mac PC</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./cable1 Ballmer Mac PC</code></pre>
<p>Humm .. maybe there is a hidden reason he is leaving the late Micro$oft? :-)
Why late? Because:</p>
<figure>
+3 -3
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -18,7 +18,7 @@ For more detailed information see [2013 cable2 bugs](../../bugs.html#2013_cable2
## To use:
```sh
```<!---sh-->
./cable2 file.bmp [color]
```
@@ -27,7 +27,7 @@ For more detailed information see [2013 cable2 bugs](../../bugs.html#2013_cable2
For different OCR examples:
```sh
```<!---sh-->
./try.sh
```
+3 -3
View File
@@ -141,16 +141,16 @@ 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#2013_cable2">2013 cable2 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">./cable2</span> file.bmp <span class="pp">[</span><span class="ss">color</span><span class="pp">]</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./cable2 file.bmp [color]</code></pre>
<h2 id="try">Try:</h2>
<p>For different OCR examples:</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>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>We can confirm that this is the first time the IOCCC has been used
to peer-review a new research. We had quite a bit of fun with a sharpie and a
+10 -10
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -10,14 +10,14 @@ available. See the [Alternate code](#alternate-code) section below.
## To use:
```sh
```<!---sh-->
./cable3 bios-image-file floppy-image-file [harddisk-image-file]
```
## Try:
```sh
```<!---sh-->
./cable3.sh
```
@@ -46,7 +46,7 @@ An alternate version, which should compile in Windows, is provided.
Assuming `make` is available and will function:
```sh
```<!---sh-->
make alt
```
@@ -173,7 +173,7 @@ non-UNIX platforms. For example, for Windows/MS Visual Studio, instead of the
Makefile definition of KB, use something slightly different - add the following
entry to the Preprocessor Definitions list in the Project Properties page:
```c
```<!---c-->
KB=(kb=H(8),kbhit())&&(r[1190]=getch(),H(7))
```
@@ -189,7 +189,7 @@ offsets) this is not the case, and to run successfully on these systems, you
will need to explicitly declare these functions by adding the appropriate
include to the top of the source:
```c
```<!---c-->
#include <unistd.h>
```
@@ -197,7 +197,7 @@ NOTE: this has been done in [cable3.c](cable3.c).
### Usage
```sh
```<!---sh-->
./cable3 bios-image-file floppy-image-file [harddisk-image-file]
```
@@ -205,7 +205,7 @@ PLEASE NOTE that under Unices the keyboard must be in raw mode for the emulator
to work properly. Therefore the emulator is best run from a shell script that
looks something like:
```sh
```<!---sh-->
stty cbreak raw -echo min 0
./cable3 bios floppy.img harddisk.img
stty cooked echo
@@ -223,7 +223,7 @@ put the keyboard into raw mode (and afterwards it needs to be put back to
cooked). So, run the emulator using something like this script (provided as
[cable3.sh](cable3.sh)):
```sh
```<!---sh-->
stty cbreak raw -echo min 0
./cable3 bios fd.img
stty cooked echo
@@ -237,7 +237,7 @@ whole bunch of software which is in the included file `hd.img`.
For the more adventurous, you can start off with (for example) a blank 40MB
image file called hd.img made using e.g. Makefile. Then use:
```sh
```<!---sh-->
stty cbreak raw -echo min 0
./cable3 bios fd.img hd.img
stty cooked echo
+16 -16
View File
@@ -141,13 +141,13 @@ 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>An alternate version that should compile in Windows/MS Visual Studio is
available. See the <a href="#alternate-code">Alternate code</a> section below.</p>
<h2 id="to-use">To use:</h2>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cable3</span> bios-image-file floppy-image-file <span class="pp">[</span><span class="ss">harddisk</span><span class="pp">-</span><span class="ss">image</span><span class="pp">-</span><span class="ss">file</span><span class="pp">]</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./cable3 bios-image-file floppy-image-file [harddisk-image-file]</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">./cable3.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./cable3.sh</code></pre>
<p>NOTE: to quit the program type <code>QUITEMU</code>. You might have to be at the top level
directory of the drive, <code>A:</code> or <code>C:</code>.</p>
<p>To send an <code>Alt+XXX</code> key combination, press (<code>^A</code> / <code>Ctrl+A</code>) then the key, so
@@ -162,7 +162,7 @@ combinations are left for the discovery of the user.</p>
<p>An alternate version, which should compile in Windows, is provided.</p>
<h3 id="alternate-build">Alternate build:</h3>
<p>Assuming <code>make</code> is available and will function:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make alt</code></pre>
<h3 id="alternate-use">Alternate use:</h3>
<p>Use <code>cable3.alt</code> as you would <code>cable3</code> above.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
@@ -264,7 +264,7 @@ has no <code>stty</code>. Therefore the Makefile includes a <code>-D</code> opti
non-UNIX platforms. For example, for Windows/MS Visual Studio, instead of the
Makefile definition of KB, use something slightly different - add the following
entry to the Preprocessor Definitions list in the Project Properties page:</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> KB<span class="op">=(</span>kb<span class="op">=</span>H<span class="op">(</span><span class="dv">8</span><span class="op">),</span>kbhit<span class="op">())&amp;&amp;(</span>r<span class="op">[</span><span class="dv">1190</span><span class="op">]=</span>getch<span class="op">(),</span>H<span class="op">(</span><span class="dv">7</span><span class="op">))</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> KB=(kb=H(8),kbhit())&amp;&amp;(r[1190]=getch(),H(7))</code></pre>
<p>NOTE: this is done in the <a href="#alternate-code">Alternate code</a>.</p>
<h3 id="posix-portability-note">POSIX portability note</h3>
<p>The code as supplied uses implicit function declarations for POSIX file I/O and
@@ -273,16 +273,16 @@ architecture. For some systems (e.g. 32-bit Mac OS X, which uses 64-bit file
offsets) this is not the case, and to run successfully on these systems, you
will need to explicitly declare these functions by adding the appropriate
include to the top of the source:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="pp">#include </span><span class="im">&lt;unistd.h&gt;</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> #include &lt;unistd.h&gt;</code></pre>
<p>NOTE: this has been done in <a href="cable3.c">cable3.c</a>.</p>
<h3 id="usage">Usage</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">./cable3</span> bios-image-file floppy-image-file <span class="pp">[</span><span class="ss">harddisk</span><span class="pp">-</span><span class="ss">image</span><span class="pp">-</span><span class="ss">file</span><span class="pp">]</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./cable3 bios-image-file floppy-image-file [harddisk-image-file]</code></pre>
<p>PLEASE NOTE that under Unices the keyboard must be in raw mode for the emulator
to work properly. Therefore the emulator is best run from a shell script that
looks something like:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">stty</span> cbreak raw <span class="at">-echo</span> min 0</span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cable3</span> bios floppy.img harddisk.img</span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">stty</span> cooked echo</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> stty cbreak raw -echo min 0
./cable3 bios floppy.img harddisk.img
stty cooked echo</code></pre>
<p>See the <a href="cable3.sh">cable3.sh</a> script.</p>
<h2 id="to-use-the-emulator---floppy-mode-only">To use the emulator - floppy mode only</h2>
<p>The simplest use of the emulator is with a single floppy boot disk image, like
@@ -291,17 +291,17 @@ the <code>fd.img</code> provided, which is a FreeDOS boot disk.</p>
put the keyboard into raw mode (and afterwards it needs to be put back to
cooked). So, run the emulator using something like this script (provided as
<a href="cable3.sh">cable3.sh</a>):</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">stty</span> cbreak raw <span class="at">-echo</span> min 0</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cable3</span> bios fd.img</span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">stty</span> cooked echo</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> stty cbreak raw -echo min 0
./cable3 bios fd.img
stty cooked echo</code></pre>
<h2 id="to-use-the-emulator---floppy-hd-mode">To use the emulator - floppy + HD mode</h2>
<p>Easiest to start with is to try a ready-made 40MB hard disk image containing a
whole bunch of software which is in the included file <code>hd.img</code>.</p>
<p>For the more adventurous, you can start off with (for example) a blank 40MB
image file called hd.img made using e.g. Makefile. Then use:</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">stty</span> cbreak raw <span class="at">-echo</span> min 0</span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cable3</span> bios fd.img hd.img</span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">stty</span> cooked echo</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> stty cbreak raw -echo min 0
./cable3 bios fd.img hd.img
stty cooked echo</code></pre>
<p>Preparing the hard disk for use in the emulator is done just like a real PC.
Boot the emulator, and use <code>FDISK</code> to partition the hard disk. When it’s done
<code>FDISK</code> will reboot the emulator. Then you can use <code>FORMAT C:</code> and you are done. The
+9 -9
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -18,7 +18,7 @@ For more detailed information see [2013 dlowe bugs](../../bugs.html#2013_dlowe).
## To use:
```sh
```<!---sh-->
./dlowe [number...]
```
@@ -27,13 +27,13 @@ where `[number...]` is one or more number, space separated.
## Try:
```sh
```<!---sh-->
./try.sh
```
What is different about the above if you do something like:
```sh
```<!---sh-->
echo 'IOCCC winning entry 2013/dlowe' > ioccc.txt
./try.sh
rm -f ioccc.txt
@@ -43,7 +43,7 @@ What is different about the above if you do something like:
To make it simpler to see try showing just the different line like:
```sh
```<!---sh-->
./diff.sh
```
@@ -58,7 +58,7 @@ with one argument or when all arguments are equal?
For extra fun, compile and run [fun.c](fun.c):
```c
```<!---c-->
#include <stdio.h>
int main() {
printf("%d %d %d\n", (int)(-1.0/0.0), (int)(0.0/0.0), (int)(1.0/0.0));
@@ -91,7 +91,7 @@ Which one is correct? :)
NOTE: `make all` will compile [fun.c](fun.c) but to provide a different compiler
you can do something like:
```sh
```<!---sh-->
make CC=clang fun
```
@@ -105,7 +105,7 @@ A tiny implementation of command-line
### Synopsis
```sh
```<!---sh-->
$ ./sparkl 0 1 2 3 4 5 6 7
▁▂▃▄▅▆▇▉
@@ -115,7 +115,7 @@ A tiny implementation of command-line
NOTE: this has been provided in [slflen.sh](slflen.sh) so you can try:
```sh
```<!---sh-->
./slflen.sh
```
+18 -18
View File
@@ -141,33 +141,33 @@ 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#2013_dlowe">2013 dlowe bugs</a>.</p>
<h2 id="to-use">To use:</h2>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./dlowe</span> <span class="pp">[</span><span class="ss">number...</span><span class="pp">]</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./dlowe [number...]</code></pre>
<p>where <code>[number...]</code> is one or more number, space separated.</p>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<p>What is different about the above if you do something like:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> <span class="st">&#39;IOCCC winning entry 2013/dlowe&#39;</span> <span class="op">&gt;</span> ioccc.txt</span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">rm</span> <span class="at">-f</span> ioccc.txt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> echo &#39;IOCCC winning entry 2013/dlowe&#39; &gt; ioccc.txt
./try.sh
rm -f ioccc.txt</code></pre>
<p>?</p>
<p>To make it simpler to see try showing just the different line like:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./diff.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./diff.sh</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>We liked how this entry used Unicode, specifically UTF-8, in a somewhat
obfuscated way.</p>
<p>Also, why doesn’t it crash but instead produces a correct output when called
with one argument or when all arguments are equal?</p>
<p>For extra fun, compile and run <a href="fun.c">fun.c</a>:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="pp">#include </span><span class="im">&lt;stdio.h&gt;</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span> main<span class="op">()</span> <span class="op">{</span></span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> printf<span class="op">(</span><span class="st">&quot;</span><span class="sc">%d</span><span class="st"> </span><span class="sc">%d</span><span class="st"> </span><span class="sc">%d\n</span><span class="st">&quot;</span><span class="op">,</span> <span class="op">(</span><span class="dt">int</span><span class="op">)(-</span><span class="fl">1.0</span><span class="op">/</span><span class="fl">0.0</span><span class="op">),</span> <span class="op">(</span><span class="dt">int</span><span class="op">)(</span><span class="fl">0.0</span><span class="op">/</span><span class="fl">0.0</span><span class="op">),</span> <span class="op">(</span><span class="dt">int</span><span class="op">)(</span><span class="fl">1.0</span><span class="op">/</span><span class="fl">0.0</span><span class="op">));</span></span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> #include &lt;stdio.h&gt;
int main() {
printf(&quot;%d %d %d\n&quot;, (int)(-1.0/0.0), (int)(0.0/0.0), (int)(1.0/0.0));
}</code></pre>
<p>with gcc and clang.</p>
<p>With GCC (4.7.2), we get</p>
<pre><code> -2147483648 -2147483648 -2147483648</code></pre>
@@ -178,19 +178,19 @@ with one argument or when all arguments are equal?</p>
<p>Which one is correct? :)</p>
<p>NOTE: <code>make all</code> will compile <a href="fun.c">fun.c</a> but to provide a different compiler
you can do something like:</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> CC=clang fun</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make CC=clang fun</code></pre>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="sparkl">sparkl</h3>
<p>A tiny implementation of command-line
<a href="https://en.wikipedia.org/wiki/Sparkline">sparkline</a> data visualization.</p>
<h3 id="synopsis">Synopsis</h3>
<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">$</span> ./sparkl 0 1 2 3 4 5 6 7</span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">▁▂▃▄▅▆▇▉</span></span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo <span class="st">&quot;sparkline of file lengths: </span><span class="va">$(</span><span class="fu">wc</span> <span class="at">-c</span> <span class="pp">*</span> <span class="kw">|</span> <span class="fu">awk</span> <span class="st">&#39;{print $1}&#39;</span> <span class="kw">|</span> <span class="fu">xargs</span> ./sparkl<span class="va">)</span><span class="st">&quot;</span></span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">sparkline</span> of file sizes: ▁▁▁▃▃▂▁▂▁▁▉</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> $ ./sparkl 0 1 2 3 4 5 6 7
▁▂▃▄▅▆▇▉
$ echo &quot;sparkline of file lengths: $(wc -c * | awk &#39;{print $1}&#39; | xargs ./sparkl)&quot;
sparkline of file sizes: ▁▁▁▃▃▂▁▂▁▁▉</code></pre>
<p>NOTE: this has been provided in <a href="slflen.sh">slflen.sh</a> so you can try:</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./slflen.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./slflen.sh</code></pre>
<p>instead (which <a href="try.sh">try.sh</a> also uses).</p>
<h3 id="description">Description</h3>
<p>This is a handy little tool for visualizing numeric series from the
+11 -11
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -18,20 +18,20 @@ For more detailed information see [2013 endoh1 bugs](../../bugs.html#2013_endoh1
## To use:
```sh
```<!---sh-->
./endoh1 [file.lazy]
```
## Try:
```sh
```<!---sh-->
./try.sh
```
You might also enjoy running:
```sh
```<!---sh-->
cc -E endoh1.c | less
```
@@ -50,7 +50,7 @@ This entry can be considered an abuse of the GCC's optimizer; it takes GCC about
### Remarks
```sh
```<!---sh-->
less endoh1.c
gcc -o endoh1 endoh1.c
./endoh1
@@ -66,7 +66,7 @@ especially, [Lazy K][2].
This program will shine when it is used as a library. For example,
[hello.lazy](hello.lazy) is a "Hello world" program written in Lazy K.
```sh
```<!---sh-->
$ lazy hello.lazy
Hello, world!
```
@@ -75,7 +75,7 @@ where `lazy` is [a reference implementation of Lazy K][3]. At the same time,
[hello.lazy](hello.lazy) is *a valid C program* that uses [endoh1.c](endoh1.c)
as a library.
```sh
```<!---sh-->
$ gcc -o hello -xc hello.lazy
$ ./hello
Hello, world!
@@ -136,7 +136,7 @@ I confirmed that the program successfully worked with the following compilers:
Recent compilers with `-Wall -W -Wextra -pedantic` say nothing.
```sh
```<!---sh-->
gcc -Wall -W -Wextra -pedantic prog.c
clang -Wall -W -Wextra -pedantic prog.c
tcc -Wall -W -Wextra -pedantic prog.c
@@ -173,7 +173,7 @@ combinator calculus. The rewriting rules are shown in the shape of the code.
Consider a sequence of function applications in C:
```c
```<!---c-->
s(x)(x)(x)(x)...
```
@@ -182,7 +182,7 @@ type", such as `typedef f (*f)();`.
So, I used a heavily nested function pointer type:
```c
```<!---c-->
typedef void *(*(*(*...(*(f))()...)())())
```
@@ -207,7 +207,7 @@ However, no type in C is callable and has a reference at the same time.
So, I addressed this issue by generating many function definitions
statically by (ab)using macros:
```c
```<!---c-->
void *x1; void f1(void *y) { return apply(x1, y); }
void *x2; void f2(void *y) { return apply(x2, y); }
void *x3; void f3(void *y) { return apply(x3, y); }
+22 -22
View File
@@ -141,17 +141,17 @@ 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>
<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#2013_endoh1">2013 endoh1 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">./endoh1</span> <span class="pp">[</span><span class="ss">file.lazy</span><span class="pp">]</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./endoh1 [file.lazy]</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>You might also enjoy running:</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">-E</span> endoh1.c <span class="kw">|</span> <span class="fu">less</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> cc -E endoh1.c | less</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>We liked this entry because it can serve as a standalone program as well as an
include file; and, as usual, because its input data is at least as obfuscated as
@@ -160,23 +160,23 @@ the program itself.</p>
4x longer to compile it with -O3 than without, compared to clang’s 2x.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="remarks">Remarks</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">less</span> endoh1.c</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> <span class="at">-o</span> endoh1 endoh1.c</span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh1</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> less endoh1.c
gcc -o endoh1 endoh1.c
./endoh1</code></pre>
<p>… Isn’t there any more to it?</p>
<p>Yes, of course.</p>
<p>This is a tool <em>for C programmers</em> to play the <a href="http://en.wikipedia.org/wiki/SKI_combinator_calculus">SKI combinator calculus</a>,
especially, <a href="https://tromp.github.io/cl/lazy-k.html">Lazy K</a>.</p>
<p>This program will shine when it is used as a library. For example,
<a href="hello.lazy">hello.lazy</a> is a “Hello world” program written in Lazy K.</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> lazy hello.lazy</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">Hello,</span> world!</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> $ lazy hello.lazy
Hello, world!</code></pre>
<p>where <code>lazy</code> is <a href="https://github.com/irori/lazyk">a reference implementation of Lazy K</a>. At the same time,
<a href="hello.lazy">hello.lazy</a> is <em>a valid C program</em> that uses <a href="endoh1.c">endoh1.c</a>
as a library.</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> gcc <span class="at">-o</span> hello <span class="at">-xc</span> hello.lazy</span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./hello</span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">Hello,</span> world!</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> $ gcc -o hello -xc hello.lazy
$ ./hello
Hello, world!</code></pre>
<p>In other words, this program is a kind of <a href="http://en.wikipedia.org/wiki/Polyglot_%28computing%29">polyglot</a>.</p>
<p>The usage is simple: you just have to wrap Lazy K program with <code>#include "endoh1.c"</code>. Note that <code>#</code> is a comment in Lazy K.</p>
<h3 id="obfuscation">Obfuscation</h3>
@@ -210,9 +210,9 @@ section</a>.</p>
</ul></li>
</ul>
<p>Recent compilers with <code>-Wall -W -Wextra -pedantic</code> say nothing.</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">gcc</span> <span class="at">-Wall</span> <span class="at">-W</span> <span class="at">-Wextra</span> <span class="at">-pedantic</span> prog.c</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">clang</span> <span class="at">-Wall</span> <span class="at">-W</span> <span class="at">-Wextra</span> <span class="at">-pedantic</span> prog.c</span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">tcc</span> <span class="at">-Wall</span> <span class="at">-W</span> <span class="at">-Wextra</span> <span class="at">-pedantic</span> prog.c</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> gcc -Wall -W -Wextra -pedantic prog.c
clang -Wall -W -Wextra -pedantic prog.c
tcc -Wall -W -Wextra -pedantic prog.c</code></pre>
<p>I think it will work on almost all platforms. I confirmed:</p>
<ul>
<li>Ubuntu Linux</li>
@@ -235,11 +235,11 @@ evaluates it.</p>
combinator calculus. The rewriting rules are shown in the shape of the code.</p>
<h4 id="abuse-of-function-pointers">Abuse of function pointers</h4>
<p>Consider a sequence of function applications in C:</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> s<span class="op">(</span>x<span class="op">)(</span>x<span class="op">)(</span>x<span class="op">)(</span>x<span class="op">)...</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> s(x)(x)(x)(x)...</code></pre>
<p>What type should <code>s</code> have? Unfortunately, C does <em>not</em> provide a “recursive
type”, such as <code>typedef f (*f)();</code>.</p>
<p>So, I used a heavily nested function pointer type:</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="kw">typedef</span> <span class="dt">void</span> <span class="op">*(*(*(*...(*(</span>f<span class="op">))()...)())())</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> typedef void *(*(*(*...(*(f))()...)())())</code></pre>
<p>This limits how many arguments one function can be consecutively applied to.
But you can increase the number by tweaking the definition of macro <code>p</code>.</p>
<h4 id="code-duplication-by-macros">Code duplication by macros</h4>
@@ -255,11 +255,11 @@ environment which is a reference to non-local variable.</p>
(It is feasible by dynamic code generation, but it is far from portable.)</p>
<p>So, I addressed this issue by generating many function definitions
statically by (ab)using macros:</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a> <span class="dt">void</span> <span class="op">*</span>x1<span class="op">;</span> <span class="dt">void</span> f1<span class="op">(</span><span class="dt">void</span> <span class="op">*</span>y<span class="op">)</span> <span class="op">{</span> <span class="cf">return</span> apply<span class="op">(</span>x1<span class="op">,</span> y<span class="op">);</span> <span class="op">}</span></span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="dt">void</span> <span class="op">*</span>x2<span class="op">;</span> <span class="dt">void</span> f2<span class="op">(</span><span class="dt">void</span> <span class="op">*</span>y<span class="op">)</span> <span class="op">{</span> <span class="cf">return</span> apply<span class="op">(</span>x2<span class="op">,</span> y<span class="op">);</span> <span class="op">}</span></span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a> <span class="dt">void</span> <span class="op">*</span>x3<span class="op">;</span> <span class="dt">void</span> f3<span class="op">(</span><span class="dt">void</span> <span class="op">*</span>y<span class="op">)</span> <span class="op">{</span> <span class="cf">return</span> apply<span class="op">(</span>x3<span class="op">,</span> y<span class="op">);</span> <span class="op">}</span></span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a> <span class="op">...</span></span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a> <span class="dt">void</span> <span class="op">*(</span>h<span class="op">[])</span> <span class="op">=</span> <span class="op">{</span> f1<span class="op">,</span> f2<span class="op">,</span> f3<span class="op">,</span> <span class="op">...</span> <span class="op">}</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> void *x1; void f1(void *y) { return apply(x1, y); }
void *x2; void f2(void *y) { return apply(x2, y); }
void *x3; void f3(void *y) { return apply(x3, y); }
...
void *(h[]) = { f1, f2, f3, ... }</code></pre>
<p>and by allotting each of them when a closure is needed.</p>
<p>This leads to another limitation: the number of pre-defined closures limits how
many identifiers (<code>S</code> <code>K</code> <code>I</code>) one program can use.</p>
+3 -3
View File
@@ -1,13 +1,13 @@
## To build:
```sh
```<!---sh-->
make
```
## To use:
```sh
```<!---sh-->
make check
```
@@ -23,7 +23,7 @@ download one or both before exiting.
## Try:
```sh
```<!---sh-->
less jpeg.c
```
+3 -3
View File
@@ -141,9 +141,9 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<h2 id="to-use">To use:</h2>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> check</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make check</code></pre>
<p>You’ll need to have both <a href="https://www.ruby-lang.org">Ruby</a> and
<a href="https://imagemagick.org/">ImageMagick</a> installed to run all the automated
checks.</p>
@@ -152,7 +152,7 @@ section to enjoy the entry. The <a href="Makefile">Makefile</a> <code>check</cod
you have both and if either is not found it will report it and tell you where to
download one or both before exiting.</p>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">less</span> jpeg.c</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> less jpeg.c</code></pre>
<p>Next look at <code>jpeg.jpg</code> in an image viewer program.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>This is a program which, when fed its own source, generates a program that
+10 -10
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -18,7 +18,7 @@ For more detailed information see [2013 endoh3 bugs](../../bugs.html#2013_endoh3
## To use:
```sh
```<!---sh-->
./endoh3
```
@@ -29,7 +29,7 @@ system up for this or if you want to verify that everything is oky.
## Try:
```sh
```<!---sh-->
./try.sh
./try.sh ABC
@@ -75,7 +75,7 @@ notation](http://en.wikipedia.org/wiki/ABC_notation).
Try:
```sh
```<!---sh-->
cc -o endoh3 endoh3.c
echo "CDEFGABc" | ./endoh3 > /dev/dsp
```
@@ -83,20 +83,20 @@ Try:
If `/dev/dsp` is not available on your system, use an OSS sound wrapper such
as `padsp` or `aoss`:
```sh
```<!---sh-->
echo "CDEFGABc" | ./endoh3 | padsp tee /dev/dsp > /dev/null
```
If you are using Mac OS X, try [sox](http://sox.sourceforge.net/) like so:
```sh
```<!---sh-->
echo "CDEFGABc" | ./endoh3 | sox -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio
```
If that does not work, use the attached script to convert the output into a wave
file format:
```sh
```<!---sh-->
echo "CDEFGABc" | ./endoh3 | ruby wavify.rb > cde.wav
```
@@ -107,7 +107,7 @@ You can also enjoy some music scores that I attached. With `/dev/dsp` you can
do so like:
```sh
```<!---sh-->
cat twinkle.abc | ./endoh3 > /dev/dsp
cat menuet.abc | ./endoh3 > /dev/dsp
```
@@ -185,7 +185,7 @@ You know, it is ["the famous song"](http://en.wikipedia.org/wiki/4%E2%80%B233%E2
Here is a magical expression which I found by brute-force:
```c
```<!---c-->
(c % 32 + 5) * 9 / 5 % 13 + n / 32 * 12 - 22
```
@@ -228,7 +228,7 @@ frequency by multiplying the value by `n` times.
Finally, the following code generates a saw wave:
```c
```<!---c-->
for(c = 0; c < len; c++) putchar(a = n * D);
```
+18 -18
View File
@@ -141,24 +141,24 @@ 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>
<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#2013_endoh3">2013 endoh3 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">./endoh3</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./endoh3</code></pre>
<p>This program plays sound. See <a href="../../faq.html#sox">FAQ 3.10 - How do I compile and use an IOCCC
entry that requires sound?</a> if you do not know how to set your
system up for this or if you want to verify that everything is oky.</p>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span> ABC</span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span> test.abc yankee.abc</span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span> <span class="pp">*</span>.abc</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh
./try.sh ABC
./try.sh test.abc yankee.abc
./try.sh *.abc</code></pre>
<p>The script will check for SoX first and next <code>padsp</code> from <code>PulseAudio</code> and
finally if neither are found if you have <code>ruby(1)</code> installed it’ll use the
included ruby script to convert it to a WAV file for you to play.</p>
@@ -180,21 +180,21 @@ will remain the same for historical purposes.</p>
<p>This is a sound synthesizer for a subset of <a href="http://en.wikipedia.org/wiki/ABC_notation">ABC music
notation</a>.</p>
<p>Try:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cc</span> <span class="at">-o</span> endoh3 endoh3.c</span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> <span class="st">&quot;CDEFGABc&quot;</span> <span class="kw">|</span> <span class="ex">./endoh3</span> <span class="op">&gt;</span> /dev/dsp</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> cc -o endoh3 endoh3.c
echo &quot;CDEFGABc&quot; | ./endoh3 &gt; /dev/dsp</code></pre>
<p>If <code>/dev/dsp</code> is not available on your system, use an OSS sound wrapper such
as <code>padsp</code> or <code>aoss</code>:</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="bu">echo</span> <span class="st">&quot;CDEFGABc&quot;</span> <span class="kw">|</span> <span class="ex">./endoh3</span> <span class="kw">|</span> <span class="ex">padsp</span> tee /dev/dsp <span class="op">&gt;</span> /dev/null</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> echo &quot;CDEFGABc&quot; | ./endoh3 | padsp tee /dev/dsp &gt; /dev/null</code></pre>
<p>If you are using Mac OS X, try <a href="http://sox.sourceforge.net/">sox</a> like so:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> <span class="st">&quot;CDEFGABc&quot;</span> <span class="kw">|</span> <span class="ex">./endoh3</span> <span class="kw">|</span> <span class="fu">sox</span> <span class="at">-q</span> <span class="at">-traw</span> <span class="at">-r8000</span> <span class="at">-b8</span> <span class="at">-e</span> unsigned-integer <span class="at">-</span> <span class="at">-tcoreaudio</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> echo &quot;CDEFGABc&quot; | ./endoh3 | sox -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio</code></pre>
<p>If that does not work, use the attached script to convert the output into a wave
file format:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> <span class="st">&quot;CDEFGABc&quot;</span> <span class="kw">|</span> <span class="ex">./endoh3</span> <span class="kw">|</span> <span class="ex">ruby</span> wavify.rb <span class="op">&gt;</span> cde.wav</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> echo &quot;CDEFGABc&quot; | ./endoh3 | ruby wavify.rb &gt; cde.wav</code></pre>
<p>and play <code>cde.wav</code>.</p>
<p>You can also enjoy some music scores that I attached. With <code>/dev/dsp</code> you can
do so like:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> twinkle.abc <span class="kw">|</span> <span class="ex">./endoh3</span> <span class="op">&gt;</span> /dev/dsp</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> menuet.abc <span class="kw">|</span> <span class="ex">./endoh3</span> <span class="op">&gt;</span> /dev/dsp</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> cat twinkle.abc | ./endoh3 &gt; /dev/dsp
cat menuet.abc | ./endoh3 &gt; /dev/dsp</code></pre>
<p>but you should be able to modify it a way to meet your system requirements as
described above.</p>
<h3 id="obfuscation">Obfuscation</h3>
@@ -257,7 +257,7 @@ But I do not attach it to protect you from W****r.</p>
You know, it is <a href="http://en.wikipedia.org/wiki/4%E2%80%B233%E2%80%B3">“the famous song”</a>.</p>
<h3 id="spoiler">Spoiler</h3>
<p>Here is a magical expression which I found by brute-force:</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="op">(</span>c <span class="op">%</span> <span class="dv">32</span> <span class="op">+</span> <span class="dv">5</span><span class="op">)</span> <span class="op">*</span> <span class="dv">9</span> <span class="op">/</span> <span class="dv">5</span> <span class="op">%</span> <span class="dv">13</span> <span class="op">+</span> n <span class="op">/</span> <span class="dv">32</span> <span class="op">*</span> <span class="dv">12</span> <span class="op">-</span> <span class="dv">22</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> (c % 32 + 5) * 9 / 5 % 13 + n / 32 * 12 - 22</code></pre>
<p>Interestingly, it converts an ASCII number of ABC notes
to the corresponding tone number.</p>
<pre><code> &#39;C&#39; (ASCII 67) =&gt; 3
@@ -287,7 +287,7 @@ found this approximation by using the <a href="http://en.wikipedia.org/wiki/Ster
tree</a>.) We can gain the
frequency by multiplying the value by <code>n</code> times.</p>
<p>Finally, the following code generates a saw wave:</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span><span class="op">(</span>c <span class="op">=</span> <span class="dv">0</span><span class="op">;</span> c <span class="op">&lt;</span> len<span class="op">;</span> c<span class="op">++)</span> putchar<span class="op">(</span>a <span class="op">=</span> n <span class="op">*</span> D<span class="op">);</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> for(c = 0; c &lt; len; c++) putchar(a = n * D);</code></pre>
<p>where <code>D</code> is a frequency and <code>a</code> is a variable whose type is <code>char</code>. By
assigning <code>float</code> to <code>char</code> variable, the implicit type conversion is performed
from <code>float</code> to <code>char</code> (modulo 256).</p>
+11 -11
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -8,7 +8,7 @@ If you wish to change the size (see the [Author's remarks](#authors-remarks)
below) you can do so with the `SIZE` variable. For instance you can do:
```sh
```<!---sh-->
make clobber SIZE=50,50 all
```
@@ -29,7 +29,7 @@ For more detailed information see [2013 endoh4 bugs](../../bugs.html#2013_endoh4
## To use:
```sh
```<!---sh-->
./endoh4 < file
./endoh4.sh file
```
@@ -41,7 +41,7 @@ line it will feed to the program [endoh4.c](endoh4.c).
## Try:
```sh
```<!---sh-->
./endoh4.sh cube.txt
```
@@ -51,13 +51,13 @@ The author recommends the use of xterm.
For an example, if you are a football/soccer fan, try:
```sh
```<!---sh-->
./endoh4.sh solids/archimedian-solid/a11-truncated-icosahedron.txt
```
You can provide more than one file:
```sh
```<!---sh-->
./endoh4.sh solids/archimedian-solid/a11-truncated-icosahedron.txt cube.txt
```
@@ -66,7 +66,7 @@ Hit ctrl-c/intr to go to the next file.
If you wish to change the size to `50,50` without passing any arg:
```sh
```<!---sh-->
SIZE=50,50 ./endoh4.sh
```
@@ -115,7 +115,7 @@ clang, and tcc. It should not trigger warnings with `-pedantic` and `-Wextra`.
You may want to use `tput` to hide the terminal cursor.
```sh
```<!---sh-->
tput civis
./endoh4 < cube.txt
tput cnorm
@@ -123,7 +123,7 @@ You may want to use `tput` to hide the terminal cursor.
or
```sh
```<!---sh-->
./endoh4.sh cube.txt
```
@@ -131,14 +131,14 @@ or
You can change the screen size. Let the aspect ratio be about 3:1.
```sh
```<!---sh-->
cc -DS=120,40 -o endoh4 endoh4.c
```
The shape of this code is the geometric net of a regular tetrahedron.
So, try:
```sh
```<!---sh-->
./endoh4 < endoh4.c # or ./endoh4.sh
```
+14 -14
View File
@@ -141,10 +141,10 @@ 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>If you wish to change the size (see the <a href="#authors-remarks">Author’s remarks</a>
below) you can do so with the <code>SIZE</code> variable. For instance you can do:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> clobber SIZE=50,50 all</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make clobber SIZE=50,50 all</code></pre>
<p>but you can also do this directly with the <a href="endoh4.sh">endoh4.sh</a> script as
described below.</p>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
@@ -152,22 +152,22 @@ described below.</p>
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
<p>For more detailed information see <a href="../../bugs.html#2013_endoh4">2013 endoh4 bugs</a>.</p>
<h2 id="to-use">To use:</h2>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh4</span> <span class="op">&lt;</span> file</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh4.sh</span> file</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./endoh4 &lt; file
./endoh4.sh file</code></pre>
<p>The second form is preferable as it will temporarily make the cursor invisible
as recommended by the author. If no file is specified in the <code>./endoh4.sh</code> command
line it will feed to the program <a href="endoh4.c">endoh4.c</a>.</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">./endoh4.sh</span> cube.txt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./endoh4.sh cube.txt</code></pre>
<p>Hit ctrl-c to end the program.</p>
<p>The author recommends the use of xterm.</p>
<p>For an example, if you are a football/soccer fan, 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">./endoh4.sh</span> solids/archimedian-solid/a11-truncated-icosahedron.txt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./endoh4.sh solids/archimedian-solid/a11-truncated-icosahedron.txt</code></pre>
<p>You can provide more than one file:</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">./endoh4.sh</span> solids/archimedian-solid/a11-truncated-icosahedron.txt cube.txt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./endoh4.sh solids/archimedian-solid/a11-truncated-icosahedron.txt cube.txt</code></pre>
<p>Hit ctrl-c/intr to go to the next file.</p>
<p>If you wish to change the size to <code>50,50</code> without passing any arg:</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="va">SIZE</span><span class="op">=</span>50,50 <span class="ex">./endoh4.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> SIZE=50,50 ./endoh4.sh</code></pre>
<p>Not specifying a file feeds <a href="endoh4.c">endoh4.c</a> to the program.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>This program is formatted as the net for a tetrahedron (hint: try feeding the
@@ -203,17 +203,17 @@ triangulated)</li>
clang, and tcc. It should not trigger warnings with <code>-pedantic</code> and <code>-Wextra</code>.</p>
<h3 id="tips">Tips</h3>
<p>You may want to use <code>tput</code> to hide the terminal cursor.</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">tput</span> civis</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh4</span> <span class="op">&lt;</span> cube.txt</span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">tput</span> cnorm</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> tput civis
./endoh4 &lt; cube.txt
tput cnorm</code></pre>
<p>or</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">./endoh4.sh</span> cube.txt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./endoh4.sh cube.txt</code></pre>
<h3 id="bonuses">Bonuses</h3>
<p>You can change the screen size. Let the aspect ratio be about 3:1.</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">cc</span> <span class="at">-DS</span><span class="op">=</span>120,40 <span class="at">-o</span> endoh4 endoh4.c</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> cc -DS=120,40 -o endoh4 endoh4.c</code></pre>
<p>The shape of this code is the geometric net of a regular tetrahedron.
So, try:</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./endoh4</span> <span class="op">&lt;</span> endoh4.c <span class="co"># or ./endoh4.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./endoh4 &lt; endoh4.c # or ./endoh4.sh</code></pre>
<p>The <a href="solids/">solids/</a> directory includes various solid data:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Platonic_solid">Platonic solids</a></li>
+5 -5
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make all
```
@@ -18,7 +18,7 @@ For more detailed information see [2013 hou bugs](../../bugs.html#2013_hou).
## To use:
```sh
```<!---sh-->
./hou [scene-file-name] [options]
```
@@ -29,7 +29,7 @@ effects should be more or less recognizable when you see 16.
## Try:
```sh
```<!---sh-->
./try.sh
```
@@ -62,7 +62,7 @@ This program will loop infinitely while progressively refining a
NOTE: the author refers to [a.c](a.c), placed in a gzipped file `a.c.gz`. We do not
include it but it can be generated like:
```sh
```<!---sh-->
cc -Wall hou.c -o hou -lm
./hou > a.c
```
@@ -78,7 +78,7 @@ needing to create a temporary file.
This program is a programmable rendering engine with a built-in default scene.
The standard command line is:
```sh
```<!---sh-->
./hou [scene-file-name] [options]
```
+6 -6
View File
@@ -141,18 +141,18 @@ Location: <a href="../../location.html#CN">CN</a> - <em>People’s Republic of C
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> all</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make all</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#2013_hou">2013 hou 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">./hou</span> <span class="pp">[</span><span class="ss">scene</span><span class="pp">-</span><span class="ss">file</span><span class="pp">-</span><span class="ss">name</span><span class="pp">]</span> <span class="pp">[</span><span class="ss">options</span><span class="pp">]</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./hou [scene-file-name] [options]</code></pre>
<p>Follow the instructions in <code>stdout</code>, preferably with an auto-refreshing PPM
image viewer ready. Refresh the image every time the output refreshes, all
effects should be more or less recognizable when you see 16.</p>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<p>Try opening the file noted by the program then let the program run a while and
every so often reopen the file, to see how it changes. The author suggests that
you leave the program running overnight to see what happens. If however you do
@@ -181,15 +181,15 @@ program.</p>
<a href="https://en.wikipedia.org/wiki/Ray_tracing_(graphics)">raytraced</a> image.</p>
<p>NOTE: the author refers to <a href="a.c">a.c</a>, placed in a gzipped file <code>a.c.gz</code>. We do not
include it but it can be generated like:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cc</span> <span class="at">-Wall</span> hou.c <span class="at">-o</span> hou <span class="at">-lm</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./hou</span> <span class="op">&gt;</span> a.c</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> cc -Wall hou.c -o hou -lm
./hou &gt; a.c</code></pre>
<p>but there is no need to do this as the Makefile takes care of it without even
needing to create a temporary file.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<h3 id="using-hou">Using hou</h3>
<p>This program is a programmable rendering engine with a built-in default scene.
The standard command line is:</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">./hou</span> <span class="pp">[</span><span class="ss">scene</span><span class="pp">-</span><span class="ss">file</span><span class="pp">-</span><span class="ss">name</span><span class="pp">]</span> <span class="pp">[</span><span class="ss">options</span><span class="pp">]</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./hou [scene-file-name] [options]</code></pre>
<p>As <code>hou</code> runs, it writes a progressively refining image to a ppm file specified
in the scene. The initialization may take a while, but once it’s done, a rough
preview should be available in seconds. Leave <code>hou</code> running for the night, and you
+3 -3
View File
@@ -155,10 +155,10 @@ authors submitted very different styles of entries.</p>
had to print a value 2053 or less when the <code>-i</code> flag was used.</p>
<p>Several people discovered an undocumented feature in that
certain comments such as:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="co">///*</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> ///*</code></pre>
<p>or:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="op">*</span>\</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="op">/</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> *\
/</code></pre>
<p>were not correctly parsed by the tool. The guidelines stated:</p>
<pre><code> In cases where the above summary and the algorithm implemented by
the IOCCC size tool source code conflict, the algorithm implemented
+4 -4
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -18,14 +18,14 @@ For more detailed information see [2013 mills bugs](../../bugs.html#2013_mills).
## To use:
```sh
```<!---sh-->
./mills
```
## Try:
```sh
```<!---sh-->
./mills &
```
@@ -61,7 +61,7 @@ while you are there, click on an ad. They could use the money.
It would be possible to fix this by adding
```c
```<!---c-->
n=1,setsockopt(s,SOL_SOCKET,SO_REUSEADDR,&n,sizeof n),
```
+4 -4
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#2013_mills">2013 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="ex">./mills</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./mills</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">./mills</span> <span class="kw">&amp;</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./mills &amp;</code></pre>
<p>While that is running, point your favorite browser at:
<a href="http://localhost:8224">http://localhost:8224</a>.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
@@ -170,7 +170,7 @@ doing so. For details as to why this is necessary, feel free to Google
<code>"TIME_WAIT"</code>, <code>"SO_REUSEADDR"</code> and <code>"SO_REUSEPORT"</code> (with the quotes). And
while you are there, click on an ad. They could use the money.</p>
<p>It would be possible to fix this by adding</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> n<span class="op">=</span><span class="dv">1</span><span class="op">,</span>setsockopt<span class="op">(</span>s<span class="op">,</span>SOL_SOCKET<span class="op">,</span>SO_REUSEADDR<span class="op">,&amp;</span>n<span class="op">,</span><span class="kw">sizeof</span> n<span class="op">),</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> n=1,setsockopt(s,SOL_SOCKET,SO_REUSEADDR,&amp;n,sizeof n),</code></pre>
<p>at an appropriate spot in the code (an exercise left to the reader). However,
as this limitation is documented, it is not technically a bug.</p>
<h3 id="details-of-operation">Details of Operation</h3>
+15 -15
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -10,7 +10,7 @@ information on all of these builds.
## To use:
```sh
```<!---sh-->
./horizontal_cat [files...] > [output]
./vertical_cat [files...] > [output]
```
@@ -20,19 +20,19 @@ information on all of these builds.
To understand the various intermediate source files that are built, try:
```sh
```<!---sh-->
make understanding
```
Also try:
```sh
```<!---sh-->
./try.sh
```
NOTE: Use - for standard input. For example:
```sh
```<!---sh-->
./vertical_cat - -
```
@@ -69,7 +69,7 @@ judging this entry.
`Misaka` is a file concatenation utility, with at least two modes of
operation:
```sh
```<!---sh-->
cc misaka.c -o horizontal_cat
./horizontal_cat [files...] > [output]
@@ -94,7 +94,7 @@ files vertically.
I thought the lack of horizontal concatenation must have been an oversight,
so I implemented this utility:
```sh
```<!---sh-->
cc misaka.c -o horizontal_cat
./horizontal_cat files...
```
@@ -109,7 +109,7 @@ can specify `-` multiple times to get `stdin` multiplied horizontally. For
example, if you have `seq(1)` in your shell, you can add line numbers to both
sides of [misaka.c](misaka.c) like this:
```sh
```<!---sh-->
seq -f ' %.0f ' 45 | ./horizontal_cat - misaka.c -
```
@@ -126,7 +126,7 @@ files vertically, so I included a vertical mode. But supporting vertical
mode with command line options would be no fun. Instead, vertical mode is
enabled by concatenating the source code horizontally:
```sh
```<!---sh-->
./horizontal_cat misaka.c misaka.c > misaka2.c
gcc misaka2.c -o vertical_cat
./vertical_cat files...
@@ -135,7 +135,7 @@ enabled by concatenating the source code horizontally:
`vertical_cat` works more or less like `cat`, except you can use
`vertical_cat` to duplicate `stdin`:
```sh
```<!---sh-->
./vertical_cat - -
```
@@ -147,7 +147,7 @@ was just more [cats](https://rationalwiki.org/wiki/Fun:Cat). So I implemented
one more mode, this one is enabled by concatenating [misaka.c](misaka.c)
vertically:
```sh
```<!---sh-->
./vertical_cat misaka.c misaka.c > misaka3.c
gcc misaka3.c -o long_cat
./long_cat
@@ -157,7 +157,7 @@ vertically:
exponentially longer by concatenating more files vertically (up to 31 levels
high, depending on `sizeof(int)` for your compiler):
```sh
```<!---sh-->
./vertical_cat misaka.c misaka.c misaka.c > misaka4.c
gcc misaka4.c -o loong_cat
@@ -171,7 +171,7 @@ high, depending on `sizeof(int)` for your compiler):
If your terminal has really thin fonts, you can also make this output fatter
by concatenating files horizontally:
```sh
```<!---sh-->
./vertical_cat misaka.c misaka.c | ./horizontal_cat - - > misaka7.c
gcc misaka7.c -o long_fat_cat
@@ -182,7 +182,7 @@ by concatenating files horizontally:
Output width is determined by the first level of stacked programs, so a
triangle like the following will not have horizontally expanded output:
```sh
```<!---sh-->
./horizontal_cat misaka.c misaka.c | ./vertical_cat misaka.c - > misaka9.c
gcc misaka9.c -o same_as_long_cat
```
@@ -192,7 +192,7 @@ together, you can feed the source to a
[brainfuck](https://en.wikipedia.org/wiki/Brainfuck) interpreter to get an
overview of how the programs are stacked. Example:
```sh
```<!---sh-->
perl bf.pl misaka9.c
```
+38 -38
View File
@@ -141,19 +141,19 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<p>This will build a bunch of versions of the code. See the author’s details for
information on all of these builds.</p>
<h2 id="to-use">To use:</h2>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./horizontal_cat</span> <span class="pp">[</span><span class="ss">files...</span><span class="pp">]</span> <span class="op">&gt;</span> <span class="pp">[</span><span class="ss">output</span><span class="pp">]</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vertical_cat</span> <span class="pp">[</span><span class="ss">files...</span><span class="pp">]</span> <span class="op">&gt;</span> <span class="pp">[</span><span class="ss">output</span><span class="pp">]</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./horizontal_cat [files...] &gt; [output]
./vertical_cat [files...] &gt; [output]</code></pre>
<h2 id="try">Try:</h2>
<p>To understand the various intermediate source files that are built, try:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> understanding</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make understanding</code></pre>
<p>Also try:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<p>NOTE: Use - for standard input. For example:</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">./vertical_cat</span> <span class="at">-</span> <span class="at">-</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./vertical_cat - -</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>There is more to cat than <a href="http://cheezburger.com/1680494336">mere cats</a>. Be
they tall, fat, long or squat, this source code is sure to amuse.</p>
@@ -176,12 +176,12 @@ judging this entry.</p>
<h3 id="overview">Overview</h3>
<p><code>Misaka</code> is a file concatenation utility, with at least two modes of
operation:</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> misaka.c <span class="at">-o</span> horizontal_cat</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./horizontal_cat</span> <span class="pp">[</span><span class="ss">files...</span><span class="pp">]</span> <span class="op">&gt;</span> <span class="pp">[</span><span class="ss">output</span><span class="pp">]</span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">./horizontal_cat</span> misaka.c misaka.c <span class="op">&gt;</span> misaka2.c</span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">cc</span> misaka2.c <span class="at">-o</span> vertical_cat</span>
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vertical_cat</span> <span class="pp">[</span><span class="ss">files...</span><span class="pp">]</span> <span class="op">&gt;</span> <span class="pp">[</span><span class="ss">output</span><span class="pp">]</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> cc misaka.c -o horizontal_cat
./horizontal_cat [files...] &gt; [output]
./horizontal_cat misaka.c misaka.c &gt; misaka2.c
cc misaka2.c -o vertical_cat
./vertical_cat [files...] &gt; [output]</code></pre>
<p>Where <code>[files...]</code> is a list of text file names. Use <code>-</code> to read from <code>stdin</code>.</p>
<h3 id="details">Details</h3>
<h3 id="horizontal-cat">Horizontal cat</h3>
@@ -192,8 +192,8 @@ concatenating files, that function only seem to work if I wanted to concatenate
files vertically.</p>
<p>I thought the lack of horizontal concatenation must have been an oversight,
so I implemented this utility:</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> misaka.c <span class="at">-o</span> horizontal_cat</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./horizontal_cat</span> files...</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> cc misaka.c -o horizontal_cat
./horizontal_cat files...</code></pre>
<p><code>horizontal_cat</code> concatenates files horizontally and write the output to
<code>stdout</code>. Each input file is padded with spaces on the right so that the
original text alignments are preserved.</p>
@@ -202,7 +202,7 @@ Unlike <code>cat</code>, <code>horizontal_cat</code> loads all input to memory f
can specify <code>-</code> multiple times to get <code>stdin</code> multiplied horizontally. For
example, if you have <code>seq(1)</code> in your shell, you can add line numbers to both
sides of <a href="misaka.c">misaka.c</a> 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="fu">seq</span> <span class="at">-f</span> <span class="st">&#39; %.0f &#39;</span> 45 <span class="kw">|</span> <span class="ex">./horizontal_cat</span> <span class="at">-</span> misaka.c <span class="at">-</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> seq -f &#39; %.0f &#39; 45 | ./horizontal_cat - misaka.c -</code></pre>
<h3 id="vertical-cat">Vertical cat</h3>
<p>Because <code>horizontal_cat</code> must know the maximum width of all files before
writing any output, all files must be processed at least twice. To support
@@ -212,47 +212,47 @@ writing any output, all files must be processed at least twice. To support
files vertically, so I included a vertical mode. But supporting vertical
mode with command line options would be no fun. Instead, vertical mode is
enabled by concatenating the source code horizontally:</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">./horizontal_cat</span> misaka.c misaka.c <span class="op">&gt;</span> misaka2.c</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> misaka2.c <span class="at">-o</span> vertical_cat</span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vertical_cat</span> files...</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./horizontal_cat misaka.c misaka.c &gt; misaka2.c
gcc misaka2.c -o vertical_cat
./vertical_cat files...</code></pre>
<p><code>vertical_cat</code> works more or less like <code>cat</code>, except you can use
<code>vertical_cat</code> to duplicate <code>stdin</code>:</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vertical_cat</span> <span class="at">-</span> <span class="at">-</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./vertical_cat - -</code></pre>
<h3 id="long-cat">Long cat</h3>
<p>After <code>horizontal_cat</code> and <code>vertical_cat</code>, I thought, maybe all I really wanted
was just more <a href="https://rationalwiki.org/wiki/Fun:Cat">cats</a>. So I implemented
one more mode, this one is enabled by concatenating <a href="misaka.c">misaka.c</a>
vertically:</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">./vertical_cat</span> misaka.c misaka.c <span class="op">&gt;</span> misaka3.c</span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> misaka3.c <span class="at">-o</span> long_cat</span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./long_cat</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./vertical_cat misaka.c misaka.c &gt; misaka3.c
gcc misaka3.c -o long_cat
./long_cat</code></pre>
<p><code>long_cat</code> outputs ASCII art of a cat to <code>stdout</code>. You can make this cat
exponentially longer by concatenating more files vertically (up to 31 levels
high, depending on <code>sizeof(int)</code> for your compiler):</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">./vertical_cat</span> misaka.c misaka.c misaka.c <span class="op">&gt;</span> misaka4.c</span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> misaka4.c <span class="at">-o</span> loong_cat</span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vertical_cat</span> misaka.c misaka.c misaka.c misaka.c <span class="op">&gt;</span> misaka5.c</span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> misaka5.c <span class="at">-o</span> loooong_cat</span>
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vertical_cat</span> misaka.c misaka.c misaka.c misaka.c misaka.c <span class="op">&gt;</span> misaka6.c</span>
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> misaka6.c <span class="at">-o</span> loooooooong_cat</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./vertical_cat misaka.c misaka.c misaka.c &gt; misaka4.c
gcc misaka4.c -o loong_cat
./vertical_cat misaka.c misaka.c misaka.c misaka.c &gt; misaka5.c
gcc misaka5.c -o loooong_cat
./vertical_cat misaka.c misaka.c misaka.c misaka.c misaka.c &gt; misaka6.c
gcc misaka6.c -o loooooooong_cat</code></pre>
<p>If your terminal has really thin fonts, you can also make this output fatter
by concatenating files horizontally:</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">./vertical_cat</span> misaka.c misaka.c <span class="kw">|</span> <span class="ex">./horizontal_cat</span> <span class="at">-</span> <span class="at">-</span> <span class="op">&gt;</span> misaka7.c</span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> misaka7.c <span class="at">-o</span> long_fat_cat</span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">./vertical_cat</span> misaka.c misaka.c <span class="kw">|</span> <span class="ex">./horizontal_cat</span> <span class="at">-</span> <span class="at">-</span> <span class="at">-</span> <span class="op">&gt;</span> misaka8.c</span>
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> misaka8.c <span class="at">-o</span> long_faat_cat</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./vertical_cat misaka.c misaka.c | ./horizontal_cat - - &gt; misaka7.c
gcc misaka7.c -o long_fat_cat
./vertical_cat misaka.c misaka.c | ./horizontal_cat - - - &gt; misaka8.c
gcc misaka8.c -o long_faat_cat</code></pre>
<p>Output width is determined by the first level of stacked programs, so a
triangle like the following will not have horizontally expanded output:</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">./horizontal_cat</span> misaka.c misaka.c <span class="kw">|</span> <span class="ex">./vertical_cat</span> misaka.c <span class="at">-</span> <span class="op">&gt;</span> misaka9.c</span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> misaka9.c <span class="at">-o</span> same_as_long_cat</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./horizontal_cat misaka.c misaka.c | ./vertical_cat misaka.c - &gt; misaka9.c
gcc misaka9.c -o same_as_long_cat</code></pre>
<p>Finally, if you lost track of how many <a href="misaka.c">misaka.c</a> you have stacked
together, you can feed the source to a
<a href="https://en.wikipedia.org/wiki/Brainfuck">brainfuck</a> interpreter to get an
overview of how the programs are stacked. Example:</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">perl</span> bf.pl misaka9.c</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> perl bf.pl misaka9.c</code></pre>
<p>This outputs:</p>
<pre><code> MISAKA
MISAKA MISAKA</code></pre>
+3 -3
View File
@@ -1,13 +1,13 @@
## To build:
```sh
```<!---sh-->
make
```
## To use:
```sh
```<!---sh-->
echo "YYYY/MM/DD" | ./morgan1
```
@@ -23,7 +23,7 @@ follows:
## Try:
```sh
```<!---sh-->
./try.sh
```
+3 -3
View File
@@ -141,9 +141,9 @@ Location: <a href="../../location.html#FR">FR</a> - <em>French Republic</em> (<e
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<h2 id="to-use">To use:</h2>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> <span class="st">&quot;YYYY/MM/DD&quot;</span> <span class="kw">|</span> <span class="ex">./morgan1</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> echo &quot;YYYY/MM/DD&quot; | ./morgan1</code></pre>
<p>where <code>YYYY</code> is the four digit year, <code>MM</code> is the two digit month and <code>DD</code> is two
digit day of the month. The arrow keys control the shifting of the date as
follows:</p>
@@ -154,7 +154,7 @@ follows:</p>
<li>Down : go backwards 20 days.</li>
</ul>
<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>Use the same keys as described above to change the dates each time the program
window is in focus.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
+3 -3
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make
```
@@ -9,13 +9,13 @@
For the console version (ncurses):
```sh
```<!---sh-->
./morgan2
```
For the graphical version (X11):
```sh
```<!---sh-->
./morgan2 X
```
+3 -3
View File
@@ -141,12 +141,12 @@ Location: <a href="../../location.html#FR">FR</a> - <em>French Republic</em> (<e
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make</code></pre>
<h2 id="to-use">To use:</h2>
<p>For the console version (ncurses):</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./morgan2</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./morgan2</code></pre>
<p>For the graphical version (X11):</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./morgan2</span> X</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./morgan2 X</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>The judges enjoyed playing the game almost to completion; if we remember
correctly, we managed to place 59 or 60 dominoes. We wonder, what would be
+3 -3
View File
@@ -1,13 +1,13 @@
## To build:
```sh
```<!---sh-->
make
```
## To use:
```sh
```<!---sh-->
./robison
# enter an expression
@@ -17,7 +17,7 @@
## Try:
```sh
```<!---sh-->
./try.sh
```
+6 -6
View File
@@ -141,14 +141,14 @@ 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>
<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">./robison</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="co"># enter an expression</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> expression <span class="kw">|</span> <span class="ex">./robison</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./robison
# enter an expression
echo expression | ./robison</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>Of integers this prog does a lot,<br />
plus minus, div times (and what not).</p>