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:
1 parent
b84c27ce02
commit
a996f8d2b8
734 files changed
+16723
-16963
No files matched your search
+2
-2
@@ -40,8 +40,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
|
||||
```
|
||||
|
||||
If you use, distribute or publish these entries in some way, please drop
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make all
|
||||
make all
|
||||
```
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ make all
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: missing file - please provide it
|
||||
STATUS: missing file - please provide it
|
||||
```
|
||||
|
||||
For more detailed information see [1993 ant bugs](../../bugs.html#1993_ant).
|
||||
@@ -19,14 +19,14 @@ For more detailed information see [1993 ant bugs](../../bugs.html#1993_ant).
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./ant 'ERE' [file ...]
|
||||
./ant 'ERE' [file ...]
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
+5
-6
@@ -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,15 +141,15 @@ 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>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: missing file - please provide it</code></pre>
|
||||
<pre><code> STATUS: missing file - please provide it</code></pre>
|
||||
<p>For more detailed information see <a href="../../bugs.html#1993_ant">1993 ant 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">./ant</span> <span class="st">'ERE'</span> [file ...]</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./ant</span> <span class="st">'ERE'</span> [file ...]</span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>See the author’s POSIX P1003.2-like documentation file <a href="ant.txt">ant.txt</a> for
|
||||
more information.</p>
|
||||
|
||||
+14
-15
@@ -5,7 +5,7 @@ this entry was like back in 1993. See the [original code](#original-code)
|
||||
section below to run the original.
|
||||
|
||||
```sh
|
||||
make alt
|
||||
make alt
|
||||
```
|
||||
|
||||
NOTE: this entry requires the `X11/Xlib.h` header file and the X11 library to
|
||||
@@ -17,7 +17,7 @@ requires X11?](../../faq.html#X11macos).
|
||||
To configure how many microseconds to sleep before updates try:
|
||||
|
||||
```sh
|
||||
make clobber SLEEP=200 alt
|
||||
make clobber SLEEP=200 alt
|
||||
```
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ make clobber SLEEP=200 alt
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: known bug - please help us fix
|
||||
STATUS: known bug - please help us fix
|
||||
```
|
||||
|
||||
For more detailed information see [1993 cmills bugs](../../bugs.html#1993_cmills).
|
||||
@@ -35,9 +35,9 @@ For more detailed information see [1993 cmills bugs](../../bugs.html#1993_cmills
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
DISPLAY="your_X_server_display"
|
||||
export DISPLAY
|
||||
./cmills.alt [speed] # must be run on an X11 server
|
||||
DISPLAY="your_X_server_display"
|
||||
export DISPLAY
|
||||
./cmills.alt [speed] # must be run on an X11 server
|
||||
```
|
||||
|
||||
where:
|
||||
@@ -57,7 +57,7 @@ on but you can use the original without any delays if you wish.
|
||||
### Original build:
|
||||
|
||||
```sh
|
||||
make all
|
||||
make all
|
||||
```
|
||||
|
||||
|
||||
@@ -71,16 +71,15 @@ Use `cmills` as you would `cmills.alt` above.
|
||||
From the San Jose Mercury News (May 15, 1993 page 20A "West Hackers
|
||||
trounce East in computer quiz game"):
|
||||
|
||||
|
||||
```
|
||||
"Since 1984, a contest has been held on Usenet for the most
|
||||
unreadable, creative, bizarre but working C program", Gates
|
||||
said. "What is the name of this contest"
|
||||
"Since 1984, a contest has been held on Usenet for the most
|
||||
unreadable, creative, bizarre but working C program", Gates
|
||||
said. "What is the name of this contest"
|
||||
|
||||
"Windows," shot back Gassee, naming Microsoft's premier product
|
||||
- a product over which Apple sued Microsoft five years ago. Not
|
||||
the right answer - it's "The Obfuscated C Contest [sic]" - but
|
||||
it brought down the house of Apple partisans...
|
||||
"Windows," shot back Gassee, naming Microsoft's premier product
|
||||
- a product over which Apple sued Microsoft five years ago. Not
|
||||
the right answer - it's "The Obfuscated C Contest [sic]" - but
|
||||
it brought down the house of Apple partisans...
|
||||
```
|
||||
|
||||
[The expression on Bill Gates' face was a sight to behold, as reported
|
||||
|
||||
+15
-16
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Christopher_Mills">Christopher Mills</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -145,21 +144,21 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
|
||||
<p>We recommend you try the alt version first so you can get a better idea of what
|
||||
this entry was like back in 1993. See the <a href="#original-code">original code</a>
|
||||
section below to run the original.</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> alt</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
|
||||
<p>NOTE: this entry requires the <code>X11/Xlib.h</code> header file and the X11 library to
|
||||
compile. If you’re under macOS and do not know how to install and use X11
|
||||
programs see <a href="../../faq.html#X11macos">FAQ 3.7 - How do I compile and use on macOS, an IOCCC entry that
|
||||
requires X11?</a>.</p>
|
||||
<p>To configure how many microseconds to sleep before updates try:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> clobber SLEEP=200 alt</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="fu">make</span> clobber SLEEP=200 alt</span></code></pre></div>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: known bug - please help us fix</code></pre>
|
||||
<pre><code> STATUS: known bug - please help us fix</code></pre>
|
||||
<p>For more detailed information see <a href="../../bugs.html#1993_cmills">1993 cmills bugs</a>.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="va">DISPLAY</span><span class="op">=</span><span class="st">"your_X_server_display"</span></span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="bu">export</span> <span class="va">DISPLAY</span></span>
|
||||
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./cmills.alt</span> <span class="pp">[</span><span class="ss">speed</span><span class="pp">]</span> <span class="co"># must be run on an X11 server</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="va">DISPLAY</span><span class="op">=</span><span class="st">"your_X_server_display"</span></span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">export</span> <span class="va">DISPLAY</span></span>
|
||||
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./cmills.alt</span> <span class="pp">[</span><span class="ss">speed</span><span class="pp">]</span> <span class="co"># must be run on an X11 server</span></span></code></pre></div>
|
||||
<p>where:</p>
|
||||
<p><code>speed</code> is update speed from 1 to 9 (default is 9).</p>
|
||||
<p>NOTE: in most cases <code>DISPLAY</code> should already be set.</p>
|
||||
@@ -167,20 +166,20 @@ requires X11?</a>.</p>
|
||||
<p>We recommend the version that uses <code>usleep(3)</code> to more easily see what is going
|
||||
on but you can use the original without any delays if you wish.</p>
|
||||
<h3 id="original-build">Original 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> all</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> all</span></code></pre></div>
|
||||
<h3 id="original-use">Original use:</h3>
|
||||
<p>Use <code>cmills</code> as you would <code>cmills.alt</code> above.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>From the San Jose Mercury News (May 15, 1993 page 20A “West Hackers
|
||||
trounce East in computer quiz game”):</p>
|
||||
<pre><code>"Since 1984, a contest has been held on Usenet for the most
|
||||
unreadable, creative, bizarre but working C program", Gates
|
||||
said. "What is the name of this contest"
|
||||
<pre><code> "Since 1984, a contest has been held on Usenet for the most
|
||||
unreadable, creative, bizarre but working C program", Gates
|
||||
said. "What is the name of this contest"
|
||||
|
||||
"Windows," shot back Gassee, naming Microsoft's premier product
|
||||
- a product over which Apple sued Microsoft five years ago. Not
|
||||
the right answer - it's "The Obfuscated C Contest [sic]" - but
|
||||
it brought down the house of Apple partisans...</code></pre>
|
||||
"Windows," shot back Gassee, naming Microsoft's premier product
|
||||
- a product over which Apple sued Microsoft five years ago. Not
|
||||
the right answer - it's "The Obfuscated C Contest [sic]" - but
|
||||
it brought down the house of Apple partisans...</code></pre>
|
||||
<p>[The expression on Bill Gates’ face was a sight to behold, as reported
|
||||
to us by several who were there].</p>
|
||||
<p>You must set <code>$DISPLAY</code> in your environment or the program will
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make all
|
||||
make all
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./dgibson.sh [datafile]
|
||||
./dgibson.sh [datafile]
|
||||
```
|
||||
|
||||
where:
|
||||
@@ -19,7 +19,7 @@ where:
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#David_Gibson">David Gibson</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,13 +141,13 @@ 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>
|
||||
<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">./dgibson.sh</span> <span class="pp">[</span><span class="ss">datafile</span><span class="pp">]</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">./dgibson.sh</span> <span class="pp">[</span><span class="ss">datafile</span><span class="pp">]</span></span></code></pre></div>
|
||||
<p>where:</p>
|
||||
<p><code>datafile</code> is the initial pattern (default: <a href="dgibson.data1">dgibson.data1</a>)</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">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>We have provided the shell script <a href="dgibson.sh">dgibson.sh</a> to make it easier
|
||||
to run this entry. Run this shell script several times to
|
||||
|
||||
+6
-6
@@ -1,27 +1,27 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make all
|
||||
make all
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./ejb level
|
||||
./ejb level
|
||||
```
|
||||
|
||||
where:
|
||||
|
||||
```sh
|
||||
level a value from -128 to 127
|
||||
level a value from -128 to 127
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ We note that this also works under macOS just fine.
|
||||
#### Output solution to Towers of Hanoi for five rings:
|
||||
|
||||
```sh
|
||||
./ejb 5
|
||||
./ejb 5
|
||||
```
|
||||
|
||||
The format of the output for the Towers of Hanoi case is simply a
|
||||
@@ -55,7 +55,7 @@ text description of how to solve the puzzle.
|
||||
#### Output solution to the Patience puzzle for six rings:
|
||||
|
||||
```sh
|
||||
./ejb -6
|
||||
./ejb -6
|
||||
```
|
||||
|
||||
|
||||
|
||||
+7
-8
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#E_Jay_Berkenbilt">E. Jay Berkenbilt</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,13 +141,13 @@ 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>
|
||||
<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">./ejb</span> level</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">./ejb</span> level</span></code></pre></div>
|
||||
<p>where:</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">level</span> a value from <span class="at">-128</span> to 127</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">level</span> a value from <span class="at">-128</span> to 127</span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>A negative argument plays the patience puzzle. An argument
|
||||
greater than 0 plays the Tower of Hanoi puzzle. In either case
|
||||
@@ -161,11 +160,11 @@ the argument 127 to this program and want to see it finish!</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<h3 id="what-this-program-does">What this program does</h3>
|
||||
<h4 id="output-solution-to-towers-of-hanoi-for-five-rings">Output solution to Towers of Hanoi for five rings:</h4>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./ejb</span> 5</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">./ejb</span> 5</span></code></pre></div>
|
||||
<p>The format of the output for the Towers of Hanoi case is simply a
|
||||
text description of how to solve the puzzle.</p>
|
||||
<h4 id="output-solution-to-the-patience-puzzle-for-six-rings">Output solution to the Patience puzzle for six rings:</h4>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./ejb</span> <span class="at">-6</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">./ejb</span> <span class="at">-6</span></span></code></pre></div>
|
||||
<p>For the patience puzzle, the output is a sequence binary codes representing
|
||||
successive states of the puzzle. The rightmost digit represents the first ring.
|
||||
A <code>1</code> means the ring is on the <code>U</code>; a <code>0</code> means it is off the <code>U</code>. The program
|
||||
|
||||
@@ -171,10 +171,7 @@ then be blocked by the first ring in its new position
|
||||
outside of the <code>U</code>.</p>
|
||||
<p>Here is an illustration of the three-ring case. The bottom
|
||||
of the puzzle is on the left-hand side of the page.</p>
|
||||
<pre><code>
|
||||
|
||||
|
||||
//==\\
|
||||
<pre><code> //==\\
|
||||
|| ||
|
||||
|| ||
|
||||
*****||** ||
|
||||
|
||||
@@ -54,9 +54,6 @@ Here is an illustration of the three-ring case. The bottom
|
||||
of the puzzle is on the left-hand side of the page.
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
//==\\
|
||||
|| ||
|
||||
|| ||
|
||||
|
||||
+2
-2
@@ -155,8 +155,8 @@ errors.</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>
|
||||
<p>If you use, distribute or publish these entries in some way, please drop
|
||||
us a line. We enjoy seeing who, where and how the contest is used.</p>
|
||||
<h2 id="final-comments">Final Comments</h2>
|
||||
|
||||
@@ -6,14 +6,14 @@ install [XQuartz](https://www.xquartz.org) in order to compile and run this
|
||||
entry.
|
||||
|
||||
```sh
|
||||
make all
|
||||
make all
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./jonth # must be run on an X11 server
|
||||
./jonth # must be run on an X11 server
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Jon_Thingvold">Jon Thingvold</a><br>
|
||||
Location: <a href="../../location.html#NO">NO</a> - <em>Kingdom of Norway</em> (<em>Norway</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#NO">NO</a> - <em>Kingdom of Norway</em> (<em>Norway</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -146,9 +145,9 @@ Location: <a href="../../location.html#NO">NO</a> - <em>Kingdom of Norway</em> (
|
||||
compile. macOS users running Mountain Lion and later will need to download and
|
||||
install <a href="https://www.xquartz.org">XQuartz</a> in order to compile and run this
|
||||
entry.</p>
|
||||
<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">./jonth</span> <span class="co"># must be run on an X11 server</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">./jonth</span> <span class="co"># must be run on an X11 server</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>Use <code>h</code> and <code>l</code> to shift objects left or right. Use <code>k</code> to
|
||||
rotate and press SPACE to drop.</p>
|
||||
|
||||
+27
-27
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make all
|
||||
make all
|
||||
```
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@ make all
|
||||
To have the computer guess:
|
||||
|
||||
```sh
|
||||
./leo [colors]
|
||||
./leo [colors]
|
||||
```
|
||||
|
||||
To guess the computer's number:
|
||||
|
||||
```sh
|
||||
./mind [colors]
|
||||
./mind [colors]
|
||||
```
|
||||
|
||||
where:
|
||||
@@ -72,35 +72,35 @@ Please don't type ^D at the prompt!!
|
||||
##### EXAMPLE: Suppose we think of 1234
|
||||
|
||||
```
|
||||
$ ./leo
|
||||
(1296): 6433
|
||||
?? 12 # one 3 is a bull, another is a cow, and 4 is a cow
|
||||
(160): 5363
|
||||
?? 02 # both 3's are cows
|
||||
(21): 4231
|
||||
?? 22 # 2 and 3 are bulls, 4 and 1 are cows
|
||||
(2): 4132
|
||||
?? 13 # 3 is a bull; 1, 2 and 4 are cows
|
||||
(1): 1234
|
||||
?? 40 # you may enter everything there
|
||||
$ ./leo
|
||||
(1296): 6433
|
||||
?? 12 # one 3 is a bull, another is a cow, and 4 is a cow
|
||||
(160): 5363
|
||||
?? 02 # both 3's are cows
|
||||
(21): 4231
|
||||
?? 22 # 2 and 3 are bulls, 4 and 1 are cows
|
||||
(2): 4132
|
||||
?? 13 # 3 is a bull; 1, 2 and 4 are cows
|
||||
(1): 1234
|
||||
?? 40 # you may enter everything there
|
||||
```
|
||||
|
||||
##### EXAMPLE: Guess the computer's number
|
||||
|
||||
```
|
||||
$ ./mind
|
||||
(1296): ???? 1122 # my strategy isn't the best, just as example
|
||||
00
|
||||
(256): ???? 3344
|
||||
20
|
||||
(18): ???? 5566
|
||||
02
|
||||
(6): ???? 3654
|
||||
11
|
||||
(2): ???? 3355
|
||||
00
|
||||
(1): ???? 6444
|
||||
40 # we have guessed the number
|
||||
$ ./mind
|
||||
(1296): ???? 1122 # my strategy isn't the best, just as example
|
||||
00
|
||||
(256): ???? 3344
|
||||
20
|
||||
(18): ???? 5566
|
||||
02
|
||||
(6): ???? 3654
|
||||
11
|
||||
(2): ???? 3355
|
||||
00
|
||||
(1): ???? 6444
|
||||
40 # we have guessed the number
|
||||
```
|
||||
|
||||
|
||||
|
||||
+28
-29
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Leonid_A_Broukhis">Leonid A. Broukhis</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,12 +141,12 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> 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>
|
||||
<p>To have the computer guess:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./leo</span> <span class="pp">[</span><span class="ss">colors</span><span class="pp">]</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">./leo</span> <span class="pp">[</span><span class="ss">colors</span><span class="pp">]</span></span></code></pre></div>
|
||||
<p>To guess the computer’s number:</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">./mind</span> <span class="pp">[</span><span class="ss">colors</span><span class="pp">]</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">./mind</span> <span class="pp">[</span><span class="ss">colors</span><span class="pp">]</span></span></code></pre></div>
|
||||
<p>where:</p>
|
||||
<p>[colors] is the number of possible colors (1 to 15) (default: 6)</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
@@ -181,31 +180,31 @@ backspaces. Do “disable scrolling” on cmdtool or similar emulators.</p>
|
||||
<h4 id="bugs">Bugs</h4>
|
||||
<p>Please don’t type ^D at the prompt!!</p>
|
||||
<h5 id="example-suppose-we-think-of-1234">EXAMPLE: Suppose we think of 1234</h5>
|
||||
<pre><code>$ ./leo
|
||||
(1296): 6433
|
||||
?? 12 # one 3 is a bull, another is a cow, and 4 is a cow
|
||||
(160): 5363
|
||||
?? 02 # both 3's are cows
|
||||
(21): 4231
|
||||
?? 22 # 2 and 3 are bulls, 4 and 1 are cows
|
||||
(2): 4132
|
||||
?? 13 # 3 is a bull; 1, 2 and 4 are cows
|
||||
(1): 1234
|
||||
?? 40 # you may enter everything there</code></pre>
|
||||
<pre><code> $ ./leo
|
||||
(1296): 6433
|
||||
?? 12 # one 3 is a bull, another is a cow, and 4 is a cow
|
||||
(160): 5363
|
||||
?? 02 # both 3's are cows
|
||||
(21): 4231
|
||||
?? 22 # 2 and 3 are bulls, 4 and 1 are cows
|
||||
(2): 4132
|
||||
?? 13 # 3 is a bull; 1, 2 and 4 are cows
|
||||
(1): 1234
|
||||
?? 40 # you may enter everything there</code></pre>
|
||||
<h5 id="example-guess-the-computers-number">EXAMPLE: Guess the computer’s number</h5>
|
||||
<pre><code>$ ./mind
|
||||
(1296): ???? 1122 # my strategy isn't the best, just as example
|
||||
00
|
||||
(256): ???? 3344
|
||||
20
|
||||
(18): ???? 5566
|
||||
02
|
||||
(6): ???? 3654
|
||||
11
|
||||
(2): ???? 3355
|
||||
00
|
||||
(1): ???? 6444
|
||||
40 # we have guessed the number</code></pre>
|
||||
<pre><code> $ ./mind
|
||||
(1296): ???? 1122 # my strategy isn't the best, just as example
|
||||
00
|
||||
(256): ???? 3344
|
||||
20
|
||||
(18): ???? 5566
|
||||
02
|
||||
(6): ???? 3654
|
||||
11
|
||||
(2): ???? 3355
|
||||
00
|
||||
(1): ???? 6444
|
||||
40 # we have guessed the number</code></pre>
|
||||
<!--
|
||||
|
||||
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
|
||||
|
||||
+11
-11
@@ -3,13 +3,13 @@
|
||||
If you have gcc < 2.3.3 you can build this entry like:
|
||||
|
||||
```sh
|
||||
make all
|
||||
make all
|
||||
```
|
||||
|
||||
This will try to create a file whose actual filename is literally:
|
||||
|
||||
```
|
||||
";main(){puts("Hello World!");}char*C=".c
|
||||
";main(){puts("Hello World!");}char*C=".c
|
||||
```
|
||||
|
||||
When that file is compiled, it will greet the world in the
|
||||
@@ -38,7 +38,7 @@ section below for more details.
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [1993 lmfjyh bugs](../../bugs.html#1993_lmfjyh).
|
||||
@@ -49,7 +49,7 @@ For more detailed information see [1993 lmfjyh bugs](../../bugs.html#1993_lmfjyh
|
||||
If you have gcc < 2.3.3 (i.e. the entry can compile):
|
||||
|
||||
```sh
|
||||
./lmfjyh
|
||||
./lmfjyh
|
||||
```
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ Nonetheless it will be compiled in case the original entry fails to compile.
|
||||
Should you wish to build this version manually:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
make alt
|
||||
```
|
||||
|
||||
|
||||
@@ -100,10 +100,10 @@ that should be familiar to all C-programmers.
|
||||
|
||||
|
||||
```c
|
||||
main()
|
||||
{
|
||||
puts("Hello World!");
|
||||
}
|
||||
main()
|
||||
{
|
||||
puts("Hello World!");
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -119,14 +119,14 @@ the file.
|
||||
#### Listing 2: Compressed "Hello world"
|
||||
|
||||
```c
|
||||
char*_=__FILE__;
|
||||
char*_=__FILE__;
|
||||
```
|
||||
|
||||
|
||||
#### Listing 3: Code embedded in the file name
|
||||
|
||||
```c
|
||||
";main(){puts("Hello World!");}char*C=".c
|
||||
";main(){puts("Hello World!");}char*C=".c
|
||||
```
|
||||
|
||||
|
||||
|
||||
+12
-13
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Jyrki_Holopainen">Jyrki Holopainen</a><br>
|
||||
Location: <a href="../../location.html#FI">FI</a> - <em>Republic of Finland </em> (<em>Finland</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#FI">FI</a> - <em>Republic of Finland </em> (<em>Finland</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -143,9 +142,9 @@ Location: <a href="../../location.html#FI">FI</a> - <em>Republic of Finland </em
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<p>If you have gcc < 2.3.3 you can build this entry like:</p>
|
||||
<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>This will try to create a file whose actual filename is literally:</p>
|
||||
<pre><code>";main(){puts("Hello World!");}char*C=".c</code></pre>
|
||||
<pre><code> ";main(){puts("Hello World!");}char*C=".c</code></pre>
|
||||
<p>When that file is compiled, it will greet the world in the
|
||||
traditional fashion of C.</p>
|
||||
<p>For an explanation of why and how this works see the author’s remarks. The gist
|
||||
@@ -163,18 +162,18 @@ with gcc >= 2.3.3 or using clang. See <a href="#alternate-code">Alternate cod
|
||||
section below for more details.</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#1993_lmfjyh">1993 lmfjyh bugs</a>.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<p>If you have gcc < 2.3.3 (i.e. the entry can compile):</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">./lmfjyh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./lmfjyh</span></span></code></pre></div>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<p>This version does what the code did but in a way that will work with modern
|
||||
compilers. We’d like to say there’s something special about it but there isn’t.
|
||||
Nonetheless it will be compiled in case the original entry fails to compile.</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<p>Should you wish to build this version manually:</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> 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>lmfjyh.alt</code> as you would <code>lmfjyh</code> above. Note that other code could also be
|
||||
done with the bug that the entry abuses but that would have to be manually
|
||||
@@ -190,10 +189,10 @@ best with C-source code.</p>
|
||||
<p>As an example, I have taken a simple “Hello world!” program
|
||||
that should be familiar to all C-programmers.</p>
|
||||
<h4 id="listing-1-a-simple-hello-world-program">Listing 1: A simple “Hello World” program</h4>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>main<span class="op">()</span></span>
|
||||
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
|
||||
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> puts<span class="op">(</span><span class="st">"Hello World!"</span><span class="op">);</span></span>
|
||||
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> main<span class="op">()</span></span>
|
||||
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="op">{</span></span>
|
||||
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> puts<span class="op">(</span><span class="st">"Hello World!"</span><span class="op">);</span></span>
|
||||
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span></code></pre></div>
|
||||
<h3 id="packing-method">Packing method</h3>
|
||||
<p>Normally a file name is used only to identify the file, but this new
|
||||
revolutionary method introduces a totally new concept: <strong>THE FILE NAME <em>IS</em> THE
|
||||
@@ -201,9 +200,9 @@ PROGRAM</strong>. There is no need to waste valuable disk space to store source
|
||||
The program is embedded in the file name, only a minor portion of it is inside
|
||||
the file.</p>
|
||||
<h4 id="listing-2-compressed-hello-world">Listing 2: Compressed “Hello world”</h4>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="dt">char</span><span class="op">*</span>_<span class="op">=</span>__FILE__<span class="op">;</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="dt">char</span><span class="op">*</span>_<span class="op">=</span>__FILE__<span class="op">;</span></span></code></pre></div>
|
||||
<h4 id="listing-3-code-embedded-in-the-file-name">Listing 3: Code embedded in the file name</h4>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="st">";main(){puts("</span>Hello World<span class="op">!</span><span class="st">");}char*C="</span><span class="op">.</span>c</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="st">";main(){puts("</span>Hello World<span class="op">!</span><span class="st">");}char*C="</span><span class="op">.</span>c</span></code></pre></div>
|
||||
<p>The sample program in listing 1 is 36 bytes long. By using the new
|
||||
compression method, the example program may be squeezed to sixteen
|
||||
bytes. In the example the compression ratio is 2:1. It is evident
|
||||
|
||||
+20
-20
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
make alt
|
||||
```
|
||||
|
||||
We recommend that you try the alternate version first to get a better idea of
|
||||
@@ -13,21 +13,21 @@ code](#original-code) below.
|
||||
If you wish to speed the entry up, say to 500 microseconds between writes, try:
|
||||
|
||||
```sh
|
||||
make clobber SLEEP=500 alt
|
||||
make clobber SLEEP=500 alt
|
||||
```
|
||||
|
||||
Alternatively if you wish to slow it down, say to 1500 microseconds between
|
||||
writes, try:
|
||||
|
||||
```sh
|
||||
make clobber SLEEP=1500 alt
|
||||
make clobber SLEEP=1500 alt
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./plummer.alt number arg
|
||||
./plummer.alt number arg
|
||||
```
|
||||
|
||||
where:
|
||||
@@ -43,21 +43,21 @@ bypass](https://hitchhikers.fandom.com/wiki/Bypass).
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.alt.sh
|
||||
./try.alt.sh
|
||||
|
||||
./try.alt.sh 21701
|
||||
./try.alt.sh 21701
|
||||
|
||||
SLEEP=500 ./try.alt.sh
|
||||
SLEEP=500 ./try.alt.sh
|
||||
|
||||
SLEEP=900 ./try.alt.sh 789789789789789
|
||||
SLEEP=900 ./try.alt.sh 789789789789789
|
||||
|
||||
./try.alt.sh 789789789
|
||||
./try.alt.sh 789789789
|
||||
|
||||
SLEEP=400 ./try.alt.sh 42424242424242
|
||||
SLEEP=400 ./try.alt.sh 42424242424242
|
||||
|
||||
SLEEP=1000 ./try.alt.sh xyzzyzzyx
|
||||
SLEEP=1000 ./try.alt.sh xyzzyzzyx
|
||||
|
||||
SLEEP=1200 ./try.alt.sh xyzzyzzyx 5555
|
||||
SLEEP=1200 ./try.alt.sh xyzzyzzyx 5555
|
||||
```
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ course).
|
||||
### Original build:
|
||||
|
||||
```sh
|
||||
make all
|
||||
make all
|
||||
```
|
||||
|
||||
|
||||
@@ -83,19 +83,19 @@ Use `plummer` as you would `plummer.alt` above.
|
||||
### Original try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
|
||||
./try.sh 21701
|
||||
./try.sh 21701
|
||||
|
||||
./try.sh 789789789789789
|
||||
./try.sh 789789789789789
|
||||
|
||||
./try.sh 789789789
|
||||
./try.sh 789789789
|
||||
|
||||
./try.sh 42424242424242
|
||||
./try.sh 42424242424242
|
||||
|
||||
./try.sh xyzzyzzyx
|
||||
./try.sh xyzzyzzyx
|
||||
|
||||
./try.sh xyzzyzzyx 5555
|
||||
./try.sh xyzzyzzyx 5555
|
||||
```
|
||||
|
||||
|
||||
|
||||
+21
-22
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Mark_Plummer">Mark Plummer</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,19 +141,19 @@ 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> alt</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> alt</span></code></pre></div>
|
||||
<p>We recommend that you try the alternate version first to get a better idea of
|
||||
what this entry looked like back in 1993. The alternate version sleeps (via
|
||||
<code>usleep(3)</code>) in between writes, defaulting at 1000 microseconds (but
|
||||
reconfigurable). If you wish to see the original entry then see <a href="#original-code">original
|
||||
code</a> below.</p>
|
||||
<p>If you wish to speed the entry up, say to 500 microseconds between writes, try:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> clobber SLEEP=500 alt</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="fu">make</span> clobber SLEEP=500 alt</span></code></pre></div>
|
||||
<p>Alternatively if you wish to slow it down, say to 1500 microseconds between
|
||||
writes, try:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> clobber SLEEP=1500 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> clobber SLEEP=1500 alt</span></code></pre></div>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./plummer.alt</span> number arg</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">./plummer.alt</span> number arg</span></code></pre></div>
|
||||
<p>where:</p>
|
||||
<ul>
|
||||
<li>number is a number (try 21701)</li>
|
||||
@@ -164,43 +163,43 @@ writes, try:</p>
|
||||
<a href="https://hitchhikers.fandom.com/wiki/Vogon">Vogons</a> build that <a href="https://hitchhikers.fandom.com/wiki/Bypass">hyperspace
|
||||
bypass</a>.</p>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.alt.sh</span></span>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.alt.sh</span></span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.alt.sh</span> 21701</span>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.alt.sh</span> 21701</span>
|
||||
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="va">SLEEP</span><span class="op">=</span>500 <span class="ex">./try.alt.sh</span></span>
|
||||
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> <span class="va">SLEEP</span><span class="op">=</span>500 <span class="ex">./try.alt.sh</span></span>
|
||||
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a><span class="va">SLEEP</span><span class="op">=</span>900 <span class="ex">./try.alt.sh</span> 789789789789789</span>
|
||||
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a> <span class="va">SLEEP</span><span class="op">=</span>900 <span class="ex">./try.alt.sh</span> 789789789789789</span>
|
||||
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.alt.sh</span> 789789789</span>
|
||||
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.alt.sh</span> 789789789</span>
|
||||
<span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a><span class="va">SLEEP</span><span class="op">=</span>400 <span class="ex">./try.alt.sh</span> 42424242424242</span>
|
||||
<span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a> <span class="va">SLEEP</span><span class="op">=</span>400 <span class="ex">./try.alt.sh</span> 42424242424242</span>
|
||||
<span id="cb5-12"><a href="#cb5-12" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb5-13"><a href="#cb5-13" aria-hidden="true" tabindex="-1"></a><span class="va">SLEEP</span><span class="op">=</span>1000 <span class="ex">./try.alt.sh</span> xyzzyzzyx</span>
|
||||
<span id="cb5-13"><a href="#cb5-13" aria-hidden="true" tabindex="-1"></a> <span class="va">SLEEP</span><span class="op">=</span>1000 <span class="ex">./try.alt.sh</span> xyzzyzzyx</span>
|
||||
<span id="cb5-14"><a href="#cb5-14" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb5-15"><a href="#cb5-15" aria-hidden="true" tabindex="-1"></a><span class="va">SLEEP</span><span class="op">=</span>1200 <span class="ex">./try.alt.sh</span> xyzzyzzyx 5555</span></code></pre></div>
|
||||
<span id="cb5-15"><a href="#cb5-15" aria-hidden="true" tabindex="-1"></a> <span class="va">SLEEP</span><span class="op">=</span>1200 <span class="ex">./try.alt.sh</span> xyzzyzzyx 5555</span></code></pre></div>
|
||||
<h2 id="original-code">Original code:</h2>
|
||||
<p>This version, the original, does not sleep in between writes, and is thus much
|
||||
faster (depending on the <code>SLEEP</code> parameter specified in the build of <code>alt</code>, of
|
||||
course).</p>
|
||||
<h3 id="original-build">Original build:</h3>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> all</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> all</span></code></pre></div>
|
||||
<h3 id="original-use">Original use:</h3>
|
||||
<p>Use <code>plummer</code> as you would <code>plummer.alt</code> above.</p>
|
||||
<h3 id="original-try">Original try:</h3>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span>
|
||||
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span> 21701</span>
|
||||
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span> 21701</span>
|
||||
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span> 789789789789789</span>
|
||||
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span> 789789789789789</span>
|
||||
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span> 789789789</span>
|
||||
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span> 789789789</span>
|
||||
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span> 42424242424242</span>
|
||||
<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span> 42424242424242</span>
|
||||
<span id="cb7-10"><a href="#cb7-10" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb7-11"><a href="#cb7-11" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span> xyzzyzzyx</span>
|
||||
<span id="cb7-11"><a href="#cb7-11" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span> xyzzyzzyx</span>
|
||||
<span id="cb7-12"><a href="#cb7-12" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb7-13"><a href="#cb7-13" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span> xyzzyzzyx 5555</span></code></pre></div>
|
||||
<span id="cb7-13"><a href="#cb7-13" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span> xyzzyzzyx 5555</span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>For extra credit: What happens when ‘number’ contains non-numeric
|
||||
characters, and why?</p>
|
||||
|
||||
+14
-14
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make all
|
||||
make all
|
||||
```
|
||||
|
||||
NOTE: there are two alternate versions of this program, both allowing one to
|
||||
@@ -14,7 +14,7 @@ See the [Alternate code](#alternate-code) section below.
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [bugs report with 1993/rince](../../bugs.html#1993_rince).
|
||||
@@ -23,7 +23,7 @@ For more detailed information see [bugs report with 1993/rince](../../bugs.html#
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./rince [cabbage]
|
||||
./rince [cabbage]
|
||||
```
|
||||
|
||||
where:
|
||||
@@ -38,13 +38,13 @@ value 17 in the lines:
|
||||
|
||||
|
||||
```c
|
||||
struct timeval v= {0,1<<17} ;
|
||||
struct timeval v= {0,1<<17} ;
|
||||
```
|
||||
|
||||
and
|
||||
|
||||
```c
|
||||
refresh(),c=select(k,&y,0,0,(v.tv_usec=1<<17,&v))?getch():0;
|
||||
refresh(),c=select(k,&y,0,0,(v.tv_usec=1<<17,&v))?getch():0;
|
||||
```
|
||||
|
||||
to another value like 18 or 19 which you can do with the alternate code.
|
||||
@@ -58,7 +58,7 @@ changed).
|
||||
### Alternate build:
|
||||
|
||||
```sh
|
||||
make SLEEP=18 clobber alt
|
||||
make SLEEP=18 clobber alt
|
||||
```
|
||||
|
||||
Replace 18 with whatever number you wish.
|
||||
@@ -108,7 +108,7 @@ used. It has been suggested that the following gcc command may help:
|
||||
|
||||
|
||||
```sh
|
||||
gcc -fno-builtin -I/usr/include -o rince rince.c -lcurses -ltermcap
|
||||
gcc -fno-builtin -I/usr/include -o rince rince.c -lcurses -ltermcap
|
||||
```
|
||||
|
||||
|
||||
@@ -145,13 +145,13 @@ The proper definition for usage would be: `./rince [data_filename]`
|
||||
I have compiled in on the following systems:
|
||||
|
||||
```
|
||||
System OS Compiler (and flags)
|
||||
DECstation 5000/240 Ultrix 4.2A c89 -std
|
||||
SPARCstation 1+ SunOS 4.1 gcc -ansi -pedantic
|
||||
SPARCstation 10/31 Solaris 2.1 gcc -ansi -pedantic (*)
|
||||
DECAlpha 3000/500 OSF/1 V1.2 c89 -std
|
||||
SGI Indigo (R4000) IRIX 4.0.5F cc -ansi
|
||||
Alliant FX2800 Conentrix 3.0.0 fxc
|
||||
System OS Compiler (and flags)
|
||||
DECstation 5000/240 Ultrix 4.2A c89 -std
|
||||
SPARCstation 1+ SunOS 4.1 gcc -ansi -pedantic
|
||||
SPARCstation 10/31 Solaris 2.1 gcc -ansi -pedantic (*)
|
||||
DECAlpha 3000/500 OSF/1 V1.2 c89 -std
|
||||
SGI Indigo (R4000) IRIX 4.0.5F cc -ansi
|
||||
Alliant FX2800 Conentrix 3.0.0 fxc
|
||||
```
|
||||
|
||||
\* I never said it worked! The guidelines state that you dislike programs that
|
||||
|
||||
+17
-18
@@ -130,24 +130,23 @@ slightly cheaty, cellular automata system, with some of the transitions
|
||||
bound to key presses.</p>
|
||||
<p>For instance, assume you wish to make a boulder <code>o</code> roll off a hill <code>/</code>
|
||||
A standard automata would have 2 rules something like this:</p>
|
||||
<pre><code>
|
||||
o.. ...
|
||||
\.. --> 'o' .o. --> '.'
|
||||
... .\.</code></pre>
|
||||
<pre><code> o.. ...
|
||||
\.. --> 'o' .o. --> '.'
|
||||
... .\.</code></pre>
|
||||
<p>However, the system I devised, in order to keep things small and neat(!),
|
||||
was to define a 3x3 to 3x3 map (instead of the 3x3 to 1x1 shown above).
|
||||
Hence:</p>
|
||||
<pre><code> .o. ...
|
||||
.\. --> .\o
|
||||
... ...</code></pre>
|
||||
<pre><code> .o. ...
|
||||
.\. --> .\o
|
||||
... ...</code></pre>
|
||||
<p>This does of course have the odd problem with clashes. What if we want to roll
|
||||
two boulders down simultaneously towards the same square. I perform no
|
||||
buffering, and so this situation is just a ‘fight it out’ and let which ever
|
||||
transition has priority win. Such a case may produce the following change of
|
||||
maps (depending on which ‘roll’ transition is used first).</p>
|
||||
<pre><code> o.o ..o o..
|
||||
\./ changes to \o/ or to \o/
|
||||
... ... ...</code></pre>
|
||||
<pre><code> o.o ..o o..
|
||||
\./ changes to \o/ or to \o/
|
||||
... ... ...</code></pre>
|
||||
<p>I claim that it is possible to perform all of the 3x3 to 1x1 transitions in a
|
||||
3x3 to 3x3 based system. One other feature added in is a workaround for the ‘no
|
||||
buffering’ problem. If we define a space ship (as in the <a href="https://en.wikipedia.org/wiki/Space_Invaders">Space
|
||||
@@ -166,24 +165,24 @@ some transitions are only valid when a certain key has been pressed.
|
||||
So for example, if we (an <code>@</code> symbol) wish to move right when the <code>l</code> key
|
||||
is hit we have a transition like:</p>
|
||||
<h2 id="key-l">Key: l</h2>
|
||||
<pre><code> * * * * * *
|
||||
* @ . * . @
|
||||
* * * * * *</code></pre>
|
||||
<pre><code> * * * * * *
|
||||
* @ . * . @
|
||||
* * * * * *</code></pre>
|
||||
<p>Here I also use wildcards. On the match side (left) of the transition, an
|
||||
asterisk will match against any character. On the update side (right), an
|
||||
asterisk means ‘keep whatever was here before’. So the above example
|
||||
simply means to swap the <code>@</code> and <code>.</code> around when <code>l</code> is pressed. For the
|
||||
purposes of space saving, this transition is shrunk to a single line.</p>
|
||||
<h2 id="key-k">Key: K</h2>
|
||||
<pre><code> a b c 1 2 3
|
||||
d e f 4 5 6
|
||||
g h i 7 8 9</code></pre>
|
||||
<pre><code> a b c 1 2 3
|
||||
d e f 4 5 6
|
||||
g h i 7 8 9</code></pre>
|
||||
<p>is written as: <code>eabcdfghi512346789K</code>.</p>
|
||||
<p>If there are no keys needed for this transition, the character <code>*1</code> should
|
||||
be used instead. Now the format of the game description file is now
|
||||
the following (angle brackets denote an ‘entity’ to be defined):</p>
|
||||
<pre><code> <top-bot transition>*\n<bot-top transition>*\n<X size>[ \t]+<Y size>\n
|
||||
<map></code></pre>
|
||||
<pre><code> <top-bot transition>*\n<bot-top transition>*\n<X size>[ \t]+<Y size>\n
|
||||
<map></code></pre>
|
||||
<p>The <code><X size></code> should take into account the newline at the end of each line
|
||||
of map, and hence should also be one larger than expected.</p>
|
||||
<!--
|
||||
|
||||
+17
-18
@@ -10,10 +10,9 @@ For instance, assume you wish to make a boulder `o` roll off a hill `/`
|
||||
A standard automata would have 2 rules something like this:
|
||||
|
||||
```
|
||||
|
||||
o.. ...
|
||||
\.. --> 'o' .o. --> '.'
|
||||
... .\.
|
||||
o.. ...
|
||||
\.. --> 'o' .o. --> '.'
|
||||
... .\.
|
||||
```
|
||||
|
||||
However, the system I devised, in order to keep things small and neat(!),
|
||||
@@ -21,9 +20,9 @@ was to define a 3x3 to 3x3 map (instead of the 3x3 to 1x1 shown above).
|
||||
Hence:
|
||||
|
||||
```
|
||||
.o. ...
|
||||
.\. --> .\o
|
||||
... ...
|
||||
.o. ...
|
||||
.\. --> .\o
|
||||
... ...
|
||||
```
|
||||
|
||||
This does of course have the odd problem with clashes. What if we want to roll
|
||||
@@ -33,9 +32,9 @@ transition has priority win. Such a case may produce the following change of
|
||||
maps (depending on which 'roll' transition is used first).
|
||||
|
||||
```
|
||||
o.o ..o o..
|
||||
\./ changes to \o/ or to \o/
|
||||
... ... ...
|
||||
o.o ..o o..
|
||||
\./ changes to \o/ or to \o/
|
||||
... ... ...
|
||||
```
|
||||
|
||||
I claim that it is possible to perform all of the 3x3 to 1x1 transitions in a
|
||||
@@ -60,9 +59,9 @@ is hit we have a transition like:
|
||||
## Key: l
|
||||
|
||||
```
|
||||
* * * * * *
|
||||
* @ . * . @
|
||||
* * * * * *
|
||||
* * * * * *
|
||||
* @ . * . @
|
||||
* * * * * *
|
||||
```
|
||||
|
||||
Here I also use wildcards. On the match side (left) of the transition, an
|
||||
@@ -74,9 +73,9 @@ purposes of space saving, this transition is shrunk to a single line.
|
||||
## Key: K
|
||||
|
||||
```
|
||||
a b c 1 2 3
|
||||
d e f 4 5 6
|
||||
g h i 7 8 9
|
||||
a b c 1 2 3
|
||||
d e f 4 5 6
|
||||
g h i 7 8 9
|
||||
```
|
||||
|
||||
is written as: `eabcdfghi512346789K`.
|
||||
@@ -87,8 +86,8 @@ the following (angle brackets denote an 'entity' to be defined):
|
||||
|
||||
|
||||
```
|
||||
<top-bot transition>*\n<bot-top transition>*\n<X size>[ \t]+<Y size>\n
|
||||
<map>
|
||||
<top-bot transition>*\n<bot-top transition>*\n<X size>[ \t]+<Y size>\n
|
||||
<map>
|
||||
```
|
||||
|
||||
The `<X size>` should take into account the newline at the end of each line
|
||||
|
||||
+15
-16
@@ -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,31 +141,31 @@ 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>NOTE: there are two alternate versions of this program, both allowing one to
|
||||
slow down the game and the second one with movements more familiar to vi users.
|
||||
See the <a href="#alternate-code">Alternate code</a> section below.</p>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code>STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<p>For more detailed information see <a href="../../bugs.html#1993_rince">bugs report with 1993/rince</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">./rince</span> <span class="pp">[</span><span class="ss">cabbage</span><span class="pp">]</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">./rince</span> <span class="pp">[</span><span class="ss">cabbage</span><span class="pp">]</span></span></code></pre></div>
|
||||
<p>where:</p>
|
||||
<p><code>[cabbage]</code> is a CABBAGE description file (default: <code>rince.c</code>)</p>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<p>Some people may want to slow down the game by increasing the
|
||||
value 17 in the lines:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> timeval v<span class="op">=</span> <span class="op">{</span><span class="dv">0</span><span class="op">,</span><span class="dv">1</span><span class="op"><<</span><span class="dv">17</span><span class="op">}</span> <span class="op">;</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="kw">struct</span> timeval v<span class="op">=</span> <span class="op">{</span><span class="dv">0</span><span class="op">,</span><span class="dv">1</span><span class="op"><<</span><span class="dv">17</span><span class="op">}</span> <span class="op">;</span></span></code></pre></div>
|
||||
<p>and</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>refresh<span class="op">(),</span>c<span class="op">=</span>select<span class="op">(</span>k<span class="op">,&</span>y<span class="op">,</span><span class="dv">0</span><span class="op">,</span><span class="dv">0</span><span class="op">,(</span>v<span class="op">.</span>tv_usec<span class="op">=</span><span class="dv">1</span><span class="op"><<</span><span class="dv">17</span><span class="op">,&</span>v<span class="op">))?</span>getch<span class="op">():</span><span class="dv">0</span><span class="op">;</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> refresh<span class="op">(),</span>c<span class="op">=</span>select<span class="op">(</span>k<span class="op">,&</span>y<span class="op">,</span><span class="dv">0</span><span class="op">,</span><span class="dv">0</span><span class="op">,(</span>v<span class="op">.</span>tv_usec<span class="op">=</span><span class="dv">1</span><span class="op"><<</span><span class="dv">17</span><span class="op">,&</span>v<span class="op">))?</span>getch<span class="op">():</span><span class="dv">0</span><span class="op">;</span></span></code></pre></div>
|
||||
<p>to another value like 18 or 19 which you can do with the alternate code.</p>
|
||||
<p>In the case of <a href="rince.alt2.c">rince.alt2.c</a> the movement keys for the default
|
||||
game are slightly different and will feel more familiar to vi users: <code>h</code> for
|
||||
left, <code>l</code> for right (that was not changed) and <code>k</code> for fire (that was also not
|
||||
changed).</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> SLEEP=18 clobber alt</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> SLEEP=18 clobber alt</span></code></pre></div>
|
||||
<p>Replace 18 with whatever number you wish.</p>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<p>Use <code>rince.alt</code> or <code>rince.alt2</code> as you would <code>rince</code> above.</p>
|
||||
@@ -195,7 +194,7 @@ with it.</p>
|
||||
<code>/usr/local/include/curses.h</code> if not <code>/usr/include/curses.h</code>) is not compatible
|
||||
with the curses library (typically <code>/lib/libcurses.a</code> for static libraries)
|
||||
used. It has been suggested that the following gcc command may help:</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> <span class="at">-fno-builtin</span> <span class="at">-I</span>/usr/include <span class="at">-o</span> rince rince.c <span class="at">-lcurses</span> <span class="at">-ltermcap</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> <span class="at">-fno-builtin</span> <span class="at">-I</span>/usr/include <span class="at">-o</span> rince rince.c <span class="at">-lcurses</span> <span class="at">-ltermcap</span></span></code></pre></div>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<p>This is a Cellular Automata Based, Beautifully Abysmal Game Environment (or
|
||||
CABBAGE for short). To execute the program simply type <code>./rince gamefile</code>,
|
||||
@@ -219,13 +218,13 @@ Levels : Ahh well… it’s not <em>totally</em> generic.</p>
|
||||
<p>The proper definition for usage would be: <code>./rince [data_filename]</code></p>
|
||||
<h3 id="portability">Portability</h3>
|
||||
<p>I have compiled in on the following systems:</p>
|
||||
<pre><code>System OS Compiler (and flags)
|
||||
DECstation 5000/240 Ultrix 4.2A c89 -std
|
||||
SPARCstation 1+ SunOS 4.1 gcc -ansi -pedantic
|
||||
SPARCstation 10/31 Solaris 2.1 gcc -ansi -pedantic (*)
|
||||
DECAlpha 3000/500 OSF/1 V1.2 c89 -std
|
||||
SGI Indigo (R4000) IRIX 4.0.5F cc -ansi
|
||||
Alliant FX2800 Conentrix 3.0.0 fxc</code></pre>
|
||||
<pre><code> System OS Compiler (and flags)
|
||||
DECstation 5000/240 Ultrix 4.2A c89 -std
|
||||
SPARCstation 1+ SunOS 4.1 gcc -ansi -pedantic
|
||||
SPARCstation 10/31 Solaris 2.1 gcc -ansi -pedantic (*)
|
||||
DECAlpha 3000/500 OSF/1 V1.2 c89 -std
|
||||
SGI Indigo (R4000) IRIX 4.0.5F cc -ansi
|
||||
Alliant FX2800 Conentrix 3.0.0 fxc</code></pre>
|
||||
<p>* I never said it worked! The guidelines state that you dislike programs that
|
||||
won’t <em>compile</em> under both BSD or SysV <code>Unix</code>. This compiles, and indeed runs
|
||||
on all the others (both BSD and SysV) correctly.</p>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make all
|
||||
make all
|
||||
```
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ make all
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [1993 schnitzi bugs](../../bugs.html#1993_schnitzi).
|
||||
@@ -19,7 +19,7 @@ For more detailed information see [1993 schnitzi bugs](../../bugs.html#1993_schn
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./schnitzi file
|
||||
./schnitzi file
|
||||
```
|
||||
|
||||
where
|
||||
@@ -34,16 +34,16 @@ in [1993 schnitzi bugs](../../bugs.html#1993_schnitzi).
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./schnitzi schnitzi.info
|
||||
# ask some questions suggested by the author, noted below
|
||||
./schnitzi schnitzi.info
|
||||
# ask some questions suggested by the author, noted below
|
||||
```
|
||||
|
||||
We also suggest you ask the program the following questions:
|
||||
|
||||
```sh
|
||||
Who is Mark Schnitzus?
|
||||
Who is Mark Schnitzus?
|
||||
|
||||
Who was Jack the Ripper ?
|
||||
Who was Jack the Ripper ?
|
||||
```
|
||||
|
||||
Notice how it still manages to answer the first question despite there being an
|
||||
@@ -52,8 +52,8 @@ intentional spelling error there.
|
||||
Try feeding the program source to the program and ask both:
|
||||
|
||||
```sh
|
||||
What is cat ?
|
||||
What is cat?
|
||||
What is cat ?
|
||||
What is cat?
|
||||
```
|
||||
|
||||
What happens if you ask it other questions with and without a space before the
|
||||
|
||||
+10
-11
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Mark_Schnitzius">Mark Schnitzius</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,29 +141,29 @@ 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>
|
||||
<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#1993_schnitzi">1993 schnitzi 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">./schnitzi</span> file</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./schnitzi</span> file</span></code></pre></div>
|
||||
<p>where</p>
|
||||
<p><code>file</code> is a file containing some text.</p>
|
||||
<p>Certain input will cause the program to fail as described
|
||||
in <a href="../../bugs.html#1993_schnitzi">1993 schnitzi bugs</a>.</p>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./schnitzi</span> schnitzi.info</span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="co"># ask some questions suggested by the author, noted below</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./schnitzi</span> schnitzi.info</span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="co"># ask some questions suggested by the author, noted below</span></span></code></pre></div>
|
||||
<p>We also suggest you ask the program the following questions:</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">Who</span> is Mark Schnitzus<span class="pp">?</span></span>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">Who</span> is Mark Schnitzus<span class="pp">?</span></span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="ex">Who</span> was Jack the Ripper <span class="pp">?</span></span></code></pre></div>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">Who</span> was Jack the Ripper <span class="pp">?</span></span></code></pre></div>
|
||||
<p>Notice how it still manages to answer the first question despite there being an
|
||||
intentional spelling error there.</p>
|
||||
<p>Try feeding the program source to the program and ask both:</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">What</span> is cat <span class="pp">?</span></span>
|
||||
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="ex">What</span> is cat<span class="pp">?</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">What</span> is cat <span class="pp">?</span></span>
|
||||
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">What</span> is cat<span class="pp">?</span></span></code></pre></div>
|
||||
<p>What happens if you ask it other questions with and without a space before the
|
||||
<code>?</code>?</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
|
||||
+80
-81
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make all
|
||||
make all
|
||||
```
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ make all
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [1993 vanb bugs](../../bugs.html#1993_vanb).
|
||||
@@ -19,7 +19,7 @@ For more detailed information see [1993 vanb bugs](../../bugs.html#1993_vanb).
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./vanb 'exp'
|
||||
./vanb 'exp'
|
||||
```
|
||||
|
||||
where `exp` is an octal expression. See below for how it can also have
|
||||
@@ -29,7 +29,7 @@ hexadecimal and decimal numbers.
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
What happens if you use something other than valid digits?
|
||||
@@ -40,12 +40,12 @@ What happens if you use something other than valid digits?
|
||||
The octal expression may contain:
|
||||
|
||||
```
|
||||
unary operators: +, -
|
||||
binary operators +, -, *, /, %
|
||||
hex numbers: x or X followed by hex digits
|
||||
decimal numbers: d or D followed by decimal digits
|
||||
octal numbers: octal digits
|
||||
grouping: ()
|
||||
unary operators: +, -
|
||||
binary operators +, -, *, /, %
|
||||
hex numbers: x or X followed by hex digits
|
||||
decimal numbers: d or D followed by decimal digits
|
||||
octal numbers: octal digits
|
||||
grouping: ()
|
||||
```
|
||||
|
||||
No spaces are allowed in the expression. To avoid shell expansion,
|
||||
@@ -94,7 +94,7 @@ what grammar non-terminal to parse. `**O7` is the next character.
|
||||
`O3` is an intermediate result. Whenever you see a construct like:
|
||||
|
||||
```
|
||||
!(expression with O2)?
|
||||
!(expression with O2)?
|
||||
```
|
||||
|
||||
it's decrementing and testing `O2` to see what state it's in. Comparisons
|
||||
@@ -104,29 +104,29 @@ Here's the grammar (`'e'` denotes the empty string) :
|
||||
|
||||
|
||||
```
|
||||
<E> ::= <T><E'>
|
||||
<E'> ::= +<T><E'> | -<T><E'> | e
|
||||
<T> ::= <F><T'>
|
||||
<T'> ::= *<F><T'> | /<F><T'> | %<F><T'> | e
|
||||
<F> ::= +<F> | -<F> | (<E><C> | d<D> | D<D> | x<X> | X<X> | <O>
|
||||
<C> ::= )
|
||||
<D> ::= [0-9]<D> | e
|
||||
<X> ::= [0-9]<X> | [A-F]<X> | [a-f]<X> | e
|
||||
<O> ::= [0-7]<O> | e
|
||||
<E> ::= <T><E'>
|
||||
<E'> ::= +<T><E'> | -<T><E'> | e
|
||||
<T> ::= <F><T'>
|
||||
<T'> ::= *<F><T'> | /<F><T'> | %<F><T'> | e
|
||||
<F> ::= +<F> | -<F> | (<E><C> | d<D> | D<D> | x<X> | X<X> | <O>
|
||||
<C> ::= )
|
||||
<D> ::= [0-9]<D> | e
|
||||
<X> ::= [0-9]<X> | [A-F]<X> | [a-f]<X> | e
|
||||
<O> ::= [0-7]<O> | e
|
||||
```
|
||||
|
||||
Here's how the grammar nonterminals map to octal state numbers:
|
||||
|
||||
```
|
||||
<E> is 012
|
||||
<E'> is 011
|
||||
<T> is 010
|
||||
<T'> is 07
|
||||
<F> is 06
|
||||
<C> is 013
|
||||
<D> is 04
|
||||
<X> is 05
|
||||
<O> is 03
|
||||
<E> is 012
|
||||
<E'> is 011
|
||||
<T> is 010
|
||||
<T'> is 07
|
||||
<F> is 06
|
||||
<C> is 013
|
||||
<D> is 04
|
||||
<X> is 05
|
||||
<O> is 03
|
||||
```
|
||||
|
||||
Here's a version of the program before it got formatted into the VIII,
|
||||
@@ -134,41 +134,41 @@ augmented with comments showing where each state begins. `N1` and `N2` are
|
||||
notes:
|
||||
|
||||
```c
|
||||
#define O5 main
|
||||
O5(O2,O7,O3)char**O7;
|
||||
{
|
||||
return
|
||||
/* N1 */ !(O2+=~01+01) ?\
|
||||
00:
|
||||
/* N2 */ !(O2-=02>01) ?\
|
||||
printf("\045\157\012",O5(012,O7+01,00)):
|
||||
/* O */ !(O2-=02>>01) ?\
|
||||
(**O7<=067 && **O7>057 ? O5(03,O7,*(*O7)++-060+010*O3):O3):
|
||||
/* D */ !(O2-=-O3-~O3) ?\
|
||||
(072>**O7 && 060<=**O7 ? O5(04,O7,012*O3-060+*(*O7)++):O3):
|
||||
/* X */ !(O2-=!O3+!!O3) ?\
|
||||
(**O7>057 && **O7<=071 ? O5(05,O7,*(*O7)+++O3*020-060):
|
||||
**O7<=0106 && 0101<=**O7 ? O5(05,O7,020*O3+*(*O7)++-067):
|
||||
0140<**O7 && **O7<0147 ? O5(05,O7,-0127+*(*O7)+++020*O3):O3):
|
||||
/* F */ !(O2-=02-01) ?\
|
||||
(**O7==050 ? 050**++*O7,O5(013,O7,O5(012,O7,00)):
|
||||
**O7<056 && 054<**O7 ? 055**++*O7,-O5(06,O7,00):
|
||||
054>**O7 && 052<**O7 ? 050**(*O7)++,O5(06,O7,00):
|
||||
!(**O7^0170)||!(0130^**O7) ? *++*O7,O5(05,O7,00):
|
||||
**O7==0144||**O7==0104 ? ++*O7,O5(04,O7,00):O5(03,O7,00)):
|
||||
/* T' */ !--O2 ?\
|
||||
(**O7==052 ? O5(07,O7,O3*(*++*O7,O5(06,O7,00))):
|
||||
!(045-**O7) ? O5(07,O7,O3%(03+(*O7)++,O5(06,O7,00))):
|
||||
!(**O7^057) ? O5(07,O7,O3/(03-*++*O7,O5(06,O7,00))):O3):
|
||||
/* T */ !(O2+=01-02) ?\
|
||||
O5(07,O7,O5(06,O7,00)):
|
||||
/* E' */ !(O2+=-02/02) ?\
|
||||
(!(**O7-053)?O5(011,O7,O3+(++*O7,O5(010,O7,00))):
|
||||
!(055^**O7) ? O5(011,O7,O3-(03+*(*O7)++,O5(010,O7,00))):O3):
|
||||
/* E */ !(O2-=0563&0215) ?\
|
||||
O5(011,O7,O5(010,O7,00)):
|
||||
/* C */ (++*O7,O3);
|
||||
}
|
||||
#define O5 main
|
||||
O5(O2,O7,O3)char**O7;
|
||||
{
|
||||
return
|
||||
/* N1 */ !(O2+=~01+01) ?\
|
||||
00:
|
||||
/* N2 */ !(O2-=02>01) ?\
|
||||
printf("\045\157\012",O5(012,O7+01,00)):
|
||||
/* O */ !(O2-=02>>01) ?\
|
||||
(**O7<=067 && **O7>057 ? O5(03,O7,*(*O7)++-060+010*O3):O3):
|
||||
/* D */ !(O2-=-O3-~O3) ?\
|
||||
(072>**O7 && 060<=**O7 ? O5(04,O7,012*O3-060+*(*O7)++):O3):
|
||||
/* X */ !(O2-=!O3+!!O3) ?\
|
||||
(**O7>057 && **O7<=071 ? O5(05,O7,*(*O7)+++O3*020-060):
|
||||
**O7<=0106 && 0101<=**O7 ? O5(05,O7,020*O3+*(*O7)++-067):
|
||||
0140<**O7 && **O7<0147 ? O5(05,O7,-0127+*(*O7)+++020*O3):O3):
|
||||
/* F */ !(O2-=02-01) ?\
|
||||
(**O7==050 ? 050**++*O7,O5(013,O7,O5(012,O7,00)):
|
||||
**O7<056 && 054<**O7 ? 055**++*O7,-O5(06,O7,00):
|
||||
054>**O7 && 052<**O7 ? 050**(*O7)++,O5(06,O7,00):
|
||||
!(**O7^0170)||!(0130^**O7) ? *++*O7,O5(05,O7,00):
|
||||
**O7==0144||**O7==0104 ? ++*O7,O5(04,O7,00):O5(03,O7,00)):
|
||||
/* T' */ !--O2 ?\
|
||||
(**O7==052 ? O5(07,O7,O3*(*++*O7,O5(06,O7,00))):
|
||||
!(045-**O7) ? O5(07,O7,O3%(03+(*O7)++,O5(06,O7,00))):
|
||||
!(**O7^057) ? O5(07,O7,O3/(03-*++*O7,O5(06,O7,00))):O3):
|
||||
/* T */ !(O2+=01-02) ?\
|
||||
O5(07,O7,O5(06,O7,00)):
|
||||
/* E' */ !(O2+=-02/02) ?\
|
||||
(!(**O7-053)?O5(011,O7,O3+(++*O7,O5(010,O7,00))):
|
||||
!(055^**O7) ? O5(011,O7,O3-(03+*(*O7)++,O5(010,O7,00))):O3):
|
||||
/* E */ !(O2-=0563&0215) ?\
|
||||
O5(011,O7,O5(010,O7,00)):
|
||||
/* C */ (++*O7,O3);
|
||||
}
|
||||
```
|
||||
|
||||
Note `N1`: It should never enter this state, unless the user invokes the
|
||||
@@ -181,39 +181,38 @@ printf, and sends the parser to state `012` (which is `<E>`).
|
||||
The `E` and `T` states work like this:
|
||||
|
||||
```c
|
||||
int e(){ return eprime( t() ); }
|
||||
int e(){ return eprime( t() ); }
|
||||
```
|
||||
|
||||
|
||||
The `E'` and `T'` states work like this:
|
||||
|
||||
```c
|
||||
int eprime( int intermediate )
|
||||
{
|
||||
if( ch == '+' )
|
||||
int eprime( int intermediate )
|
||||
{
|
||||
ch = nextchar();
|
||||
return eprime( intermediate + t() );
|
||||
if( ch == '+' )
|
||||
{
|
||||
ch = nextchar();
|
||||
return eprime( intermediate + t() );
|
||||
}
|
||||
else return intermediate;
|
||||
}
|
||||
else return intermediate;
|
||||
}
|
||||
```
|
||||
|
||||
The `D`, `X` and `O` states work like this (they assume that they're initially
|
||||
called with `0`):
|
||||
|
||||
```c
|
||||
int octal( int intermediate )
|
||||
{
|
||||
if( ch>='0' && ch<='7' )
|
||||
int octal( int intermediate )
|
||||
{
|
||||
intermediate = intermediate * 8 + ch - '0';
|
||||
ch = nextchar();
|
||||
return octal( intermediate );
|
||||
if( ch>='0' && ch<='7' )
|
||||
{
|
||||
intermediate = intermediate * 8 + ch - '0';
|
||||
ch = nextchar();
|
||||
return octal( intermediate );
|
||||
}
|
||||
else return intermediate;
|
||||
}
|
||||
else return intermediate;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
`F` and `C` work similarly.
|
||||
|
||||
+85
-86
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#David_Van_Brackle">David Van Brackle</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,26 +141,26 @@ 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>
|
||||
<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#1993_vanb">1993 vanb 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">./vanb</span> <span class="st">'exp'</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">./vanb</span> <span class="st">'exp'</span></span></code></pre></div>
|
||||
<p>where <code>exp</code> is an octal expression. See below for how it can also have
|
||||
hexadecimal and decimal numbers.</p>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<p>What happens if you use something other than valid digits?</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>The octal expression may contain:</p>
|
||||
<pre><code>unary operators: +, -
|
||||
binary operators +, -, *, /, %
|
||||
hex numbers: x or X followed by hex digits
|
||||
decimal numbers: d or D followed by decimal digits
|
||||
octal numbers: octal digits
|
||||
grouping: ()</code></pre>
|
||||
<pre><code> unary operators: +, -
|
||||
binary operators +, -, *, /, %
|
||||
hex numbers: x or X followed by hex digits
|
||||
decimal numbers: d or D followed by decimal digits
|
||||
octal numbers: octal digits
|
||||
grouping: ()</code></pre>
|
||||
<p>No spaces are allowed in the expression. To avoid shell expansion,
|
||||
one should surround the expression in single quotes.</p>
|
||||
<p>It is a good thing that this program consists of only one
|
||||
@@ -192,96 +191,96 @@ time, to make the program harder to understand.</p></li>
|
||||
for all of its recursion. <code>O2</code> is a state variable, telling <code>main()</code>
|
||||
what grammar non-terminal to parse. <code>**O7</code> is the next character.
|
||||
<code>O3</code> is an intermediate result. Whenever you see a construct like:</p>
|
||||
<pre><code>!(expression with O2)?</code></pre>
|
||||
<pre><code> !(expression with O2)?</code></pre>
|
||||
<p>it’s decrementing and testing <code>O2</code> to see what state it’s in. Comparisons
|
||||
involving <code>**O7</code> and octal constants are looking for certain characters.</p>
|
||||
<p>Here’s the grammar (<code>'e'</code> denotes the empty string) :</p>
|
||||
<pre><code><E> ::= <T><E'>
|
||||
<E'> ::= +<T><E'> | -<T><E'> | e
|
||||
<T> ::= <F><T'>
|
||||
<T'> ::= *<F><T'> | /<F><T'> | %<F><T'> | e
|
||||
<F> ::= +<F> | -<F> | (<E><C> | d<D> | D<D> | x<X> | X<X> | <O>
|
||||
<C> ::= )
|
||||
<D> ::= [0-9]<D> | e
|
||||
<X> ::= [0-9]<X> | [A-F]<X> | [a-f]<X> | e
|
||||
<O> ::= [0-7]<O> | e</code></pre>
|
||||
<pre><code> <E> ::= <T><E'>
|
||||
<E'> ::= +<T><E'> | -<T><E'> | e
|
||||
<T> ::= <F><T'>
|
||||
<T'> ::= *<F><T'> | /<F><T'> | %<F><T'> | e
|
||||
<F> ::= +<F> | -<F> | (<E><C> | d<D> | D<D> | x<X> | X<X> | <O>
|
||||
<C> ::= )
|
||||
<D> ::= [0-9]<D> | e
|
||||
<X> ::= [0-9]<X> | [A-F]<X> | [a-f]<X> | e
|
||||
<O> ::= [0-7]<O> | e</code></pre>
|
||||
<p>Here’s how the grammar nonterminals map to octal state numbers:</p>
|
||||
<pre><code><E> is 012
|
||||
<E'> is 011
|
||||
<T> is 010
|
||||
<T'> is 07
|
||||
<F> is 06
|
||||
<C> is 013
|
||||
<D> is 04
|
||||
<X> is 05
|
||||
<O> is 03</code></pre>
|
||||
<pre><code> <E> is 012
|
||||
<E'> is 011
|
||||
<T> is 010
|
||||
<T'> is 07
|
||||
<F> is 06
|
||||
<C> is 013
|
||||
<D> is 04
|
||||
<X> is 05
|
||||
<O> is 03</code></pre>
|
||||
<p>Here’s a version of the program before it got formatted into the VIII,
|
||||
augmented with comments showing where each state begins. <code>N1</code> and <code>N2</code> are
|
||||
notes:</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><span class="pp">#define O5 main</span></span>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a>O5<span class="op">(</span>O2<span class="op">,</span>O7<span class="op">,</span>O3<span class="op">)</span><span class="dt">char</span><span class="op">**</span>O7<span class="op">;</span></span>
|
||||
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
|
||||
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span></span>
|
||||
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a><span class="co">/* N1 */</span> <span class="op">!(</span>O2<span class="op">+=~</span><span class="bn">01</span><span class="op">+</span><span class="bn">01</span><span class="op">)</span> <span class="op">?</span>\</span>
|
||||
<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a> <span class="bn">00</span><span class="op">:</span></span>
|
||||
<span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a><span class="co">/* N2 */</span> <span class="op">!(</span>O2<span class="op">-=</span><span class="bn">02</span><span class="op">></span><span class="bn">01</span><span class="op">)</span> <span class="op">?</span>\</span>
|
||||
<span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a> printf<span class="op">(</span><span class="st">"</span><span class="sc">\045</span><span class="er">\1</span><span class="st">57</span><span class="sc">\012</span><span class="st">"</span><span class="op">,</span>O5<span class="op">(</span><span class="bn">012</span><span class="op">,</span>O7<span class="op">+</span><span class="bn">01</span><span class="op">,</span><span class="bn">00</span><span class="op">)):</span></span>
|
||||
<span id="cb9-9"><a href="#cb9-9" aria-hidden="true" tabindex="-1"></a><span class="co">/* O */</span> <span class="op">!(</span>O2<span class="op">-=</span><span class="bn">02</span><span class="op">>></span><span class="bn">01</span><span class="op">)</span> <span class="op">?</span>\</span>
|
||||
<span id="cb9-10"><a href="#cb9-10" aria-hidden="true" tabindex="-1"></a> <span class="op">(**</span>O7<span class="op"><=</span><span class="bn">067</span> <span class="op">&&</span> <span class="op">**</span>O7<span class="op">></span><span class="bn">057</span> <span class="op">?</span> O5<span class="op">(</span><span class="bn">03</span><span class="op">,</span>O7<span class="op">,*(*</span>O7<span class="op">)++-</span><span class="bn">060</span><span class="op">+</span><span class="bn">010</span><span class="op">*</span>O3<span class="op">):</span>O3<span class="op">):</span></span>
|
||||
<span id="cb9-11"><a href="#cb9-11" aria-hidden="true" tabindex="-1"></a><span class="co">/* D */</span> <span class="op">!(</span>O2<span class="op">-=-</span>O3<span class="op">-~</span>O3<span class="op">)</span> <span class="op">?</span>\</span>
|
||||
<span id="cb9-12"><a href="#cb9-12" aria-hidden="true" tabindex="-1"></a> <span class="op">(</span><span class="bn">072</span><span class="op">>**</span>O7 <span class="op">&&</span> <span class="bn">060</span><span class="op"><=**</span>O7 <span class="op">?</span> O5<span class="op">(</span><span class="bn">04</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">012</span><span class="op">*</span>O3<span class="op">-</span><span class="bn">060</span><span class="op">+*(*</span>O7<span class="op">)++):</span>O3<span class="op">):</span></span>
|
||||
<span id="cb9-13"><a href="#cb9-13" aria-hidden="true" tabindex="-1"></a><span class="co">/* X */</span> <span class="op">!(</span>O2<span class="op">-=!</span>O3<span class="op">+!!</span>O3<span class="op">)</span> <span class="op">?</span>\</span>
|
||||
<span id="cb9-14"><a href="#cb9-14" aria-hidden="true" tabindex="-1"></a> <span class="op">(**</span>O7<span class="op">></span><span class="bn">057</span> <span class="op">&&</span> <span class="op">**</span>O7<span class="op"><=</span><span class="bn">071</span> <span class="op">?</span> O5<span class="op">(</span><span class="bn">05</span><span class="op">,</span>O7<span class="op">,*(*</span>O7<span class="op">)+++</span>O3<span class="op">*</span><span class="bn">020</span><span class="op">-</span><span class="bn">060</span><span class="op">):</span></span>
|
||||
<span id="cb9-15"><a href="#cb9-15" aria-hidden="true" tabindex="-1"></a> <span class="op">**</span>O7<span class="op"><=</span><span class="bn">0106</span> <span class="op">&&</span> <span class="bn">0101</span><span class="op"><=**</span>O7 <span class="op">?</span> O5<span class="op">(</span><span class="bn">05</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">020</span><span class="op">*</span>O3<span class="op">+*(*</span>O7<span class="op">)++-</span><span class="bn">067</span><span class="op">):</span></span>
|
||||
<span id="cb9-16"><a href="#cb9-16" aria-hidden="true" tabindex="-1"></a> <span class="bn">0140</span><span class="op"><**</span>O7 <span class="op">&&</span> <span class="op">**</span>O7<span class="op"><</span><span class="bn">0147</span> <span class="op">?</span> O5<span class="op">(</span><span class="bn">05</span><span class="op">,</span>O7<span class="op">,-</span><span class="bn">0127</span><span class="op">+*(*</span>O7<span class="op">)+++</span><span class="bn">020</span><span class="op">*</span>O3<span class="op">):</span>O3<span class="op">):</span></span>
|
||||
<span id="cb9-17"><a href="#cb9-17" aria-hidden="true" tabindex="-1"></a><span class="co">/* F */</span> <span class="op">!(</span>O2<span class="op">-=</span><span class="bn">02</span><span class="op">-</span><span class="bn">01</span><span class="op">)</span> <span class="op">?</span>\</span>
|
||||
<span id="cb9-18"><a href="#cb9-18" aria-hidden="true" tabindex="-1"></a> <span class="op">(**</span>O7<span class="op">==</span><span class="bn">050</span> <span class="op">?</span> <span class="bn">050</span><span class="op">**++*</span>O7<span class="op">,</span>O5<span class="op">(</span><span class="bn">013</span><span class="op">,</span>O7<span class="op">,</span>O5<span class="op">(</span><span class="bn">012</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">)):</span></span>
|
||||
<span id="cb9-19"><a href="#cb9-19" aria-hidden="true" tabindex="-1"></a> <span class="op">**</span>O7<span class="op"><</span><span class="bn">056</span> <span class="op">&&</span> <span class="bn">054</span><span class="op"><**</span>O7 <span class="op">?</span> <span class="bn">055</span><span class="op">**++*</span>O7<span class="op">,-</span>O5<span class="op">(</span><span class="bn">06</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">):</span></span>
|
||||
<span id="cb9-20"><a href="#cb9-20" aria-hidden="true" tabindex="-1"></a> <span class="bn">054</span><span class="op">>**</span>O7 <span class="op">&&</span> <span class="bn">052</span><span class="op"><**</span>O7 <span class="op">?</span> <span class="bn">050</span><span class="op">**(*</span>O7<span class="op">)++,</span>O5<span class="op">(</span><span class="bn">06</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">):</span></span>
|
||||
<span id="cb9-21"><a href="#cb9-21" aria-hidden="true" tabindex="-1"></a> <span class="op">!(**</span>O7<span class="op">^</span><span class="bn">0170</span><span class="op">)||!(</span><span class="bn">0130</span><span class="op">^**</span>O7<span class="op">)</span> <span class="op">?</span> <span class="op">*++*</span>O7<span class="op">,</span>O5<span class="op">(</span><span class="bn">05</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">):</span></span>
|
||||
<span id="cb9-22"><a href="#cb9-22" aria-hidden="true" tabindex="-1"></a> <span class="op">**</span>O7<span class="op">==</span><span class="bn">0144</span><span class="op">||**</span>O7<span class="op">==</span><span class="bn">0104</span> <span class="op">?</span> <span class="op">++*</span>O7<span class="op">,</span>O5<span class="op">(</span><span class="bn">04</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">):</span>O5<span class="op">(</span><span class="bn">03</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">)):</span></span>
|
||||
<span id="cb9-23"><a href="#cb9-23" aria-hidden="true" tabindex="-1"></a><span class="co">/* T' */</span> <span class="op">!--</span>O2 <span class="op">?</span>\</span>
|
||||
<span id="cb9-24"><a href="#cb9-24" aria-hidden="true" tabindex="-1"></a> <span class="op">(**</span>O7<span class="op">==</span><span class="bn">052</span> <span class="op">?</span> O5<span class="op">(</span><span class="bn">07</span><span class="op">,</span>O7<span class="op">,</span>O3<span class="op">*(*++*</span>O7<span class="op">,</span>O5<span class="op">(</span><span class="bn">06</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">))):</span></span>
|
||||
<span id="cb9-25"><a href="#cb9-25" aria-hidden="true" tabindex="-1"></a> <span class="op">!(</span><span class="bn">045</span><span class="op">-**</span>O7<span class="op">)</span> <span class="op">?</span> O5<span class="op">(</span><span class="bn">07</span><span class="op">,</span>O7<span class="op">,</span>O3<span class="op">%(</span><span class="bn">03</span><span class="op">+(*</span>O7<span class="op">)++,</span>O5<span class="op">(</span><span class="bn">06</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">))):</span></span>
|
||||
<span id="cb9-26"><a href="#cb9-26" aria-hidden="true" tabindex="-1"></a> <span class="op">!(**</span>O7<span class="op">^</span><span class="bn">057</span><span class="op">)</span> <span class="op">?</span> O5<span class="op">(</span><span class="bn">07</span><span class="op">,</span>O7<span class="op">,</span>O3<span class="op">/(</span><span class="bn">03</span><span class="op">-*++*</span>O7<span class="op">,</span>O5<span class="op">(</span><span class="bn">06</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">))):</span>O3<span class="op">):</span></span>
|
||||
<span id="cb9-27"><a href="#cb9-27" aria-hidden="true" tabindex="-1"></a><span class="co">/* T */</span> <span class="op">!(</span>O2<span class="op">+=</span><span class="bn">01</span><span class="op">-</span><span class="bn">02</span><span class="op">)</span> <span class="op">?</span>\</span>
|
||||
<span id="cb9-28"><a href="#cb9-28" aria-hidden="true" tabindex="-1"></a> O5<span class="op">(</span><span class="bn">07</span><span class="op">,</span>O7<span class="op">,</span>O5<span class="op">(</span><span class="bn">06</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">)):</span></span>
|
||||
<span id="cb9-29"><a href="#cb9-29" aria-hidden="true" tabindex="-1"></a><span class="co">/* E' */</span> <span class="op">!(</span>O2<span class="op">+=-</span><span class="bn">02</span><span class="op">/</span><span class="bn">02</span><span class="op">)</span> <span class="op">?</span>\</span>
|
||||
<span id="cb9-30"><a href="#cb9-30" aria-hidden="true" tabindex="-1"></a> <span class="op">(!(**</span>O7<span class="op">-</span><span class="bn">053</span><span class="op">)?</span>O5<span class="op">(</span><span class="bn">011</span><span class="op">,</span>O7<span class="op">,</span>O3<span class="op">+(++*</span>O7<span class="op">,</span>O5<span class="op">(</span><span class="bn">010</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">))):</span></span>
|
||||
<span id="cb9-31"><a href="#cb9-31" aria-hidden="true" tabindex="-1"></a> <span class="op">!(</span><span class="bn">055</span><span class="op">^**</span>O7<span class="op">)</span> <span class="op">?</span> O5<span class="op">(</span><span class="bn">011</span><span class="op">,</span>O7<span class="op">,</span>O3<span class="op">-(</span><span class="bn">03</span><span class="op">+*(*</span>O7<span class="op">)++,</span>O5<span class="op">(</span><span class="bn">010</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">))):</span>O3<span class="op">):</span></span>
|
||||
<span id="cb9-32"><a href="#cb9-32" aria-hidden="true" tabindex="-1"></a><span class="co">/* E */</span> <span class="op">!(</span>O2<span class="op">-=</span><span class="bn">0563</span><span class="op">&</span><span class="bn">0215</span><span class="op">)</span> <span class="op">?</span>\</span>
|
||||
<span id="cb9-33"><a href="#cb9-33" aria-hidden="true" tabindex="-1"></a> O5<span class="op">(</span><span class="bn">011</span><span class="op">,</span>O7<span class="op">,</span>O5<span class="op">(</span><span class="bn">010</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">)):</span></span>
|
||||
<span id="cb9-34"><a href="#cb9-34" aria-hidden="true" tabindex="-1"></a><span class="co">/* C */</span> <span class="op">(++*</span>O7<span class="op">,</span>O3<span class="op">);</span></span>
|
||||
<span id="cb9-35"><a href="#cb9-35" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
|
||||
<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> <span class="pp">#define O5 main</span></span>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> O5<span class="op">(</span>O2<span class="op">,</span>O7<span class="op">,</span>O3<span class="op">)</span><span class="dt">char</span><span class="op">**</span>O7<span class="op">;</span></span>
|
||||
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="op">{</span></span>
|
||||
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span></span>
|
||||
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a> <span class="co">/* N1 */</span> <span class="op">!(</span>O2<span class="op">+=~</span><span class="bn">01</span><span class="op">+</span><span class="bn">01</span><span class="op">)</span> <span class="op">?</span>\</span>
|
||||
<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a> <span class="bn">00</span><span class="op">:</span></span>
|
||||
<span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a> <span class="co">/* N2 */</span> <span class="op">!(</span>O2<span class="op">-=</span><span class="bn">02</span><span class="op">></span><span class="bn">01</span><span class="op">)</span> <span class="op">?</span>\</span>
|
||||
<span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a> printf<span class="op">(</span><span class="st">"</span><span class="sc">\045</span><span class="er">\1</span><span class="st">57</span><span class="sc">\012</span><span class="st">"</span><span class="op">,</span>O5<span class="op">(</span><span class="bn">012</span><span class="op">,</span>O7<span class="op">+</span><span class="bn">01</span><span class="op">,</span><span class="bn">00</span><span class="op">)):</span></span>
|
||||
<span id="cb9-9"><a href="#cb9-9" aria-hidden="true" tabindex="-1"></a> <span class="co">/* O */</span> <span class="op">!(</span>O2<span class="op">-=</span><span class="bn">02</span><span class="op">>></span><span class="bn">01</span><span class="op">)</span> <span class="op">?</span>\</span>
|
||||
<span id="cb9-10"><a href="#cb9-10" aria-hidden="true" tabindex="-1"></a> <span class="op">(**</span>O7<span class="op"><=</span><span class="bn">067</span> <span class="op">&&</span> <span class="op">**</span>O7<span class="op">></span><span class="bn">057</span> <span class="op">?</span> O5<span class="op">(</span><span class="bn">03</span><span class="op">,</span>O7<span class="op">,*(*</span>O7<span class="op">)++-</span><span class="bn">060</span><span class="op">+</span><span class="bn">010</span><span class="op">*</span>O3<span class="op">):</span>O3<span class="op">):</span></span>
|
||||
<span id="cb9-11"><a href="#cb9-11" aria-hidden="true" tabindex="-1"></a> <span class="co">/* D */</span> <span class="op">!(</span>O2<span class="op">-=-</span>O3<span class="op">-~</span>O3<span class="op">)</span> <span class="op">?</span>\</span>
|
||||
<span id="cb9-12"><a href="#cb9-12" aria-hidden="true" tabindex="-1"></a> <span class="op">(</span><span class="bn">072</span><span class="op">>**</span>O7 <span class="op">&&</span> <span class="bn">060</span><span class="op"><=**</span>O7 <span class="op">?</span> O5<span class="op">(</span><span class="bn">04</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">012</span><span class="op">*</span>O3<span class="op">-</span><span class="bn">060</span><span class="op">+*(*</span>O7<span class="op">)++):</span>O3<span class="op">):</span></span>
|
||||
<span id="cb9-13"><a href="#cb9-13" aria-hidden="true" tabindex="-1"></a> <span class="co">/* X */</span> <span class="op">!(</span>O2<span class="op">-=!</span>O3<span class="op">+!!</span>O3<span class="op">)</span> <span class="op">?</span>\</span>
|
||||
<span id="cb9-14"><a href="#cb9-14" aria-hidden="true" tabindex="-1"></a> <span class="op">(**</span>O7<span class="op">></span><span class="bn">057</span> <span class="op">&&</span> <span class="op">**</span>O7<span class="op"><=</span><span class="bn">071</span> <span class="op">?</span> O5<span class="op">(</span><span class="bn">05</span><span class="op">,</span>O7<span class="op">,*(*</span>O7<span class="op">)+++</span>O3<span class="op">*</span><span class="bn">020</span><span class="op">-</span><span class="bn">060</span><span class="op">):</span></span>
|
||||
<span id="cb9-15"><a href="#cb9-15" aria-hidden="true" tabindex="-1"></a> <span class="op">**</span>O7<span class="op"><=</span><span class="bn">0106</span> <span class="op">&&</span> <span class="bn">0101</span><span class="op"><=**</span>O7 <span class="op">?</span> O5<span class="op">(</span><span class="bn">05</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">020</span><span class="op">*</span>O3<span class="op">+*(*</span>O7<span class="op">)++-</span><span class="bn">067</span><span class="op">):</span></span>
|
||||
<span id="cb9-16"><a href="#cb9-16" aria-hidden="true" tabindex="-1"></a> <span class="bn">0140</span><span class="op"><**</span>O7 <span class="op">&&</span> <span class="op">**</span>O7<span class="op"><</span><span class="bn">0147</span> <span class="op">?</span> O5<span class="op">(</span><span class="bn">05</span><span class="op">,</span>O7<span class="op">,-</span><span class="bn">0127</span><span class="op">+*(*</span>O7<span class="op">)+++</span><span class="bn">020</span><span class="op">*</span>O3<span class="op">):</span>O3<span class="op">):</span></span>
|
||||
<span id="cb9-17"><a href="#cb9-17" aria-hidden="true" tabindex="-1"></a> <span class="co">/* F */</span> <span class="op">!(</span>O2<span class="op">-=</span><span class="bn">02</span><span class="op">-</span><span class="bn">01</span><span class="op">)</span> <span class="op">?</span>\</span>
|
||||
<span id="cb9-18"><a href="#cb9-18" aria-hidden="true" tabindex="-1"></a> <span class="op">(**</span>O7<span class="op">==</span><span class="bn">050</span> <span class="op">?</span> <span class="bn">050</span><span class="op">**++*</span>O7<span class="op">,</span>O5<span class="op">(</span><span class="bn">013</span><span class="op">,</span>O7<span class="op">,</span>O5<span class="op">(</span><span class="bn">012</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">)):</span></span>
|
||||
<span id="cb9-19"><a href="#cb9-19" aria-hidden="true" tabindex="-1"></a> <span class="op">**</span>O7<span class="op"><</span><span class="bn">056</span> <span class="op">&&</span> <span class="bn">054</span><span class="op"><**</span>O7 <span class="op">?</span> <span class="bn">055</span><span class="op">**++*</span>O7<span class="op">,-</span>O5<span class="op">(</span><span class="bn">06</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">):</span></span>
|
||||
<span id="cb9-20"><a href="#cb9-20" aria-hidden="true" tabindex="-1"></a> <span class="bn">054</span><span class="op">>**</span>O7 <span class="op">&&</span> <span class="bn">052</span><span class="op"><**</span>O7 <span class="op">?</span> <span class="bn">050</span><span class="op">**(*</span>O7<span class="op">)++,</span>O5<span class="op">(</span><span class="bn">06</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">):</span></span>
|
||||
<span id="cb9-21"><a href="#cb9-21" aria-hidden="true" tabindex="-1"></a> <span class="op">!(**</span>O7<span class="op">^</span><span class="bn">0170</span><span class="op">)||!(</span><span class="bn">0130</span><span class="op">^**</span>O7<span class="op">)</span> <span class="op">?</span> <span class="op">*++*</span>O7<span class="op">,</span>O5<span class="op">(</span><span class="bn">05</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">):</span></span>
|
||||
<span id="cb9-22"><a href="#cb9-22" aria-hidden="true" tabindex="-1"></a> <span class="op">**</span>O7<span class="op">==</span><span class="bn">0144</span><span class="op">||**</span>O7<span class="op">==</span><span class="bn">0104</span> <span class="op">?</span> <span class="op">++*</span>O7<span class="op">,</span>O5<span class="op">(</span><span class="bn">04</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">):</span>O5<span class="op">(</span><span class="bn">03</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">)):</span></span>
|
||||
<span id="cb9-23"><a href="#cb9-23" aria-hidden="true" tabindex="-1"></a> <span class="co">/* T' */</span> <span class="op">!--</span>O2 <span class="op">?</span>\</span>
|
||||
<span id="cb9-24"><a href="#cb9-24" aria-hidden="true" tabindex="-1"></a> <span class="op">(**</span>O7<span class="op">==</span><span class="bn">052</span> <span class="op">?</span> O5<span class="op">(</span><span class="bn">07</span><span class="op">,</span>O7<span class="op">,</span>O3<span class="op">*(*++*</span>O7<span class="op">,</span>O5<span class="op">(</span><span class="bn">06</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">))):</span></span>
|
||||
<span id="cb9-25"><a href="#cb9-25" aria-hidden="true" tabindex="-1"></a> <span class="op">!(</span><span class="bn">045</span><span class="op">-**</span>O7<span class="op">)</span> <span class="op">?</span> O5<span class="op">(</span><span class="bn">07</span><span class="op">,</span>O7<span class="op">,</span>O3<span class="op">%(</span><span class="bn">03</span><span class="op">+(*</span>O7<span class="op">)++,</span>O5<span class="op">(</span><span class="bn">06</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">))):</span></span>
|
||||
<span id="cb9-26"><a href="#cb9-26" aria-hidden="true" tabindex="-1"></a> <span class="op">!(**</span>O7<span class="op">^</span><span class="bn">057</span><span class="op">)</span> <span class="op">?</span> O5<span class="op">(</span><span class="bn">07</span><span class="op">,</span>O7<span class="op">,</span>O3<span class="op">/(</span><span class="bn">03</span><span class="op">-*++*</span>O7<span class="op">,</span>O5<span class="op">(</span><span class="bn">06</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">))):</span>O3<span class="op">):</span></span>
|
||||
<span id="cb9-27"><a href="#cb9-27" aria-hidden="true" tabindex="-1"></a> <span class="co">/* T */</span> <span class="op">!(</span>O2<span class="op">+=</span><span class="bn">01</span><span class="op">-</span><span class="bn">02</span><span class="op">)</span> <span class="op">?</span>\</span>
|
||||
<span id="cb9-28"><a href="#cb9-28" aria-hidden="true" tabindex="-1"></a> O5<span class="op">(</span><span class="bn">07</span><span class="op">,</span>O7<span class="op">,</span>O5<span class="op">(</span><span class="bn">06</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">)):</span></span>
|
||||
<span id="cb9-29"><a href="#cb9-29" aria-hidden="true" tabindex="-1"></a> <span class="co">/* E' */</span> <span class="op">!(</span>O2<span class="op">+=-</span><span class="bn">02</span><span class="op">/</span><span class="bn">02</span><span class="op">)</span> <span class="op">?</span>\</span>
|
||||
<span id="cb9-30"><a href="#cb9-30" aria-hidden="true" tabindex="-1"></a> <span class="op">(!(**</span>O7<span class="op">-</span><span class="bn">053</span><span class="op">)?</span>O5<span class="op">(</span><span class="bn">011</span><span class="op">,</span>O7<span class="op">,</span>O3<span class="op">+(++*</span>O7<span class="op">,</span>O5<span class="op">(</span><span class="bn">010</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">))):</span></span>
|
||||
<span id="cb9-31"><a href="#cb9-31" aria-hidden="true" tabindex="-1"></a> <span class="op">!(</span><span class="bn">055</span><span class="op">^**</span>O7<span class="op">)</span> <span class="op">?</span> O5<span class="op">(</span><span class="bn">011</span><span class="op">,</span>O7<span class="op">,</span>O3<span class="op">-(</span><span class="bn">03</span><span class="op">+*(*</span>O7<span class="op">)++,</span>O5<span class="op">(</span><span class="bn">010</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">))):</span>O3<span class="op">):</span></span>
|
||||
<span id="cb9-32"><a href="#cb9-32" aria-hidden="true" tabindex="-1"></a> <span class="co">/* E */</span> <span class="op">!(</span>O2<span class="op">-=</span><span class="bn">0563</span><span class="op">&</span><span class="bn">0215</span><span class="op">)</span> <span class="op">?</span>\</span>
|
||||
<span id="cb9-33"><a href="#cb9-33" aria-hidden="true" tabindex="-1"></a> O5<span class="op">(</span><span class="bn">011</span><span class="op">,</span>O7<span class="op">,</span>O5<span class="op">(</span><span class="bn">010</span><span class="op">,</span>O7<span class="op">,</span><span class="bn">00</span><span class="op">)):</span></span>
|
||||
<span id="cb9-34"><a href="#cb9-34" aria-hidden="true" tabindex="-1"></a> <span class="co">/* C */</span> <span class="op">(++*</span>O7<span class="op">,</span>O3<span class="op">);</span></span>
|
||||
<span id="cb9-35"><a href="#cb9-35" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span></code></pre></div>
|
||||
<p>Note <code>N1</code>: It should never enter this state, unless the user invokes the
|
||||
program with no parameters, in which case it just returns 0.</p>
|
||||
<p>Note <code>N2</code>: Since the program is properly invoked with 1 parameter, this is
|
||||
the first state it will go into. This state just invokes
|
||||
printf, and sends the parser to state <code>012</code> (which is <code><E></code>).</p>
|
||||
<p>The <code>E</code> and <code>T</code> states work like this:</p>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="dt">int</span> e<span class="op">(){</span> <span class="cf">return</span> eprime<span class="op">(</span> t<span class="op">()</span> <span class="op">);</span> <span class="op">}</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span> e<span class="op">(){</span> <span class="cf">return</span> eprime<span class="op">(</span> t<span class="op">()</span> <span class="op">);</span> <span class="op">}</span></span></code></pre></div>
|
||||
<p>The <code>E'</code> and <code>T'</code> states work like this:</p>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="dt">int</span> eprime<span class="op">(</span> <span class="dt">int</span> intermediate <span class="op">)</span></span>
|
||||
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
|
||||
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span><span class="op">(</span> ch <span class="op">==</span> <span class="ch">'+'</span> <span class="op">)</span></span>
|
||||
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a> <span class="op">{</span></span>
|
||||
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a> ch <span class="op">=</span> nextchar<span class="op">();</span></span>
|
||||
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> eprime<span class="op">(</span> intermediate <span class="op">+</span> t<span class="op">()</span> <span class="op">);</span></span>
|
||||
<span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
|
||||
<span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a> <span class="cf">else</span> <span class="cf">return</span> intermediate<span class="op">;</span></span>
|
||||
<span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="dt">int</span> eprime<span class="op">(</span> <span class="dt">int</span> intermediate <span class="op">)</span></span>
|
||||
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="op">{</span></span>
|
||||
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span><span class="op">(</span> ch <span class="op">==</span> <span class="ch">'+'</span> <span class="op">)</span></span>
|
||||
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a> <span class="op">{</span></span>
|
||||
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a> ch <span class="op">=</span> nextchar<span class="op">();</span></span>
|
||||
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> eprime<span class="op">(</span> intermediate <span class="op">+</span> t<span class="op">()</span> <span class="op">);</span></span>
|
||||
<span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
|
||||
<span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a> <span class="cf">else</span> <span class="cf">return</span> intermediate<span class="op">;</span></span>
|
||||
<span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span></code></pre></div>
|
||||
<p>The <code>D</code>, <code>X</code> and <code>O</code> states work like this (they assume that they’re initially
|
||||
called with <code>0</code>):</p>
|
||||
<div class="sourceCode" id="cb12"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="dt">int</span> octal<span class="op">(</span> <span class="dt">int</span> intermediate <span class="op">)</span></span>
|
||||
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
|
||||
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span><span class="op">(</span> ch<span class="op">>=</span><span class="ch">'0'</span> <span class="op">&&</span> ch<span class="op"><=</span><span class="ch">'7'</span> <span class="op">)</span></span>
|
||||
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a> <span class="op">{</span></span>
|
||||
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a> intermediate <span class="op">=</span> intermediate <span class="op">*</span> <span class="dv">8</span> <span class="op">+</span> ch <span class="op">-</span> <span class="ch">'0'</span><span class="op">;</span></span>
|
||||
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a> ch <span class="op">=</span> nextchar<span class="op">();</span></span>
|
||||
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> octal<span class="op">(</span> intermediate <span class="op">);</span></span>
|
||||
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
|
||||
<span id="cb12-9"><a href="#cb12-9" aria-hidden="true" tabindex="-1"></a> <span class="cf">else</span> <span class="cf">return</span> intermediate<span class="op">;</span></span>
|
||||
<span id="cb12-10"><a href="#cb12-10" aria-hidden="true" tabindex="-1"></a><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> <span class="dt">int</span> octal<span class="op">(</span> <span class="dt">int</span> intermediate <span class="op">)</span></span>
|
||||
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="op">{</span></span>
|
||||
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span><span class="op">(</span> ch<span class="op">>=</span><span class="ch">'0'</span> <span class="op">&&</span> ch<span class="op"><=</span><span class="ch">'7'</span> <span class="op">)</span></span>
|
||||
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a> <span class="op">{</span></span>
|
||||
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a> intermediate <span class="op">=</span> intermediate <span class="op">*</span> <span class="dv">8</span> <span class="op">+</span> ch <span class="op">-</span> <span class="ch">'0'</span><span class="op">;</span></span>
|
||||
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a> ch <span class="op">=</span> nextchar<span class="op">();</span></span>
|
||||
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> octal<span class="op">(</span> intermediate <span class="op">);</span></span>
|
||||
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
|
||||
<span id="cb12-9"><a href="#cb12-9" aria-hidden="true" tabindex="-1"></a> <span class="cf">else</span> <span class="cf">return</span> intermediate<span class="op">;</span></span>
|
||||
<span id="cb12-10"><a href="#cb12-10" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span></code></pre></div>
|
||||
<p><code>F</code> and <code>C</code> work similarly.</p>
|
||||
<!--
|
||||
|
||||
|
||||
Reference in new issue
Block a user