improved indentation and whitespace for markdown code blocks

All code blocks in markdown have been intended by at least 4 spaces.

We add `--tab-stop=8` to all `pandoc(1)` executions in order to set
a better tab stop indentation, especially for tab intended code blocks.

Changed `bin/pandoc-wrapper.sh` VERSION from "1.5.3 2024-03-26"
to "1.6 2024-03-31".

Fixed `1991/brnstnd/sorta.README.md` so that the sorta code
is code blocks.

Removed unneeded paragraph group in copyright in `inc/footer.default.html`.

Fixed excess whitespace after list Author on entry `index.html` page.

Changed `bin/output-index-author.sh` VERSION from "1.5.2 2024-03-26"
to "1.6 2024-03-31".

Performed `make www` to perform the above and test under macOS.

TODO: Fix the problem of the initial line of code being extra intended.
TODO: Fix excess whitespace around code that is inline.
This commit is contained in:
Landon Curt Noll committed 2024-04-01 04:48:48 -07:00
1 parent b84c27ce02
commit a996f8d2b8
734 files changed
+16723 -16963

No files matched your search

+8 -8
View File
@@ -36,8 +36,8 @@ been eliminated, and will likely be considered in future years.
A number of entries made use of the following C pre-processor feature:
```c
#define X define
#X foo bar
#define X define
#X foo bar
```
This is not permitted under ANSI C. Some ANSI C compilers do allow this. In
@@ -61,10 +61,10 @@ In order to encourage more 'normal' looking C programs, we are considering
the following change to the maximum size rule:
```
Your source, not counting any <space>, <tab>, and a <newline> character,
and not counting any ';', '{' and '}' character followed by a <newline>
character, must be 1536 bytes or less. The entire source, counting all
characters, be 4096 bytes or less.
Your source, not counting any <space>, <tab>, and a <newline> character,
and not counting any ';', '{' and '}' character followed by a <newline>
character, must be 1536 bytes or less. The entire source, counting all
characters, be 4096 bytes or less.
```
Some thought has been given to adding some C++ categories, however this
@@ -80,8 +80,8 @@ Also include anything else that you would like to see in future contests.
Send such email to:
```
...!{sun,pacbell,uunet,pyramid}!hoptoad!judges
judges@toad.com
...!{sun,pacbell,uunet,pyramid}!hoptoad!judges
judges@toad.com
```
+7 -7
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make all
make all
```
There is an [alternate version](#alternate-code) that might feel a bit more
@@ -11,7 +11,7 @@ familiar to vi(m) users.
## To use:
```sh
./ant some_file
./ant some_file
```
NOTE: the file must already exist and not specifying any arg will make the
@@ -21,13 +21,13 @@ program exit without doing anything.
## Try:
```sh
make hill
./ant hill
make hill
./ant hill
```
```sh
make mole
./ant mole
make mole
./ant mole
```
@@ -47,7 +47,7 @@ rest was unchanged.
### Alternate build:
```sh
make alt
make alt
```
+8 -9
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Anthony_C_Howe">Anthony C. Howe</a><br>
Location: <a href="../../location.html#CA">CA</a> - <em>Canada</em>
<br><br></li>
Location: <a href="../../location.html#CA">CA</a> - <em>Canada</em></li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,18 +141,18 @@ Location: <a href="../../location.html#CA">CA</a> - <em>Canada</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>
<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>
<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>
<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>
<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>
<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>
<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
@@ -164,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>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
<h3 id="alternate-use">Alternate use:</h3>
<p>Use <code>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>
+3 -3
View File
@@ -1,16 +1,16 @@
## To build:
```sh
make all
make all
```
## Try:
```sh
./try.sh
./try.sh
./sorta < sorta.itailrec
./sorta < sorta.itailrec
```
+4 -5
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Daniel_J_Bernstein">Daniel J. Bernstein</a><br>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
<br><br></li>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,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>
<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>
<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>
<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>
<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>
<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
+6 -6
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make all
make all
```
There is an [alternate version](#alternate-code) which might feel more at home
@@ -13,7 +13,7 @@ for vi(m) users in navigation.
The current status of this entry is:
```
STATUS: INABIAF - please **DO NOT** fix
STATUS: INABIAF - please **DO NOT** fix
```
For more detailed information see [1991 buzzard bugs](../../bugs.html#1991_buzzard).
@@ -22,7 +22,7 @@ For more detailed information see [1991 buzzard bugs](../../bugs.html#1991_buzza
## To use:
```sh
./buzzard
./buzzard
```
@@ -38,14 +38,14 @@ code directly so the keys are not made a `-D` at the compiler.
### Alternate build:
```sh
make alt
make alt
```
### Alternate use:
```sh
./buzzard.alt
./buzzard.alt
```
@@ -90,7 +90,7 @@ so make sure to convert tabs to spaces before using it.
Usage:
```sh
./buzzard [filename [escape-char [start-x start-yNNN
./buzzard [filename [escape-char [start-x start-yNNN
```
Filename is the name of the file containing the maze. This
+7 -8
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Sean_Barrett">Sean Barrett</a><br>
Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em>
<br><br></li>
Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</em></li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,15 +141,15 @@ Location: <a href="../../location.html#ZZ">ZZ</a> - <em>Unknown location</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>
<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>
<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>
<p>The current status of this entry is:</p>
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
<p>For more detailed information see <a href="../../bugs.html#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>
<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>
<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
@@ -158,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>
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
<h3 id="alternate-use">Alternate use:</h3>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./buzzard.alt</span></span></code></pre></div>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./buzzard.alt</span></span></code></pre></div>
<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>
@@ -187,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>
<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>
<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,14 +1,14 @@
## To build:
```sh
make all
make all
```
## To use:
```sh
./cdupont
./cdupont
```
@@ -17,7 +17,7 @@ make all
Why is the following label necessary?
```c
sorryfor_this_unused_but_very_needed_label:
sorryfor_this_unused_but_very_needed_label:
```
Notice that if you C beautify (cb) or pre-process this program, it
+4 -5
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Christian_Dupont">Christian Dupont</a><br>
Location: <a href="../../location.html#FR">FR</a> - <em>French Republic</em> (<em>France</em>)
<br><br></li>
Location: <a href="../../location.html#FR">FR</a> - <em>French Republic</em> (<em>France</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,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>
<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>
<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>
<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>
<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>
<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>
<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
+5 -5
View File
@@ -1,14 +1,14 @@
## To build:
```sh
make all
make all
```
## To use:
```sh
./davidguy ip_address:server.screen
./davidguy ip_address:server.screen
```
where `ip_address` in an IP address of an X server.
@@ -17,7 +17,7 @@ where `ip_address` in an IP address of an X server.
## Try:
```sh
./davidguy 127.0.0.1:0.0
./davidguy 127.0.0.1:0.0
```
Of course, you may need to supply a more reasonable address. :-)
@@ -25,8 +25,8 @@ Of course, you may need to supply a more reasonable address. :-)
## Also try:
```sh
cp -f davidguy guydavid
./guydavid 127.0.0.1:0.0
cp -f davidguy guydavid
./guydavid 127.0.0.1:0.0
```
Can you determine why this makes a difference?
+6 -7
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#David_Applegate">David Applegate</a><br>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
<br><br></li>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
+6 -6
View File
@@ -1,15 +1,15 @@
## To build:
```sh
make all
make all
```
## To use:
```sh
./dds basic_program
./a.out 2>/dev/null
./dds basic_program
./a.out 2>/dev/null
```
@@ -18,8 +18,8 @@ make all
The author suggests trying:
```sh
./dds LANDER.BAS
./a.out
./dds LANDER.BAS
./a.out
```
Notice that a file `a.c` has been generated. Can you tell how `a.c` was
@@ -28,7 +28,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
./dds dds.c
./dds dds.c
```
You'll get errors yes but what does the generated file look like? What about
+7 -8
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Diomidis_Spinellis">Diomidis Spinellis</a><br>
Location: <a href="../../location.html#GR">GR</a> - <em>Hellenic Republic</em> (<em>Greece</em>)
<br><br></li>
Location: <a href="../../location.html#GR">GR</a> - <em>Hellenic Republic</em> (<em>Greece</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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,21 +1,21 @@
## To build:
```sh
make all
make all
```
## To use:
```sh
echo text | ./fine
echo text | ./fine
```
## Try:
```sh
./try.sh
./try.sh
```
Make sure that you read the last line backwards! Credit goes to [Merlyn LeRoy (Brian
+4 -5
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Thomas_A_Fine">Thomas A. Fine</a><br>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
<br><br></li>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,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>
<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>
<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>
<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>
<h2 id="try">Try:</h2>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
<p>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
+8 -8
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>
<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>
<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
@@ -173,10 +173,10 @@ specific display hardware, or a specific user interface (<code>Openl**k</code>,
explanation of our viewpoint in next year’s rules.</p>
<p>In order to encourage more ‘normal’ looking C programs, we are considering
the following change to the maximum size rule:</p>
<pre><code>Your source, not counting any &lt;space&gt;, &lt;tab&gt;, and a &lt;newline&gt; character,
and not counting any &#39;;&#39;, &#39;{&#39; and &#39;}&#39; character followed by a &lt;newline&gt;
character, must be 1536 bytes or less. The entire source, counting all
characters, be 4096 bytes or less.</code></pre>
<pre><code> Your source, not counting any &lt;space&gt;, &lt;tab&gt;, and a &lt;newline&gt; character,
and not counting any &#39;;&#39;, &#39;{&#39; and &#39;}&#39; character followed by a &lt;newline&gt;
character, must be 1536 bytes or less. The entire source, counting all
characters, be 4096 bytes or less.</code></pre>
<p>Some thought has been given to adding some C++ categories, however this
is not likely to happen soon. We are waiting until C++ compilers become
common place on a wide number of systems. We also need time to brace
@@ -186,8 +186,8 @@ We may fine tune the rules to reflect the some ideas above.</p>
<p>Please send us comments and suggestions what we have expressed above.
Also include anything else that you would like to see in future contests.
Send such email to:</p>
<pre><code>...!{sun,pacbell,uunet,pyramid}!hoptoad!judges
judges@toad.com</code></pre>
<pre><code> ...!{sun,pacbell,uunet,pyramid}!hoptoad!judges
judges@toad.com</code></pre>
<h2 id="final-comments">Final Comments</h2>
<p><strong>IMPORTANT NOTE</strong>: The email addresses found above are for historical
purposes only, and should not be used today. See
+23 -23
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make all
make all
```
There are two [alternate versions](#alternate-code) which allow one to not be
@@ -12,7 +12,7 @@ that's fewer than the original program.
## To use:
```sh
./rince
./rince
```
@@ -31,7 +31,7 @@ The author set the maximum number of moves to 484.
### Alternate build:
```sh
make alt
make alt
```
This will build both alt versions where the first one, `rince.alt`, has no
@@ -42,7 +42,7 @@ configurable maximum number of moves allowed, defaulting to the entry's max,
To reconfigure the maximum number of moves to 700:
```sh
make clobber MAXMOVES=700 alt
make clobber MAXMOVES=700 alt
```
@@ -51,13 +51,13 @@ make clobber MAXMOVES=700 alt
To run the first alt version:
```sh
./rince.alt
./rince.alt
```
To run the second alt version:
```sh
./rince.alt2
./rince.alt2
```
Can you figure out how to make the two alternate versions equivalent in
@@ -83,23 +83,23 @@ enjoyment high.
Key to map:
```
|
###### | | | /\ /--\ ==| /\ | | Directonal keys
###### Solid Wall | ----|| \/ /\ ||---- (unlock doors of
###### | \/ ==| \--/ \/ the same direction)
|\
| << >> Doors. Unlocked by
Blank space | << vvvvvv ^^^^^^ >> the above keys.
| << >>
|\
___ | o__O\ O__O ^__^ /O__o\
/ \ 'Crushable' | \___/ /----\ /----\ \___/ The four sprites for
\___/ boulder | _/_\ _/ \_ _/ \_ /_\_ your character :-)
|\
___ uncrushable | /\ Diamonds. They can either be found lying
/@@@\ boulder | < > around (if only!) or manufacture by pushing
\@@@/ | \/ two 'crushable' rocks together.
|
|
###### | | | /\ /--\ ==| /\ | | Directonal keys
###### Solid Wall | ----|| \/ /\ ||---- (unlock doors of
###### | \/ ==| \--/ \/ the same direction)
|\
| << >> Doors. Unlocked by
Blank space | << vvvvvv ^^^^^^ >> the above keys.
| << >>
|\
___ | o__O\ O__O ^__^ /O__o\
/ \ 'Crushable' | \___/ /----\ /----\ \___/ The four sprites for
\___/ boulder | _/_\ _/ \_ _/ \_ /_\_ your character :-)
|\
___ uncrushable | /\ Diamonds. They can either be found lying
/@@@\ boulder | < > around (if only!) or manufacture by pushing
\@@@/ | \/ two 'crushable' rocks together.
|
```
The general idea of the game is to collect all the diamonds. This must
+24 -25
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#James_Bonfield">James Bonfield</a><br>
Location: <a href="../../location.html#GB">GB</a> - <em>United Kingdom of Great Britain and Northern Ireland</em> (<em>United Kingdom</em>)
<br><br></li>
Location: <a href="../../location.html#GB">GB</a> - <em>United Kingdom of Great Britain and Northern Ireland</em> (<em>United Kingdom</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,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>
<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>
<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>
<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>
<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,
@@ -157,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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
@@ -182,23 +181,23 @@ write the smallest playable game, but keep the playability and
enjoyment high.</p>
<h3 id="instructions">Instructions:</h3>
<p>Key to map:</p>
<pre><code> |
###### | | | /\ /--\ ==| /\ | | Directonal keys
###### Solid Wall | ----|| \/ /\ ||---- (unlock doors of
###### | \/ ==| \--/ \/ the same direction)
|\
| &lt;&lt; &gt;&gt; Doors. Unlocked by
Blank space | &lt;&lt; vvvvvv ^^^^^^ &gt;&gt; the above keys.
| &lt;&lt; &gt;&gt;
|\
___ | o__O\ O__O ^__^ /O__o\
/ \ &#39;Crushable&#39; | \___/ /----\ /----\ \___/ The four sprites for
\___/ boulder | _/_\ _/ \_ _/ \_ /_\_ your character :-)
|\
___ uncrushable | /\ Diamonds. They can either be found lying
/@@@\ boulder | &lt; &gt; around (if only!) or manufacture by pushing
\@@@/ | \/ two &#39;crushable&#39; rocks together.
|</code></pre>
<pre><code> |
###### | | | /\ /--\ ==| /\ | | Directonal keys
###### Solid Wall | ----|| \/ /\ ||---- (unlock doors of
###### | \/ ==| \--/ \/ the same direction)
|\
| &lt;&lt; &gt;&gt; Doors. Unlocked by
Blank space | &lt;&lt; vvvvvv ^^^^^^ &gt;&gt; the above keys.
| &lt;&lt; &gt;&gt;
|\
___ | o__O\ O__O ^__^ /O__o\
/ \ &#39;Crushable&#39; | \___/ /----\ /----\ \___/ The four sprites for
\___/ boulder | _/_\ _/ \_ _/ \_ /_\_ your character :-)
|\
___ uncrushable | /\ Diamonds. They can either be found lying
/@@@\ boulder | &lt; &gt; around (if only!) or manufacture by pushing
\@@@/ | \/ two &#39;crushable&#39; rocks together.
|</code></pre>
<p>The general idea of the game is to collect all the diamonds. This must
be done in the minimum amount of moves. I’ve allowed a margin of 5
moves which brings the moves allowed to <code>484</code>. (alter the value of <code>u</code> in
+79 -80
View File
@@ -1,7 +1,7 @@
## To build:
```sh
make all
make all
```
There is an [alternate version](#alternate-code) that is supposed to win all the
@@ -13,7 +13,7 @@ time.
The current status of this entry is:
```
STATUS: INABIAF - please **DO NOT** fix
STATUS: INABIAF - please **DO NOT** fix
```
For more detailed information see [1991 westley bugs](../../bugs.html#1991_westley).
@@ -28,24 +28,24 @@ Make and then run as follows:
```sh
./westley [move_location] | tee nextmove.c
./westley [move_location] | tee nextmove.c
```
where the `move_location` is a digit from 1 to 9 that represents
a move on a tic-tac-toe board:
```
1 2 3
4 5 6
7 8 9
1 2 3
4 5 6
7 8 9
```
If you omit `move_location`, then the computer moves first. For your
next move, recompile `nextmove.c` and play it again:
```sh
make nextmove
./nextmove move_location | tee nextmove.c
make nextmove
./nextmove move_location | tee nextmove.c
```
@@ -55,10 +55,9 @@ We have provided the shell script, [ttt](ttt.sh), to make it easier to play the
game:
```sh
make ttt
./ttt [first_move] # <- omit first arg to have it move first
./ttt next_move
make ttt
./ttt [first_move] # <- omit first arg to have it move first
./ttt next_move
```
The shell script determines when the game is over, and automatically replaces
@@ -66,50 +65,50 @@ The shell script determines when the game is over, and automatically replaces
loss). The [ttt](ttt.sh) script has two other modes:
```sh
./ttt quitgame # cancel any game in progress, revert to merlyn.c
./ttt clobber # remove all game files, revert to original source
./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
./ttt 1
./ttt 4
./ttt 6
./ttt 1
./ttt 4
./ttt 6
```
The final might look like:
```c
a(X){/*/X=- a(X){/*/X=-
X -1;F;X=- -1;F;X=-
-1;F;}/*/ -1;F;}/*/
char z[][100]={"char z[][100]={","a(X){/*/X=-","-1;F;X=-","-1;F;}/*/","1999999999 :-) ",
"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<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&&Q;*r;)P(*r++);q&&(Q,P(44));}M(m){P(9);i-2||P(X&m?88:O&m?48:32);P(",
"9);}y(A){for(j=8;j;)~A&w[--j]||(q=0);}e(W,Z){for(i-=i*q;i<9&&q;)y(W|(1<<i++&",
"~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<<57-*v[u];y(X);K=40+q;q?e(O,X),q&&(K='|'),e(X",
",O),R(),O|=1<<--i:J[*J-48+(X=O=0)]--;L(q=0);for(s(i=0);q=i<12;)s(i++),i>4&&N",
";s(q=12);P(48);P('}');P(59);N;q=0;L(1);for(i=5;i<13;)s(i++),N;L(2);}",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<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&&Q;*r;)P(*r++);q&&(Q,P(44));}M(m){P(9);i-2||P(X&m?88:O&m?48:32);P(
9);}y(A){for(j=8;j;)~A&w[--j]||(q=0);}e(W,Z){for(i-=i*q;i<9&&q;)y(W|(1<<i++&
~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<<57-*v[u];y(X);K=40+q;q?e(O,X),q&&(K='|'),e(X
,O),R(),O|=1<<--i:J[*J-48+(X=O=0)]--;L(q=0);for(s(i=0);q=i<12;)s(i++),i>4&&N
;s(q=12);P(48);P('}');P(59);N;q=0;L(1);for(i=5;i<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;}/*/
a(X){/*/X=- a(X){/*/X=-
X -1;F;X=- -1;F;X=-
-1;F;}/*/ -1;F;}/*/
char z[][100]={"char z[][100]={","a(X){/*/X=-","-1;F;X=-","-1;F;}/*/","1999999999 :-) ",
"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<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&&Q;*r;)P(*r++);q&&(Q,P(44));}M(m){P(9);i-2||P(X&m?88:O&m?48:32);P(",
"9);}y(A){for(j=8;j;)~A&w[--j]||(q=0);}e(W,Z){for(i-=i*q;i<9&&q;)y(W|(1<<i++&",
"~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<<57-*v[u];y(X);K=40+q;q?e(O,X),q&&(K='|'),e(X",
",O),R(),O|=1<<--i:J[*J-48+(X=O=0)]--;L(q=0);for(s(i=0);q=i<12;)s(i++),i>4&&N",
";s(q=12);P(48);P('}');P(59);N;q=0;L(1);for(i=5;i<13;)s(i++),N;L(2);}",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<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&&Q;*r;)P(*r++);q&&(Q,P(44));}M(m){P(9);i-2||P(X&m?88:O&m?48:32);P(
9);}y(A){for(j=8;j;)~A&w[--j]||(q=0);}e(W,Z){for(i-=i*q;i<9&&q;)y(W|(1<<i++&
~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<<57-*v[u];y(X);K=40+q;q?e(O,X),q&&(K='|'),e(X
,O),R(),O|=1<<--i:J[*J-48+(X=O=0)]--;L(q=0);for(s(i=0);q=i<12;)s(i++),i>4&&N
;s(q=12);P(48);P('}');P(59);N;q=0;L(1);for(i=5;i<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!
ttt: I win!
```
Redirects stderr to `/dev/null` by default. If you need errors or warnings use
@@ -125,7 +124,7 @@ can lose if you cheat. That's supposed to happen. Can you win any other time?
### Alternate build:
```sh
make alt
make alt
```
@@ -159,7 +158,7 @@ This is supposed to happen. As is written in the
[The Jargon File](http://catb.org/jargon/html/F/feature.html):
```
That's not a bug, that's a feature.
That's not a bug, that's a feature.
```
Try not to cheat (even though it's very easy :-) ), the computer has not learned
@@ -196,7 +195,7 @@ variables `X` and `O` contain bitmasks of where all the `X`s and `O`s are placed
The statement:
```c
X=- <char> -1;
X=- <char> -1;
```
evaluates to `1`, `-1`, or `-2` when `X` is `1` and `<char>` is one of `"X"`,
@@ -234,9 +233,9 @@ possible moves by making the `e()` function return "winning" moves,
e.g. the template:
```
. . .
O , O (this is the value 40; 2^3+2^5)
. . . ("O"s are 1 bits, "." and "," are 0 bits)
. . .
O , O (this is the value 40; 2^3+2^5)
. . . ("O"s are 1 bits, "." and "," are 0 bits)
```
...will make the `e()` function return a center move, as this is the only move
@@ -254,45 +253,45 @@ changing the compile line.
The templates are:
```
O , O
, , ,
O , O
O , O
, , ,
O , O
, . .
. O .
. . O
, . .
. O .
. . O
. . .
O , O
. . .
. . .
O , O
. . .
. . .
O O ,
. . .
. . .
O O ,
. . .
. . .
O , O
. . .
. . .
O , O
. . .
. , ,
. O .
O O ,
. , ,
. O .
O O ,
O , O
, , .
O . .
O , O
, , .
O . .
, . O
O , O
O . ,
, . O
O , O
O . ,
O . ,
O , O
, . O
O . ,
O , O
, . O
O , O
, , ,
O , O
O , O
, , ,
O , O
```
A digit of `9` means start with the first template, `8` starts at
+80 -81
View File
@@ -132,8 +132,7 @@
<h2 id="author"><a name="author"></a>Author:</h2>
<ul>
<li>Name: <a href="../../authors.html#Brian_Westley">Brian Westley</a><br>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
<br><br></li>
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
</ul>
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
@@ -142,78 +141,78 @@ 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>
<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>
<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>
<p>The current status of this entry is:</p>
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
<p>For more detailed information see <a href="../../bugs.html#1991_westley">1991 westley bugs</a>.</p>
<h2 id="to-use">To use:</h2>
<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>
<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>
<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
4 5 6
7 8 9</code></pre>
<pre><code> 1 2 3
4 5 6
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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
@@ -236,7 +235,7 @@ you can win tic-tac-toe, that there can be acceptable draws.</p>
</blockquote>
<p>This is supposed to happen. As is written in the
<a href="http://catb.org/jargon/html/F/feature.html">The Jargon File</a>:</p>
<pre><code>That&#39;s not a bug, that&#39;s a feature.</code></pre>
<pre><code> That&#39;s not a bug, that&#39;s a feature.</code></pre>
<p>Try not to cheat (even though it’s very easy :-) ), the computer has not learned
how to catch you doing it.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
@@ -260,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>
<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>
<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
@@ -288,9 +287,9 @@ an <code>X</code> or <code>O</code> is returned.</p>
<p>The “move templates” are static tic-tac-toe positions that generate
possible moves by making the <code>e()</code> function return “winning” moves,
e.g. the template:</p>
<pre><code>. . .
O , O (this is the value 40; 2^3+2^5)
. . . (&quot;O&quot;s are 1 bits, &quot;.&quot; and &quot;,&quot; are 0 bits)</code></pre>
<pre><code> . . .
O , O (this is the value 40; 2^3+2^5)
. . . (&quot;O&quot;s are 1 bits, &quot;.&quot; and &quot;,&quot; are 0 bits)</code></pre>
<p>…will make the <code>e()</code> function return a center move, as this is the only move
that produces three in a row. Notice that the computer does not consider which
cells contain <code>X</code>s and <code>O</code>s when making a template move, only which cells are
@@ -301,45 +300,45 @@ try, by just blundering in the way.</p>
compile line, making it possible to change the rules of the game by
changing the compile line.</p>
<p>The templates are:</p>
<pre><code>O , O
, , ,
O , O
<pre><code> O , O
, , ,
O , O
, . .
. O .
. . O
, . .
. O .
. . O
. . .
O , O
. . .
. . .
O , O
. . .
. . .
O O ,
. . .
. . .
O O ,
. . .
. . .
O , O
. . .
. . .
O , O
. . .
. , ,
. O .
O O ,
. , ,
. O .
O O ,
O , O
, , .
O . .
O , O
, , .
O . .
, . O
O , O
O . ,
, . O
O , O
O . ,
O . ,
O , O
, . O
O . ,
O , O
, . O
O , O
, , ,
O , O</code></pre>
O , O
, , ,
O , O</code></pre>
<p>A digit of <code>9</code> means start with the first template, <code>8</code> starts at
the second, etc. The templates are scanned until a legal move is
found. A template is scanned from bottom to top, right to left