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

+1 -1
View File
@@ -35,7 +35,7 @@ been eliminated, and will likely be considered in future years.
A number of entries made use of the following C pre-processor feature:
```c
```<!---c-->
#define X define
#X foo bar
```
+5 -5
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make all
```
@@ -10,7 +10,7 @@ familiar to vi(m) users.
## To use:
```sh
```<!---sh-->
./ant some_file
```
@@ -20,12 +20,12 @@ program exit without doing anything.
## Try:
```sh
```<!---sh-->
make hill
./ant hill
```
```sh
```<!---sh-->
make mole
./ant mole
```
@@ -46,7 +46,7 @@ rest was unchanged.
### Alternate build:
```sh
```<!---sh-->
make alt
```
+7 -7
View File
@@ -141,18 +141,18 @@ Location: <a href="../../location.html#CA">CA</a> - <em>Canada</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> all</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make all</code></pre>
<p>There is an <a href="#alternate-code">alternate version</a> that might feel a bit more
familiar to vi(m) users.</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">./ant</span> some_file</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./ant some_file</code></pre>
<p>NOTE: the file must already exist and not specifying any arg will make the
program exit without doing anything.</p>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> hill</span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./ant</span> hill</span></code></pre></div>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> mole</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./ant</span> mole</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make hill
./ant hill</code></pre>
<pre class="&lt;!---sh--&gt;"><code> make mole
./ant mole</code></pre>
<h2 id="alternate-code">Alternate code:</h2>
<p>This version changes the commands slightly so that to go to the first column you
should enter <code>0</code>, to go to the last column you should enter <code>$</code>, to quit you
@@ -163,7 +163,7 @@ ESC (<code>\x1b</code>).</p>
<p>These will make it slightly less unwieldy for those familiar with vi(m); the
rest was unchanged.</p>
<h3 id="alternate-build">Alternate build:</h3>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make alt</code></pre>
<h3 id="alternate-use">Alternate use:</h3>
<p>Use <code>ant.alt</code> as you would <code>ant</code> above with the changes in the input keys. See
the author’s remarks for the remaining keys.</p>
+2 -2
View File
@@ -1,13 +1,13 @@
## To build:
```sh
```<!---sh-->
make all
```
## Try:
```sh
```<!---sh-->
./try.sh
./sorta < sorta.itailrec
+4 -4
View File
@@ -141,11 +141,11 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> all</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make all</code></pre>
<h2 id="try">Try:</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">./try.sh</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./sorta</span> <span class="op">&lt;</span> sorta.itailrec</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh
./sorta &lt; sorta.itailrec</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>For info on more examples, read the <a href="sorta.README.html">sorta.README.html</a> web page.</p>
<p>The author wished to win the “most useful program” award and documented this in
+5 -5
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make all
```
@@ -21,7 +21,7 @@ For more detailed information see [1991 buzzard bugs](../../bugs.html#1991_buzza
## To use:
```sh
```<!---sh-->
./buzzard
```
@@ -37,14 +37,14 @@ code directly so the keys are not made a `-D` at the compiler.
### Alternate build:
```sh
```<!---sh-->
make alt
```
### Alternate use:
```sh
```<!---sh-->
./buzzard.alt
```
@@ -89,7 +89,7 @@ so make sure to convert tabs to spaces before using it.
Usage:
```sh
```<!---sh-->
./buzzard [filename [escape-char [start-x start-yNNN
```
+5 -5
View File
@@ -141,7 +141,7 @@ Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em></l
<!-- 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>
<p>There is an <a href="#alternate-code">alternate version</a> which might feel more at home
for vi(m) users in navigation.</p>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
@@ -149,7 +149,7 @@ for vi(m) users in navigation.</p>
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
<p>For more detailed information see <a href="../../bugs.html#1991_buzzard">1991 buzzard 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">./buzzard</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./buzzard</code></pre>
<h2 id="alternate-code">Alternate code:</h2>
<p>This version changes the keys <code>f</code> for forward, <code>l</code> for left and <code>r</code> for right by
default to <code>k</code> for forward, <code>l</code> for right and <code>h</code> for left, which is more
@@ -157,9 +157,9 @@ natural for those who use vi(m). Also one can just hit <code>q</code> followed b
quit the maze. It is problematic to reconfigure the keys except by modifying the
code directly so the keys are not made a <code>-D</code> at the compiler.</p>
<h3 id="alternate-build">Alternate build:</h3>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make alt</code></pre>
<h3 id="alternate-use">Alternate use:</h3>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./buzzard.alt</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./buzzard.alt</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>You will be A-mazed.</p>
<p>You are invited to try to cheat, … if you can figure out how! :-)</p>
@@ -186,7 +186,7 @@ separate physical rows in the maze; a space indicates a corridor,
and any other character is a wall. Tabs are also considered walls,
so make sure to convert tabs to spaces before using it.</p>
<p>Usage:</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">./buzzard</span> [filename [escape-char [start-x start-yNNN</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./buzzard [filename [escape-char [start-x start-yNNN</code></pre>
<p>Filename is the name of the file containing the maze. This
defaults to <code>buzzard.c</code> or rather <code>__FILE__</code>.</p>
<p>Escape-char is the character in the maze that represents the exit.
+3 -3
View File
@@ -1,13 +1,13 @@
## To build:
```sh
```<!---sh-->
make all
```
## To use:
```sh
```<!---sh-->
./cdupont
```
@@ -16,7 +16,7 @@
Why is the following label necessary?
```c
```<!---c-->
sorryfor_this_unused_but_very_needed_label:
```
+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> all</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make all</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">./cdupont</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./cdupont</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>Why is the following label necessary?</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> sorryfor_this_unused_but_very_needed_label<span class="op">:</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> sorryfor_this_unused_but_very_needed_label:</code></pre>
<p>Notice that if you C beautify (cb) or pre-process this program, it
will no longer work correctly, if at all. (go ahead, try it… :-))</p>
<p>NOTE: One should remove the final trailing newline to obtain the
+4 -4
View File
@@ -1,13 +1,13 @@
## To build:
```sh
```<!---sh-->
make all
```
## To use:
```sh
```<!---sh-->
./davidguy ip_address:server.screen
```
@@ -16,7 +16,7 @@ where `ip_address` in an IP address of an X server.
## Try:
```sh
```<!---sh-->
./davidguy 127.0.0.1:0.0
```
@@ -24,7 +24,7 @@ Of course, you may need to supply a more reasonable address. :-)
## Also try:
```sh
```<!---sh-->
cp -f davidguy guydavid
./guydavid 127.0.0.1:0.0
```
+5 -5
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> all</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make all</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">./davidguy</span> ip_address:server.screen</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./davidguy ip_address:server.screen</code></pre>
<p>where <code>ip_address</code> in an IP address of an X server.</p>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./davidguy</span> 127.0.0.1:0.0</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./davidguy 127.0.0.1:0.0</code></pre>
<p>Of course, you may need to supply a more reasonable address. :-)</p>
<h2 id="also-try">Also 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="fu">cp</span> <span class="at">-f</span> davidguy guydavid</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./guydavid</span> 127.0.0.1:0.0</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> cp -f davidguy guydavid
./guydavid 127.0.0.1:0.0</code></pre>
<p>Can you determine why this makes a difference?</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>We permitted this type of entry to win because:</p>
+4 -4
View File
@@ -1,13 +1,13 @@
## To build:
```sh
```<!---sh-->
make all
```
## To use:
```sh
```<!---sh-->
./dds basic_program
./a.out 2>/dev/null
```
@@ -17,7 +17,7 @@
The author suggests trying:
```sh
```<!---sh-->
./dds LANDER.BAS
./a.out
```
@@ -27,7 +27,7 @@ produced? How does `a.c` relate to [LANDER.BAS](LANDER.BAS)?
What happens if you give the program a C program like itself? Try:
```sh
```<!---sh-->
./dds dds.c
```
+6 -6
View File
@@ -141,18 +141,18 @@ Location: <a href="../../location.html#GR">GR</a> - <em>Hellenic Republic</em> (
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> all</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make all</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">./dds</span> basic_program</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./a.out</span> <span class="dv">2</span><span class="op">&gt;</span>/dev/null</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./dds basic_program
./a.out 2&gt;/dev/null</code></pre>
<h2 id="try">Try:</h2>
<p>The author suggests trying:</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">./dds</span> LANDER.BAS</span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./a.out</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./dds LANDER.BAS
./a.out</code></pre>
<p>Notice that a file <code>a.c</code> has been generated. Can you tell how <code>a.c</code> was
produced? How does <code>a.c</code> relate to <a href="LANDER.BAS">LANDER.BAS</a>?</p>
<p>What happens if you give the program a C program like itself? 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">./dds</span> dds.c</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./dds dds.c</code></pre>
<p>You’ll get errors yes but what does the generated file look like? What about
other types of files?</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
+3 -3
View File
@@ -1,20 +1,20 @@
## To build:
```sh
```<!---sh-->
make all
```
## To use:
```sh
```<!---sh-->
echo text | ./fine
```
## Try:
```sh
```<!---sh-->
./try.sh
```
+3 -3
View File
@@ -141,11 +141,11 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> all</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make all</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> text <span class="kw">|</span> <span class="ex">./fine</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> echo text | ./fine</code></pre>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./try.sh</code></pre>
<p>Make sure that you read the last line backwards! Credit goes to <a href="../../authors.html#Brian_Westley">Merlyn LeRoy (Brian
Westley)</a> for that. See his 22 August 1992
<a href="https://groups.google.com/g/rec.puzzles/c/z_xVPMRVBtg/m/lyEYSAeBD4gJ">rec.puzzles
+2 -2
View File
@@ -155,8 +155,8 @@ a winning entry for the past 5 years!</p>
would deny awards to more deserving entries. These categories have not
been eliminated, and will likely be considered in future years.</p>
<p>A number of entries made use of the following C pre-processor feature:</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="pp">#define X define</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> <span class="pp">#</span><span class="er">X foo bar</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> #define X define
#X foo bar</code></pre>
<p>This is not permitted under ANSI C. Some ANSI C compilers do allow this. In
the future, we do not want programs to use this feature. Because this request
was not stated in the <a href="rules.txt">1991 rules</a>, we did not reject entries of this
+6 -6
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make all
```
@@ -11,7 +11,7 @@ that's fewer than the original program.
## To use:
```sh
```<!---sh-->
./rince
```
@@ -30,7 +30,7 @@ The author set the maximum number of moves to 484.
### Alternate build:
```sh
```<!---sh-->
make alt
```
@@ -41,7 +41,7 @@ configurable maximum number of moves allowed, defaulting to the entry's max,
To reconfigure the maximum number of moves to 700:
```sh
```<!---sh-->
make clobber MAXMOVES=700 alt
```
@@ -50,13 +50,13 @@ To reconfigure the maximum number of moves to 700:
To run the first alt version:
```sh
```<!---sh-->
./rince.alt
```
To run the second alt version:
```sh
```<!---sh-->
./rince.alt2
```
+6 -6
View File
@@ -141,12 +141,12 @@ Location: <a href="../../location.html#GB">GB</a> - <em>United Kingdom of Great
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> all</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make all</code></pre>
<p>There are two <a href="#alternate-code">alternate versions</a> which allow one to not be
restricted in movements or to change the maximum number of movements, even if
that’s fewer than the original program.</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">./rince</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./rince</code></pre>
<h2 id="alternate-code">Alternate code:</h2>
<p>The first alternate version, <a href="rince.alt.c">rince.alt.c</a>, disables a maximum move
count so that anyone with enough patience and time can complete the puzzle,
@@ -156,18 +156,18 @@ reconfigure at compilation the maximum number of moves, even if that is lowering
the count.</p>
<p>The author set the maximum number of moves to 484.</p>
<h3 id="alternate-build">Alternate build:</h3>
<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> alt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make alt</code></pre>
<p>This will build both alt versions where the first one, <code>rince.alt</code>, has no
restrictions in the number of movements and the second one, <code>rince.alt2</code>, has a
configurable maximum number of moves allowed, defaulting to the entry’s max,
484.</p>
<p>To reconfigure the maximum number of moves to 700:</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 MAXMOVES=700 alt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make clobber MAXMOVES=700 alt</code></pre>
<h3 id="alternate-use">Alternate use:</h3>
<p>To run the first alt version:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./rince.alt</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./rince.alt</code></pre>
<p>To run the second alt version:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./rince.alt2</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./rince.alt2</code></pre>
<p>Can you figure out how to make the two alternate versions equivalent in
functionality without modifying the code? That is can you make the second alt
version end up allowing any number of movements?</p>
+9 -9
View File
@@ -1,6 +1,6 @@
## To build:
```sh
```<!---sh-->
make all
```
@@ -27,7 +27,7 @@ for the interested. See the [try](#try) section if you just want to play.
Make and then run as follows:
```sh
```<!---sh-->
./westley [move_location] | tee nextmove.c
```
@@ -43,7 +43,7 @@ a move on a tic-tac-toe board:
If you omit `move_location`, then the computer moves first. For your
next move, recompile `nextmove.c` and play it again:
```sh
```<!---sh-->
make nextmove
./nextmove move_location | tee nextmove.c
```
@@ -54,7 +54,7 @@ next move, recompile `nextmove.c` and play it again:
We have provided the shell script, [ttt](ttt.sh), to make it easier to play the
game:
```sh
```<!---sh-->
make ttt
./ttt [first_move] # <- omit first arg to have it move first
./ttt next_move
@@ -64,14 +64,14 @@ The shell script determines when the game is over, and automatically replaces
`merlyn.c` (copied from [westley.c](westley.c) with an improved version after a
loss). The [ttt](ttt.sh) script has two other modes:
```sh
```<!---sh-->
./ttt quitgame # cancel any game in progress, revert to merlyn.c
./ttt clobber # remove all game files, revert to original source
```
For example here is a potentially losing game:
```sh
```<!---sh-->
./ttt 1
./ttt 4
./ttt 6
@@ -80,7 +80,7 @@ For example here is a potentially losing game:
The final might look like:
```c
```<!---c-->
a(X){/*/X=- a(X){/*/X=-
X -1;F;X=- -1;F;X=-
-1;F;}/*/ -1;F;}/*/
@@ -123,7 +123,7 @@ can lose if you cheat. That's supposed to happen. Can you win any other time?
### Alternate build:
```sh
```<!---sh-->
make alt
```
@@ -194,7 +194,7 @@ function as `a()`, `b()`, or `c()`. After each function is called, the global
variables `X` and `O` contain bitmasks of where all the `X`s and `O`s are placed.
The statement:
```c
```<!---c-->
X=- <char> -1;
```
+42 -42
View File
@@ -141,7 +141,7 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h2 id="to-build">To build:</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> all</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make all</code></pre>
<p>There is an <a href="#alternate-code">alternate version</a> that is supposed to win all the
time.</p>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
@@ -152,7 +152,7 @@ time.</p>
<p>NOTE: we have provided a script to perform the below procedure which we include
for the interested. See the <a href="#try">try</a> section if you just want to play.</p>
<p>Make and then run as follows:</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">./westley</span> <span class="pp">[</span><span class="ss">move_location</span><span class="pp">]</span> <span class="kw">|</span> <span class="fu">tee</span> nextmove.c</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./westley [move_location] | tee nextmove.c</code></pre>
<p>where the <code>move_location</code> is a digit from 1 to 9 that represents
a move on a tic-tac-toe board:</p>
<pre><code> 1 2 3
@@ -160,59 +160,59 @@ a move on a tic-tac-toe board:</p>
7 8 9</code></pre>
<p>If you omit <code>move_location</code>, then the computer moves first. For your
next move, recompile <code>nextmove.c</code> and play it again:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> nextmove</span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./nextmove</span> move_location <span class="kw">|</span> <span class="fu">tee</span> nextmove.c</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make nextmove
./nextmove move_location | tee nextmove.c</code></pre>
<h2 id="try">Try:</h2>
<p>We have provided the shell script, <a href="ttt.sh">ttt</a>, to make it easier to play the
game:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> ttt</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./ttt</span> <span class="pp">[</span><span class="ss">first_move</span><span class="pp">]</span> <span class="co"># &lt;- omit first arg to have it move first</span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./ttt</span> next_move</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make ttt
./ttt [first_move] # &lt;- omit first arg to have it move first
./ttt next_move</code></pre>
<p>The shell script determines when the game is over, and automatically replaces
<code>merlyn.c</code> (copied from <a href="westley.c">westley.c</a> with an improved version after a
loss). The <a href="ttt.sh">ttt</a> script has two other modes:</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">./ttt</span> quitgame <span class="co"># cancel any game in progress, revert to merlyn.c</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./ttt</span> clobber <span class="co"># remove all game files, revert to original source</span></span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./ttt quitgame # cancel any game in progress, revert to merlyn.c
./ttt clobber # remove all game files, revert to original source</code></pre>
<p>For example here is a potentially losing game:</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">./ttt</span> 1</span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./ttt</span> 4</span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./ttt</span> 6</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> ./ttt 1
./ttt 4
./ttt 6</code></pre>
<p>The final might look like:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> a<span class="op">(</span>X<span class="op">){</span><span class="co">/*/X=- a(X){/*/</span>X<span class="op">=-</span></span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> X <span class="op">-</span><span class="dv">1</span><span class="op">;</span>F<span class="op">;</span>X<span class="op">=-</span> <span class="op">-</span><span class="dv">1</span><span class="op">;</span>F<span class="op">;</span>X<span class="op">=-</span></span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="op">-</span><span class="dv">1</span><span class="op">;</span>F<span class="op">;}</span><span class="co">/*/ -1;F;}/*/</span></span>
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a> <span class="dt">char</span> z<span class="op">[][</span><span class="dv">100</span><span class="op">]={</span><span class="st">&quot;char z[][100]={&quot;</span><span class="op">,</span><span class="st">&quot;a(X){/*/X=-&quot;</span><span class="op">,</span><span class="st">&quot;-1;F;X=-&quot;</span><span class="op">,</span><span class="st">&quot;-1;F;}/*/&quot;</span><span class="op">,</span><span class="st">&quot;1999999999 :-) &quot;</span><span class="op">,</span></span>
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;int q,i,j,k,X,O=0,H;S(x)int*x;{X+=X;O+=O;*x+1?*x+2||X++:O++;*x=1;}L(n){for(*&quot;</span><span class="op">,</span></span>
<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;z[i=1]=n+97;i&lt;4;i++)M(256),s(i),M(128),s(i),M(64),N;X*=8;O*=8;}s(R){char*r=z&quot;</span><span class="op">,</span></span>
<span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;[R];for(q&amp;&amp;Q;*r;)P(*r++);q&amp;&amp;(Q,P(44));}M(m){P(9);i-2||P(X&amp;m?88:O&amp;m?48:32);P(&quot;</span><span class="op">,</span></span>
<span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;9);}y(A){for(j=8;j;)~A&amp;w[--j]||(q=0);}e(W,Z){for(i-=i*q;i&lt;9&amp;&amp;q;)y(W|(1&lt;&lt;i++&amp;&quot;</span><span class="op">,</span></span>
<span id="cb9-9"><a href="#cb9-9" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;~Z));}R(){for(k=J[*J-48]-40;k;)e(w[k--],X|O);}main(u,v)char**v;{a(q=1);b(1);&quot;</span><span class="op">,</span></span>
<span id="cb9-10"><a href="#cb9-10" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;c(1);*J=--u?O?*J:*v[1]:53;X|=u&lt;&lt;57-*v[u];y(X);K=40+q;q?e(O,X),q&amp;&amp;(K=&#39;|&#39;),e(X&quot;</span><span class="op">,</span></span>
<span id="cb9-11"><a href="#cb9-11" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;,O),R(),O|=1&lt;&lt;--i:J[*J-48+(X=O=0)]--;L(q=0);for(s(i=0);q=i&lt;12;)s(i++),i&gt;4&amp;&amp;N&quot;</span><span class="op">,</span></span>
<span id="cb9-12"><a href="#cb9-12" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;;s(q=12);P(48);P(&#39;}&#39;);P(59);N;q=0;L(1);for(i=5;i&lt;13;)s(i++),N;L(2);}&quot;</span><span class="op">,</span><span class="dv">0</span><span class="op">};</span></span>
<span id="cb9-13"><a href="#cb9-13" aria-hidden="true" tabindex="-1"></a> b<span class="op">(</span>X<span class="op">){</span><span class="co">/*/X=- b(X){/*/</span>X<span class="op">=-</span></span>
<span id="cb9-14"><a href="#cb9-14" aria-hidden="true" tabindex="-1"></a> X <span class="op">-</span><span class="dv">1</span><span class="op">;</span>F<span class="op">;</span>X<span class="op">=-</span> <span class="op">-</span><span class="dv">1</span><span class="op">;</span>F<span class="op">;</span>X<span class="op">=-</span> X</span>
<span id="cb9-15"><a href="#cb9-15" aria-hidden="true" tabindex="-1"></a> <span class="op">-</span><span class="dv">1</span><span class="op">;</span>F<span class="op">;}</span><span class="co">/*/ -1;F;}/*/</span></span>
<span id="cb9-16"><a href="#cb9-16" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span> q<span class="op">,</span>i<span class="op">,</span>j<span class="op">,</span>k<span class="op">,</span>X<span class="op">,</span>O<span class="op">=</span><span class="dv">0</span><span class="op">,</span>H<span class="op">;</span>S<span class="op">(</span>x<span class="op">)</span><span class="dt">int</span><span class="op">*</span>x<span class="op">;{</span>X<span class="op">+=</span>X<span class="op">;</span>O<span class="op">+=</span>O<span class="op">;*</span>x<span class="op">+</span><span class="dv">1</span><span class="op">?*</span>x<span class="op">+</span><span class="dv">2</span><span class="op">||</span>X<span class="op">++:</span>O<span class="op">++;*</span>x<span class="op">=</span><span class="dv">1</span><span class="op">;}</span>L<span class="op">(</span>n<span class="op">){</span><span class="cf">for</span><span class="op">(*</span></span>
<span id="cb9-17"><a href="#cb9-17" aria-hidden="true" tabindex="-1"></a> z<span class="op">[</span>i<span class="op">=</span><span class="dv">1</span><span class="op">]=</span>n<span class="op">+</span><span class="dv">97</span><span class="op">;</span>i<span class="op">&lt;</span><span class="dv">4</span><span class="op">;</span>i<span class="op">++)</span>M<span class="op">(</span><span class="dv">256</span><span class="op">),</span>s<span class="op">(</span>i<span class="op">),</span>M<span class="op">(</span><span class="dv">128</span><span class="op">),</span>s<span class="op">(</span>i<span class="op">),</span>M<span class="op">(</span><span class="dv">64</span><span class="op">),</span>N<span class="op">;</span>X<span class="op">*=</span><span class="dv">8</span><span class="op">;</span>O<span class="op">*=</span><span class="dv">8</span><span class="op">;}</span>s<span class="op">(</span>R<span class="op">){</span><span class="dt">char</span><span class="op">*</span>r<span class="op">=</span>z</span>
<span id="cb9-18"><a href="#cb9-18" aria-hidden="true" tabindex="-1"></a> <span class="op">[</span>R<span class="op">];</span><span class="cf">for</span><span class="op">(</span>q<span class="op">&amp;&amp;</span>Q<span class="op">;*</span>r<span class="op">;)</span>P<span class="op">(*</span>r<span class="op">++);</span>q<span class="op">&amp;&amp;(</span>Q<span class="op">,</span>P<span class="op">(</span><span class="dv">44</span><span class="op">));}</span>M<span class="op">(</span>m<span class="op">){</span>P<span class="op">(</span><span class="dv">9</span><span class="op">);</span>i<span class="op">-</span><span class="dv">2</span><span class="op">||</span>P<span class="op">(</span>X<span class="op">&amp;</span>m<span class="op">?</span><span class="dv">88</span><span class="op">:</span>O<span class="op">&amp;</span>m<span class="op">?</span><span class="dv">48</span><span class="op">:</span><span class="dv">32</span><span class="op">);</span>P<span class="op">(</span></span>
<span id="cb9-19"><a href="#cb9-19" aria-hidden="true" tabindex="-1"></a> <span class="dv">9</span><span class="op">);}</span>y<span class="op">(</span>A<span class="op">){</span><span class="cf">for</span><span class="op">(</span>j<span class="op">=</span><span class="dv">8</span><span class="op">;</span>j<span class="op">;)~</span>A<span class="op">&amp;</span>w<span class="op">[--</span>j<span class="op">]||(</span>q<span class="op">=</span><span class="dv">0</span><span class="op">);}</span>e<span class="op">(</span>W<span class="op">,</span>Z<span class="op">){</span><span class="cf">for</span><span class="op">(</span>i<span class="op">-=</span>i<span class="op">*</span>q<span class="op">;</span>i<span class="op">&lt;</span><span class="dv">9</span><span class="op">&amp;&amp;</span>q<span class="op">;)</span>y<span class="op">(</span>W<span class="op">|(</span><span class="dv">1</span><span class="op">&lt;&lt;</span>i<span class="op">++&amp;</span></span>
<span id="cb9-20"><a href="#cb9-20" aria-hidden="true" tabindex="-1"></a> <span class="op">~</span>Z<span class="op">));}</span>R<span class="op">(){</span><span class="cf">for</span><span class="op">(</span>k<span class="op">=</span>J<span class="op">[*</span>J<span class="op">-</span><span class="dv">48</span><span class="op">]-</span><span class="dv">40</span><span class="op">;</span>k<span class="op">;)</span>e<span class="op">(</span>w<span class="op">[</span>k<span class="op">--],</span>X<span class="op">|</span>O<span class="op">);}</span>main<span class="op">(</span>u<span class="op">,</span>v<span class="op">)</span><span class="dt">char</span><span class="op">**</span>v<span class="op">;{</span>a<span class="op">(</span>q<span class="op">=</span><span class="dv">1</span><span class="op">);</span>b<span class="op">(</span><span class="dv">1</span><span class="op">);</span></span>
<span id="cb9-21"><a href="#cb9-21" aria-hidden="true" tabindex="-1"></a> c<span class="op">(</span><span class="dv">1</span><span class="op">);*</span>J<span class="op">=--</span>u<span class="op">?</span>O<span class="op">?*</span>J<span class="op">:*</span>v<span class="op">[</span><span class="dv">1</span><span class="op">]:</span><span class="dv">53</span><span class="op">;</span>X<span class="op">|=</span>u<span class="op">&lt;&lt;</span><span class="dv">57</span><span class="op">-*</span>v<span class="op">[</span>u<span class="op">];</span>y<span class="op">(</span>X<span class="op">);</span>K<span class="op">=</span><span class="dv">40</span><span class="op">+</span>q<span class="op">;</span>q<span class="op">?</span>e<span class="op">(</span>O<span class="op">,</span>X<span class="op">),</span>q<span class="op">&amp;&amp;(</span>K<span class="op">=</span><span class="ch">&#39;|&#39;</span><span class="op">),</span>e<span class="op">(</span>X</span>
<span id="cb9-22"><a href="#cb9-22" aria-hidden="true" tabindex="-1"></a> <span class="op">,</span>O<span class="op">),</span>R<span class="op">(),</span>O<span class="op">|=</span><span class="dv">1</span><span class="op">&lt;&lt;--</span>i<span class="op">:</span>J<span class="op">[*</span>J<span class="op">-</span><span class="dv">48</span><span class="op">+(</span>X<span class="op">=</span>O<span class="op">=</span><span class="dv">0</span><span class="op">)]--;</span>L<span class="op">(</span>q<span class="op">=</span><span class="dv">0</span><span class="op">);</span><span class="cf">for</span><span class="op">(</span>s<span class="op">(</span>i<span class="op">=</span><span class="dv">0</span><span class="op">);</span>q<span class="op">=</span>i<span class="op">&lt;</span><span class="dv">12</span><span class="op">;)</span>s<span class="op">(</span>i<span class="op">++),</span>i<span class="op">&gt;</span><span class="dv">4</span><span class="op">&amp;&amp;</span>N</span>
<span id="cb9-23"><a href="#cb9-23" aria-hidden="true" tabindex="-1"></a> <span class="op">;</span>s<span class="op">(</span>q<span class="op">=</span><span class="dv">12</span><span class="op">);</span>P<span class="op">(</span><span class="dv">48</span><span class="op">);</span>P<span class="op">(</span><span class="ch">&#39;}&#39;</span><span class="op">);</span>P<span class="op">(</span><span class="dv">59</span><span class="op">);</span>N<span class="op">;</span>q<span class="op">=</span><span class="dv">0</span><span class="op">;</span>L<span class="op">(</span><span class="dv">1</span><span class="op">);</span><span class="cf">for</span><span class="op">(</span>i<span class="op">=</span><span class="dv">5</span><span class="op">;</span>i<span class="op">&lt;</span><span class="dv">13</span><span class="op">;)</span>s<span class="op">(</span>i<span class="op">++),</span>N<span class="op">;</span>L<span class="op">(</span><span class="dv">2</span><span class="op">);}</span></span>
<span id="cb9-24"><a href="#cb9-24" aria-hidden="true" tabindex="-1"></a> c<span class="op">(</span>X<span class="op">){</span><span class="co">/*/X=- c(X){/*/</span>X<span class="op">=-</span></span>
<span id="cb9-25"><a href="#cb9-25" aria-hidden="true" tabindex="-1"></a> <span class="dv">0</span> <span class="op">-</span><span class="dv">1</span><span class="op">;</span>F<span class="op">;</span>X<span class="op">=-</span> <span class="dv">0</span> <span class="op">-</span><span class="dv">1</span><span class="op">;</span>F<span class="op">;</span>X<span class="op">=-</span> <span class="dv">0</span></span>
<span id="cb9-26"><a href="#cb9-26" aria-hidden="true" tabindex="-1"></a> <span class="op">-</span><span class="dv">1</span><span class="op">;</span>F<span class="op">;}</span><span class="co">/*/ -1;F;}/*/</span></span>
<span id="cb9-27"><a href="#cb9-27" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb9-28"><a href="#cb9-28" aria-hidden="true" tabindex="-1"></a> ttt<span class="op">:</span> I win<span class="op">!</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> a(X){/*/X=- a(X){/*/X=-
X -1;F;X=- -1;F;X=-
-1;F;}/*/ -1;F;}/*/
char z[][100]={&quot;char z[][100]={&quot;,&quot;a(X){/*/X=-&quot;,&quot;-1;F;X=-&quot;,&quot;-1;F;}/*/&quot;,&quot;1999999999 :-) &quot;,
&quot;int q,i,j,k,X,O=0,H;S(x)int*x;{X+=X;O+=O;*x+1?*x+2||X++:O++;*x=1;}L(n){for(*&quot;,
&quot;z[i=1]=n+97;i&lt;4;i++)M(256),s(i),M(128),s(i),M(64),N;X*=8;O*=8;}s(R){char*r=z&quot;,
&quot;[R];for(q&amp;&amp;Q;*r;)P(*r++);q&amp;&amp;(Q,P(44));}M(m){P(9);i-2||P(X&amp;m?88:O&amp;m?48:32);P(&quot;,
&quot;9);}y(A){for(j=8;j;)~A&amp;w[--j]||(q=0);}e(W,Z){for(i-=i*q;i&lt;9&amp;&amp;q;)y(W|(1&lt;&lt;i++&amp;&quot;,
&quot;~Z));}R(){for(k=J[*J-48]-40;k;)e(w[k--],X|O);}main(u,v)char**v;{a(q=1);b(1);&quot;,
&quot;c(1);*J=--u?O?*J:*v[1]:53;X|=u&lt;&lt;57-*v[u];y(X);K=40+q;q?e(O,X),q&amp;&amp;(K=&#39;|&#39;),e(X&quot;,
&quot;,O),R(),O|=1&lt;&lt;--i:J[*J-48+(X=O=0)]--;L(q=0);for(s(i=0);q=i&lt;12;)s(i++),i&gt;4&amp;&amp;N&quot;,
&quot;;s(q=12);P(48);P(&#39;}&#39;);P(59);N;q=0;L(1);for(i=5;i&lt;13;)s(i++),N;L(2);}&quot;,0};
b(X){/*/X=- b(X){/*/X=-
X -1;F;X=- -1;F;X=- X
-1;F;}/*/ -1;F;}/*/
int q,i,j,k,X,O=0,H;S(x)int*x;{X+=X;O+=O;*x+1?*x+2||X++:O++;*x=1;}L(n){for(*
z[i=1]=n+97;i&lt;4;i++)M(256),s(i),M(128),s(i),M(64),N;X*=8;O*=8;}s(R){char*r=z
[R];for(q&amp;&amp;Q;*r;)P(*r++);q&amp;&amp;(Q,P(44));}M(m){P(9);i-2||P(X&amp;m?88:O&amp;m?48:32);P(
9);}y(A){for(j=8;j;)~A&amp;w[--j]||(q=0);}e(W,Z){for(i-=i*q;i&lt;9&amp;&amp;q;)y(W|(1&lt;&lt;i++&amp;
~Z));}R(){for(k=J[*J-48]-40;k;)e(w[k--],X|O);}main(u,v)char**v;{a(q=1);b(1);
c(1);*J=--u?O?*J:*v[1]:53;X|=u&lt;&lt;57-*v[u];y(X);K=40+q;q?e(O,X),q&amp;&amp;(K=&#39;|&#39;),e(X
,O),R(),O|=1&lt;&lt;--i:J[*J-48+(X=O=0)]--;L(q=0);for(s(i=0);q=i&lt;12;)s(i++),i&gt;4&amp;&amp;N
;s(q=12);P(48);P(&#39;}&#39;);P(59);N;q=0;L(1);for(i=5;i&lt;13;)s(i++),N;L(2);}
c(X){/*/X=- c(X){/*/X=-
0 -1;F;X=- 0 -1;F;X=- 0
-1;F;}/*/ -1;F;}/*/
ttt: I win!</code></pre>
<p>Redirects stderr to <code>/dev/null</code> by default. If you need errors or warnings use
<code>-e</code>.</p>
<h2 id="alternate-code">Alternate code:</h2>
<p>This version is based on the author’s remarks. It is not supposed to lose but it
can lose if you cheat. That’s supposed to happen. Can you win any other time?</p>
<h3 id="alternate-build">Alternate build:</h3>
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
<pre class="&lt;!---sh--&gt;"><code> make alt</code></pre>
<h3 id="alternate-use">Alternate use:</h3>
<p>Rather than use <code>ttt</code> try the script <code>ttt.alt</code> instead.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
@@ -259,7 +259,7 @@ longer loses games.</p>
function as <code>a()</code>, <code>b()</code>, or <code>c()</code>. After each function is called, the global
variables <code>X</code> and <code>O</code> contain bitmasks of where all the <code>X</code>s and <code>O</code>s are placed.
The statement:</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> X<span class="op">=-</span> <span class="op">&lt;</span><span class="dt">char</span><span class="op">&gt;</span> <span class="op">-</span><span class="dv">1</span><span class="op">;</span></span></code></pre></div>
<pre class="&lt;!---c--&gt;"><code> X=- &lt;char&gt; -1;</code></pre>
<p>evaluates to <code>1</code>, <code>-1</code>, or <code>-2</code> when <code>X</code> is <code>1</code> and <code>&lt;char&gt;</code> is one of <code>"X"</code>,
<code>"0"</code>, or <code>" "</code>. The function <code>S(&amp;X)</code> sets the appropriate bits in (global
vars) <code>X</code> and <code>O</code> and resets the value of <code>&amp;X</code> to <code>1</code>. This is how the current