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
+8
-8
@@ -67,14 +67,14 @@ and 22 (one third of 666).
|
||||
Rule 22, now known as **Catch 22** states:
|
||||
|
||||
```
|
||||
| 22) Your source code, data files, remarks and program output must NOT
|
||||
| identify the authors of your code. The judges STRONGLY prefer to
|
||||
| not know who is submitting entries to the IOCCC.
|
||||
| 22) Your source code, data files, remarks and program output must NOT
|
||||
| identify the authors of your code. The judges STRONGLY prefer to
|
||||
| not know who is submitting entries to the IOCCC.
|
||||
|
||||
| The "Peter Honeyman is exempt" guideline also applies to this rule.
|
||||
| Identifying yourself, in an obvious way in your code, data, remarks
|
||||
| or program output, unless you are Peter Honeyman or pretending
|
||||
| to be Peter Honeyman, will be grounds for disqualification of your entry.
|
||||
| The "Peter Honeyman is exempt" guideline also applies to this rule.
|
||||
| Identifying yourself, in an obvious way in your code, data, remarks
|
||||
| or program output, unless you are Peter Honeyman or pretending
|
||||
| to be Peter Honeyman, will be grounds for disqualification of your entry.
|
||||
```
|
||||
|
||||
A number of other entries were based on [iocccsize.c](iocccsize.c), making
|
||||
@@ -83,7 +83,7 @@ derivative works rather than original works.
|
||||
Still other entries were too large, violating the first line of rule 2:
|
||||
|
||||
```
|
||||
2) The size of your program source must be <= 4096 bytes in length.
|
||||
2) The size of your program source must be <= 4096 bytes in length.
|
||||
```
|
||||
|
||||
While these entries might have passed under the 2053 limit for iocccsize,
|
||||
|
||||
+13
-13
@@ -1,20 +1,20 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./prog "expression"
|
||||
./prog "expression"
|
||||
```
|
||||
|
||||
or:
|
||||
|
||||
```sh
|
||||
./prog
|
||||
./prog
|
||||
```
|
||||
|
||||
Type in expressions on standard input.
|
||||
@@ -23,13 +23,13 @@ Type in expressions on standard input.
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
Notice how the script reads in from a file. If you type just:
|
||||
|
||||
```sh
|
||||
./prog
|
||||
./prog
|
||||
```
|
||||
|
||||
it will prompt you in the same way. Send ctrl-c to exit.
|
||||
@@ -38,7 +38,7 @@ it will prompt you in the same way. Send ctrl-c to exit.
|
||||
Finally, if you wish to read the man page:
|
||||
|
||||
```sh
|
||||
man ./calc.1
|
||||
man ./calc.1
|
||||
```
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ author's remarks below.
|
||||
### Alternate build:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
make alt
|
||||
```
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ However, unlike any other calculator source code the author is aware of,
|
||||
this one contains no digits. At all. Anywhere. As in
|
||||
|
||||
```sh
|
||||
grep '[0-9]' prog.c || echo no digits!
|
||||
grep '[0-9]' prog.c || echo no digits!
|
||||
```
|
||||
|
||||
Nor are the digits simply obfuscated. There are no character constants. There
|
||||
@@ -192,8 +192,8 @@ long`. Changing the two `long long` typedefs to `long`, and compiling with `gcc
|
||||
shifts mod 32:
|
||||
|
||||
```
|
||||
1<<48
|
||||
65536 0x00010000
|
||||
1<<48
|
||||
65536 0x00010000
|
||||
```
|
||||
|
||||
gcc 4.2.1 without arguments compiles cleanly (e.g. `cc prog.c -o prog`).
|
||||
@@ -203,7 +203,7 @@ clang 3.6.0 lives up to its namesake, resounding on non-problems.
|
||||
To stifle these complaints:
|
||||
|
||||
```
|
||||
-Wno-return-type -Wno-parentheses -Wno-empty-body
|
||||
-Wno-return-type -Wno-parentheses -Wno-empty-body
|
||||
```
|
||||
|
||||
When invoked with `-ansi -pedantic`, there are two warnings, which can be ignored:
|
||||
@@ -223,8 +223,8 @@ If the program name begins with an `e`, it echoes `stdin` to `stdout`.
|
||||
This allows for a convenient test suite:
|
||||
|
||||
```sh
|
||||
ln -sf prog eprog
|
||||
PATH=. eprog < test.in | diff - test.out
|
||||
ln -sf prog eprog
|
||||
PATH=. eprog < test.in | diff - test.out
|
||||
```
|
||||
|
||||
### Spoilers:
|
||||
|
||||
+14
-15
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Dave_Burton">Dave Burton</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,25 +141,25 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> <span class="st">"expression"</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">./prog</span> <span class="st">"expression"</span></span></code></pre></div>
|
||||
<p>or:</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">./prog</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">./prog</span></span></code></pre></div>
|
||||
<p>Type in expressions on standard input.</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>Notice how the script reads in from a file. If you type just:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span></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">./prog</span></span></code></pre></div>
|
||||
<p>it will prompt you in the same way. Send ctrl-c to exit.</p>
|
||||
<p>Finally, if you wish to read the man page:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">man</span> ./calc.1</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">man</span> ./calc.1</span></code></pre></div>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<p>An alternate version of this entry, <a href="prog.alt.c">prog.alt.c</a>, is provided.
|
||||
This alternate code is discussed in the “prog.c vs prog.alt.c” section of the
|
||||
author’s remarks below.</p>
|
||||
<h3 id="alternate-build">Alternate build:</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="fu">make</span> alt</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">make</span> alt</span></code></pre></div>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<p>Use <code>prog.alt</code> as you would <code>prog</code> above.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
@@ -190,7 +189,7 @@ corrected by adding <code>-fsigned-char</code> to the compile line.</p>
|
||||
<p>Yes, this is another calculator program.</p>
|
||||
<p>However, unlike any other calculator source code the author is aware of,
|
||||
this one contains no digits. At all. Anywhere. As in</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="fu">grep</span> <span class="st">'[0-9]'</span> prog.c <span class="kw">||</span> <span class="bu">echo</span> no digits!</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">grep</span> <span class="st">'[0-9]'</span> prog.c <span class="kw">||</span> <span class="bu">echo</span> no digits!</span></code></pre></div>
|
||||
<p>Nor are the digits simply obfuscated. There are no character constants. There
|
||||
is only one single, short string, and it does not contain any obfuscated digits.
|
||||
And yet the output is in decimal and hexadecimal, and it accepts octal, decimal,
|
||||
@@ -246,13 +245,13 @@ they are to write.</p></li>
|
||||
<h3 id="compiler-warnings">Compiler warnings</h3>
|
||||
<p><code>calc</code> is C99 compliant, and is ANSI/C90 compliant except for wanting 64-bit <code>long long</code>. Changing the two <code>long long</code> typedefs to <code>long</code>, and compiling with <code>gcc -m32</code> yields a program that operates on 32-bit values, with wrap-around of
|
||||
shifts mod 32:</p>
|
||||
<pre><code>1<<48
|
||||
65536 0x00010000</code></pre>
|
||||
<pre><code> 1<<48
|
||||
65536 0x00010000</code></pre>
|
||||
<p>gcc 4.2.1 without arguments compiles cleanly (e.g. <code>cc prog.c -o prog</code>).
|
||||
This is my workaday compiler. gcc is also clean with <code>-ansi</code>, and <code>-std=c99</code>.</p>
|
||||
<p>clang 3.6.0 lives up to its namesake, resounding on non-problems.
|
||||
To stifle these complaints:</p>
|
||||
<pre><code>-Wno-return-type -Wno-parentheses -Wno-empty-body</code></pre>
|
||||
<pre><code> -Wno-return-type -Wno-parentheses -Wno-empty-body</code></pre>
|
||||
<p>When invoked with <code>-ansi -pedantic</code>, there are two warnings, which can be ignored:</p>
|
||||
<ul>
|
||||
<li><code>ISO C90 does not support 'long long'</code></li>
|
||||
@@ -266,8 +265,8 @@ To stifle these complaints:</p>
|
||||
<h3 id="test-suite">Test Suite:</h3>
|
||||
<p>If the program name begins with an <code>e</code>, it echoes <code>stdin</code> to <code>stdout</code>.
|
||||
This allows for a convenient test suite:</p>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ln</span> <span class="at">-sf</span> prog eprog</span>
|
||||
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="va">PATH</span><span class="op">=</span>. <span class="ex">eprog</span> <span class="op"><</span> test.in <span class="kw">|</span> <span class="fu">diff</span> <span class="at">-</span> test.out</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">ln</span> <span class="at">-sf</span> prog eprog</span>
|
||||
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="va">PATH</span><span class="op">=</span>. <span class="ex">eprog</span> <span class="op"><</span> test.in <span class="kw">|</span> <span class="fu">diff</span> <span class="at">-</span> test.out</span></code></pre></div>
|
||||
<h3 id="spoilers">Spoilers:</h3>
|
||||
<p>If you do not want to puzzle out how it works, see <a href="spoilers.html">spoilers.html</a>.</p>
|
||||
<!--
|
||||
|
||||
@@ -135,50 +135,50 @@ did the basic four operations, but as a programmer, I needed more, so those
|
||||
were added over time.</p>
|
||||
<p><code>calc</code> is a useful, functioning utility. The operators before the obfuscation
|
||||
dance began (this is called foreshadowing):</p>
|
||||
<pre><code>() forced precedence
|
||||
- ~ ? unary minus, compl, byteswap
|
||||
* / % & << >> mul, div, mod, bitand, shift: left, right
|
||||
+ - | ^ add, sub, bitor, xor
|
||||
NUM 0-9</code></pre>
|
||||
<pre><code> () forced precedence
|
||||
- ~ ? unary minus, compl, byteswap
|
||||
* / % & << >> mul, div, mod, bitand, shift: left, right
|
||||
+ - | ^ add, sub, bitor, xor
|
||||
NUM 0-9</code></pre>
|
||||
<p>This seemed like a reasonable candidate to experiment with obfuscation; perhaps
|
||||
it might yield good results.</p>
|
||||
<h2 id="principle-of-operation">Principle of operation</h2>
|
||||
<p>The algorithm was and is rather straightforward:</p>
|
||||
<pre><code>expr() {
|
||||
n = term()
|
||||
t = token()
|
||||
if (t == ADD) return n += expr()
|
||||
if (t == SUB) return n -= expr()
|
||||
if (t == BOR) return n |= expr()
|
||||
if (t == XOR) return n ^= expr()
|
||||
ungettoken(t)
|
||||
return n
|
||||
}
|
||||
term() {
|
||||
n = factor()
|
||||
t = token()
|
||||
if (t == MUL) return n *= term()
|
||||
if (t == DIV) return n /= term()
|
||||
if (t == AND) return n &= term()
|
||||
if (t == RSH) return n >> term()
|
||||
if (t == LSH) return n << term()
|
||||
ungettoken(t)
|
||||
return n
|
||||
}
|
||||
factor() {
|
||||
t = token()
|
||||
if (t == LPAREN) {
|
||||
n = expr()
|
||||
if token() == RPAREN
|
||||
return n
|
||||
error()
|
||||
}
|
||||
if (t == SUB) return -factor()
|
||||
if (t == CMP) return ~factor()
|
||||
if (t == QUE) return byteswap(factor())
|
||||
if (t == DIG) return strtol()
|
||||
error()
|
||||
}</code></pre>
|
||||
<pre><code> expr() {
|
||||
n = term()
|
||||
t = token()
|
||||
if (t == ADD) return n += expr()
|
||||
if (t == SUB) return n -= expr()
|
||||
if (t == BOR) return n |= expr()
|
||||
if (t == XOR) return n ^= expr()
|
||||
ungettoken(t)
|
||||
return n
|
||||
}
|
||||
term() {
|
||||
n = factor()
|
||||
t = token()
|
||||
if (t == MUL) return n *= term()
|
||||
if (t == DIV) return n /= term()
|
||||
if (t == AND) return n &= term()
|
||||
if (t == RSH) return n >> term()
|
||||
if (t == LSH) return n << term()
|
||||
ungettoken(t)
|
||||
return n
|
||||
}
|
||||
factor() {
|
||||
t = token()
|
||||
if (t == LPAREN) {
|
||||
n = expr()
|
||||
if token() == RPAREN
|
||||
return n
|
||||
error()
|
||||
}
|
||||
if (t == SUB) return -factor()
|
||||
if (t == CMP) return ~factor()
|
||||
if (t == QUE) return byteswap(factor())
|
||||
if (t == DIG) return strtol()
|
||||
error()
|
||||
}</code></pre>
|
||||
<h2 id="obfuscation-is-a-process">Obfuscation is a process</h2>
|
||||
<p>Within the above algorithm, there are many details unmentioned, all ripe for
|
||||
obfuscation:</p>
|
||||
|
||||
@@ -17,11 +17,11 @@ were added over time.
|
||||
dance began (this is called foreshadowing):
|
||||
|
||||
```
|
||||
() forced precedence
|
||||
- ~ ? unary minus, compl, byteswap
|
||||
* / % & << >> mul, div, mod, bitand, shift: left, right
|
||||
+ - | ^ add, sub, bitor, xor
|
||||
NUM 0-9
|
||||
() forced precedence
|
||||
- ~ ? unary minus, compl, byteswap
|
||||
* / % & << >> mul, div, mod, bitand, shift: left, right
|
||||
+ - | ^ add, sub, bitor, xor
|
||||
NUM 0-9
|
||||
```
|
||||
|
||||
This seemed like a reasonable candidate to experiment with obfuscation; perhaps
|
||||
@@ -33,41 +33,41 @@ it might yield good results.
|
||||
The algorithm was and is rather straightforward:
|
||||
|
||||
```
|
||||
expr() {
|
||||
n = term()
|
||||
t = token()
|
||||
if (t == ADD) return n += expr()
|
||||
if (t == SUB) return n -= expr()
|
||||
if (t == BOR) return n |= expr()
|
||||
if (t == XOR) return n ^= expr()
|
||||
ungettoken(t)
|
||||
return n
|
||||
}
|
||||
term() {
|
||||
n = factor()
|
||||
t = token()
|
||||
if (t == MUL) return n *= term()
|
||||
if (t == DIV) return n /= term()
|
||||
if (t == AND) return n &= term()
|
||||
if (t == RSH) return n >> term()
|
||||
if (t == LSH) return n << term()
|
||||
ungettoken(t)
|
||||
return n
|
||||
}
|
||||
factor() {
|
||||
t = token()
|
||||
if (t == LPAREN) {
|
||||
n = expr()
|
||||
if token() == RPAREN
|
||||
return n
|
||||
error()
|
||||
}
|
||||
if (t == SUB) return -factor()
|
||||
if (t == CMP) return ~factor()
|
||||
if (t == QUE) return byteswap(factor())
|
||||
if (t == DIG) return strtol()
|
||||
error()
|
||||
}
|
||||
expr() {
|
||||
n = term()
|
||||
t = token()
|
||||
if (t == ADD) return n += expr()
|
||||
if (t == SUB) return n -= expr()
|
||||
if (t == BOR) return n |= expr()
|
||||
if (t == XOR) return n ^= expr()
|
||||
ungettoken(t)
|
||||
return n
|
||||
}
|
||||
term() {
|
||||
n = factor()
|
||||
t = token()
|
||||
if (t == MUL) return n *= term()
|
||||
if (t == DIV) return n /= term()
|
||||
if (t == AND) return n &= term()
|
||||
if (t == RSH) return n >> term()
|
||||
if (t == LSH) return n << term()
|
||||
ungettoken(t)
|
||||
return n
|
||||
}
|
||||
factor() {
|
||||
t = token()
|
||||
if (t == LPAREN) {
|
||||
n = expr()
|
||||
if token() == RPAREN
|
||||
return n
|
||||
error()
|
||||
}
|
||||
if (t == SUB) return -factor()
|
||||
if (t == CMP) return ~factor()
|
||||
if (t == QUE) return byteswap(factor())
|
||||
if (t == DIG) return strtol()
|
||||
error()
|
||||
}
|
||||
```
|
||||
|
||||
## Obfuscation is a process
|
||||
|
||||
@@ -134,11 +134,11 @@ global pointer variable, and the integers from uninitialized global <code>int</c
|
||||
variables. If <code>x</code> is a global <code>int</code>, then <code>!x</code> is <code>1</code>, and the derivation
|
||||
proceeds from there, using some identities that are confusingly similar and
|
||||
interestingly combined (increasing obfuscation):</p>
|
||||
<pre><code>obc clr
|
||||
--- ---
|
||||
-~x x+1
|
||||
~-x x-1
|
||||
y-~x y+x+1</code></pre>
|
||||
<pre><code> obc clr
|
||||
--- ---
|
||||
-~x x+1
|
||||
~-x x-1
|
||||
y-~x y+x+1</code></pre>
|
||||
<p>The derived constants are a compromise between simple expressions, maximum utility,
|
||||
and minimum number of variables used.</p>
|
||||
<p>Command line arguments are copied into the upper half of the input buffer,
|
||||
|
||||
@@ -14,11 +14,11 @@ proceeds from there, using some identities that are confusingly similar and
|
||||
interestingly combined (increasing obfuscation):
|
||||
|
||||
```
|
||||
obc clr
|
||||
--- ---
|
||||
-~x x+1
|
||||
~-x x-1
|
||||
y-~x y+x+1
|
||||
obc clr
|
||||
--- ---
|
||||
-~x x+1
|
||||
~-x x-1
|
||||
y-~x y+x+1
|
||||
```
|
||||
|
||||
The derived constants are a compromise between simple expressions, maximum utility,
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
To change the dimensions you can use the `WIDTH` and `HEIGHT` variables when
|
||||
compiling (default 1024 x 800):
|
||||
|
||||
```sh
|
||||
make clobber WIDTH=640 HEIGHT=480
|
||||
make clobber WIDTH=640 HEIGHT=480
|
||||
```
|
||||
|
||||
to make the game 640 x 480. Obviously changing it to non numbers or negative
|
||||
@@ -23,14 +23,14 @@ code](#alternate-code) below.
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./prog
|
||||
./prog
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./prog
|
||||
./prog
|
||||
```
|
||||
|
||||
Press and hold the Left Arrow key until you turn 90-degrees to the left.
|
||||
@@ -67,9 +67,9 @@ The author suggested that one change `q` to `0x82000820000000` instead of
|
||||
`0x820008202625a0` to see a bug that they avoided, writing:
|
||||
|
||||
```
|
||||
To see this bug in action change the assignment above
|
||||
to q=0x82000820000000`, and look towards the negative
|
||||
direction of the main tunnel.
|
||||
To see this bug in action change the assignment above
|
||||
to q=0x82000820000000`, and look towards the negative
|
||||
direction of the main tunnel.
|
||||
```
|
||||
|
||||
This alt version does this for you.
|
||||
@@ -78,7 +78,7 @@ This alt version does this for you.
|
||||
### Alternate build:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
make alt
|
||||
```
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ size limit, and allows us to use such fun expression for arrow view control as
|
||||
the following:
|
||||
|
||||
```c
|
||||
*(a&1?&C:&B)-=(.05 -a/2%2*.1)*!(a-1&4092^3920)
|
||||
*(a&1?&C:&B)-=(.05 -a/2%2*.1)*!(a-1&4092^3920)
|
||||
```
|
||||
|
||||
### Precision issues:
|
||||
|
||||
+10
-11
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Gil_Dogon">Gil Dogon</a><br>
|
||||
Location: <a href="../../location.html#IL">IL</a> - <em>State of Israel</em> (<em>Israel</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#IL">IL</a> - <em>State of Israel</em> (<em>Israel</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,19 +141,19 @@ Location: <a href="../../location.html#IL">IL</a> - <em>State of Israel</em> (<e
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<p>To change the dimensions you can use the <code>WIDTH</code> and <code>HEIGHT</code> variables when
|
||||
compiling (default 1024 x 800):</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 WIDTH=640 HEIGHT=480</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 WIDTH=640 HEIGHT=480</span></code></pre></div>
|
||||
<p>to make the game 640 x 480. Obviously changing it to non numbers or negative
|
||||
numbers or too large numbers will cause problems.</p>
|
||||
<p>There is an alternate version that is based on the author’s suggestion to change
|
||||
a value in order to see a bug that they avoided in their entry. See <a href="#alternate-code">Alternate
|
||||
code</a> below.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span></span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span></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">./prog</span></span></code></pre></div>
|
||||
<p>Press and hold the Left Arrow key until you turn 90-degrees to the left.</p>
|
||||
<p>When you see a long tunnel, press the function key F2.</p>
|
||||
<p>Use the Up, Down, Left and Right keys to change your path.</p>
|
||||
@@ -172,12 +171,12 @@ again.</p>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<p>The author suggested that one change <code>q</code> to <code>0x82000820000000</code> instead of
|
||||
<code>0x820008202625a0</code> to see a bug that they avoided, writing:</p>
|
||||
<pre><code>To see this bug in action change the assignment above
|
||||
to q=0x82000820000000`, and look towards the negative
|
||||
direction of the main tunnel.</code></pre>
|
||||
<pre><code> To see this bug in action change the assignment above
|
||||
to q=0x82000820000000`, and look towards the negative
|
||||
direction of the main tunnel.</code></pre>
|
||||
<p>This alt version does this for you.</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> alt</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<p>Use <code>prog.alt</code> as you would <code>prog</code> above.</p>
|
||||
<h3 id="alternate-try">Alternate try:</h3>
|
||||
@@ -247,7 +246,7 @@ important support of up to 32 function keys keyboards without spilling over the
|
||||
size limit, and allows us to use such fun expression for arrow view control as
|
||||
the following:</li>
|
||||
</ul>
|
||||
<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="op">*(</span>a<span class="op">&</span><span class="dv">1</span><span class="op">?&</span>C<span class="op">:&</span>B<span class="op">)-=(</span><span class="fl">.05</span> <span class="op">-</span>a<span class="op">/</span><span class="dv">2</span><span class="op">%</span><span class="dv">2</span><span class="op">*</span><span class="fl">.1</span><span class="op">)*!(</span>a<span class="op">-</span><span class="dv">1</span><span class="op">&</span><span class="dv">4092</span><span class="op">^</span><span class="dv">3920</span><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="op">*(</span>a<span class="op">&</span><span class="dv">1</span><span class="op">?&</span>C<span class="op">:&</span>B<span class="op">)-=(</span><span class="fl">.05</span> <span class="op">-</span>a<span class="op">/</span><span class="dv">2</span><span class="op">%</span><span class="dv">2</span><span class="op">*</span><span class="fl">.1</span><span class="op">)*!(</span>a<span class="op">-</span><span class="dv">1</span><span class="op">&</span><span class="dv">4092</span><span class="op">^</span><span class="dv">3920</span><span class="op">)</span></span></code></pre></div>
|
||||
<h3 id="precision-issues">Precision issues:</h3>
|
||||
<p>The entry, on purpose, (see the section about SIMD below) does not use enough
|
||||
bits of precision, so sometimes the ray will miss the intersection of two voxel
|
||||
|
||||
+17
-17
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
There is an alternate version of this entry, discussed in the author's remarks.
|
||||
@@ -11,14 +11,14 @@ See [Alternate code](#alternate-code) below.
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
echo Some text | ./prog
|
||||
echo Some text | ./prog
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
As the script says if you want to move to the next command at any point
|
||||
@@ -35,7 +35,7 @@ author in the '[prog.c](prog.c) vs [prog.alt.c](prog.alt.c)' section of their re
|
||||
### Alternate build:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
make alt
|
||||
```
|
||||
|
||||
|
||||
@@ -85,13 +85,13 @@ been shortened in this file.
|
||||
If you have `clang`:
|
||||
|
||||
```sh
|
||||
CC=clang make -e
|
||||
CC=clang make -e
|
||||
```
|
||||
|
||||
Otherwise (gcc):
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
(You will get a few warnings in this case.)
|
||||
@@ -117,21 +117,21 @@ needed in this case).
|
||||
#### Basic mode:
|
||||
|
||||
```sh
|
||||
$ echo 'I am testing this thing.' | ./prog
|
||||
[... rendering ...]
|
||||
$ echo 'I am testing this thing.' | ./prog
|
||||
[... rendering ...]
|
||||
|
||||
$ ./prog < lorem-ipsum.txt
|
||||
[... rendering ...]
|
||||
$ ./prog < lorem-ipsum.txt
|
||||
[... rendering ...]
|
||||
```
|
||||
|
||||
|
||||
#### Interactive mode:
|
||||
|
||||
```sh
|
||||
$ ./prog
|
||||
> hello world!!!
|
||||
[... rendering ...]
|
||||
>
|
||||
$ ./prog
|
||||
> hello world!!!
|
||||
[... rendering ...]
|
||||
>
|
||||
```
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ In order to comply with the size rule, I encoded only a part of the visible ASCI
|
||||
chars:
|
||||
|
||||
```
|
||||
a-z, A-Z, '.' ':' ',' ';' '!' and '?'.
|
||||
a-z, A-Z, '.' ':' ',' ';' '!' and '?'.
|
||||
```
|
||||
|
||||
Uppercase and lowercase chars are rendered the same. The program also
|
||||
@@ -207,7 +207,7 @@ simple text documents.
|
||||
Thus, if you try for example:
|
||||
|
||||
```sh
|
||||
$ ./prog < prog.c
|
||||
$ ./prog < prog.c
|
||||
```
|
||||
|
||||
You will not get something that looks like C code. (but you can still try, if
|
||||
@@ -220,7 +220,7 @@ Defining an environment variable called `DRAFT` will enable the 'draft-mode'.
|
||||
Try for example:
|
||||
|
||||
```sh
|
||||
$ echo 'testing the draft mode' | DRAFT=1 ./prog
|
||||
$ echo 'testing the draft mode' | DRAFT=1 ./prog
|
||||
```
|
||||
|
||||
The program will run much faster but the rendering will be less precise.
|
||||
|
||||
+18
-19
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Etienne_Duble">Etienne Duble</a><br>
|
||||
Location: <a href="../../location.html#FR">FR</a> - <em>French Republic</em> (<em>France</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#FR">FR</a> - <em>French Republic</em> (<em>France</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,13 +141,13 @@ Location: <a href="../../location.html#FR">FR</a> - <em>French Republic</em> (<e
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<p>There is an alternate version of this entry, discussed in the author’s remarks.
|
||||
See <a href="#alternate-code">Alternate code</a> below.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> Some text <span class="kw">|</span> <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> Some text <span class="kw">|</span> <span class="ex">./prog</span></span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<p>As the script says if you want to move to the next command at any point
|
||||
(lorem-ipsum.txt takes a while to print in particular) you may do so by hitting
|
||||
ctrl-c/sending intr.</p>
|
||||
@@ -156,7 +155,7 @@ ctrl-c/sending intr.</p>
|
||||
<p>This alternate code, provided by the author, is discussed in more detail by the
|
||||
author in the ‘<a href="prog.c">prog.c</a> vs <a href="prog.alt.c">prog.alt.c</a>’ section of their remarks.</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> alt</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<p>Use <code>prog.alt</code> as you would <code>prog</code> above.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
@@ -182,9 +181,9 @@ with other compilers or optimization levels). These have been fixed in
|
||||
been shortened in this file.</p>
|
||||
<h3 id="how-to-build">How to build</h3>
|
||||
<p>If you have <code>clang</code>:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="va">CC</span><span class="op">=</span>clang <span class="fu">make</span> <span class="at">-e</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="va">CC</span><span class="op">=</span>clang <span class="fu">make</span> <span class="at">-e</span></span></code></pre></div>
|
||||
<p>Otherwise (gcc):</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></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></span></code></pre></div>
|
||||
<p>(You will get a few warnings in this case.)</p>
|
||||
<h3 id="how-to-use-it">How to use it</h3>
|
||||
<p>You need a terminal configured to handle a <em>UTF-8</em> encoding and a font including
|
||||
@@ -197,16 +196,16 @@ configuration was needed.</p>
|
||||
<p>I also tested it on FreeBSD 9.3 32bits (font and encoding configuration was
|
||||
needed in this case).</p>
|
||||
<h4 id="basic-mode">Basic mode:</h4>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo <span class="st">'I am testing this thing.'</span> <span class="kw">|</span> <span class="ex">./prog</span></span>
|
||||
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="ex">[...</span> rendering ...]</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">$</span> echo <span class="st">'I am testing this thing.'</span> <span class="kw">|</span> <span class="ex">./prog</span></span>
|
||||
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">[...</span> rendering ...]</span>
|
||||
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./prog <span class="op"><</span> lorem-ipsum.txt</span>
|
||||
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a><span class="ex">[...</span> rendering ...]</span></code></pre></div>
|
||||
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./prog <span class="op"><</span> lorem-ipsum.txt</span>
|
||||
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">[...</span> rendering ...]</span></code></pre></div>
|
||||
<h4 id="interactive-mode">Interactive mode:</h4>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./prog</span>
|
||||
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="op">></span> hello <span class="ex">world!!!</span></span>
|
||||
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="ex">[...</span> rendering ...]</span>
|
||||
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a><span class="op">></span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./prog</span>
|
||||
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="op">></span> hello <span class="ex">world!!!</span></span>
|
||||
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">[...</span> rendering ...]</span>
|
||||
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> <span class="op">></span></span></code></pre></div>
|
||||
<h3 id="obfuscation">Obfuscation:</h3>
|
||||
<p>This entry is obfuscated in various ways:</p>
|
||||
<ul>
|
||||
@@ -239,7 +238,7 @@ encoded in macro <code>O_o</code> at the top of the source file.</li>
|
||||
<h4 id="charset">Charset</h4>
|
||||
<p>In order to comply with the size rule, I encoded only a part of the visible ASCII
|
||||
chars:</p>
|
||||
<pre><code>a-z, A-Z, '.' ':' ',' ';' '!' and '?'.</code></pre>
|
||||
<pre><code> a-z, A-Z, '.' ':' ',' ';' '!' and '?'.</code></pre>
|
||||
<p>Uppercase and lowercase chars are rendered the same. The program also
|
||||
understands space and linefeed (<code>\n</code>). Other chars are simply ignored (most of
|
||||
the time ;)</p>
|
||||
@@ -256,13 +255,13 @@ could still happen in case of long words.</p>
|
||||
<p>Given the limited set of characters handled, the program is mostly limited to
|
||||
simple text documents.</p>
|
||||
<p>Thus, if you try for example:</p>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./prog <span class="op"><</span> prog.c</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./prog <span class="op"><</span> prog.c</span></code></pre></div>
|
||||
<p>You will not get something that looks like C code. (but you can still try, if
|
||||
you are curious. :)</p>
|
||||
<h4 id="a-draft-mode">A ‘draft’ mode</h4>
|
||||
<p>Defining an environment variable called <code>DRAFT</code> will enable the ‘draft-mode’.
|
||||
Try for example:</p>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> echo <span class="st">'testing the draft mode'</span> <span class="kw">|</span> <span class="va">DRAFT</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> echo <span class="st">'testing the draft mode'</span> <span class="kw">|</span> <span class="va">DRAFT</span><span class="op">=</span>1 <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>The program will run much faster but the rendering will be less precise.</p>
|
||||
<h4 id="the-subtle-interactive-mode">The subtle interactive mode</h4>
|
||||
<p>I saved the best for last: usually, programs that handle an “interactive mode”
|
||||
|
||||
+26
-26
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
NOTE: this program requires the tool `tcpserver` to use. If you do not have this
|
||||
@@ -12,7 +12,7 @@ require it](../../faq.html#tcpserver).
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
tcpserver -v 127.0.0.1 10333 ./prog ioccc.txt
|
||||
tcpserver -v 127.0.0.1 10333 ./prog ioccc.txt
|
||||
```
|
||||
|
||||
Then connect to http://localhost:10333 with your browser.
|
||||
@@ -45,13 +45,13 @@ his work.
|
||||
Compile the program as follows:
|
||||
|
||||
```sh
|
||||
cc -O3 -std=c99 \
|
||||
-Wall -Wextra -pedantic -o prog prog.c \
|
||||
-Delta_u="Du*laplacian(u)-u*v*v+F*(1-u)" \
|
||||
-Delta_v="Dv*laplacian(v)+u*v*v-v*(F+K)" \
|
||||
-DF=0.040 -DK=0.060 -DDu=0.200 -DDv=0.100 \
|
||||
-DUV_BACKGROUND=1,0 -DUV_DROP=-0.5,0.5 \
|
||||
-DTIMESTEP=1.0 -DSPEED=2 -DRGB=255:128:192
|
||||
cc -O3 -std=c99 \
|
||||
-Wall -Wextra -pedantic -o prog prog.c \
|
||||
-Delta_u="Du*laplacian(u)-u*v*v+F*(1-u)" \
|
||||
-Delta_v="Dv*laplacian(v)+u*v*v-v*(F+K)" \
|
||||
-DF=0.040 -DK=0.060 -DDu=0.200 -DDv=0.100 \
|
||||
-DUV_BACKGROUND=1,0 -DUV_DROP=-0.5,0.5 \
|
||||
-DTIMESTEP=1.0 -DSPEED=2 -DRGB=255:128:192
|
||||
```
|
||||
|
||||
Then, run it with the `tcpserver` command in the
|
||||
@@ -60,7 +60,7 @@ Then, run it with the `tcpserver` command in the
|
||||
[1991/brndstd](../../1991/brnstnd/index.html) "Best of Show".
|
||||
|
||||
```sh
|
||||
tcpserver -v 127.0.0.1 10333 ./prog ioccc.txt
|
||||
tcpserver -v 127.0.0.1 10333 ./prog ioccc.txt
|
||||
```
|
||||
|
||||
Finally, open `http://127.0.0.1:10333/` in a modern browser supporting HTML5.
|
||||
@@ -81,8 +81,8 @@ form non-trivial patterns, such as spots, spiral, dappling, and labyrinths.
|
||||
The systems are generally formulated as follows:
|
||||
|
||||
```
|
||||
du/dt = F(u, v) + Du * laplacian(u)
|
||||
dv/dt = G(u, v) + Dv * laplacian(v)
|
||||
du/dt = F(u, v) + Du * laplacian(u)
|
||||
dv/dt = G(u, v) + Dv * laplacian(v)
|
||||
```
|
||||
|
||||
The functions `F(u, v)` and `G(u, v)` represent reactions of each substance, and
|
||||
@@ -113,15 +113,15 @@ model](http://groups.csail.mit.edu/mac/projects/amorphous/GrayScott/) in TeX
|
||||
notation.
|
||||
|
||||
```
|
||||
\frac{\partial u}{\partial t} = D_u \Delta u - u v^2 + F (1 - u)
|
||||
\frac{\partial v}{\partial t} = D_v \Delta v + u v^2 - v (F + K)
|
||||
\frac{\partial u}{\partial t} = D_u \Delta u - u v^2 + F (1 - u)
|
||||
\frac{\partial v}{\partial t} = D_v \Delta v + u v^2 - v (F + K)
|
||||
```
|
||||
|
||||
You can specify this model as follows:
|
||||
|
||||
```
|
||||
-Delta_u="Du*laplacian(u)-u*v*v+F*(1-u)" \
|
||||
-Delta_v="Dv*laplacian(v)+u*v*v-v*(F+K)"
|
||||
-Delta_u="Du*laplacian(u)-u*v*v+F*(1-u)" \
|
||||
-Delta_v="Dv*laplacian(v)+u*v*v-v*(F+K)"
|
||||
```
|
||||
|
||||
`Du`, `Dv`, `F`, and `K` are parameters of that model.
|
||||
@@ -159,15 +159,15 @@ Some interesting parameters are included in `Makefile`. Do one of the following
|
||||
commands and open `http://127.0.0.1:10333`.
|
||||
|
||||
```
|
||||
make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 ioccc.txt
|
||||
make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 center.txt
|
||||
make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 line.txt
|
||||
make gray-scott-2 && tcpserver -v 127.0.0.1 10333 ./gray-scott-2 ioccc.txt
|
||||
make gray-scott-3 && tcpserver -v 127.0.0.1 10333 ./gray-scott-3 ioccc.txt
|
||||
make gray-scott-4 && tcpserver -v 127.0.0.1 10333 ./gray-scott-4 ioccc.txt
|
||||
make fitzhugh-nagumo-1 && tcpserver -v 127.0.0.1 10333 ./fitzhugh-nagumo-1 ioccc.txt
|
||||
make fitzhugh-nagumo-2 && tcpserver -v 127.0.0.1 10333 ./fitzhugh-nagumo-2 ioccc.txt
|
||||
make oregonator && tcpserver -v 127.0.0.1 10333 ./oregonator ioccc.txt
|
||||
make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 ioccc.txt
|
||||
make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 center.txt
|
||||
make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 line.txt
|
||||
make gray-scott-2 && tcpserver -v 127.0.0.1 10333 ./gray-scott-2 ioccc.txt
|
||||
make gray-scott-3 && tcpserver -v 127.0.0.1 10333 ./gray-scott-3 ioccc.txt
|
||||
make gray-scott-4 && tcpserver -v 127.0.0.1 10333 ./gray-scott-4 ioccc.txt
|
||||
make fitzhugh-nagumo-1 && tcpserver -v 127.0.0.1 10333 ./fitzhugh-nagumo-1 ioccc.txt
|
||||
make fitzhugh-nagumo-2 && tcpserver -v 127.0.0.1 10333 ./fitzhugh-nagumo-2 ioccc.txt
|
||||
make oregonator && tcpserver -v 127.0.0.1 10333 ./oregonator ioccc.txt
|
||||
```
|
||||
|
||||
These examples are created by drawing (and modifying) the pattern files of
|
||||
@@ -204,7 +204,7 @@ I think you may use `inetd` and `xinetd` instead of `tcpserver`. Here is an
|
||||
example `inetd` configuration.
|
||||
|
||||
```
|
||||
10333 stream tcp nowait nobody /path/to/prog /path/to/prog /path/to/initial-pattern.txt
|
||||
10333 stream tcp nowait nobody /path/to/prog /path/to/prog /path/to/initial-pattern.txt
|
||||
```
|
||||
|
||||
But note that I didn't test well.
|
||||
|
||||
+27
-28
@@ -135,8 +135,7 @@
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<br><br></li>
|
||||
<li>Name: <a href="../../authors.html#Yusuke_Endoh">Yusuke Endoh</a><br>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -145,12 +144,12 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<p>NOTE: this program requires the tool <code>tcpserver</code> to use. If you do not have this
|
||||
program see <a href="../../faq.html#tcpserver">FAQ 3.14 - How do I compile and install tcpserver for entries that
|
||||
require it</a>.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">tcpserver</span> <span class="at">-v</span> 127.0.0.1 10333 ./prog ioccc.txt</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">tcpserver</span> <span class="at">-v</span> 127.0.0.1 10333 ./prog ioccc.txt</span></code></pre></div>
|
||||
<p>Then connect to http://localhost:10333 with your browser.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p><a href="https://www.livescience.com/950-leopard-spots.html">How did the leopard get its
|
||||
@@ -169,18 +168,18 @@ test</a>? This program is also based on
|
||||
his work.</p>
|
||||
<h3 id="whirlwind-tour">Whirlwind tour</h3>
|
||||
<p>Compile the program as follows:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> <span class="at">-O3</span> <span class="at">-std</span><span class="op">=</span>c99 <span class="dt">\</span></span>
|
||||
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="at">-Wall</span> <span class="at">-Wextra</span> <span class="at">-pedantic</span> <span class="at">-o</span> prog prog.c <span class="dt">\</span></span>
|
||||
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="at">-Delta_u</span><span class="op">=</span><span class="st">"Du*laplacian(u)-u*v*v+F*(1-u)"</span> <span class="dt">\</span></span>
|
||||
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="at">-Delta_v</span><span class="op">=</span><span class="st">"Dv*laplacian(v)+u*v*v-v*(F+K)"</span> <span class="dt">\</span></span>
|
||||
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="at">-DF</span><span class="op">=</span>0.040 <span class="at">-DK</span><span class="op">=</span>0.060 <span class="at">-DDu</span><span class="op">=</span>0.200 <span class="at">-DDv</span><span class="op">=</span>0.100 <span class="dt">\</span></span>
|
||||
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a> <span class="at">-DUV_BACKGROUND</span><span class="op">=</span>1,0 <span class="at">-DUV_DROP</span><span class="op">=</span>-0.5,0.5 <span class="dt">\</span></span>
|
||||
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a> <span class="at">-DTIMESTEP</span><span class="op">=</span>1.0 <span class="at">-DSPEED</span><span class="op">=</span>2 <span class="at">-DRGB</span><span class="op">=</span>255:128:192</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">cc</span> <span class="at">-O3</span> <span class="at">-std</span><span class="op">=</span>c99 <span class="dt">\</span></span>
|
||||
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="at">-Wall</span> <span class="at">-Wextra</span> <span class="at">-pedantic</span> <span class="at">-o</span> prog prog.c <span class="dt">\</span></span>
|
||||
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="at">-Delta_u</span><span class="op">=</span><span class="st">"Du*laplacian(u)-u*v*v+F*(1-u)"</span> <span class="dt">\</span></span>
|
||||
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="at">-Delta_v</span><span class="op">=</span><span class="st">"Dv*laplacian(v)+u*v*v-v*(F+K)"</span> <span class="dt">\</span></span>
|
||||
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="at">-DF</span><span class="op">=</span>0.040 <span class="at">-DK</span><span class="op">=</span>0.060 <span class="at">-DDu</span><span class="op">=</span>0.200 <span class="at">-DDv</span><span class="op">=</span>0.100 <span class="dt">\</span></span>
|
||||
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a> <span class="at">-DUV_BACKGROUND</span><span class="op">=</span>1,0 <span class="at">-DUV_DROP</span><span class="op">=</span>-0.5,0.5 <span class="dt">\</span></span>
|
||||
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a> <span class="at">-DTIMESTEP</span><span class="op">=</span>1.0 <span class="at">-DSPEED</span><span class="op">=</span>2 <span class="at">-DRGB</span><span class="op">=</span>255:128:192</span></code></pre></div>
|
||||
<p>Then, run it with the <code>tcpserver</code> command in the
|
||||
<a href="http://cr.yp.to/ucspi-tcp.html">ucspi-tcp</a> package, which was created by
|
||||
<a href="../../authors.html#Daniel_J_Bernstein">Daniel J. Bernstein</a>’s
|
||||
<a href="../../1991/brnstnd/index.html">1991/brndstd</a> “Best of Show”.</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">tcpserver</span> <span class="at">-v</span> 127.0.0.1 10333 ./prog ioccc.txt</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">tcpserver</span> <span class="at">-v</span> 127.0.0.1 10333 ./prog ioccc.txt</span></code></pre></div>
|
||||
<p>Finally, open <code>http://127.0.0.1:10333/</code> in a modern browser supporting HTML5.
|
||||
You can use the mouse cursor to place drops into the <a href="https://en.wikipedia.org/wiki/Petri_dish">Petri
|
||||
dish</a> interactively.</p>
|
||||
@@ -192,8 +191,8 @@ models in which two chemical substances are transformed into each other (<em>loc
|
||||
chemical reactions</em>) and spread out (<em>diffusion</em>). Their interactions sometimes
|
||||
form non-trivial patterns, such as spots, spiral, dappling, and labyrinths.</p>
|
||||
<p>The systems are generally formulated as follows:</p>
|
||||
<pre><code>du/dt = F(u, v) + Du * laplacian(u)
|
||||
dv/dt = G(u, v) + Dv * laplacian(v)</code></pre>
|
||||
<pre><code> du/dt = F(u, v) + Du * laplacian(u)
|
||||
dv/dt = G(u, v) + Dv * laplacian(v)</code></pre>
|
||||
<p>The functions <code>F(u, v)</code> and <code>G(u, v)</code> represent reactions of each substance, and
|
||||
the parameters <code>Du</code> and <code>Dv</code> are diffusion coefficients. By changing the
|
||||
functions and parameters, you can see a wide range of behaviors.</p>
|
||||
@@ -212,11 +211,11 @@ definition.</p>
|
||||
example, the following is <a href="http://groups.csail.mit.edu/mac/projects/amorphous/GrayScott/">the Gray-Scott
|
||||
model</a> in TeX
|
||||
notation.</p>
|
||||
<pre><code>\frac{\partial u}{\partial t} = D_u \Delta u - u v^2 + F (1 - u)
|
||||
\frac{\partial v}{\partial t} = D_v \Delta v + u v^2 - v (F + K)</code></pre>
|
||||
<pre><code> \frac{\partial u}{\partial t} = D_u \Delta u - u v^2 + F (1 - u)
|
||||
\frac{\partial v}{\partial t} = D_v \Delta v + u v^2 - v (F + K)</code></pre>
|
||||
<p>You can specify this model as follows:</p>
|
||||
<pre><code>-Delta_u="Du*laplacian(u)-u*v*v+F*(1-u)" \
|
||||
-Delta_v="Dv*laplacian(v)+u*v*v-v*(F+K)"</code></pre>
|
||||
<pre><code> -Delta_u="Du*laplacian(u)-u*v*v+F*(1-u)" \
|
||||
-Delta_v="Dv*laplacian(v)+u*v*v-v*(F+K)"</code></pre>
|
||||
<p><code>Du</code>, <code>Dv</code>, <code>F</code>, and <code>K</code> are parameters of that model.</p>
|
||||
<h4 id="initial-pattern--duv_backgroundu0v0--duv_dropu1v1">Initial pattern: <code>-DUV_BACKGROUND=<u0>,<v0> -DUV_DROP=<u1>,<v1></code></h4>
|
||||
<p>The definitions specifies the initial amount of the two substances <code>u</code> and <code>v</code>.
|
||||
@@ -235,15 +234,15 @@ added by <code>(u1, v1)</code>.</p>
|
||||
<h3 id="examples">Examples</h3>
|
||||
<p>Some interesting parameters are included in <code>Makefile</code>. Do one of the following
|
||||
commands and open <code>http://127.0.0.1:10333</code>.</p>
|
||||
<pre><code>make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 ioccc.txt
|
||||
make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 center.txt
|
||||
make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 line.txt
|
||||
make gray-scott-2 && tcpserver -v 127.0.0.1 10333 ./gray-scott-2 ioccc.txt
|
||||
make gray-scott-3 && tcpserver -v 127.0.0.1 10333 ./gray-scott-3 ioccc.txt
|
||||
make gray-scott-4 && tcpserver -v 127.0.0.1 10333 ./gray-scott-4 ioccc.txt
|
||||
make fitzhugh-nagumo-1 && tcpserver -v 127.0.0.1 10333 ./fitzhugh-nagumo-1 ioccc.txt
|
||||
make fitzhugh-nagumo-2 && tcpserver -v 127.0.0.1 10333 ./fitzhugh-nagumo-2 ioccc.txt
|
||||
make oregonator && tcpserver -v 127.0.0.1 10333 ./oregonator ioccc.txt</code></pre>
|
||||
<pre><code> make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 ioccc.txt
|
||||
make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 center.txt
|
||||
make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 line.txt
|
||||
make gray-scott-2 && tcpserver -v 127.0.0.1 10333 ./gray-scott-2 ioccc.txt
|
||||
make gray-scott-3 && tcpserver -v 127.0.0.1 10333 ./gray-scott-3 ioccc.txt
|
||||
make gray-scott-4 && tcpserver -v 127.0.0.1 10333 ./gray-scott-4 ioccc.txt
|
||||
make fitzhugh-nagumo-1 && tcpserver -v 127.0.0.1 10333 ./fitzhugh-nagumo-1 ioccc.txt
|
||||
make fitzhugh-nagumo-2 && tcpserver -v 127.0.0.1 10333 ./fitzhugh-nagumo-2 ioccc.txt
|
||||
make oregonator && tcpserver -v 127.0.0.1 10333 ./oregonator ioccc.txt</code></pre>
|
||||
<p>These examples are created by drawing (and modifying) the pattern files of
|
||||
<a href="https://github.com/GollyGang/ready">Ready</a>, a cross-platform implementation of
|
||||
various reaction-diffusion systems <a href="#fn2" class="footnote-ref" id="fnref2" role="doc-noteref"><sup>2</sup></a>.</p>
|
||||
@@ -263,7 +262,7 @@ WebSocket <a href="#fn3" class="footnote-ref" id="fnref3" role="doc-noteref"><su
|
||||
<h4 id="tcpserver-alternatives">tcpserver alternatives</h4>
|
||||
<p>I think you may use <code>inetd</code> and <code>xinetd</code> instead of <code>tcpserver</code>. Here is an
|
||||
example <code>inetd</code> configuration.</p>
|
||||
<pre><code>10333 stream tcp nowait nobody /path/to/prog /path/to/prog /path/to/initial-pattern.txt</code></pre>
|
||||
<pre><code> 10333 stream tcp nowait nobody /path/to/prog /path/to/prog /path/to/initial-pattern.txt</code></pre>
|
||||
<p>But note that I didn’t test well.</p>
|
||||
<h3 id="internal">Internal</h3>
|
||||
<ol type="1">
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./prog
|
||||
./prog
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -32,9 +32,9 @@ At this point you might be wondering, [WTF](http://acronyms.thefreedictionary.co
|
||||
How is this code obfuscated? Well look again:
|
||||
|
||||
```sh
|
||||
less prog.c
|
||||
less prog.c
|
||||
|
||||
more prog.c
|
||||
more prog.c
|
||||
```
|
||||
|
||||
Where did those underscores come from? Well [RTFS](http://acronyms.thefreedictionary.com/RTFS)!\*\*
|
||||
@@ -50,9 +50,9 @@ If you are still puzzled, look at [prog.c](prog.c) with your favorite text edito
|
||||
**Follow these instructions literally!**
|
||||
|
||||
```sh
|
||||
cat prog.c
|
||||
gcc -w -o prog prog.c
|
||||
./prog
|
||||
cat prog.c
|
||||
gcc -w -o prog prog.c
|
||||
./prog
|
||||
```
|
||||
|
||||
You will do a double take.
|
||||
|
||||
+9
-10
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Yusuke_Endoh">Yusuke Endoh</a><br>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,11 +141,11 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span></span></code></pre></div>
|
||||
<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>At this point you might be wondering, <a href="http://acronyms.thefreedictionary.com/WTF">WTF</a>?*</p>
|
||||
<ul>
|
||||
@@ -155,18 +154,18 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<li><p>What the Fish (python form)</p></li>
|
||||
</ul>
|
||||
<p>How is this code obfuscated? Well look again:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">less</span> prog.c</span>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">less</span> prog.c</span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="fu">more</span> prog.c</span></code></pre></div>
|
||||
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">more</span> prog.c</span></code></pre></div>
|
||||
<p>Where did those underscores come from? Well <a href="http://acronyms.thefreedictionary.com/RTFS">RTFS</a>!**</p>
|
||||
<p>** Read the Freaking Source (polite form)
|
||||
** Read The Freaking Screen (polite form)</p>
|
||||
<p>If you are still puzzled, look at <a href="prog.c">prog.c</a> with your favorite text editor.</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<p><strong>Follow these instructions literally!</strong></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">cat</span> prog.c</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> <span class="at">-w</span> <span class="at">-o</span> prog prog.c</span>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cat</span> prog.c</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> <span class="at">-w</span> <span class="at">-o</span> prog prog.c</span>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>You will do a double take.</p>
|
||||
<p>Hint 1: Do <code>less prog.c</code>. You will see an <strong>emphasized</strong> string if your
|
||||
terminal supports bold.</p>
|
||||
|
||||
+122
-122
@@ -1,14 +1,14 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./prog
|
||||
./prog
|
||||
```
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ make
|
||||
To see the original [mullender](mullender.c) in action:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
Observe what happens when you hit enter or another character! You might even try
|
||||
@@ -27,9 +27,9 @@ like at the end. Send INTR to end the program.
|
||||
More generally use:
|
||||
|
||||
```sh
|
||||
cc -o prog prog.c foo.c
|
||||
./prog
|
||||
^C # if necessary, where ^C is ctrl-C, interrrupt
|
||||
cc -o prog prog.c foo.c
|
||||
./prog
|
||||
^C # if necessary, where ^C is ctrl-C, interrrupt
|
||||
```
|
||||
|
||||
to compile and run `prog` as whatever foo.c is in the joke PDP-11 emulator.
|
||||
@@ -72,9 +72,9 @@ Read it upside down.)
|
||||
You got it? This program is supposed to be used in this way:
|
||||
|
||||
```sh
|
||||
wget https://www.ioccc.org/1984/mullender.c
|
||||
clang -o prog prog.c mullender.c
|
||||
./prog
|
||||
wget https://www.ioccc.org/1984/mullender.c
|
||||
clang -o prog prog.c mullender.c
|
||||
./prog
|
||||
```
|
||||
|
||||
You can enjoy the legendary winning entry of the first IOCCC, again.
|
||||
@@ -118,119 +118,119 @@ register).
|
||||
Note: this program writes a binary file to `stdout`:
|
||||
|
||||
```
|
||||
short main[]={5568,1,-30460,12,2782,0,-29921,2056,-4864,6873,770,30054,11886,
|
||||
24948,114,21716,-28851,14043,-8944,32691,-16187,-12247,22692,-9781,-20403,
|
||||
-11771,16546,18710,17873,9233,31304,-32215,-24382,-28247,-25916,10466,24988,
|
||||
-3404,-4177,-28528,-531,-3016,17300,-28552,-7708,-26180,-4297,-367,-2312,
|
||||
-25611,28535,-8533,24004,25421,-1224,-5354,-20807,-21589,-6761,-5203,-1055,
|
||||
-6715,-26673,-1433,-17732,-24198,14681,-3714,-6660,-14891,-25575,20349,-7701,
|
||||
-8336,31433,16695,-14773,26819,3096,-12584,-28808,17825,-21200,-32399,15877,
|
||||
-28890,-3728,-27126,21375,-32630,-7615,32004,-29230,-6611,-5508,-28921,12418,
|
||||
27204,-5725,9643,3520,26836,-29347,2101,-29311,9320,29287,-29990,-6593,29825,
|
||||
-29114,16232,25641,20672,-23501,-32127,-6546,-956,10474,-29647,1070,5516,13760,
|
||||
-27814,-32488,-28006,-17968,-3146,10963,19234,22132,23988,7142,5523,9639,-6888,
|
||||
-11428,7964,23099,-16822,16518,31109,-12958,10351,2434,3091,3625,2244,27512,
|
||||
-28559,-10724,-19377,23625,30056,11478,-21176,27660,26517,-29037,-9390,12297,
|
||||
-11903,5980,-21927,-7483,6671,11249,29638,-23827,-26358,-6856,-1063,-5303,
|
||||
26636,25797,31818,26798,-4243,-18772,-13266,27472,-12005,-10642,-22524,24373,
|
||||
-13111,-9062,6274,-20002,24150,22189,-14965,-31249,-13934,-6341,-18384,-32054,
|
||||
-29246,10622,-9260,19428,-15485,2724,23810,16447,11627,18604,2739,27812,30295,
|
||||
-21538,-31786,11355,-11308,-9006,-4987,25363,-18927,-21130,-31213,-27411,17231,
|
||||
-19608,20232,27754,16476,11213,-19803,-24048,30918,-25329,21233,-10160,13519,
|
||||
11828,26653,-6703,10893,6871,-12417,24471,20310,-12137,-19677,4457,-19530,
|
||||
10147,17724,533,-10055,27076,10264,11274,-10511,4809,25208,16065,-5105,-19953,
|
||||
3772,-12124,13475,-27559,-9955,26446,15133,15207,-23640,6425,-11010,28688,
|
||||
-20064,26353,-889,-25008,10380,-14449,-6894,18920,-23900,16902,-31018,16093,
|
||||
20875,-19576,4585,13126,18589,24789,19424,31274,-5059,-14538,-3125,-16527,
|
||||
-25070,-9013,26628,15756,-7652,30841,-1283,17707,25717,-18315,-6342,6880,
|
||||
-19176,6995,5672,2853,-9044,-3409,-14421,-7522,13108,20582,-25317,1376,-5648,
|
||||
13821,17300,1220,-29437,-25832,-8332,-15575,-9744,28297,31995,-1217,23852,
|
||||
14382,31059,9160,-3296,20287,-28357,24449,-10323,-21992,-4655,-32548,13237,
|
||||
-15083,-25226,-21121,2015,-8996,-20247,-27551,-14771,-16089,-6920,-9645,21578,
|
||||
7142,-5613,14029,24730,-29253,13931,-3862,-16634,-7388,16951,15771,31302,
|
||||
-22186,-6716,18416,1698,-26200,-16231,9821,-10886,-4994,-30527,-9448,-16923,
|
||||
29549,-11207,-14909,-3643,-27548,17865,28859,29753,17616,16874,-17733,9424,
|
||||
21435,-31715,24544,8666,30844,25075,-18267,12027,-5346,2717,19615,-4548,-21763,
|
||||
28514,11691,22268,-2338,1406,-27379,-23568,-24525,13633,11295,-14715,7877,
|
||||
-27669,3475,20345,7779,-17849,2184,7132,4079,-24937,11585,22740,5810,-10855,
|
||||
16203,-6371,23235,-7,-24828,-11205,-11006,-10,-17812,-14274,11504,-27517,463,
|
||||
4498,-32180,-9775,-3190,-22435,-18662,-30146,-31834,-26449,-19374,-12616,
|
||||
-10596,14341,-10089,-18449,-16535,21439,21191,-1651,7695,-30009,-23339,-8675,
|
||||
-20774,21588,-2793,8218,-14337,-10866,14060,-15343,31712,25247,-8539,18074,
|
||||
-28683,-7363,-7663,-3563,-30718,17771,28687,-30495,30584,14022,-28053,5292,
|
||||
-31576,-32486,-15470,-1330,23551,-2185,-10829,-13216,-4825,-2964,-14668,24559,
|
||||
-4930,23731,-1152,-11493,-2321,15987,-27073,-20305,-24065,-25048,32750,-27440,
|
||||
-1169,-25633,-4356,-24993,30439,-17165,-4580,8662,22655,-4588,-6162,-3122,
|
||||
31986,-2569,20371,-12320,-25613,-16133,-25644,23677,12254,5855,26325,-13425,
|
||||
-15903,-1930,-28488,31222,31153,17607,-2758,7594,-8868,30434,-2518,27956,
|
||||
-19424,7370,6199,-17602,17347,-14358,25588,11611,-25209,-23701,-27444,-29788,
|
||||
2680,-27406,9318,22483,-28356,28482,4577,-14891,17323,-30152,2507,2977,5004,
|
||||
-11696,-31623,-15149,13357,28938,-14048,19490,-19860,-26050,10842,-24922,
|
||||
-20986,8847,-31184,28519,-29168,32195,10516,25713,-3493,670,31283,-12769,
|
||||
-17461,11357,13180,26133,15944,18051,-32167,-27990,16813,17676,21787,-17578,
|
||||
11173,19093,2836,656,-15239,4632,23937,4106,-21655,-7494,-21575,-17647,-18465,
|
||||
-14654,-29990,-10707,-12440,21465,5822,26164,-1404,-14303,-26635,-6900,-23611,
|
||||
11998,-18551,971,27579,13325,4579,23059,29281,22291,29880,-17546,25664,-14990,
|
||||
-526,-35,28218,-3214,11965,11263,6633,30719,32400,-29,-3733,24383,32678,-27542,
|
||||
-4444,6196,5975,-19722,11902,16840,-11680,11146,-26391,-8980,21573,-9043,2349,
|
||||
-12887,5916,-2996,10410,-23374,26338,11867,-14518,18281,14450,-5815,13842,359,
|
||||
25450,27043,3355,13423,-20880,-26311,-30720,-2503,-6046,-18156,-18558,-14774,
|
||||
-15664,-29001,3365,-12689,10233,23608,24692,12039,15445,18411,-27469,3764,
|
||||
-10841,22672,23844,2282,-12443,2851,-27163,13651,13738,17201,-29819,27414,
|
||||
-29764,-5308,-16171,-32427,-26312,-7460,-27376,-6004,25717,29254,-15015,8754,
|
||||
15493,22232,-28513,-23355,23676,7736,10571,-8120,-16677,7696,32549,-2646,25538,
|
||||
3498,30960,-28459,24716,12655,-10496,402,26209,482,-16661,-20350,-3403,14015,
|
||||
32299,11262,-25886,4092,-7843,-100,-1975,-58,-3729,-19269,-23583,-6929,20000,
|
||||
-6089,17780,-3250,29830,19954,-29277,27896,10330,9277,-25358,31279,-14454,
|
||||
24203,-30170,12872,-21973,-25773,-10502,-6647,-26143,6394,-13479,-24559,23007,
|
||||
-21844,1505,24702,-23187,-24364,-20470,20765,-7107,15674,9404,17408,17964,
|
||||
19820,18952,2154,-26052,30056,-3227,17770,-8557,-31018,-27700,-25974,9003,
|
||||
18218,22730,-19981,6737,3532,1562,-23626,14990,28472,-5270,17358,-32204,-29197,
|
||||
-3647,4296,8588,25302,-23906,30328,-29119,-24392,8992,-16557,31530,-31216,
|
||||
14107,13041,-6976,7529,-8296,17865,-1462,8181,-21588,-131,-10177,-25931,-14627,
|
||||
8301,3708,-32097,20808,13892,-21179,1192,20853,3249,-8774,20843,3520,24954,
|
||||
-14215,-25170,-16170,2390,25964,-23923,-17464,-7177,-27568,-9880,-4647,-7323,
|
||||
15388,2113,-12338,-7737,26255,26818,-22156,-19610,-911,-17057,-556,29935,27647,
|
||||
31806,23676,-18132,-19234,-10869,-3715,24983,-10900,-29564,19856,-16392,-31860,
|
||||
-25826,24077,12080,15383,-29852,-2266,-27217,31931,-3183,17385,-14211,19050,
|
||||
-2449,-468,-2871,-11466,973,2866,649,1367,-8688,-24069,20992,25139,-25850,1184,
|
||||
15851,785,16951,12160,22337,-21851,1849,-18801,14247,-429,-12682,30881,-11273,
|
||||
-24819,-9794,8389,-27287,7525,16633,1328,-26650,32607,-8217,31912,7774,-16188,
|
||||
-3546,-6550,-16279,-32696,1940,2577,-23723,-6484,2009,-424,27833,-21763,-13902,
|
||||
7044,27360,-18450,27889,23987,3137,-7669,-5784,-7490,24946,32302,26464,-15513,
|
||||
28898,2493,-17645,-4615,-13434,-20884,-4058,-29951,-22281,24784,21083,-8536,
|
||||
22147,-11261,-15069,20659,2993,19029,21909,6748,-3263,1401,30960,11000,-16871,
|
||||
-30566,-14959,-26356,-2885,21526,-26531,31063,12857,4992,-5067,3130,-17602,
|
||||
-1732,-6593,30200,24679,3267,310,20733,24863,-15669,7875,-4577,-13821,-22325,
|
||||
15548,29744,3733,-14547,21459,22122,3854,-2572,30197,-24770,-21263,8793,-8316,
|
||||
1571,28191,-16143,-6446,31524,-26496,-17349,-29097,2806,11281,-7041,-683,14149,
|
||||
19689,-22094,-1657,-30904,183,-15226,-6358,25461,461,1495,28345,-10554,-4004,
|
||||
27119,13484,-21600,-12272,-7272,-14064,-299,10697,11280,19066,-9841,-7265,
|
||||
-18002,19906,-17247,21482,-10939,-5897,-22300,-13978,27575,-8684,-6222,-19041,
|
||||
5788,-30863,-10134,15142,2895,14705,-17713,12940,-21535,-11619,29416,18417,
|
||||
-24973,24867,-26462,-24910,-32556,-26705,-7187,-7750,-758,-14809,20289,9260,
|
||||
13778,-1422,30301,-1922,30646,27662,-15465,-912,29340,13846,-1263,28887,-20019,
|
||||
32421,-29411,-27632,-7495,-8368,29230,-6386,-19536,-5235,2054,1854,23563,12348,
|
||||
-15165,-2936,-28063,-15760,20126,-25531,4963,-5739,23182,16895,-17258,-10470,
|
||||
-3969,-7742,-140,4475,-24014,-31961,19231,27153,-18551,20157,26443,11530,
|
||||
-22214,2284,-24238,-31051,-26422,9088,29868,18458,8488,-9515,6799,-12507,54,
|
||||
-19441,-32665,12561,23560,4725,-28617,-14800,-10224,-13503,-17636,-16823,
|
||||
-24072,18735,-29798,-23658,-670,-21769,7489,-6468,-8961,-14785,22255,11582,
|
||||
-29831,16303,-19652,2922,-4362,22966,16173,-18446,-6148,27381,-8493,-32289,
|
||||
24005,-3027,-18665,-16472,-17793,-27027,-7443,17854,31365,-17726,-2510,-17546,
|
||||
14893,21773,-23634,21117,32533,6637,-1106,-8152,-3672,-113,-2149,-34,-22700,
|
||||
-4102,-28533,-14104,-10086,4378,13695,-15320,-28258,2246,7595,30021,13281,
|
||||
-11968,-29983,14274,27152,26713,19434,17058,1142,-3043,-16496,18630,-11976,
|
||||
29168,-3634,32746,27287,-268,16711,-8712,-471,12895,17406,-22548,-3969,-10733,
|
||||
13128,10530,-31667,7929,-32277,30926,-1983,8401,-7705,6790,4532,1442,26728,
|
||||
29600,-15358,21622,9744,11406,15989,-30741,-15044,29913,24534,6774,-3755,17623,
|
||||
19647,18762,10042,9653,-5889,2408,-32579,-6285,-28559,-30655,6294,-21175,4390,
|
||||
1668,25437,2821,21066,-13680,5274,-27253,-5248,-26307,29744,-26428,25358,17196,
|
||||
15199,-29784,-4604,25653,-8048,-23131,-28995,31340,-9558,26186,11268,27916,
|
||||
9646,-7389,-11384,-29116,-4100,160,18394,7856,738,-25920,12148,24713,-31664,
|
||||
8203,-25556,13494,30352,29161,30898,1432,-5991,25411,1344,-4019,22299,15685,
|
||||
-16401,-23136,-28110,11874,-18945,1879,2,0,-32256,-20996,-18169,29220,12,0,0,0,
|
||||
335,-27277,-30776,20480,0};
|
||||
short main[]={5568,1,-30460,12,2782,0,-29921,2056,-4864,6873,770,30054,11886,
|
||||
24948,114,21716,-28851,14043,-8944,32691,-16187,-12247,22692,-9781,-20403,
|
||||
-11771,16546,18710,17873,9233,31304,-32215,-24382,-28247,-25916,10466,24988,
|
||||
-3404,-4177,-28528,-531,-3016,17300,-28552,-7708,-26180,-4297,-367,-2312,
|
||||
-25611,28535,-8533,24004,25421,-1224,-5354,-20807,-21589,-6761,-5203,-1055,
|
||||
-6715,-26673,-1433,-17732,-24198,14681,-3714,-6660,-14891,-25575,20349,-7701,
|
||||
-8336,31433,16695,-14773,26819,3096,-12584,-28808,17825,-21200,-32399,15877,
|
||||
-28890,-3728,-27126,21375,-32630,-7615,32004,-29230,-6611,-5508,-28921,12418,
|
||||
27204,-5725,9643,3520,26836,-29347,2101,-29311,9320,29287,-29990,-6593,29825,
|
||||
-29114,16232,25641,20672,-23501,-32127,-6546,-956,10474,-29647,1070,5516,13760,
|
||||
-27814,-32488,-28006,-17968,-3146,10963,19234,22132,23988,7142,5523,9639,-6888,
|
||||
-11428,7964,23099,-16822,16518,31109,-12958,10351,2434,3091,3625,2244,27512,
|
||||
-28559,-10724,-19377,23625,30056,11478,-21176,27660,26517,-29037,-9390,12297,
|
||||
-11903,5980,-21927,-7483,6671,11249,29638,-23827,-26358,-6856,-1063,-5303,
|
||||
26636,25797,31818,26798,-4243,-18772,-13266,27472,-12005,-10642,-22524,24373,
|
||||
-13111,-9062,6274,-20002,24150,22189,-14965,-31249,-13934,-6341,-18384,-32054,
|
||||
-29246,10622,-9260,19428,-15485,2724,23810,16447,11627,18604,2739,27812,30295,
|
||||
-21538,-31786,11355,-11308,-9006,-4987,25363,-18927,-21130,-31213,-27411,17231,
|
||||
-19608,20232,27754,16476,11213,-19803,-24048,30918,-25329,21233,-10160,13519,
|
||||
11828,26653,-6703,10893,6871,-12417,24471,20310,-12137,-19677,4457,-19530,
|
||||
10147,17724,533,-10055,27076,10264,11274,-10511,4809,25208,16065,-5105,-19953,
|
||||
3772,-12124,13475,-27559,-9955,26446,15133,15207,-23640,6425,-11010,28688,
|
||||
-20064,26353,-889,-25008,10380,-14449,-6894,18920,-23900,16902,-31018,16093,
|
||||
20875,-19576,4585,13126,18589,24789,19424,31274,-5059,-14538,-3125,-16527,
|
||||
-25070,-9013,26628,15756,-7652,30841,-1283,17707,25717,-18315,-6342,6880,
|
||||
-19176,6995,5672,2853,-9044,-3409,-14421,-7522,13108,20582,-25317,1376,-5648,
|
||||
13821,17300,1220,-29437,-25832,-8332,-15575,-9744,28297,31995,-1217,23852,
|
||||
14382,31059,9160,-3296,20287,-28357,24449,-10323,-21992,-4655,-32548,13237,
|
||||
-15083,-25226,-21121,2015,-8996,-20247,-27551,-14771,-16089,-6920,-9645,21578,
|
||||
7142,-5613,14029,24730,-29253,13931,-3862,-16634,-7388,16951,15771,31302,
|
||||
-22186,-6716,18416,1698,-26200,-16231,9821,-10886,-4994,-30527,-9448,-16923,
|
||||
29549,-11207,-14909,-3643,-27548,17865,28859,29753,17616,16874,-17733,9424,
|
||||
21435,-31715,24544,8666,30844,25075,-18267,12027,-5346,2717,19615,-4548,-21763,
|
||||
28514,11691,22268,-2338,1406,-27379,-23568,-24525,13633,11295,-14715,7877,
|
||||
-27669,3475,20345,7779,-17849,2184,7132,4079,-24937,11585,22740,5810,-10855,
|
||||
16203,-6371,23235,-7,-24828,-11205,-11006,-10,-17812,-14274,11504,-27517,463,
|
||||
4498,-32180,-9775,-3190,-22435,-18662,-30146,-31834,-26449,-19374,-12616,
|
||||
-10596,14341,-10089,-18449,-16535,21439,21191,-1651,7695,-30009,-23339,-8675,
|
||||
-20774,21588,-2793,8218,-14337,-10866,14060,-15343,31712,25247,-8539,18074,
|
||||
-28683,-7363,-7663,-3563,-30718,17771,28687,-30495,30584,14022,-28053,5292,
|
||||
-31576,-32486,-15470,-1330,23551,-2185,-10829,-13216,-4825,-2964,-14668,24559,
|
||||
-4930,23731,-1152,-11493,-2321,15987,-27073,-20305,-24065,-25048,32750,-27440,
|
||||
-1169,-25633,-4356,-24993,30439,-17165,-4580,8662,22655,-4588,-6162,-3122,
|
||||
31986,-2569,20371,-12320,-25613,-16133,-25644,23677,12254,5855,26325,-13425,
|
||||
-15903,-1930,-28488,31222,31153,17607,-2758,7594,-8868,30434,-2518,27956,
|
||||
-19424,7370,6199,-17602,17347,-14358,25588,11611,-25209,-23701,-27444,-29788,
|
||||
2680,-27406,9318,22483,-28356,28482,4577,-14891,17323,-30152,2507,2977,5004,
|
||||
-11696,-31623,-15149,13357,28938,-14048,19490,-19860,-26050,10842,-24922,
|
||||
-20986,8847,-31184,28519,-29168,32195,10516,25713,-3493,670,31283,-12769,
|
||||
-17461,11357,13180,26133,15944,18051,-32167,-27990,16813,17676,21787,-17578,
|
||||
11173,19093,2836,656,-15239,4632,23937,4106,-21655,-7494,-21575,-17647,-18465,
|
||||
-14654,-29990,-10707,-12440,21465,5822,26164,-1404,-14303,-26635,-6900,-23611,
|
||||
11998,-18551,971,27579,13325,4579,23059,29281,22291,29880,-17546,25664,-14990,
|
||||
-526,-35,28218,-3214,11965,11263,6633,30719,32400,-29,-3733,24383,32678,-27542,
|
||||
-4444,6196,5975,-19722,11902,16840,-11680,11146,-26391,-8980,21573,-9043,2349,
|
||||
-12887,5916,-2996,10410,-23374,26338,11867,-14518,18281,14450,-5815,13842,359,
|
||||
25450,27043,3355,13423,-20880,-26311,-30720,-2503,-6046,-18156,-18558,-14774,
|
||||
-15664,-29001,3365,-12689,10233,23608,24692,12039,15445,18411,-27469,3764,
|
||||
-10841,22672,23844,2282,-12443,2851,-27163,13651,13738,17201,-29819,27414,
|
||||
-29764,-5308,-16171,-32427,-26312,-7460,-27376,-6004,25717,29254,-15015,8754,
|
||||
15493,22232,-28513,-23355,23676,7736,10571,-8120,-16677,7696,32549,-2646,25538,
|
||||
3498,30960,-28459,24716,12655,-10496,402,26209,482,-16661,-20350,-3403,14015,
|
||||
32299,11262,-25886,4092,-7843,-100,-1975,-58,-3729,-19269,-23583,-6929,20000,
|
||||
-6089,17780,-3250,29830,19954,-29277,27896,10330,9277,-25358,31279,-14454,
|
||||
24203,-30170,12872,-21973,-25773,-10502,-6647,-26143,6394,-13479,-24559,23007,
|
||||
-21844,1505,24702,-23187,-24364,-20470,20765,-7107,15674,9404,17408,17964,
|
||||
19820,18952,2154,-26052,30056,-3227,17770,-8557,-31018,-27700,-25974,9003,
|
||||
18218,22730,-19981,6737,3532,1562,-23626,14990,28472,-5270,17358,-32204,-29197,
|
||||
-3647,4296,8588,25302,-23906,30328,-29119,-24392,8992,-16557,31530,-31216,
|
||||
14107,13041,-6976,7529,-8296,17865,-1462,8181,-21588,-131,-10177,-25931,-14627,
|
||||
8301,3708,-32097,20808,13892,-21179,1192,20853,3249,-8774,20843,3520,24954,
|
||||
-14215,-25170,-16170,2390,25964,-23923,-17464,-7177,-27568,-9880,-4647,-7323,
|
||||
15388,2113,-12338,-7737,26255,26818,-22156,-19610,-911,-17057,-556,29935,27647,
|
||||
31806,23676,-18132,-19234,-10869,-3715,24983,-10900,-29564,19856,-16392,-31860,
|
||||
-25826,24077,12080,15383,-29852,-2266,-27217,31931,-3183,17385,-14211,19050,
|
||||
-2449,-468,-2871,-11466,973,2866,649,1367,-8688,-24069,20992,25139,-25850,1184,
|
||||
15851,785,16951,12160,22337,-21851,1849,-18801,14247,-429,-12682,30881,-11273,
|
||||
-24819,-9794,8389,-27287,7525,16633,1328,-26650,32607,-8217,31912,7774,-16188,
|
||||
-3546,-6550,-16279,-32696,1940,2577,-23723,-6484,2009,-424,27833,-21763,-13902,
|
||||
7044,27360,-18450,27889,23987,3137,-7669,-5784,-7490,24946,32302,26464,-15513,
|
||||
28898,2493,-17645,-4615,-13434,-20884,-4058,-29951,-22281,24784,21083,-8536,
|
||||
22147,-11261,-15069,20659,2993,19029,21909,6748,-3263,1401,30960,11000,-16871,
|
||||
-30566,-14959,-26356,-2885,21526,-26531,31063,12857,4992,-5067,3130,-17602,
|
||||
-1732,-6593,30200,24679,3267,310,20733,24863,-15669,7875,-4577,-13821,-22325,
|
||||
15548,29744,3733,-14547,21459,22122,3854,-2572,30197,-24770,-21263,8793,-8316,
|
||||
1571,28191,-16143,-6446,31524,-26496,-17349,-29097,2806,11281,-7041,-683,14149,
|
||||
19689,-22094,-1657,-30904,183,-15226,-6358,25461,461,1495,28345,-10554,-4004,
|
||||
27119,13484,-21600,-12272,-7272,-14064,-299,10697,11280,19066,-9841,-7265,
|
||||
-18002,19906,-17247,21482,-10939,-5897,-22300,-13978,27575,-8684,-6222,-19041,
|
||||
5788,-30863,-10134,15142,2895,14705,-17713,12940,-21535,-11619,29416,18417,
|
||||
-24973,24867,-26462,-24910,-32556,-26705,-7187,-7750,-758,-14809,20289,9260,
|
||||
13778,-1422,30301,-1922,30646,27662,-15465,-912,29340,13846,-1263,28887,-20019,
|
||||
32421,-29411,-27632,-7495,-8368,29230,-6386,-19536,-5235,2054,1854,23563,12348,
|
||||
-15165,-2936,-28063,-15760,20126,-25531,4963,-5739,23182,16895,-17258,-10470,
|
||||
-3969,-7742,-140,4475,-24014,-31961,19231,27153,-18551,20157,26443,11530,
|
||||
-22214,2284,-24238,-31051,-26422,9088,29868,18458,8488,-9515,6799,-12507,54,
|
||||
-19441,-32665,12561,23560,4725,-28617,-14800,-10224,-13503,-17636,-16823,
|
||||
-24072,18735,-29798,-23658,-670,-21769,7489,-6468,-8961,-14785,22255,11582,
|
||||
-29831,16303,-19652,2922,-4362,22966,16173,-18446,-6148,27381,-8493,-32289,
|
||||
24005,-3027,-18665,-16472,-17793,-27027,-7443,17854,31365,-17726,-2510,-17546,
|
||||
14893,21773,-23634,21117,32533,6637,-1106,-8152,-3672,-113,-2149,-34,-22700,
|
||||
-4102,-28533,-14104,-10086,4378,13695,-15320,-28258,2246,7595,30021,13281,
|
||||
-11968,-29983,14274,27152,26713,19434,17058,1142,-3043,-16496,18630,-11976,
|
||||
29168,-3634,32746,27287,-268,16711,-8712,-471,12895,17406,-22548,-3969,-10733,
|
||||
13128,10530,-31667,7929,-32277,30926,-1983,8401,-7705,6790,4532,1442,26728,
|
||||
29600,-15358,21622,9744,11406,15989,-30741,-15044,29913,24534,6774,-3755,17623,
|
||||
19647,18762,10042,9653,-5889,2408,-32579,-6285,-28559,-30655,6294,-21175,4390,
|
||||
1668,25437,2821,21066,-13680,5274,-27253,-5248,-26307,29744,-26428,25358,17196,
|
||||
15199,-29784,-4604,25653,-8048,-23131,-28995,31340,-9558,26186,11268,27916,
|
||||
9646,-7389,-11384,-29116,-4100,160,18394,7856,738,-25920,12148,24713,-31664,
|
||||
8203,-25556,13494,30352,29161,30898,1432,-5991,25411,1344,-4019,22299,15685,
|
||||
-16401,-23136,-28110,11874,-18945,1879,2,0,-32256,-20996,-18169,29220,12,0,0,0,
|
||||
335,-27277,-30776,20480,0};
|
||||
```
|
||||
|
||||
<!--
|
||||
|
||||
+123
-124
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Yusuke_Endoh">Yusuke Endoh</a><br>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,19 +141,19 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span></span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<p>To see the original <a href="mullender.c">mullender</a> in action:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<p>Observe what happens when you hit enter or another character! You might even try
|
||||
typing out, one character at a time, <code>1984/mullender</code>, and then see what it looks
|
||||
like at the end. Send INTR to end the program.</p>
|
||||
<p>More generally use:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> <span class="at">-o</span> prog prog.c foo.c</span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span></span>
|
||||
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="ex">^C</span> <span class="co"># if necessary, where ^C is ctrl-C, interrrupt</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="fu">cc</span> <span class="at">-o</span> prog prog.c foo.c</span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span></span>
|
||||
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">^C</span> <span class="co"># if necessary, where ^C is ctrl-C, interrrupt</span></span></code></pre></div>
|
||||
<p>to compile and run <code>prog</code> as whatever foo.c is in the joke PDP-11 emulator.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>Like <a href="https://en.wikipedia.org/wiki/Marty_McFly">Marty</a> and
|
||||
@@ -182,9 +181,9 @@ the source code from all angles..</li>
|
||||
<p>This program is a joke PDP-11 emulator. (“ll-dpd” is embedded in the code.
|
||||
Read it upside down.)</p>
|
||||
<p>You got it? This program is supposed to be used in this way:</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">wget</span> https://www.ioccc.org/1984/mullender.c</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="fu">clang</span> <span class="at">-o</span> prog prog.c mullender.c</span>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">wget</span> https://www.ioccc.org/1984/mullender.c</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">clang</span> <span class="at">-o</span> prog prog.c mullender.c</span>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>You can enjoy the legendary winning entry of the first IOCCC, again.</p>
|
||||
<h3 id="internal">Internal</h3>
|
||||
<p>This program uses <code>__attribute__((constructor))</code>, which is a GCC extension, to
|
||||
@@ -218,119 +217,119 @@ destination register. Index addressing mode works well only for R7 (PC
|
||||
register).</p>
|
||||
<h3 id="one-more-thing">One more thing</h3>
|
||||
<p>Note: this program writes a binary file to <code>stdout</code>:</p>
|
||||
<pre><code>short main[]={5568,1,-30460,12,2782,0,-29921,2056,-4864,6873,770,30054,11886,
|
||||
24948,114,21716,-28851,14043,-8944,32691,-16187,-12247,22692,-9781,-20403,
|
||||
-11771,16546,18710,17873,9233,31304,-32215,-24382,-28247,-25916,10466,24988,
|
||||
-3404,-4177,-28528,-531,-3016,17300,-28552,-7708,-26180,-4297,-367,-2312,
|
||||
-25611,28535,-8533,24004,25421,-1224,-5354,-20807,-21589,-6761,-5203,-1055,
|
||||
-6715,-26673,-1433,-17732,-24198,14681,-3714,-6660,-14891,-25575,20349,-7701,
|
||||
-8336,31433,16695,-14773,26819,3096,-12584,-28808,17825,-21200,-32399,15877,
|
||||
-28890,-3728,-27126,21375,-32630,-7615,32004,-29230,-6611,-5508,-28921,12418,
|
||||
27204,-5725,9643,3520,26836,-29347,2101,-29311,9320,29287,-29990,-6593,29825,
|
||||
-29114,16232,25641,20672,-23501,-32127,-6546,-956,10474,-29647,1070,5516,13760,
|
||||
-27814,-32488,-28006,-17968,-3146,10963,19234,22132,23988,7142,5523,9639,-6888,
|
||||
-11428,7964,23099,-16822,16518,31109,-12958,10351,2434,3091,3625,2244,27512,
|
||||
-28559,-10724,-19377,23625,30056,11478,-21176,27660,26517,-29037,-9390,12297,
|
||||
-11903,5980,-21927,-7483,6671,11249,29638,-23827,-26358,-6856,-1063,-5303,
|
||||
26636,25797,31818,26798,-4243,-18772,-13266,27472,-12005,-10642,-22524,24373,
|
||||
-13111,-9062,6274,-20002,24150,22189,-14965,-31249,-13934,-6341,-18384,-32054,
|
||||
-29246,10622,-9260,19428,-15485,2724,23810,16447,11627,18604,2739,27812,30295,
|
||||
-21538,-31786,11355,-11308,-9006,-4987,25363,-18927,-21130,-31213,-27411,17231,
|
||||
-19608,20232,27754,16476,11213,-19803,-24048,30918,-25329,21233,-10160,13519,
|
||||
11828,26653,-6703,10893,6871,-12417,24471,20310,-12137,-19677,4457,-19530,
|
||||
10147,17724,533,-10055,27076,10264,11274,-10511,4809,25208,16065,-5105,-19953,
|
||||
3772,-12124,13475,-27559,-9955,26446,15133,15207,-23640,6425,-11010,28688,
|
||||
-20064,26353,-889,-25008,10380,-14449,-6894,18920,-23900,16902,-31018,16093,
|
||||
20875,-19576,4585,13126,18589,24789,19424,31274,-5059,-14538,-3125,-16527,
|
||||
-25070,-9013,26628,15756,-7652,30841,-1283,17707,25717,-18315,-6342,6880,
|
||||
-19176,6995,5672,2853,-9044,-3409,-14421,-7522,13108,20582,-25317,1376,-5648,
|
||||
13821,17300,1220,-29437,-25832,-8332,-15575,-9744,28297,31995,-1217,23852,
|
||||
14382,31059,9160,-3296,20287,-28357,24449,-10323,-21992,-4655,-32548,13237,
|
||||
-15083,-25226,-21121,2015,-8996,-20247,-27551,-14771,-16089,-6920,-9645,21578,
|
||||
7142,-5613,14029,24730,-29253,13931,-3862,-16634,-7388,16951,15771,31302,
|
||||
-22186,-6716,18416,1698,-26200,-16231,9821,-10886,-4994,-30527,-9448,-16923,
|
||||
29549,-11207,-14909,-3643,-27548,17865,28859,29753,17616,16874,-17733,9424,
|
||||
21435,-31715,24544,8666,30844,25075,-18267,12027,-5346,2717,19615,-4548,-21763,
|
||||
28514,11691,22268,-2338,1406,-27379,-23568,-24525,13633,11295,-14715,7877,
|
||||
-27669,3475,20345,7779,-17849,2184,7132,4079,-24937,11585,22740,5810,-10855,
|
||||
16203,-6371,23235,-7,-24828,-11205,-11006,-10,-17812,-14274,11504,-27517,463,
|
||||
4498,-32180,-9775,-3190,-22435,-18662,-30146,-31834,-26449,-19374,-12616,
|
||||
-10596,14341,-10089,-18449,-16535,21439,21191,-1651,7695,-30009,-23339,-8675,
|
||||
-20774,21588,-2793,8218,-14337,-10866,14060,-15343,31712,25247,-8539,18074,
|
||||
-28683,-7363,-7663,-3563,-30718,17771,28687,-30495,30584,14022,-28053,5292,
|
||||
-31576,-32486,-15470,-1330,23551,-2185,-10829,-13216,-4825,-2964,-14668,24559,
|
||||
-4930,23731,-1152,-11493,-2321,15987,-27073,-20305,-24065,-25048,32750,-27440,
|
||||
-1169,-25633,-4356,-24993,30439,-17165,-4580,8662,22655,-4588,-6162,-3122,
|
||||
31986,-2569,20371,-12320,-25613,-16133,-25644,23677,12254,5855,26325,-13425,
|
||||
-15903,-1930,-28488,31222,31153,17607,-2758,7594,-8868,30434,-2518,27956,
|
||||
-19424,7370,6199,-17602,17347,-14358,25588,11611,-25209,-23701,-27444,-29788,
|
||||
2680,-27406,9318,22483,-28356,28482,4577,-14891,17323,-30152,2507,2977,5004,
|
||||
-11696,-31623,-15149,13357,28938,-14048,19490,-19860,-26050,10842,-24922,
|
||||
-20986,8847,-31184,28519,-29168,32195,10516,25713,-3493,670,31283,-12769,
|
||||
-17461,11357,13180,26133,15944,18051,-32167,-27990,16813,17676,21787,-17578,
|
||||
11173,19093,2836,656,-15239,4632,23937,4106,-21655,-7494,-21575,-17647,-18465,
|
||||
-14654,-29990,-10707,-12440,21465,5822,26164,-1404,-14303,-26635,-6900,-23611,
|
||||
11998,-18551,971,27579,13325,4579,23059,29281,22291,29880,-17546,25664,-14990,
|
||||
-526,-35,28218,-3214,11965,11263,6633,30719,32400,-29,-3733,24383,32678,-27542,
|
||||
-4444,6196,5975,-19722,11902,16840,-11680,11146,-26391,-8980,21573,-9043,2349,
|
||||
-12887,5916,-2996,10410,-23374,26338,11867,-14518,18281,14450,-5815,13842,359,
|
||||
25450,27043,3355,13423,-20880,-26311,-30720,-2503,-6046,-18156,-18558,-14774,
|
||||
-15664,-29001,3365,-12689,10233,23608,24692,12039,15445,18411,-27469,3764,
|
||||
-10841,22672,23844,2282,-12443,2851,-27163,13651,13738,17201,-29819,27414,
|
||||
-29764,-5308,-16171,-32427,-26312,-7460,-27376,-6004,25717,29254,-15015,8754,
|
||||
15493,22232,-28513,-23355,23676,7736,10571,-8120,-16677,7696,32549,-2646,25538,
|
||||
3498,30960,-28459,24716,12655,-10496,402,26209,482,-16661,-20350,-3403,14015,
|
||||
32299,11262,-25886,4092,-7843,-100,-1975,-58,-3729,-19269,-23583,-6929,20000,
|
||||
-6089,17780,-3250,29830,19954,-29277,27896,10330,9277,-25358,31279,-14454,
|
||||
24203,-30170,12872,-21973,-25773,-10502,-6647,-26143,6394,-13479,-24559,23007,
|
||||
-21844,1505,24702,-23187,-24364,-20470,20765,-7107,15674,9404,17408,17964,
|
||||
19820,18952,2154,-26052,30056,-3227,17770,-8557,-31018,-27700,-25974,9003,
|
||||
18218,22730,-19981,6737,3532,1562,-23626,14990,28472,-5270,17358,-32204,-29197,
|
||||
-3647,4296,8588,25302,-23906,30328,-29119,-24392,8992,-16557,31530,-31216,
|
||||
14107,13041,-6976,7529,-8296,17865,-1462,8181,-21588,-131,-10177,-25931,-14627,
|
||||
8301,3708,-32097,20808,13892,-21179,1192,20853,3249,-8774,20843,3520,24954,
|
||||
-14215,-25170,-16170,2390,25964,-23923,-17464,-7177,-27568,-9880,-4647,-7323,
|
||||
15388,2113,-12338,-7737,26255,26818,-22156,-19610,-911,-17057,-556,29935,27647,
|
||||
31806,23676,-18132,-19234,-10869,-3715,24983,-10900,-29564,19856,-16392,-31860,
|
||||
-25826,24077,12080,15383,-29852,-2266,-27217,31931,-3183,17385,-14211,19050,
|
||||
-2449,-468,-2871,-11466,973,2866,649,1367,-8688,-24069,20992,25139,-25850,1184,
|
||||
15851,785,16951,12160,22337,-21851,1849,-18801,14247,-429,-12682,30881,-11273,
|
||||
-24819,-9794,8389,-27287,7525,16633,1328,-26650,32607,-8217,31912,7774,-16188,
|
||||
-3546,-6550,-16279,-32696,1940,2577,-23723,-6484,2009,-424,27833,-21763,-13902,
|
||||
7044,27360,-18450,27889,23987,3137,-7669,-5784,-7490,24946,32302,26464,-15513,
|
||||
28898,2493,-17645,-4615,-13434,-20884,-4058,-29951,-22281,24784,21083,-8536,
|
||||
22147,-11261,-15069,20659,2993,19029,21909,6748,-3263,1401,30960,11000,-16871,
|
||||
-30566,-14959,-26356,-2885,21526,-26531,31063,12857,4992,-5067,3130,-17602,
|
||||
-1732,-6593,30200,24679,3267,310,20733,24863,-15669,7875,-4577,-13821,-22325,
|
||||
15548,29744,3733,-14547,21459,22122,3854,-2572,30197,-24770,-21263,8793,-8316,
|
||||
1571,28191,-16143,-6446,31524,-26496,-17349,-29097,2806,11281,-7041,-683,14149,
|
||||
19689,-22094,-1657,-30904,183,-15226,-6358,25461,461,1495,28345,-10554,-4004,
|
||||
27119,13484,-21600,-12272,-7272,-14064,-299,10697,11280,19066,-9841,-7265,
|
||||
-18002,19906,-17247,21482,-10939,-5897,-22300,-13978,27575,-8684,-6222,-19041,
|
||||
5788,-30863,-10134,15142,2895,14705,-17713,12940,-21535,-11619,29416,18417,
|
||||
-24973,24867,-26462,-24910,-32556,-26705,-7187,-7750,-758,-14809,20289,9260,
|
||||
13778,-1422,30301,-1922,30646,27662,-15465,-912,29340,13846,-1263,28887,-20019,
|
||||
32421,-29411,-27632,-7495,-8368,29230,-6386,-19536,-5235,2054,1854,23563,12348,
|
||||
-15165,-2936,-28063,-15760,20126,-25531,4963,-5739,23182,16895,-17258,-10470,
|
||||
-3969,-7742,-140,4475,-24014,-31961,19231,27153,-18551,20157,26443,11530,
|
||||
-22214,2284,-24238,-31051,-26422,9088,29868,18458,8488,-9515,6799,-12507,54,
|
||||
-19441,-32665,12561,23560,4725,-28617,-14800,-10224,-13503,-17636,-16823,
|
||||
-24072,18735,-29798,-23658,-670,-21769,7489,-6468,-8961,-14785,22255,11582,
|
||||
-29831,16303,-19652,2922,-4362,22966,16173,-18446,-6148,27381,-8493,-32289,
|
||||
24005,-3027,-18665,-16472,-17793,-27027,-7443,17854,31365,-17726,-2510,-17546,
|
||||
14893,21773,-23634,21117,32533,6637,-1106,-8152,-3672,-113,-2149,-34,-22700,
|
||||
-4102,-28533,-14104,-10086,4378,13695,-15320,-28258,2246,7595,30021,13281,
|
||||
-11968,-29983,14274,27152,26713,19434,17058,1142,-3043,-16496,18630,-11976,
|
||||
29168,-3634,32746,27287,-268,16711,-8712,-471,12895,17406,-22548,-3969,-10733,
|
||||
13128,10530,-31667,7929,-32277,30926,-1983,8401,-7705,6790,4532,1442,26728,
|
||||
29600,-15358,21622,9744,11406,15989,-30741,-15044,29913,24534,6774,-3755,17623,
|
||||
19647,18762,10042,9653,-5889,2408,-32579,-6285,-28559,-30655,6294,-21175,4390,
|
||||
1668,25437,2821,21066,-13680,5274,-27253,-5248,-26307,29744,-26428,25358,17196,
|
||||
15199,-29784,-4604,25653,-8048,-23131,-28995,31340,-9558,26186,11268,27916,
|
||||
9646,-7389,-11384,-29116,-4100,160,18394,7856,738,-25920,12148,24713,-31664,
|
||||
8203,-25556,13494,30352,29161,30898,1432,-5991,25411,1344,-4019,22299,15685,
|
||||
-16401,-23136,-28110,11874,-18945,1879,2,0,-32256,-20996,-18169,29220,12,0,0,0,
|
||||
335,-27277,-30776,20480,0};</code></pre>
|
||||
<pre><code> short main[]={5568,1,-30460,12,2782,0,-29921,2056,-4864,6873,770,30054,11886,
|
||||
24948,114,21716,-28851,14043,-8944,32691,-16187,-12247,22692,-9781,-20403,
|
||||
-11771,16546,18710,17873,9233,31304,-32215,-24382,-28247,-25916,10466,24988,
|
||||
-3404,-4177,-28528,-531,-3016,17300,-28552,-7708,-26180,-4297,-367,-2312,
|
||||
-25611,28535,-8533,24004,25421,-1224,-5354,-20807,-21589,-6761,-5203,-1055,
|
||||
-6715,-26673,-1433,-17732,-24198,14681,-3714,-6660,-14891,-25575,20349,-7701,
|
||||
-8336,31433,16695,-14773,26819,3096,-12584,-28808,17825,-21200,-32399,15877,
|
||||
-28890,-3728,-27126,21375,-32630,-7615,32004,-29230,-6611,-5508,-28921,12418,
|
||||
27204,-5725,9643,3520,26836,-29347,2101,-29311,9320,29287,-29990,-6593,29825,
|
||||
-29114,16232,25641,20672,-23501,-32127,-6546,-956,10474,-29647,1070,5516,13760,
|
||||
-27814,-32488,-28006,-17968,-3146,10963,19234,22132,23988,7142,5523,9639,-6888,
|
||||
-11428,7964,23099,-16822,16518,31109,-12958,10351,2434,3091,3625,2244,27512,
|
||||
-28559,-10724,-19377,23625,30056,11478,-21176,27660,26517,-29037,-9390,12297,
|
||||
-11903,5980,-21927,-7483,6671,11249,29638,-23827,-26358,-6856,-1063,-5303,
|
||||
26636,25797,31818,26798,-4243,-18772,-13266,27472,-12005,-10642,-22524,24373,
|
||||
-13111,-9062,6274,-20002,24150,22189,-14965,-31249,-13934,-6341,-18384,-32054,
|
||||
-29246,10622,-9260,19428,-15485,2724,23810,16447,11627,18604,2739,27812,30295,
|
||||
-21538,-31786,11355,-11308,-9006,-4987,25363,-18927,-21130,-31213,-27411,17231,
|
||||
-19608,20232,27754,16476,11213,-19803,-24048,30918,-25329,21233,-10160,13519,
|
||||
11828,26653,-6703,10893,6871,-12417,24471,20310,-12137,-19677,4457,-19530,
|
||||
10147,17724,533,-10055,27076,10264,11274,-10511,4809,25208,16065,-5105,-19953,
|
||||
3772,-12124,13475,-27559,-9955,26446,15133,15207,-23640,6425,-11010,28688,
|
||||
-20064,26353,-889,-25008,10380,-14449,-6894,18920,-23900,16902,-31018,16093,
|
||||
20875,-19576,4585,13126,18589,24789,19424,31274,-5059,-14538,-3125,-16527,
|
||||
-25070,-9013,26628,15756,-7652,30841,-1283,17707,25717,-18315,-6342,6880,
|
||||
-19176,6995,5672,2853,-9044,-3409,-14421,-7522,13108,20582,-25317,1376,-5648,
|
||||
13821,17300,1220,-29437,-25832,-8332,-15575,-9744,28297,31995,-1217,23852,
|
||||
14382,31059,9160,-3296,20287,-28357,24449,-10323,-21992,-4655,-32548,13237,
|
||||
-15083,-25226,-21121,2015,-8996,-20247,-27551,-14771,-16089,-6920,-9645,21578,
|
||||
7142,-5613,14029,24730,-29253,13931,-3862,-16634,-7388,16951,15771,31302,
|
||||
-22186,-6716,18416,1698,-26200,-16231,9821,-10886,-4994,-30527,-9448,-16923,
|
||||
29549,-11207,-14909,-3643,-27548,17865,28859,29753,17616,16874,-17733,9424,
|
||||
21435,-31715,24544,8666,30844,25075,-18267,12027,-5346,2717,19615,-4548,-21763,
|
||||
28514,11691,22268,-2338,1406,-27379,-23568,-24525,13633,11295,-14715,7877,
|
||||
-27669,3475,20345,7779,-17849,2184,7132,4079,-24937,11585,22740,5810,-10855,
|
||||
16203,-6371,23235,-7,-24828,-11205,-11006,-10,-17812,-14274,11504,-27517,463,
|
||||
4498,-32180,-9775,-3190,-22435,-18662,-30146,-31834,-26449,-19374,-12616,
|
||||
-10596,14341,-10089,-18449,-16535,21439,21191,-1651,7695,-30009,-23339,-8675,
|
||||
-20774,21588,-2793,8218,-14337,-10866,14060,-15343,31712,25247,-8539,18074,
|
||||
-28683,-7363,-7663,-3563,-30718,17771,28687,-30495,30584,14022,-28053,5292,
|
||||
-31576,-32486,-15470,-1330,23551,-2185,-10829,-13216,-4825,-2964,-14668,24559,
|
||||
-4930,23731,-1152,-11493,-2321,15987,-27073,-20305,-24065,-25048,32750,-27440,
|
||||
-1169,-25633,-4356,-24993,30439,-17165,-4580,8662,22655,-4588,-6162,-3122,
|
||||
31986,-2569,20371,-12320,-25613,-16133,-25644,23677,12254,5855,26325,-13425,
|
||||
-15903,-1930,-28488,31222,31153,17607,-2758,7594,-8868,30434,-2518,27956,
|
||||
-19424,7370,6199,-17602,17347,-14358,25588,11611,-25209,-23701,-27444,-29788,
|
||||
2680,-27406,9318,22483,-28356,28482,4577,-14891,17323,-30152,2507,2977,5004,
|
||||
-11696,-31623,-15149,13357,28938,-14048,19490,-19860,-26050,10842,-24922,
|
||||
-20986,8847,-31184,28519,-29168,32195,10516,25713,-3493,670,31283,-12769,
|
||||
-17461,11357,13180,26133,15944,18051,-32167,-27990,16813,17676,21787,-17578,
|
||||
11173,19093,2836,656,-15239,4632,23937,4106,-21655,-7494,-21575,-17647,-18465,
|
||||
-14654,-29990,-10707,-12440,21465,5822,26164,-1404,-14303,-26635,-6900,-23611,
|
||||
11998,-18551,971,27579,13325,4579,23059,29281,22291,29880,-17546,25664,-14990,
|
||||
-526,-35,28218,-3214,11965,11263,6633,30719,32400,-29,-3733,24383,32678,-27542,
|
||||
-4444,6196,5975,-19722,11902,16840,-11680,11146,-26391,-8980,21573,-9043,2349,
|
||||
-12887,5916,-2996,10410,-23374,26338,11867,-14518,18281,14450,-5815,13842,359,
|
||||
25450,27043,3355,13423,-20880,-26311,-30720,-2503,-6046,-18156,-18558,-14774,
|
||||
-15664,-29001,3365,-12689,10233,23608,24692,12039,15445,18411,-27469,3764,
|
||||
-10841,22672,23844,2282,-12443,2851,-27163,13651,13738,17201,-29819,27414,
|
||||
-29764,-5308,-16171,-32427,-26312,-7460,-27376,-6004,25717,29254,-15015,8754,
|
||||
15493,22232,-28513,-23355,23676,7736,10571,-8120,-16677,7696,32549,-2646,25538,
|
||||
3498,30960,-28459,24716,12655,-10496,402,26209,482,-16661,-20350,-3403,14015,
|
||||
32299,11262,-25886,4092,-7843,-100,-1975,-58,-3729,-19269,-23583,-6929,20000,
|
||||
-6089,17780,-3250,29830,19954,-29277,27896,10330,9277,-25358,31279,-14454,
|
||||
24203,-30170,12872,-21973,-25773,-10502,-6647,-26143,6394,-13479,-24559,23007,
|
||||
-21844,1505,24702,-23187,-24364,-20470,20765,-7107,15674,9404,17408,17964,
|
||||
19820,18952,2154,-26052,30056,-3227,17770,-8557,-31018,-27700,-25974,9003,
|
||||
18218,22730,-19981,6737,3532,1562,-23626,14990,28472,-5270,17358,-32204,-29197,
|
||||
-3647,4296,8588,25302,-23906,30328,-29119,-24392,8992,-16557,31530,-31216,
|
||||
14107,13041,-6976,7529,-8296,17865,-1462,8181,-21588,-131,-10177,-25931,-14627,
|
||||
8301,3708,-32097,20808,13892,-21179,1192,20853,3249,-8774,20843,3520,24954,
|
||||
-14215,-25170,-16170,2390,25964,-23923,-17464,-7177,-27568,-9880,-4647,-7323,
|
||||
15388,2113,-12338,-7737,26255,26818,-22156,-19610,-911,-17057,-556,29935,27647,
|
||||
31806,23676,-18132,-19234,-10869,-3715,24983,-10900,-29564,19856,-16392,-31860,
|
||||
-25826,24077,12080,15383,-29852,-2266,-27217,31931,-3183,17385,-14211,19050,
|
||||
-2449,-468,-2871,-11466,973,2866,649,1367,-8688,-24069,20992,25139,-25850,1184,
|
||||
15851,785,16951,12160,22337,-21851,1849,-18801,14247,-429,-12682,30881,-11273,
|
||||
-24819,-9794,8389,-27287,7525,16633,1328,-26650,32607,-8217,31912,7774,-16188,
|
||||
-3546,-6550,-16279,-32696,1940,2577,-23723,-6484,2009,-424,27833,-21763,-13902,
|
||||
7044,27360,-18450,27889,23987,3137,-7669,-5784,-7490,24946,32302,26464,-15513,
|
||||
28898,2493,-17645,-4615,-13434,-20884,-4058,-29951,-22281,24784,21083,-8536,
|
||||
22147,-11261,-15069,20659,2993,19029,21909,6748,-3263,1401,30960,11000,-16871,
|
||||
-30566,-14959,-26356,-2885,21526,-26531,31063,12857,4992,-5067,3130,-17602,
|
||||
-1732,-6593,30200,24679,3267,310,20733,24863,-15669,7875,-4577,-13821,-22325,
|
||||
15548,29744,3733,-14547,21459,22122,3854,-2572,30197,-24770,-21263,8793,-8316,
|
||||
1571,28191,-16143,-6446,31524,-26496,-17349,-29097,2806,11281,-7041,-683,14149,
|
||||
19689,-22094,-1657,-30904,183,-15226,-6358,25461,461,1495,28345,-10554,-4004,
|
||||
27119,13484,-21600,-12272,-7272,-14064,-299,10697,11280,19066,-9841,-7265,
|
||||
-18002,19906,-17247,21482,-10939,-5897,-22300,-13978,27575,-8684,-6222,-19041,
|
||||
5788,-30863,-10134,15142,2895,14705,-17713,12940,-21535,-11619,29416,18417,
|
||||
-24973,24867,-26462,-24910,-32556,-26705,-7187,-7750,-758,-14809,20289,9260,
|
||||
13778,-1422,30301,-1922,30646,27662,-15465,-912,29340,13846,-1263,28887,-20019,
|
||||
32421,-29411,-27632,-7495,-8368,29230,-6386,-19536,-5235,2054,1854,23563,12348,
|
||||
-15165,-2936,-28063,-15760,20126,-25531,4963,-5739,23182,16895,-17258,-10470,
|
||||
-3969,-7742,-140,4475,-24014,-31961,19231,27153,-18551,20157,26443,11530,
|
||||
-22214,2284,-24238,-31051,-26422,9088,29868,18458,8488,-9515,6799,-12507,54,
|
||||
-19441,-32665,12561,23560,4725,-28617,-14800,-10224,-13503,-17636,-16823,
|
||||
-24072,18735,-29798,-23658,-670,-21769,7489,-6468,-8961,-14785,22255,11582,
|
||||
-29831,16303,-19652,2922,-4362,22966,16173,-18446,-6148,27381,-8493,-32289,
|
||||
24005,-3027,-18665,-16472,-17793,-27027,-7443,17854,31365,-17726,-2510,-17546,
|
||||
14893,21773,-23634,21117,32533,6637,-1106,-8152,-3672,-113,-2149,-34,-22700,
|
||||
-4102,-28533,-14104,-10086,4378,13695,-15320,-28258,2246,7595,30021,13281,
|
||||
-11968,-29983,14274,27152,26713,19434,17058,1142,-3043,-16496,18630,-11976,
|
||||
29168,-3634,32746,27287,-268,16711,-8712,-471,12895,17406,-22548,-3969,-10733,
|
||||
13128,10530,-31667,7929,-32277,30926,-1983,8401,-7705,6790,4532,1442,26728,
|
||||
29600,-15358,21622,9744,11406,15989,-30741,-15044,29913,24534,6774,-3755,17623,
|
||||
19647,18762,10042,9653,-5889,2408,-32579,-6285,-28559,-30655,6294,-21175,4390,
|
||||
1668,25437,2821,21066,-13680,5274,-27253,-5248,-26307,29744,-26428,25358,17196,
|
||||
15199,-29784,-4604,25653,-8048,-23131,-28995,31340,-9558,26186,11268,27916,
|
||||
9646,-7389,-11384,-29116,-4100,160,18394,7856,738,-25920,12148,24713,-31664,
|
||||
8203,-25556,13494,30352,29161,30898,1432,-5991,25411,1344,-4019,22299,15685,
|
||||
-16401,-23136,-28110,11874,-18945,1879,2,0,-32256,-20996,-18169,29220,12,0,0,0,
|
||||
335,-27277,-30776,20480,0};</code></pre>
|
||||
<!--
|
||||
|
||||
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
|
||||
|
||||
+12
-12
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
@@ -12,14 +12,14 @@ code](#alternate-code) below for details.
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./prog <a number of arguments>
|
||||
./prog <a number of arguments>
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ Dogon](../../authors.html#Gil_Dogon); it is the author's original entry.
|
||||
### Alternate build:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
make alt
|
||||
```
|
||||
|
||||
|
||||
@@ -55,14 +55,14 @@ experiment with numbers that have more or larger factors?
|
||||
Visual factorization 1-liner. Try:
|
||||
|
||||
```sh
|
||||
gcc -o prog prog.c
|
||||
./prog @
|
||||
./prog @ @
|
||||
./prog @ @ @
|
||||
./prog @ @ @ @
|
||||
./prog @ @ @ @ @ @
|
||||
./prog @ @ @ @ @ @ @ @
|
||||
./prog @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
|
||||
gcc -o prog prog.c
|
||||
./prog @
|
||||
./prog @ @
|
||||
./prog @ @ @
|
||||
./prog @ @ @ @
|
||||
./prog @ @ @ @ @ @
|
||||
./prog @ @ @ @ @ @ @ @
|
||||
./prog @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
|
||||
```
|
||||
|
||||
Inspired by [Animated Factorization
|
||||
|
||||
+13
-14
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Yusuke_Endoh">Yusuke Endoh</a><br>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,19 +141,19 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em>
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<p>There is an alt version which is the originally submitted entry. See <a href="#alternate-code">Alternate
|
||||
code</a> below for details.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> <span class="op"><</span>a number of arguments<span class="op">></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">./prog</span> <span class="op"><</span>a number of arguments<span class="op">></span></span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<p>An alternate version of this entry, <a href="prog.alt.c">prog.alt.c</a>, is provided.
|
||||
This alternate code does not contain improvements suggested by <a href="../../authors.html#Gil_Dogon">Gil
|
||||
Dogon</a>; it is the author’s original entry.</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> alt</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<p>Use <code>prog.alt</code> as you would <code>prog</code> above.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
@@ -164,14 +163,14 @@ run out of command line argument space? How could you modify the program to
|
||||
experiment with numbers that have more or larger factors?</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<p>Visual factorization 1-liner. Try:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="fu">gcc</span> <span class="at">-o</span> prog prog.c</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> @</span>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> @ @</span>
|
||||
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> @ @ @</span>
|
||||
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> @ @ @ @</span>
|
||||
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> @ @ @ @ @ @</span>
|
||||
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> @ @ @ @ @ @ @ @</span>
|
||||
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">gcc</span> <span class="at">-o</span> prog prog.c</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> @</span>
|
||||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> @ @</span>
|
||||
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> @ @ @</span>
|
||||
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> @ @ @ @</span>
|
||||
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> @ @ @ @ @ @</span>
|
||||
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> @ @ @ @ @ @ @ @</span>
|
||||
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @</span></code></pre></div>
|
||||
<p>Inspired by <a href="http://www.datapointed.net/visualizations/math/factorization/animated-diagrams/">Animated Factorization
|
||||
Diagrams</a>.</p>
|
||||
<p><a href="prog.alt.c">prog.alt.c</a> is the original version that I submitted. <a href="../../authors.html#Gil_Dogon">Gil
|
||||
|
||||
+8
-8
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ make
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2015 hou bugs](../../bugs.html#2015_hou).
|
||||
@@ -19,15 +19,15 @@ For more detailed information see [2015 hou bugs](../../bugs.html#2015_hou).
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
echo something | ./prog
|
||||
./prog < file
|
||||
echo something | ./prog
|
||||
./prog < file
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -43,8 +43,8 @@ the reference code!
|
||||
Some things that make you go, "huh?"
|
||||
|
||||
```sh
|
||||
./prog < prog.c | cut -c-5
|
||||
./prog < Makefile | cut -c-4
|
||||
./prog < prog.c | cut -c-5
|
||||
./prog < Makefile | cut -c-4
|
||||
```
|
||||
|
||||
How are those values magically returned?
|
||||
@@ -52,7 +52,7 @@ How are those values magically returned?
|
||||
What happens with a large file? Something over 256K.
|
||||
|
||||
```sh
|
||||
./prog < large_file
|
||||
./prog < large_file
|
||||
```
|
||||
|
||||
Where does that message come from?
|
||||
|
||||
+9
-10
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Qiming_HOU">Qiming HOU</a><br>
|
||||
Location: <a href="../../location.html#CN">CN</a> - <em>People’s Republic of China</em> (<em>China</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#CN">CN</a> - <em>People’s Republic of China</em> (<em>China</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,16 +141,16 @@ Location: <a href="../../location.html#CN">CN</a> - <em>People’s Republic of C
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></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></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#2015_hou">2015 hou bugs</a>.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> something <span class="kw">|</span> <span class="ex">./prog</span></span>
|
||||
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> <span class="op"><</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="bu">echo</span> something <span class="kw">|</span> <span class="ex">./prog</span></span>
|
||||
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> <span class="op"><</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>A good start for understanding this entry might be
|
||||
<a href="rfc1321.txt">rfc1321.txt</a>. How does it compute this using only a
|
||||
@@ -160,11 +159,11 @@ algorithm is about 355 lines of code, yet this entry is only 199 lines with
|
||||
one statement per line and it isn’t using lots of macro expansion tricks like
|
||||
the reference code!</p>
|
||||
<p>Some things that make you go, “huh?”</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> <span class="op"><</span> prog.c <span class="kw">|</span> <span class="fu">cut</span> <span class="at">-c-5</span></span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> <span class="op"><</span> Makefile <span class="kw">|</span> <span class="fu">cut</span> <span class="at">-c-4</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> <span class="op"><</span> prog.c <span class="kw">|</span> <span class="fu">cut</span> <span class="at">-c-5</span></span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> <span class="op"><</span> Makefile <span class="kw">|</span> <span class="fu">cut</span> <span class="at">-c-4</span></span></code></pre></div>
|
||||
<p>How are those values magically returned?</p>
|
||||
<p>What happens with a large file? Something over 256K.</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> <span class="op"><</span> large_file</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">./prog</span> <span class="op"><</span> large_file</span></code></pre></div>
|
||||
<p>Where does that message come from?</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<p>This looks like a normal C program.</p>
|
||||
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
There is an alternate version provided. See [Alternate code](#alternate-code)
|
||||
@@ -11,16 +11,16 @@ below.
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./prog file1 file2
|
||||
./prog file1 file2
|
||||
|
||||
./prog -d file1 file2
|
||||
./prog -d file1 file2
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ entry but was changed to be the alt version.
|
||||
### Alternate build:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
make alt
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -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,20 +141,20 @@ 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></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></span></code></pre></div>
|
||||
<p>There is an alternate version provided. See <a href="#alternate-code">Alternate code</a>
|
||||
below.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> file1 file2</span>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> file1 file2</span>
|
||||
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a></span>
|
||||
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> <span class="at">-d</span> file1 file2</span></code></pre></div>
|
||||
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> <span class="at">-d</span> file1 file2</span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<p>This alternate version does not use a 64-bit FNV hash. This was the original
|
||||
entry but was changed to be the alt version.</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> alt</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> alt</span></code></pre></div>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<p>Use <code>prog.alt</code> as you would <code>prog</code> above.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
|
||||
+8
-8
@@ -169,18 +169,18 @@ one of the all time best IOCCC entries from 1984.</p>
|
||||
would have been much higher had some people paid attention to rules 2
|
||||
and 22 (one third of 666).</p>
|
||||
<p>Rule 22, now known as <strong>Catch 22</strong> states:</p>
|
||||
<pre><code>| 22) Your source code, data files, remarks and program output must NOT
|
||||
| identify the authors of your code. The judges STRONGLY prefer to
|
||||
| not know who is submitting entries to the IOCCC.
|
||||
<pre><code> | 22) Your source code, data files, remarks and program output must NOT
|
||||
| identify the authors of your code. The judges STRONGLY prefer to
|
||||
| not know who is submitting entries to the IOCCC.
|
||||
|
||||
| The "Peter Honeyman is exempt" guideline also applies to this rule.
|
||||
| Identifying yourself, in an obvious way in your code, data, remarks
|
||||
| or program output, unless you are Peter Honeyman or pretending
|
||||
| to be Peter Honeyman, will be grounds for disqualification of your entry.</code></pre>
|
||||
| The "Peter Honeyman is exempt" guideline also applies to this rule.
|
||||
| Identifying yourself, in an obvious way in your code, data, remarks
|
||||
| or program output, unless you are Peter Honeyman or pretending
|
||||
| to be Peter Honeyman, will be grounds for disqualification of your entry.</code></pre>
|
||||
<p>A number of other entries were based on <a href="iocccsize.c">iocccsize.c</a>, making
|
||||
derivative works rather than original works.</p>
|
||||
<p>Still other entries were too large, violating the first line of rule 2:</p>
|
||||
<pre><code>2) The size of your program source must be <= 4096 bytes in length.</code></pre>
|
||||
<pre><code> 2) The size of your program source must be <= 4096 bytes in length.</code></pre>
|
||||
<p>While these entries might have passed under the 2053 limit for iocccsize,
|
||||
they were larger than <= 4096 bytes, sometimes by an order or magnitude.</p>
|
||||
<p>We hope the authors of some of those entries will fix and re-submit
|
||||
|
||||
+34
-32
@@ -1,21 +1,21 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./prog
|
||||
./prog
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./prog
|
||||
./prog
|
||||
```
|
||||
|
||||
Press the up arrow and the down arrow at the right time.
|
||||
@@ -28,52 +28,52 @@ Well you can adjust the Makefile parameters to make life a
|
||||
bit easier for you:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
which runs:
|
||||
|
||||
```sh
|
||||
make clobber all DW=199999 DW=22 DH=16 DA=50 DI=-150
|
||||
./prog
|
||||
make clobber all DW=199999 DW=22 DH=16 DA=50 DI=-150
|
||||
./prog
|
||||
```
|
||||
|
||||
|
||||
From the Makefile:
|
||||
|
||||
```
|
||||
# Game parameters
|
||||
#
|
||||
DU=99999 # Time between steps in microseconds.
|
||||
# Make it larger if the game is too fast for you.
|
||||
# Game parameters
|
||||
#
|
||||
DU=99999 # Time between steps in microseconds.
|
||||
# Make it larger if the game is too fast for you.
|
||||
|
||||
DW=28 # Pipe-to-pipe spacing, in columns.
|
||||
# Farther apart is easier.
|
||||
DW=28 # Pipe-to-pipe spacing, in columns.
|
||||
# Farther apart is easier.
|
||||
|
||||
DD=20 # Space between pipes.
|
||||
# The difference between DD and DW is the width of a pipe.
|
||||
# Narrow pipes are easier to fly though.
|
||||
DD=20 # Space between pipes.
|
||||
# The difference between DD and DW is the width of a pipe.
|
||||
# Narrow pipes are easier to fly though.
|
||||
|
||||
DH=8 # Height of gap in pipe.
|
||||
# Make this larger to make the game easier.
|
||||
DH=8 # Height of gap in pipe.
|
||||
# Make this larger to make the game easier.
|
||||
|
||||
DA=100 # Acceleration due to gravity (scaled by 256).
|
||||
# Smaller values make you glide slower.
|
||||
DA=100 # Acceleration due to gravity (scaled by 256).
|
||||
# Smaller values make you glide slower.
|
||||
|
||||
DI=-200 # Impulse velocity of a flap (scaled by 256).
|
||||
# Make larger if you want a less intense tapping experience!
|
||||
DI=-200 # Impulse velocity of a flap (scaled by 256).
|
||||
# Make larger if you want a less intense tapping experience!
|
||||
|
||||
DB='"<o^="' # Sprite for player when gliding.
|
||||
# HINT: Try using various emojis.
|
||||
# NOTE: The string MUST be enclosed inside double quotes.
|
||||
DB='"<o^="' # Sprite for player when gliding.
|
||||
# HINT: Try using various emojis.
|
||||
# NOTE: The string MUST be enclosed inside double quotes.
|
||||
|
||||
DF='"<ov="' # Sprite for player when flapping.
|
||||
# HINT: Try using various emojis.
|
||||
# NOTE: The string MUST be enclosed inside double quotes.
|
||||
DF='"<ov="' # Sprite for player when flapping.
|
||||
# HINT: Try using various emojis.
|
||||
# NOTE: The string MUST be enclosed inside double quotes.
|
||||
|
||||
DG='"Tap to Flap!"' # Instruction text.
|
||||
# Change to your native tongue.
|
||||
# NOTE: The string MUST be enclosed inside double quotes.
|
||||
DG='"Tap to Flap!"' # Instruction text.
|
||||
# Change to your native tongue.
|
||||
# NOTE: The string MUST be enclosed inside double quotes.
|
||||
```
|
||||
|
||||
WARNING: if you have good eye-hand coordination and too much time on your hands
|
||||
@@ -84,8 +84,10 @@ already scored over 90.
|
||||
|
||||
Enjoy!
|
||||
|
||||
```
|
||||
TAP!! TAP!! TAP!!
|
||||
FLAP! FLAP! FLAP!
|
||||
```
|
||||
|
||||
|
||||
## Author's remarks:
|
||||
@@ -146,13 +148,13 @@ To help you get started, I've included some example substitutions for emojis
|
||||
sprites and instruction text; for example, type
|
||||
|
||||
```sh
|
||||
make EMOJI=beer LANGUAGE=spanish
|
||||
make EMOJI=beer LANGUAGE=spanish
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```sh
|
||||
make EMOJI=globe
|
||||
make EMOJI=globe
|
||||
```
|
||||
|
||||
for some examples (the full list of options is in the `Makefile`). Don't forget
|
||||
|
||||
+35
-36
@@ -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 -->
|
||||
@@ -142,61 +141,61 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span></span></code></pre></div>
|
||||
<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">./prog</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">./prog</span></span></code></pre></div>
|
||||
<p>Press the up arrow and the down arrow at the right time.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>Did you find that mobile application game a bit frustrating?
|
||||
Well you can adjust the Makefile parameters to make life a
|
||||
bit easier for you:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<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>which runs:</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> clobber all DW=199999 DW=22 DH=16 DA=50 DI=-150</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> clobber all DW=199999 DW=22 DH=16 DA=50 DI=-150</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span></span></code></pre></div>
|
||||
<p>From the Makefile:</p>
|
||||
<pre><code># Game parameters
|
||||
#
|
||||
DU=99999 # Time between steps in microseconds.
|
||||
# Make it larger if the game is too fast for you.
|
||||
<pre><code> # Game parameters
|
||||
#
|
||||
DU=99999 # Time between steps in microseconds.
|
||||
# Make it larger if the game is too fast for you.
|
||||
|
||||
DW=28 # Pipe-to-pipe spacing, in columns.
|
||||
# Farther apart is easier.
|
||||
DW=28 # Pipe-to-pipe spacing, in columns.
|
||||
# Farther apart is easier.
|
||||
|
||||
DD=20 # Space between pipes.
|
||||
# The difference between DD and DW is the width of a pipe.
|
||||
# Narrow pipes are easier to fly though.
|
||||
DD=20 # Space between pipes.
|
||||
# The difference between DD and DW is the width of a pipe.
|
||||
# Narrow pipes are easier to fly though.
|
||||
|
||||
DH=8 # Height of gap in pipe.
|
||||
# Make this larger to make the game easier.
|
||||
DH=8 # Height of gap in pipe.
|
||||
# Make this larger to make the game easier.
|
||||
|
||||
DA=100 # Acceleration due to gravity (scaled by 256).
|
||||
# Smaller values make you glide slower.
|
||||
DA=100 # Acceleration due to gravity (scaled by 256).
|
||||
# Smaller values make you glide slower.
|
||||
|
||||
DI=-200 # Impulse velocity of a flap (scaled by 256).
|
||||
# Make larger if you want a less intense tapping experience!
|
||||
DI=-200 # Impulse velocity of a flap (scaled by 256).
|
||||
# Make larger if you want a less intense tapping experience!
|
||||
|
||||
DB='"<o^="' # Sprite for player when gliding.
|
||||
# HINT: Try using various emojis.
|
||||
# NOTE: The string MUST be enclosed inside double quotes.
|
||||
DB='"<o^="' # Sprite for player when gliding.
|
||||
# HINT: Try using various emojis.
|
||||
# NOTE: The string MUST be enclosed inside double quotes.
|
||||
|
||||
DF='"<ov="' # Sprite for player when flapping.
|
||||
# HINT: Try using various emojis.
|
||||
# NOTE: The string MUST be enclosed inside double quotes.
|
||||
DF='"<ov="' # Sprite for player when flapping.
|
||||
# HINT: Try using various emojis.
|
||||
# NOTE: The string MUST be enclosed inside double quotes.
|
||||
|
||||
DG='"Tap to Flap!"' # Instruction text.
|
||||
# Change to your native tongue.
|
||||
# NOTE: The string MUST be enclosed inside double quotes.</code></pre>
|
||||
DG='"Tap to Flap!"' # Instruction text.
|
||||
# Change to your native tongue.
|
||||
# NOTE: The string MUST be enclosed inside double quotes.</code></pre>
|
||||
<p>WARNING: if you have good eye-hand coordination and too much time on your hands
|
||||
you might fall asleep while playing as you probably will never die in this mode.
|
||||
We only stopped when a reminder came through and we tried to mark it complete at
|
||||
the same time as playing and we almost managed to survive that. At that point we
|
||||
already scored over 90.</p>
|
||||
<p>Enjoy!</p>
|
||||
<p>TAP!! TAP!! TAP!!
|
||||
FLAP! FLAP! FLAP!</p>
|
||||
<pre><code> TAP!! TAP!! TAP!!
|
||||
FLAP! FLAP! FLAP!</code></pre>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<h3 id="the-program">The Program</h3>
|
||||
<p>Better late than never to jump on the bandwagon of 2014’s most successful
|
||||
@@ -241,9 +240,9 @@ characters (needed for UTF-8 support, which is needed for emojis), you may need
|
||||
to make some changes to the <code>Makefile</code> to get emojis to work on your system.
|
||||
To help you get started, I’ve included some example substitutions for emojis
|
||||
sprites and instruction text; for example, type</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> EMOJI=beer LANGUAGE=spanish</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> EMOJI=beer LANGUAGE=spanish</span></code></pre></div>
|
||||
<p>or</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> EMOJI=globe</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span> EMOJI=globe</span></code></pre></div>
|
||||
<p>for some examples (the full list of options is in the <code>Makefile</code>). Don’t forget
|
||||
to <code>make clobber</code> first (or use <code>make -B</code>). If the output doesn’t look right,
|
||||
you may need to link with the “wide” version of <code>ncurses</code>. On MacOSX 10.11, it
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ make
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2015 mills2 bugs](../../bugs.html#2015_mills2).
|
||||
@@ -19,14 +19,14 @@ For more detailed information see [2015 mills2 bugs](../../bugs.html#2015_mills2
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./prog compressed_file.Z
|
||||
./prog compressed_file.Z
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ for a `compress(1)`-like compressor using a similar idea.
|
||||
Why is the sad smiley on line 12 in that particular place?
|
||||
|
||||
```c
|
||||
c=0) :( O
|
||||
c=0) :( O
|
||||
```
|
||||
|
||||
|
||||
@@ -67,8 +67,8 @@ on your system, I've provided compressed copies of this year's IOCCC rules
|
||||
and guidelines files. To print them, just do
|
||||
|
||||
```sh
|
||||
./prog ioccc_guidelines.txt.Z
|
||||
./prog ioccc_rules.txt.Z
|
||||
./prog ioccc_guidelines.txt.Z
|
||||
./prog ioccc_rules.txt.Z
|
||||
```
|
||||
|
||||
### The Details
|
||||
|
||||
@@ -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 -->
|
||||
@@ -142,22 +141,22 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<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#2015_mills2">2015 mills2 bugs</a>.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> compressed_file.Z</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">./prog</span> compressed_file.Z</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>Without ASCII art, the source code of this entry would have been exactly 256
|
||||
bytes. Compared to <a href="../../years.html#1990_jaw">1990/jaw</a>, it is very
|
||||
impressive, even taking into account the missing <code>atob</code> functionality. Now we wish
|
||||
for a <code>compress(1)</code>-like compressor using a similar idea.</p>
|
||||
<p>Why is the sad smiley on line 12 in that particular place?</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> c<span class="op">=</span><span class="dv">0</span><span class="op">)</span> <span class="op">:(</span> O</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> c<span class="op">=</span><span class="dv">0</span><span class="op">)</span> <span class="op">:(</span> O</span></code></pre></div>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<h3 id="the-program">The Program</h3>
|
||||
<p>This program is an implementation of the unix <code>zcat(1)</code> command for printing
|
||||
@@ -175,8 +174,8 @@ single function and a few <code>int</code>s.</p>
|
||||
on the command line. On the odd chance you don’t have <code>compress(1)</code> hanging about
|
||||
on your system, I’ve provided compressed copies of this year’s IOCCC rules
|
||||
and guidelines files. To print them, just do</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> ioccc_guidelines.txt.Z</span>
|
||||
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> ioccc_rules.txt.Z</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">./prog</span> ioccc_guidelines.txt.Z</span>
|
||||
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> ioccc_rules.txt.Z</span></code></pre></div>
|
||||
<h3 id="the-details">The Details</h3>
|
||||
<p>The basic cleverness here comes from realizing that the compressed data is
|
||||
itself an encoded version of the code dictionary. When the encoder sees
|
||||
|
||||
+8
-8
@@ -1,21 +1,21 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
make -B [MACHINE=your_machine.h] [TAPE=your_tape.h] [X=[0|1|2|3|4|5|6|7|8|9]] [V=[0|1|2]] run
|
||||
make -B [MACHINE=your_machine.h] [TAPE=your_tape.h] [X=[0|1|2|3|4|5|6|7|8|9]] [V=[0|1|2]] run
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -69,13 +69,13 @@ files for examples.
|
||||
Every symbol used (except `_`) must be explicitly declared using
|
||||
|
||||
```c
|
||||
#define sym_SYMBOL(sym, _SYMBOL) sym
|
||||
#define sym_SYMBOL(sym, _SYMBOL) sym
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```c
|
||||
#define sym_1(sym, _1) sym
|
||||
#define sym_1(sym, _1) sym
|
||||
```
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ The initial content of the tape must be defined in the tape header using a
|
||||
triple like:
|
||||
|
||||
```c
|
||||
#define tape ((((,),...l2), l1), c, (r1, (r2..., (,))))
|
||||
#define tape ((((,),...l2), l1), c, (r1, (r2..., (,))))
|
||||
```
|
||||
|
||||
- `l1`, `l2`, ... are the symbols to the left
|
||||
@@ -101,7 +101,7 @@ underscore symbols (`_`). They are expanded on demand.
|
||||
All transitions are defined in the machine header using the syntax
|
||||
|
||||
```
|
||||
#define CURRENT_SCANNED (WRITE, MOVEMENT, NEXT)
|
||||
#define CURRENT_SCANNED (WRITE, MOVEMENT, NEXT)
|
||||
```
|
||||
|
||||
where
|
||||
@@ -120,7 +120,7 @@ machine.
|
||||
To halt the machine, use the keyword `break` as in
|
||||
|
||||
```c
|
||||
#define A_1 (2, break)
|
||||
#define A_1 (2, break)
|
||||
```
|
||||
|
||||
<!--
|
||||
|
||||
+9
-10
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Dominik_Muth">Dominik Muth</a><br>
|
||||
Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germany</em> (<em>Germany</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germany</em> (<em>Germany</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,11 +141,11 @@ Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germ
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> <span class="at">-B</span> <span class="pp">[</span><span class="ss">MACHINE=your_machine.h</span><span class="pp">]</span> <span class="pp">[</span><span class="ss">TAPE=your_tape.h</span><span class="pp">]</span> [X=[0<span class="kw">|</span><span class="ex">1</span><span class="kw">|</span><span class="ex">2</span><span class="kw">|</span><span class="ex">3</span><span class="kw">|</span><span class="ex">4</span><span class="kw">|</span><span class="ex">5</span><span class="kw">|</span><span class="ex">6</span><span class="kw">|</span><span class="ex">7</span><span class="kw">|</span><span class="ex">8</span><span class="kw">|</span><span class="ex">9]]</span> [V=[0<span class="kw">|</span><span class="ex">1</span><span class="kw">|</span><span class="ex">2]]</span> run</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> <span class="at">-B</span> <span class="pp">[</span><span class="ss">MACHINE=your_machine.h</span><span class="pp">]</span> <span class="pp">[</span><span class="ss">TAPE=your_tape.h</span><span class="pp">]</span> [X=[0<span class="kw">|</span><span class="ex">1</span><span class="kw">|</span><span class="ex">2</span><span class="kw">|</span><span class="ex">3</span><span class="kw">|</span><span class="ex">4</span><span class="kw">|</span><span class="ex">5</span><span class="kw">|</span><span class="ex">6</span><span class="kw">|</span><span class="ex">7</span><span class="kw">|</span><span class="ex">8</span><span class="kw">|</span><span class="ex">9]]</span> [V=[0<span class="kw">|</span><span class="ex">1</span><span class="kw">|</span><span class="ex">2]]</span> run</span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>This is something we were fearing all along: that the C preprocessor is Turing-complete
|
||||
even without conditionals and recursive file inclusion as some kind of a
|
||||
@@ -180,13 +179,13 @@ macros in the output.</p>
|
||||
files for examples.</p>
|
||||
<h4 id="tape-symbols">Tape Symbols</h4>
|
||||
<p>Every symbol used (except <code>_</code>) must be explicitly declared using</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="pp">#define sym_SYMBOL</span><span class="op">(</span><span class="pp">sym</span><span class="op">,</span><span class="pp"> _SYMBOL</span><span class="op">)</span><span class="pp"> sym</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="pp">#define sym_SYMBOL</span><span class="op">(</span><span class="pp">sym</span><span class="op">,</span><span class="pp"> _SYMBOL</span><span class="op">)</span><span class="pp"> sym</span></span></code></pre></div>
|
||||
<p>Example:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#define sym_1</span><span class="op">(</span><span class="pp">sym</span><span class="op">,</span><span class="pp"> _1</span><span class="op">)</span><span class="pp"> sym</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> <span class="pp">#define sym_1</span><span class="op">(</span><span class="pp">sym</span><span class="op">,</span><span class="pp"> _1</span><span class="op">)</span><span class="pp"> sym</span></span></code></pre></div>
|
||||
<h4 id="tape">Tape</h4>
|
||||
<p>The initial content of the tape must be defined in the tape header using a
|
||||
triple like:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#define tape </span><span class="op">((((,),...</span><span class="pp">l2</span><span class="op">),</span><span class="pp"> l1</span><span class="op">),</span><span class="pp"> c</span><span class="op">,</span><span class="pp"> </span><span class="op">(</span><span class="pp">r1</span><span class="op">,</span><span class="pp"> </span><span class="op">(</span><span class="pp">r2</span><span class="op">...,</span><span class="pp"> </span><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> <span class="pp">#define tape </span><span class="op">((((,),...</span><span class="pp">l2</span><span class="op">),</span><span class="pp"> l1</span><span class="op">),</span><span class="pp"> c</span><span class="op">,</span><span class="pp"> </span><span class="op">(</span><span class="pp">r1</span><span class="op">,</span><span class="pp"> </span><span class="op">(</span><span class="pp">r2</span><span class="op">...,</span><span class="pp"> </span><span class="op">(,))))</span></span></code></pre></div>
|
||||
<ul>
|
||||
<li><code>l1</code>, <code>l2</code>, … are the symbols to the left</li>
|
||||
<li><code>c</code> is the symbol at the current position</li>
|
||||
@@ -196,7 +195,7 @@ triple like:</p>
|
||||
underscore symbols (<code>_</code>). They are expanded on demand.</p>
|
||||
<h4 id="state-machine">State Machine</h4>
|
||||
<p>All transitions are defined in the machine header using the syntax</p>
|
||||
<pre><code>#define CURRENT_SCANNED (WRITE, MOVEMENT, NEXT)</code></pre>
|
||||
<pre><code> #define CURRENT_SCANNED (WRITE, MOVEMENT, NEXT)</code></pre>
|
||||
<p>where</p>
|
||||
<ul>
|
||||
<li><code>CURRENT</code> is the current state.</li>
|
||||
@@ -210,7 +209,7 @@ want no movement.</li>
|
||||
<p>There must be a state <code>A</code> defined, which becomes the initial state of the
|
||||
machine.</p>
|
||||
<p>To halt the machine, use the keyword <code>break</code> as in</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#define A_1 </span><span class="op">(</span><span class="dv">2</span><span class="op">,</span><span class="pp"> </span><span class="cf">break</span><span class="op">)</span></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="pp">#define A_1 </span><span class="op">(</span><span class="dv">2</span><span class="op">,</span><span class="pp"> </span><span class="cf">break</span><span class="op">)</span></span></code></pre></div>
|
||||
<!--
|
||||
|
||||
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
|
||||
|
||||
+159
-159
@@ -1,7 +1,7 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ make
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2015 schweikhardt bugs](../../bugs.html#2015_schweikhardt).
|
||||
@@ -19,7 +19,7 @@ For more detailed information see [2015 schweikhardt bugs](../../bugs.html#2015_
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./prog n
|
||||
./prog n
|
||||
```
|
||||
|
||||
where n is a base 16 number of any size.
|
||||
@@ -31,7 +31,7 @@ doing something else. The author explains this in more details.
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
After running it once to see what commands are run, you might wish to run it a
|
||||
@@ -45,7 +45,7 @@ This code is clean. When you compile with all warnings enabled,
|
||||
such as with clang:
|
||||
|
||||
```sh
|
||||
cc -Weverything -pedantic -std=c11 -Dtyp=uint64\_t -O3 prog.c -o prog
|
||||
cc -Weverything -pedantic -std=c11 -Dtyp=uint64\_t -O3 prog.c -o prog
|
||||
```
|
||||
|
||||
The code compiles without warnings on the systems that we tested!
|
||||
@@ -58,9 +58,9 @@ Bell](http://members.tip.net.au/~dbell/) once described
|
||||
as having one of the largest "yummo quotients" in number theory:
|
||||
|
||||
```
|
||||
complexity of the solution
|
||||
yummo quotient = -----------------------------------
|
||||
complexity of the problem statement
|
||||
complexity of the solution
|
||||
yummo quotient = -----------------------------------
|
||||
complexity of the problem statement
|
||||
```
|
||||
|
||||
[Erdős](https://en.wikipedia.org/wiki/Paul_Erdős) privately told one of the IOCCC judges:
|
||||
@@ -74,15 +74,15 @@ the [Collatz conjecture](https://en.wikipedia.org/wiki/Collatz_conjecture).
|
||||
You may explore this famous conjecture using this entry:
|
||||
|
||||
```sh
|
||||
./prog 2410
|
||||
./prog abfff
|
||||
./prog 27f8cebf
|
||||
./prog 246f8fddf
|
||||
./prog 2e95ab51ffea9de
|
||||
./prog e6a5c22fd7bde9f
|
||||
./prog 1b7dd73a937485bf
|
||||
./prog 7d3237680d190a77e53751b
|
||||
./prog 302ab3d052fb87c06228d249581be0e4
|
||||
./prog 2410
|
||||
./prog abfff
|
||||
./prog 27f8cebf
|
||||
./prog 246f8fddf
|
||||
./prog 2e95ab51ffea9de
|
||||
./prog e6a5c22fd7bde9f
|
||||
./prog 1b7dd73a937485bf
|
||||
./prog 7d3237680d190a77e53751b
|
||||
./prog 302ab3d052fb87c06228d249581be0e4
|
||||
```
|
||||
|
||||
NOTE: [try.sh](try.sh) runs these for you, filtered through `less(1)`.
|
||||
@@ -142,13 +142,13 @@ Interesting factoid: if you allow *negative* start values, there are
|
||||
a few more cycles, each of different length:
|
||||
|
||||
```
|
||||
−1, −2, −1
|
||||
−1, −2, −1
|
||||
|
||||
−5, −14, −7, −20, −10, −5
|
||||
−5, −14, −7, −20, −10, −5
|
||||
|
||||
−17, −50, −25, −74, −37, −110, −55, −164,
|
||||
−82, −41, −122, −61, −182, −91, −272, −136,
|
||||
−68, −34, −17
|
||||
−17, −50, −25, −74, −37, −110, −55, −164,
|
||||
−82, −41, −122, −61, −182, −91, −272, −136,
|
||||
−68, −34, −17
|
||||
```
|
||||
|
||||
|
||||
@@ -159,16 +159,16 @@ zero-padded hex and each iteration along with a line count in decimal.
|
||||
The example above looks like this (compiled with 64 bit word size):
|
||||
|
||||
```sh
|
||||
$ ./prog 6
|
||||
0000000000000006
|
||||
0000000000000003 1
|
||||
000000000000000A 2
|
||||
0000000000000005 3
|
||||
0000000000000010 4
|
||||
0000000000000008 5
|
||||
0000000000000004 6
|
||||
0000000000000002 7
|
||||
0000000000000001 8
|
||||
$ ./prog 6
|
||||
0000000000000006
|
||||
0000000000000003 1
|
||||
000000000000000A 2
|
||||
0000000000000005 3
|
||||
0000000000000010 4
|
||||
0000000000000008 5
|
||||
0000000000000004 6
|
||||
0000000000000002 7
|
||||
0000000000000001 8
|
||||
```
|
||||
|
||||
The size of `n` is only limited by the argument size limit of your
|
||||
@@ -176,8 +176,8 @@ shell/OS (the program implements arbitrary size `bignum`s).
|
||||
To query this on your POSIX system, run
|
||||
|
||||
```sh
|
||||
$ getconf ARG_MAX
|
||||
262144
|
||||
$ getconf ARG_MAX
|
||||
262144
|
||||
```
|
||||
|
||||
which reports the limit in bytes, here 256KB. This allows to test
|
||||
@@ -188,12 +188,12 @@ Fear not,
|
||||
to the rescue:
|
||||
|
||||
```sh
|
||||
$ printf 'obase=16;10^100\n' | bc
|
||||
1249AD2594C37CEB0B2784C4CE0BF38ACE408E211A7CAAB24308A82E8F1000000000\
|
||||
0000000000000000
|
||||
$ ./prog 1249AD2594C37CEB0B2784C4CE0BF38ACE408E211A7CAAB24308A82E8F10000000000000000000000000 \
|
||||
| less
|
||||
[...]
|
||||
$ printf 'obase=16;10^100\n' | bc
|
||||
1249AD2594C37CEB0B2784C4CE0BF38ACE408E211A7CAAB24308A82E8F1000000000\
|
||||
0000000000000000
|
||||
$ ./prog 1249AD2594C37CEB0B2784C4CE0BF38ACE408E211A7CAAB24308A82E8F10000000000000000000000000 \
|
||||
| less
|
||||
[...]
|
||||
```
|
||||
|
||||
Observe how the first 100 iterations melt the zeros to the right. Can you explain
|
||||
@@ -293,10 +293,10 @@ the rule "[No original
|
||||
research](https://en.wikipedia.org/wiki/Wikipedia:No_original_research)"):
|
||||
|
||||
```
|
||||
and Androgynine
|
||||
xor Xenoricine
|
||||
not Notanamine
|
||||
tla Triletramine
|
||||
and Androgynine
|
||||
xor Xenoricine
|
||||
not Notanamine
|
||||
tla Triletramine
|
||||
```
|
||||
|
||||
Interestingly, the TLI are the perfect mnemonics for C language source.
|
||||
@@ -334,24 +334,24 @@ Another identity operation. I've done it for you already. Use this
|
||||
`.indent.pro` with FreeBSD indent:
|
||||
|
||||
```sh
|
||||
$ cat .indent.pro
|
||||
-bad /* blank line after decls */
|
||||
-bap /* blank line after functions */
|
||||
-br /* braces on if line */
|
||||
-i8 /* indent */
|
||||
-l999 /* line length */
|
||||
-npcs /* no space after function call names */
|
||||
-npsl /* don't break procedure type */
|
||||
-ut /* use tabs */
|
||||
-ce /* cuddle else */
|
||||
-nip /* no parameter indentation */
|
||||
-di1 /* declaration indent */
|
||||
-Tand
|
||||
-Tmet
|
||||
-Tthr
|
||||
-Tpro
|
||||
-Tser
|
||||
-Tala
|
||||
$ cat .indent.pro
|
||||
-bad /* blank line after decls */
|
||||
-bap /* blank line after functions */
|
||||
-br /* braces on if line */
|
||||
-i8 /* indent */
|
||||
-l999 /* line length */
|
||||
-npcs /* no space after function call names */
|
||||
-npsl /* don't break procedure type */
|
||||
-ut /* use tabs */
|
||||
-ce /* cuddle else */
|
||||
-nip /* no parameter indentation */
|
||||
-di1 /* declaration indent */
|
||||
-Tand
|
||||
-Tmet
|
||||
-Tthr
|
||||
-Tpro
|
||||
-Tser
|
||||
-Tala
|
||||
```
|
||||
|
||||
It looks like a perfect program should have:
|
||||
@@ -384,31 +384,31 @@ Spoilers ahead. Duh!
|
||||
Pseudocode, with comments matching those in the C source:
|
||||
|
||||
```c
|
||||
/* run */
|
||||
if (non-NULL and nonempty argv[1]) {
|
||||
n = convert(argv[1])
|
||||
print n /* 2hx */
|
||||
while (n != 1) { /* one */
|
||||
if (n is odd) { /* odd */
|
||||
m = deep copy of n /* cpy */
|
||||
n <<= 1 /* shl */
|
||||
n += m /* add */
|
||||
increment n /* inc */
|
||||
} else { /* eve */
|
||||
n >>= 1 /* shr */
|
||||
/* run */
|
||||
if (non-NULL and nonempty argv[1]) {
|
||||
n = convert(argv[1])
|
||||
print n /* 2hx */
|
||||
while (n != 1) { /* one */
|
||||
if (n is odd) { /* odd */
|
||||
m = deep copy of n /* cpy */
|
||||
n <<= 1 /* shl */
|
||||
n += m /* add */
|
||||
increment n /* inc */
|
||||
} else { /* eve */
|
||||
n >>= 1 /* shr */
|
||||
}
|
||||
print n /* 2hx */
|
||||
}
|
||||
print n /* 2hx */
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`Bignum`s are represented as the two member `struct`s:
|
||||
|
||||
```c
|
||||
typedef struct {
|
||||
size_t places; /* number of places in base 2 to the power of (8*sizeof(type)) */
|
||||
type *number; /* dynamically allocated memory for number */
|
||||
} bignum
|
||||
typedef struct {
|
||||
size_t places; /* number of places in base 2 to the power of (8*sizeof(type)) */
|
||||
type *number; /* dynamically allocated memory for number */
|
||||
} bignum
|
||||
```
|
||||
|
||||
|
||||
@@ -439,9 +439,9 @@ crunching. Nothing stops you from executing
|
||||
|
||||
|
||||
```sh
|
||||
./prog "$(cat prog.c)" # Kind of quine?
|
||||
./prog "$(cat rules guidelines)" # A jackpot? Maybe next year...
|
||||
./prog "$(cat /bin/ls)" # Number cut short at first NUL byte.
|
||||
./prog "$(cat prog.c)" # Kind of quine?
|
||||
./prog "$(cat rules guidelines)" # A jackpot? Maybe next year...
|
||||
./prog "$(cat /bin/ls)" # Number cut short at first NUL byte.
|
||||
```
|
||||
|
||||
In a certain way, the program is character set and encoding agnostic.
|
||||
@@ -474,7 +474,7 @@ checks various problems with respect to style, performance, portability
|
||||
and general fishiness. To enable all checks, run
|
||||
|
||||
```sh
|
||||
cppcheck --enable=all --force -I/usr/include -Dtyp=uint32_t prog.c
|
||||
cppcheck --enable=all --force -I/usr/include -Dtyp=uint32_t prog.c
|
||||
```
|
||||
|
||||
No issues found.
|
||||
@@ -487,13 +487,13 @@ function arguments to known troublemaker functions and more. It doesn't need to
|
||||
pre-process code, so can be run without the `typ` macro being defined:
|
||||
|
||||
```sh
|
||||
$ flawfinder prog.c
|
||||
Flawfinder version 1.31, (C) 2001-2014 David A. Wheeler.
|
||||
Number of rules (primarily dangerous function names) in C/C++ ruleset: 169
|
||||
Examining prog.c
|
||||
FINAL RESULTS:
|
||||
ANALYSIS SUMMARY:
|
||||
No hits found.
|
||||
$ flawfinder prog.c
|
||||
Flawfinder version 1.31, (C) 2001-2014 David A. Wheeler.
|
||||
Number of rules (primarily dangerous function names) in C/C++ ruleset: 169
|
||||
Examining prog.c
|
||||
FINAL RESULTS:
|
||||
ANALYSIS SUMMARY:
|
||||
No hits found.
|
||||
```
|
||||
|
||||
#### valgrind
|
||||
@@ -505,31 +505,31 @@ execution paths, even when it must bail out, valgrind should be happy. An early
|
||||
version of my program however reported this:
|
||||
|
||||
```
|
||||
valgrind --leak-check=full --show-leak-kinds=all ./prog 6
|
||||
[...]
|
||||
==14615== HEAP SUMMARY:
|
||||
==14615== in use at exit: 4,096 bytes in 1 blocks
|
||||
==14615== total heap usage: 4 allocs, 3 frees, 4,108 bytes allocated
|
||||
==14615==
|
||||
==14615== 4,096 bytes in 1 blocks are still reachable in loss record 1 of 1
|
||||
==14615== at 0x4C236C0: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so)
|
||||
==14615== by 0x4F62175: ??? (in /lib/libc.so.7)
|
||||
==14615== by 0x4F62073: ??? (in /lib/libc.so.7)
|
||||
==14615== by 0x4F514EE: ??? (in /lib/libc.so.7)
|
||||
==14615== by 0x4F51265: vfprintf_l (in /lib/libc.so.7)
|
||||
==14615== by 0x4F3E001: printf (in /lib/libc.so.7)
|
||||
==14615== by 0x40101E: phe (in ./prog)
|
||||
==14615== by 0x400A9F: main (in ./prog)
|
||||
==14615==
|
||||
==14615== LEAK SUMMARY:
|
||||
==14615== definitely lost: 0 bytes in 0 blocks
|
||||
==14615== indirectly lost: 0 bytes in 0 blocks
|
||||
==14615== possibly lost: 0 bytes in 0 blocks
|
||||
==14615== still reachable: 4,096 bytes in 1 blocks
|
||||
==14615== suppressed: 0 bytes in 0 blocks
|
||||
==14615==
|
||||
==14615== For counts of detected and suppressed errors, rerun with: -v
|
||||
==14615== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
|
||||
valgrind --leak-check=full --show-leak-kinds=all ./prog 6
|
||||
[...]
|
||||
==14615== HEAP SUMMARY:
|
||||
==14615== in use at exit: 4,096 bytes in 1 blocks
|
||||
==14615== total heap usage: 4 allocs, 3 frees, 4,108 bytes allocated
|
||||
==14615==
|
||||
==14615== 4,096 bytes in 1 blocks are still reachable in loss record 1 of 1
|
||||
==14615== at 0x4C236C0: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so)
|
||||
==14615== by 0x4F62175: ??? (in /lib/libc.so.7)
|
||||
==14615== by 0x4F62073: ??? (in /lib/libc.so.7)
|
||||
==14615== by 0x4F514EE: ??? (in /lib/libc.so.7)
|
||||
==14615== by 0x4F51265: vfprintf_l (in /lib/libc.so.7)
|
||||
==14615== by 0x4F3E001: printf (in /lib/libc.so.7)
|
||||
==14615== by 0x40101E: phe (in ./prog)
|
||||
==14615== by 0x400A9F: main (in ./prog)
|
||||
==14615==
|
||||
==14615== LEAK SUMMARY:
|
||||
==14615== definitely lost: 0 bytes in 0 blocks
|
||||
==14615== indirectly lost: 0 bytes in 0 blocks
|
||||
==14615== possibly lost: 0 bytes in 0 blocks
|
||||
==14615== still reachable: 4,096 bytes in 1 blocks
|
||||
==14615== suppressed: 0 bytes in 0 blocks
|
||||
==14615==
|
||||
==14615== For counts of detected and suppressed errors, rerun with: -v
|
||||
==14615== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
|
||||
```
|
||||
|
||||
From which I concluded that `printf(3)` allocated a single 4K block for
|
||||
@@ -546,30 +546,30 @@ of C99 7.19.5.1, "The fclose function", was encouraging:
|
||||
So I `fclose(stdout)` before returning and now:
|
||||
|
||||
```
|
||||
valgrind --leak-check=full --show-leak-kinds=all ./prog 6
|
||||
==14571== Memcheck, a memory error detector
|
||||
==14571== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
|
||||
==14571== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
|
||||
==14571== Command: ./prog 6
|
||||
==14571==
|
||||
0000000000000006
|
||||
0000000000000003 1
|
||||
000000000000000A 2
|
||||
0000000000000005 3
|
||||
0000000000000010 4
|
||||
0000000000000008 5
|
||||
0000000000000004 6
|
||||
0000000000000002 7
|
||||
0000000000000001 8
|
||||
==14571==
|
||||
==14571== HEAP SUMMARY:
|
||||
==14571== in use at exit: 0 bytes in 0 blocks
|
||||
==14571== total heap usage: 4 allocs, 4 frees, 4,120 bytes allocated
|
||||
==14571==
|
||||
==14571== All heap blocks were freed -- no leaks are possible
|
||||
==14571==
|
||||
==14571== For counts of detected and suppressed errors, rerun with: -v
|
||||
==14571== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
|
||||
valgrind --leak-check=full --show-leak-kinds=all ./prog 6
|
||||
==14571== Memcheck, a memory error detector
|
||||
==14571== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
|
||||
==14571== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
|
||||
==14571== Command: ./prog 6
|
||||
==14571==
|
||||
0000000000000006
|
||||
0000000000000003 1
|
||||
000000000000000A 2
|
||||
0000000000000005 3
|
||||
0000000000000010 4
|
||||
0000000000000008 5
|
||||
0000000000000004 6
|
||||
0000000000000002 7
|
||||
0000000000000001 8
|
||||
==14571==
|
||||
==14571== HEAP SUMMARY:
|
||||
==14571== in use at exit: 0 bytes in 0 blocks
|
||||
==14571== total heap usage: 4 allocs, 4 frees, 4,120 bytes allocated
|
||||
==14571==
|
||||
==14571== All heap blocks were freed -- no leaks are possible
|
||||
==14571==
|
||||
==14571== For counts of detected and suppressed errors, rerun with: -v
|
||||
==14571== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
|
||||
```
|
||||
|
||||
A squeaky clean valgrind result!
|
||||
@@ -706,7 +706,7 @@ that printing digits with `'0' + digit` is not allowed (even though
|
||||
`'0'` is technically an `int`!) so I am forced to output hex digits with
|
||||
|
||||
```c
|
||||
printf("%c", (met)tyr + 32 + 16 + ((8 + EOF) * ((met)tyr / (8 + 2))));
|
||||
printf("%c", (met)tyr + 32 + 16 + ((8 + EOF) * ((met)tyr / (8 + 2))));
|
||||
```
|
||||
|
||||
because of the "no magic numbers other than powers of two" rule. How is this
|
||||
@@ -731,8 +731,8 @@ all expressions involving more than one operator, especially those for which
|
||||
a cast is required, leading to hard to understand expressions such as
|
||||
|
||||
```c
|
||||
const ser glx = (ser)((asx > (ser)64u) ? (ser)((ser)asx + (ser)8u + (ser)1u) : (ser)asx);
|
||||
not.not[leu] = (and)((and)not.not[leu] | (and)(((and)glx % (and)16u) << (and)lys));
|
||||
const ser glx = (ser)((asx > (ser)64u) ? (ser)((ser)asx + (ser)8u + (ser)1u) : (ser)asx);
|
||||
not.not[leu] = (and)((and)not.not[leu] | (and)(((and)glx % (and)16u) << (and)lys));
|
||||
```
|
||||
|
||||
MISRA 14.7: "A function shall have a single point of exit at the end of
|
||||
@@ -748,17 +748,17 @@ information shall be tested." A cast to `void` would draw a lint warning, so
|
||||
I use the `printf(3)` result in expressions,
|
||||
|
||||
```c
|
||||
lys -= 4 * printf("%c", (met)tyr + 32 + 16 + ((8 + EOF) * ((met)tyr / (8 + 2))));
|
||||
val += printf("\n") / ((__LINE__ * L_tmpnam) + TMP_MAX);
|
||||
val -= (printf(" %d\n", val) > BUFSIZ) ? FILENAME_MAX : EOF;
|
||||
lys -= 4 * printf("%c", (met)tyr + 32 + 16 + ((8 + EOF) * ((met)tyr / (8 + 2))));
|
||||
val += printf("\n") / ((__LINE__ * L_tmpnam) + TMP_MAX);
|
||||
val -= (printf(" %d\n", val) > BUFSIZ) ? FILENAME_MAX : EOF;
|
||||
```
|
||||
|
||||
which are, in the absence of errors, equivalent to
|
||||
|
||||
```c
|
||||
lys -= 4;
|
||||
/*nop*/
|
||||
++val;
|
||||
lys -= 4;
|
||||
/*nop*/
|
||||
++val;
|
||||
```
|
||||
|
||||
|
||||
@@ -773,9 +773,9 @@ addressed object." in conjunction with lint's "Note 952: Parameter could
|
||||
be declared `const`" causes `const`-poisoning for all functions,
|
||||
|
||||
```c
|
||||
static void phe(const ala not);
|
||||
static void gly(ala *const not, const and his);
|
||||
met main(met val, const pro *const his[]);
|
||||
static void phe(const ala not);
|
||||
static void gly(ala *const not, const and his);
|
||||
met main(met val, const pro *const his[]);
|
||||
```
|
||||
|
||||
and quite a number of automatic variables.
|
||||
@@ -793,17 +793,17 @@ If your compiler supports a 128 bit wide type (e.g. clang, gcc) then
|
||||
you can use it via the `typ` macro:
|
||||
|
||||
```sh
|
||||
clang -Dtyp=__uint128_t -o prog prog.c
|
||||
clang -Dtyp=__uint128_t -o prog prog.c
|
||||
```
|
||||
|
||||
Indeed, the program can use (and lints clean for) all of
|
||||
|
||||
```sh
|
||||
clang -Dtyp=uint8_t -o prog8 prog.c
|
||||
clang -Dtyp=uint16_t -o prog16 prog.c
|
||||
clang -Dtyp=uint32_t -o prog32 prog.c
|
||||
clang -Dtyp=uint64_t -o prog64 prog.c
|
||||
clang -std=c89 -Dtyp="unsigned long" -o prog89 prog.c
|
||||
clang -Dtyp=uint8_t -o prog8 prog.c
|
||||
clang -Dtyp=uint16_t -o prog16 prog.c
|
||||
clang -Dtyp=uint32_t -o prog32 prog.c
|
||||
clang -Dtyp=uint64_t -o prog64 prog.c
|
||||
clang -std=c89 -Dtyp="unsigned long" -o prog89 prog.c
|
||||
```
|
||||
|
||||
This works because the program has no need for corresponding `SCN` or `PRI`
|
||||
|
||||
+161
-162
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Jens_Schweikhardt">Jens Schweikhardt</a><br>
|
||||
Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germany</em> (<em>Germany</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germany</em> (<em>Germany</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,34 +141,34 @@ Location: <a href="../../location.html#DE">DE</a> - <em>Federal Republic of Germ
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">make</span></span></code></pre></div>
|
||||
<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#2015_schweikhardt">2015 schweikhardt bugs</a>.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> n</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">./prog</span> n</span></code></pre></div>
|
||||
<p>where n is a base 16 number of any size.</p>
|
||||
<p>NOTE: although it’s supposed to be a base 16 number nothing will stop you from
|
||||
doing something else. The author explains this in more details.</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>After running it once to see what commands are run, you might wish to run it a
|
||||
second time and just hold down space to see a fun scroll of numbers especially
|
||||
where zeroes move to the right.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>This code is clean. When you compile with all warnings enabled,
|
||||
such as with clang:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> <span class="at">-Weverything</span> <span class="at">-pedantic</span> <span class="at">-std</span><span class="op">=</span>c11 <span class="at">-Dtyp</span><span class="op">=</span>uint64<span class="dt">\_</span>t <span class="at">-O3</span> prog.c <span class="at">-o</span> prog</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">cc</span> <span class="at">-Weverything</span> <span class="at">-pedantic</span> <span class="at">-std</span><span class="op">=</span>c11 <span class="at">-Dtyp</span><span class="op">=</span>uint64<span class="dt">\_</span>t <span class="at">-O3</span> prog.c <span class="at">-o</span> prog</span></code></pre></div>
|
||||
<p>The code compiles without warnings on the systems that we tested!</p>
|
||||
<p>Even more, the code was 100% clean when we ran it against various
|
||||
static source checkers.</p>
|
||||
<p>This tool references a problem that <a href="http://members.tip.net.au/~dbell/">David I.
|
||||
Bell</a> once described
|
||||
as having one of the largest “yummo quotients” in number theory:</p>
|
||||
<pre><code> complexity of the solution
|
||||
yummo quotient = -----------------------------------
|
||||
complexity of the problem statement</code></pre>
|
||||
<pre><code> complexity of the solution
|
||||
yummo quotient = -----------------------------------
|
||||
complexity of the problem statement</code></pre>
|
||||
<p><a href="https://en.wikipedia.org/wiki/Paul_Erdős">Erdős</a> privately told one of the IOCCC judges:</p>
|
||||
<blockquote>
|
||||
<p>Solving the <a href="https://en.wikipedia.org/wiki/Generalized_Riemann_hypothesis#Extended_Riemann_hypothesis_.28ERH.29">Generalized Riemann
|
||||
@@ -178,15 +177,15 @@ would be a good warm-up exercise for someone to get ready to begin to work on
|
||||
the <a href="https://en.wikipedia.org/wiki/Collatz_conjecture">Collatz conjecture</a>.</p>
|
||||
</blockquote>
|
||||
<p>You may explore this famous conjecture using this entry:</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> 2410</span>
|
||||
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> abfff</span>
|
||||
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> 27f8cebf</span>
|
||||
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> 246f8fddf</span>
|
||||
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> 2e95ab51ffea9de</span>
|
||||
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> e6a5c22fd7bde9f</span>
|
||||
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> 1b7dd73a937485bf</span>
|
||||
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> 7d3237680d190a77e53751b</span>
|
||||
<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> 302ab3d052fb87c06228d249581be0e4</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> 2410</span>
|
||||
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> abfff</span>
|
||||
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> 27f8cebf</span>
|
||||
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> 246f8fddf</span>
|
||||
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> 2e95ab51ffea9de</span>
|
||||
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> e6a5c22fd7bde9f</span>
|
||||
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> 1b7dd73a937485bf</span>
|
||||
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> 7d3237680d190a77e53751b</span>
|
||||
<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> 302ab3d052fb87c06228d249581be0e4</span></code></pre></div>
|
||||
<p>NOTE: <a href="try.sh">try.sh</a> runs these for you, filtered through <code>less(1)</code>.</p>
|
||||
<p>When you first look at the source, the code looks fairly straightforward.
|
||||
But look again. Like the Collatz conjecture, simplicity is deceptive!
|
||||
@@ -227,45 +226,45 @@ you eventually reach <code>1</code>.</p>
|
||||
<p>Continuing past one leads to the <em>cycle</em> 1, 4, 2, 1, 4, 2, 1, …
|
||||
Interesting factoid: if you allow <em>negative</em> start values, there are
|
||||
a few more cycles, each of different length:</p>
|
||||
<pre><code>−1, −2, −1
|
||||
<pre><code> −1, −2, −1
|
||||
|
||||
−5, −14, −7, −20, −10, −5
|
||||
−5, −14, −7, −20, −10, −5
|
||||
|
||||
−17, −50, −25, −74, −37, −110, −55, −164,
|
||||
−82, −41, −122, −61, −182, −91, −272, −136,
|
||||
−68, −34, −17</code></pre>
|
||||
−17, −50, −25, −74, −37, −110, −55, −164,
|
||||
−82, −41, −122, −61, −182, −91, −272, −136,
|
||||
−68, −34, −17</code></pre>
|
||||
<p>The program computes the sequence for a given positive natural number
|
||||
and stops at <code>1</code>. The number <code>n</code> is specified in hexadecimal (without <code>0x</code>
|
||||
prefix) as the first argument. The program prints the given number in
|
||||
zero-padded hex and each iteration along with a line count in decimal.
|
||||
The example above looks like this (compiled with 64 bit word size):</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./prog 6</span>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a><span class="ex">0000000000000006</span></span>
|
||||
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="ex">0000000000000003</span> 1</span>
|
||||
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a><span class="ex">000000000000000A</span> 2</span>
|
||||
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a><span class="ex">0000000000000005</span> 3</span>
|
||||
<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a><span class="ex">0000000000000010</span> 4</span>
|
||||
<span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a><span class="ex">0000000000000008</span> 5</span>
|
||||
<span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a><span class="ex">0000000000000004</span> 6</span>
|
||||
<span id="cb9-9"><a href="#cb9-9" aria-hidden="true" tabindex="-1"></a><span class="ex">0000000000000002</span> 7</span>
|
||||
<span id="cb9-10"><a href="#cb9-10" aria-hidden="true" tabindex="-1"></a><span class="ex">0000000000000001</span> 8</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./prog 6</span>
|
||||
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">0000000000000006</span></span>
|
||||
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">0000000000000003</span> 1</span>
|
||||
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">000000000000000A</span> 2</span>
|
||||
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">0000000000000005</span> 3</span>
|
||||
<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">0000000000000010</span> 4</span>
|
||||
<span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">0000000000000008</span> 5</span>
|
||||
<span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">0000000000000004</span> 6</span>
|
||||
<span id="cb9-9"><a href="#cb9-9" aria-hidden="true" tabindex="-1"></a> <span class="ex">0000000000000002</span> 7</span>
|
||||
<span id="cb9-10"><a href="#cb9-10" aria-hidden="true" tabindex="-1"></a> <span class="ex">0000000000000001</span> 8</span></code></pre></div>
|
||||
<p>The size of <code>n</code> is only limited by the argument size limit of your
|
||||
shell/OS (the program implements arbitrary size <code>bignum</code>s).
|
||||
To query this on your POSIX system, run</p>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> getconf ARG_MAX</span>
|
||||
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="ex">262144</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> getconf ARG_MAX</span>
|
||||
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">262144</span></span></code></pre></div>
|
||||
<p>which reports the limit in bytes, here 256KB. This allows to test
|
||||
whether a <a href="https://en.wikipedia.org/wiki/Googol">Googol</a>, which is
|
||||
10<sup>100</sup>, satisfies the conjecture. But what is a googol in hex?
|
||||
Fear not,
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html">bc(1)</a>
|
||||
to the rescue:</p>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> printf <span class="st">'obase=16;10^100\n'</span> <span class="kw">|</span> <span class="fu">bc</span></span>
|
||||
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="ex">1249AD2594C37CEB0B2784C4CE0BF38ACE408E211A7CAAB24308A82E8F1000000000</span><span class="dt">\</span></span>
|
||||
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a><span class="ex">0000000000000000</span></span>
|
||||
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> ./prog 1249AD2594C37CEB0B2784C4CE0BF38ACE408E211A7CAAB24308A82E8F10000000000000000000000000 <span class="dt">\</span></span>
|
||||
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a><span class="kw">|</span> <span class="fu">less</span></span>
|
||||
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a><span class="ex">[...]</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> printf <span class="st">'obase=16;10^100\n'</span> <span class="kw">|</span> <span class="fu">bc</span></span>
|
||||
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">1249AD2594C37CEB0B2784C4CE0BF38ACE408E211A7CAAB24308A82E8F1000000000</span><span class="dt">\</span></span>
|
||||
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> 0000000000000000</span>
|
||||
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> ./prog 1249AD2594C37CEB0B2784C4CE0BF38ACE408E211A7CAAB24308A82E8F10000000000000000000000000 <span class="dt">\</span></span>
|
||||
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a> <span class="kw">|</span> <span class="fu">less</span></span>
|
||||
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">[...]</span></span></code></pre></div>
|
||||
<p>Observe how the first 100 iterations melt the zeros to the right. Can you explain
|
||||
why?</p>
|
||||
<p>For a given <code>n</code> the program behavior is one of the following 3:</p>
|
||||
@@ -350,10 +349,10 @@ acid</a>):</p>
|
||||
<p>My own research results complete this list (not yet in Wikipedia due to
|
||||
the rule “<a href="https://en.wikipedia.org/wiki/Wikipedia:No_original_research">No original
|
||||
research</a>”):</p>
|
||||
<pre><code>and Androgynine
|
||||
xor Xenoricine
|
||||
not Notanamine
|
||||
tla Triletramine</code></pre>
|
||||
<pre><code> and Androgynine
|
||||
xor Xenoricine
|
||||
not Notanamine
|
||||
tla Triletramine</code></pre>
|
||||
<p>Interestingly, the TLI are the perfect mnemonics for C language source.
|
||||
For example, <code>met</code> is “<code>main()'s Exit Type</code>” (<code>int</code>), <code>ala</code> is “<code>A Large Algebraic</code>” (<code>bignum</code>), <code>ile</code> an “<code>Incremented Local Entity</code>” (index
|
||||
counter), <code>gly</code> means “<code>Grow Larger memorY</code>”, <code>gln</code> is “<code>Grown Larger Now</code>”
|
||||
@@ -374,24 +373,24 @@ hard, I could use <code>__LINE__</code> and <code>stdio.h</code> macros <code>EO
|
||||
<h3 id="run-it-through-a-c-beautifier">Run it through a C beautifier</h3>
|
||||
<p>Another identity operation. I’ve done it for you already. Use this
|
||||
<code>.indent.pro</code> with FreeBSD indent:</p>
|
||||
<div class="sourceCode" id="cb14"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> cat .indent.pro</span>
|
||||
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">-bad</span> /<span class="pp">*</span> blank line after decls <span class="pp">*</span>/</span>
|
||||
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">-bap</span> /<span class="pp">*</span> blank line after functions <span class="pp">*</span>/</span>
|
||||
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">-br</span> /<span class="pp">*</span> braces on if line <span class="pp">*</span>/</span>
|
||||
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">-i8</span> /<span class="pp">*</span> indent <span class="pp">*</span>/</span>
|
||||
<span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">-l999</span> /<span class="pp">*</span> line length <span class="pp">*</span>/</span>
|
||||
<span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">-npcs</span> /<span class="pp">*</span> no space after function call names <span class="pp">*</span>/</span>
|
||||
<span id="cb14-8"><a href="#cb14-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">-npsl</span> /<span class="pp">*</span> don<span class="st">'t break procedure type */</span></span>
|
||||
<span id="cb14-9"><a href="#cb14-9" aria-hidden="true" tabindex="-1"></a><span class="st"> -ut /* use tabs */</span></span>
|
||||
<span id="cb14-10"><a href="#cb14-10" aria-hidden="true" tabindex="-1"></a><span class="st"> -ce /* cuddle else */</span></span>
|
||||
<span id="cb14-11"><a href="#cb14-11" aria-hidden="true" tabindex="-1"></a><span class="st"> -nip /* no parameter indentation */</span></span>
|
||||
<span id="cb14-12"><a href="#cb14-12" aria-hidden="true" tabindex="-1"></a><span class="st"> -di1 /* declaration indent */</span></span>
|
||||
<span id="cb14-13"><a href="#cb14-13" aria-hidden="true" tabindex="-1"></a><span class="st"> -Tand</span></span>
|
||||
<span id="cb14-14"><a href="#cb14-14" aria-hidden="true" tabindex="-1"></a><span class="st"> -Tmet</span></span>
|
||||
<span id="cb14-15"><a href="#cb14-15" aria-hidden="true" tabindex="-1"></a><span class="st"> -Tthr</span></span>
|
||||
<span id="cb14-16"><a href="#cb14-16" aria-hidden="true" tabindex="-1"></a><span class="st"> -Tpro</span></span>
|
||||
<span id="cb14-17"><a href="#cb14-17" aria-hidden="true" tabindex="-1"></a><span class="st"> -Tser</span></span>
|
||||
<span id="cb14-18"><a href="#cb14-18" aria-hidden="true" tabindex="-1"></a><span class="st"> -Tala</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb14"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> cat .indent.pro</span>
|
||||
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">-bad</span> /<span class="pp">*</span> blank line after decls <span class="pp">*</span>/</span>
|
||||
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">-bap</span> /<span class="pp">*</span> blank line after functions <span class="pp">*</span>/</span>
|
||||
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">-br</span> /<span class="pp">*</span> braces on if line <span class="pp">*</span>/</span>
|
||||
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">-i8</span> /<span class="pp">*</span> indent <span class="pp">*</span>/</span>
|
||||
<span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">-l999</span> /<span class="pp">*</span> line length <span class="pp">*</span>/</span>
|
||||
<span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">-npcs</span> /<span class="pp">*</span> no space after function call names <span class="pp">*</span>/</span>
|
||||
<span id="cb14-8"><a href="#cb14-8" aria-hidden="true" tabindex="-1"></a> <span class="ex">-npsl</span> /<span class="pp">*</span> don<span class="st">'t break procedure type */</span></span>
|
||||
<span id="cb14-9"><a href="#cb14-9" aria-hidden="true" tabindex="-1"></a><span class="st"> -ut /* use tabs */</span></span>
|
||||
<span id="cb14-10"><a href="#cb14-10" aria-hidden="true" tabindex="-1"></a><span class="st"> -ce /* cuddle else */</span></span>
|
||||
<span id="cb14-11"><a href="#cb14-11" aria-hidden="true" tabindex="-1"></a><span class="st"> -nip /* no parameter indentation */</span></span>
|
||||
<span id="cb14-12"><a href="#cb14-12" aria-hidden="true" tabindex="-1"></a><span class="st"> -di1 /* declaration indent */</span></span>
|
||||
<span id="cb14-13"><a href="#cb14-13" aria-hidden="true" tabindex="-1"></a><span class="st"> -Tand</span></span>
|
||||
<span id="cb14-14"><a href="#cb14-14" aria-hidden="true" tabindex="-1"></a><span class="st"> -Tmet</span></span>
|
||||
<span id="cb14-15"><a href="#cb14-15" aria-hidden="true" tabindex="-1"></a><span class="st"> -Tthr</span></span>
|
||||
<span id="cb14-16"><a href="#cb14-16" aria-hidden="true" tabindex="-1"></a><span class="st"> -Tpro</span></span>
|
||||
<span id="cb14-17"><a href="#cb14-17" aria-hidden="true" tabindex="-1"></a><span class="st"> -Tser</span></span>
|
||||
<span id="cb14-18"><a href="#cb14-18" aria-hidden="true" tabindex="-1"></a><span class="st"> -Tala</span></span></code></pre></div>
|
||||
<p>It looks like a perfect program should have:</p>
|
||||
<ul>
|
||||
<li>two and a half <code>#include</code>s of non-suspicious standard headers</li>
|
||||
@@ -416,27 +415,27 @@ to be.</p>
|
||||
<h3 id="examine-the-algorithm">Examine the algorithm</h3>
|
||||
<p>Spoilers ahead. Duh!</p>
|
||||
<p>Pseudocode, with comments matching those in the C source:</p>
|
||||
<div class="sourceCode" id="cb15"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="co">/* run */</span></span>
|
||||
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> <span class="op">(</span>non<span class="op">-</span>NULL and nonempty argv<span class="op">[</span><span class="dv">1</span><span class="op">])</span> <span class="op">{</span></span>
|
||||
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a> n <span class="op">=</span> convert<span class="op">(</span>argv<span class="op">[</span><span class="dv">1</span><span class="op">])</span></span>
|
||||
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a> print n <span class="co">/* 2hx */</span></span>
|
||||
<span id="cb15-5"><a href="#cb15-5" aria-hidden="true" tabindex="-1"></a> <span class="cf">while</span> <span class="op">(</span>n <span class="op">!=</span> <span class="dv">1</span><span class="op">)</span> <span class="op">{</span> <span class="co">/* one */</span></span>
|
||||
<span id="cb15-6"><a href="#cb15-6" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>n is odd<span class="op">)</span> <span class="op">{</span> <span class="co">/* odd */</span></span>
|
||||
<span id="cb15-7"><a href="#cb15-7" aria-hidden="true" tabindex="-1"></a> m <span class="op">=</span> deep copy of n <span class="co">/* cpy */</span></span>
|
||||
<span id="cb15-8"><a href="#cb15-8" aria-hidden="true" tabindex="-1"></a> n <span class="op"><<=</span> <span class="dv">1</span> <span class="co">/* shl */</span></span>
|
||||
<span id="cb15-9"><a href="#cb15-9" aria-hidden="true" tabindex="-1"></a> n <span class="op">+=</span> m <span class="co">/* add */</span></span>
|
||||
<span id="cb15-10"><a href="#cb15-10" aria-hidden="true" tabindex="-1"></a> increment n <span class="co">/* inc */</span></span>
|
||||
<span id="cb15-11"><a href="#cb15-11" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span> <span class="cf">else</span> <span class="op">{</span> <span class="co">/* eve */</span></span>
|
||||
<span id="cb15-12"><a href="#cb15-12" aria-hidden="true" tabindex="-1"></a> n <span class="op">>>=</span> <span class="dv">1</span> <span class="co">/* shr */</span></span>
|
||||
<span id="cb15-13"><a href="#cb15-13" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
|
||||
<span id="cb15-14"><a href="#cb15-14" aria-hidden="true" tabindex="-1"></a> print n <span class="co">/* 2hx */</span></span>
|
||||
<span id="cb15-15"><a href="#cb15-15" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
|
||||
<span id="cb15-16"><a href="#cb15-16" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb15"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a> <span class="co">/* run */</span></span>
|
||||
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>non<span class="op">-</span>NULL and nonempty argv<span class="op">[</span><span class="dv">1</span><span class="op">])</span> <span class="op">{</span></span>
|
||||
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a> n <span class="op">=</span> convert<span class="op">(</span>argv<span class="op">[</span><span class="dv">1</span><span class="op">])</span></span>
|
||||
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a> print n <span class="co">/* 2hx */</span></span>
|
||||
<span id="cb15-5"><a href="#cb15-5" aria-hidden="true" tabindex="-1"></a> <span class="cf">while</span> <span class="op">(</span>n <span class="op">!=</span> <span class="dv">1</span><span class="op">)</span> <span class="op">{</span> <span class="co">/* one */</span></span>
|
||||
<span id="cb15-6"><a href="#cb15-6" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> <span class="op">(</span>n is odd<span class="op">)</span> <span class="op">{</span> <span class="co">/* odd */</span></span>
|
||||
<span id="cb15-7"><a href="#cb15-7" aria-hidden="true" tabindex="-1"></a> m <span class="op">=</span> deep copy of n <span class="co">/* cpy */</span></span>
|
||||
<span id="cb15-8"><a href="#cb15-8" aria-hidden="true" tabindex="-1"></a> n <span class="op"><<=</span> <span class="dv">1</span> <span class="co">/* shl */</span></span>
|
||||
<span id="cb15-9"><a href="#cb15-9" aria-hidden="true" tabindex="-1"></a> n <span class="op">+=</span> m <span class="co">/* add */</span></span>
|
||||
<span id="cb15-10"><a href="#cb15-10" aria-hidden="true" tabindex="-1"></a> increment n <span class="co">/* inc */</span></span>
|
||||
<span id="cb15-11"><a href="#cb15-11" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span> <span class="cf">else</span> <span class="op">{</span> <span class="co">/* eve */</span></span>
|
||||
<span id="cb15-12"><a href="#cb15-12" aria-hidden="true" tabindex="-1"></a> n <span class="op">>>=</span> <span class="dv">1</span> <span class="co">/* shr */</span></span>
|
||||
<span id="cb15-13"><a href="#cb15-13" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
|
||||
<span id="cb15-14"><a href="#cb15-14" aria-hidden="true" tabindex="-1"></a> print n <span class="co">/* 2hx */</span></span>
|
||||
<span id="cb15-15"><a href="#cb15-15" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span>
|
||||
<span id="cb15-16"><a href="#cb15-16" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span></span></code></pre></div>
|
||||
<p><code>Bignum</code>s are represented as the two member <code>struct</code>s:</p>
|
||||
<div class="sourceCode" id="cb16"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="kw">typedef</span> <span class="kw">struct</span> <span class="op">{</span></span>
|
||||
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a> <span class="dt">size_t</span> places<span class="op">;</span> <span class="co">/* number of places in base 2 to the power of (8*sizeof(type)) */</span></span>
|
||||
<span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a> type <span class="op">*</span>number<span class="op">;</span> <span class="co">/* dynamically allocated memory for number */</span></span>
|
||||
<span id="cb16-4"><a href="#cb16-4" aria-hidden="true" tabindex="-1"></a><span class="op">}</span> bignum</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb16"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a> <span class="kw">typedef</span> <span class="kw">struct</span> <span class="op">{</span></span>
|
||||
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a> <span class="dt">size_t</span> places<span class="op">;</span> <span class="co">/* number of places in base 2 to the power of (8*sizeof(type)) */</span></span>
|
||||
<span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a> type <span class="op">*</span>number<span class="op">;</span> <span class="co">/* dynamically allocated memory for number */</span></span>
|
||||
<span id="cb16-4"><a href="#cb16-4" aria-hidden="true" tabindex="-1"></a> <span class="op">}</span> bignum</span></code></pre></div>
|
||||
<h3 id="compile-it-with-flags-to-enable-all-warnings">Compile it (with flags to enable all warnings)</h3>
|
||||
<p>Here’s where the program shines brighter than a <a href="https://en.wikipedia.org/wiki/Gamma-ray_burst">gamma-ray
|
||||
burst</a>!</p>
|
||||
@@ -453,9 +452,9 @@ expected.</p>
|
||||
<p>This means however, that the program accepts <strong>any string</strong>, turns it
|
||||
into a starting number (which is output as the first line), and starts
|
||||
crunching. Nothing stops you from executing</p>
|
||||
<div class="sourceCode" id="cb17"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> <span class="st">"</span><span class="va">$(</span><span class="fu">cat</span> prog.c<span class="va">)</span><span class="st">"</span> <span class="co"># Kind of quine?</span></span>
|
||||
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> <span class="st">"</span><span class="va">$(</span><span class="fu">cat</span> rules guidelines<span class="va">)</span><span class="st">"</span> <span class="co"># A jackpot? Maybe next year...</span></span>
|
||||
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./prog</span> <span class="st">"</span><span class="va">$(</span><span class="fu">cat</span> /bin/ls<span class="va">)</span><span class="st">"</span> <span class="co"># Number cut short at first NUL byte.</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb17"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> <span class="st">"</span><span class="va">$(</span><span class="fu">cat</span> prog.c<span class="va">)</span><span class="st">"</span> <span class="co"># Kind of quine?</span></span>
|
||||
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> <span class="st">"</span><span class="va">$(</span><span class="fu">cat</span> rules guidelines<span class="va">)</span><span class="st">"</span> <span class="co"># A jackpot? Maybe next year...</span></span>
|
||||
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">./prog</span> <span class="st">"</span><span class="va">$(</span><span class="fu">cat</span> /bin/ls<span class="va">)</span><span class="st">"</span> <span class="co"># Number cut short at first NUL byte.</span></span></code></pre></div>
|
||||
<p>In a certain way, the program is character set and encoding agnostic.</p>
|
||||
<h3 id="assumptions-made">Assumptions made</h3>
|
||||
<ul>
|
||||
@@ -476,51 +475,51 @@ use <code>8 * sizeof(typ)</code> bits per place. It does not work when <code>CHA
|
||||
<p>The open source static checker <a href="http://cppcheck.sourceforge.net/">cppcheck</a>
|
||||
checks various problems with respect to style, performance, portability
|
||||
and general fishiness. To enable all checks, run</p>
|
||||
<div class="sourceCode" id="cb18"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="ex">cppcheck</span> <span class="at">--enable</span><span class="op">=</span>all <span class="at">--force</span> <span class="at">-I</span>/usr/include <span class="at">-Dtyp</span><span class="op">=</span>uint32_t prog.c</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb18"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">cppcheck</span> <span class="at">--enable</span><span class="op">=</span>all <span class="at">--force</span> <span class="at">-I</span>/usr/include <span class="at">-Dtyp</span><span class="op">=</span>uint32_t prog.c</span></code></pre></div>
|
||||
<p>No issues found.</p>
|
||||
<h3 id="flawfinder">flawfinder</h3>
|
||||
<p>The open source static checker <a href="http://www.dwheeler.com/flawfinder/">flawfinder</a>
|
||||
checks various problems with respect to security like buffer overflows,
|
||||
function arguments to known troublemaker functions and more. It doesn’t need to
|
||||
pre-process code, so can be run without the <code>typ</code> macro being defined:</p>
|
||||
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> flawfinder prog.c</span>
|
||||
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Flawfinder</span> version 1.31, <span class="er">(</span><span class="ex">C</span><span class="kw">)</span> <span class="ex">2001-2014</span> David A. Wheeler.</span>
|
||||
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a><span class="ex">Number</span> of rules <span class="er">(</span><span class="ex">primarily</span> dangerous function names<span class="kw">)</span> <span class="er">in</span> <span class="ex">C/C++</span> ruleset: 169</span>
|
||||
<span id="cb19-4"><a href="#cb19-4" aria-hidden="true" tabindex="-1"></a><span class="ex">Examining</span> prog.c</span>
|
||||
<span id="cb19-5"><a href="#cb19-5" aria-hidden="true" tabindex="-1"></a><span class="ex">FINAL</span> RESULTS:</span>
|
||||
<span id="cb19-6"><a href="#cb19-6" aria-hidden="true" tabindex="-1"></a><span class="ex">ANALYSIS</span> SUMMARY:</span>
|
||||
<span id="cb19-7"><a href="#cb19-7" aria-hidden="true" tabindex="-1"></a><span class="ex">No</span> hits found.</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb19"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">$</span> flawfinder prog.c</span>
|
||||
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">Flawfinder</span> version 1.31, <span class="er">(</span><span class="ex">C</span><span class="kw">)</span> <span class="ex">2001-2014</span> David A. Wheeler.</span>
|
||||
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a> <span class="ex">Number</span> of rules <span class="er">(</span><span class="ex">primarily</span> dangerous function names<span class="kw">)</span> <span class="er">in</span> <span class="ex">C/C++</span> ruleset: 169</span>
|
||||
<span id="cb19-4"><a href="#cb19-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">Examining</span> prog.c</span>
|
||||
<span id="cb19-5"><a href="#cb19-5" aria-hidden="true" tabindex="-1"></a> <span class="ex">FINAL</span> RESULTS:</span>
|
||||
<span id="cb19-6"><a href="#cb19-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">ANALYSIS</span> SUMMARY:</span>
|
||||
<span id="cb19-7"><a href="#cb19-7" aria-hidden="true" tabindex="-1"></a> <span class="ex">No</span> hits found.</span></code></pre></div>
|
||||
<h4 id="valgrind">valgrind</h4>
|
||||
<p>The open source dynamic checker <a href="http://valgrind.org/">valgrind</a> runs an
|
||||
executable and verifies all memory accesses and (de)allocations for proper
|
||||
bounds and memory leaks. Since the program frees all memory in all possible
|
||||
execution paths, even when it must bail out, valgrind should be happy. An early
|
||||
version of my program however reported this:</p>
|
||||
<pre><code>valgrind --leak-check=full --show-leak-kinds=all ./prog 6
|
||||
[...]
|
||||
==14615== HEAP SUMMARY:
|
||||
==14615== in use at exit: 4,096 bytes in 1 blocks
|
||||
==14615== total heap usage: 4 allocs, 3 frees, 4,108 bytes allocated
|
||||
==14615==
|
||||
==14615== 4,096 bytes in 1 blocks are still reachable in loss record 1 of 1
|
||||
==14615== at 0x4C236C0: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so)
|
||||
==14615== by 0x4F62175: ??? (in /lib/libc.so.7)
|
||||
==14615== by 0x4F62073: ??? (in /lib/libc.so.7)
|
||||
==14615== by 0x4F514EE: ??? (in /lib/libc.so.7)
|
||||
==14615== by 0x4F51265: vfprintf_l (in /lib/libc.so.7)
|
||||
==14615== by 0x4F3E001: printf (in /lib/libc.so.7)
|
||||
==14615== by 0x40101E: phe (in ./prog)
|
||||
==14615== by 0x400A9F: main (in ./prog)
|
||||
==14615==
|
||||
==14615== LEAK SUMMARY:
|
||||
==14615== definitely lost: 0 bytes in 0 blocks
|
||||
==14615== indirectly lost: 0 bytes in 0 blocks
|
||||
==14615== possibly lost: 0 bytes in 0 blocks
|
||||
==14615== still reachable: 4,096 bytes in 1 blocks
|
||||
==14615== suppressed: 0 bytes in 0 blocks
|
||||
==14615==
|
||||
==14615== For counts of detected and suppressed errors, rerun with: -v
|
||||
==14615== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)</code></pre>
|
||||
<pre><code> valgrind --leak-check=full --show-leak-kinds=all ./prog 6
|
||||
[...]
|
||||
==14615== HEAP SUMMARY:
|
||||
==14615== in use at exit: 4,096 bytes in 1 blocks
|
||||
==14615== total heap usage: 4 allocs, 3 frees, 4,108 bytes allocated
|
||||
==14615==
|
||||
==14615== 4,096 bytes in 1 blocks are still reachable in loss record 1 of 1
|
||||
==14615== at 0x4C236C0: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so)
|
||||
==14615== by 0x4F62175: ??? (in /lib/libc.so.7)
|
||||
==14615== by 0x4F62073: ??? (in /lib/libc.so.7)
|
||||
==14615== by 0x4F514EE: ??? (in /lib/libc.so.7)
|
||||
==14615== by 0x4F51265: vfprintf_l (in /lib/libc.so.7)
|
||||
==14615== by 0x4F3E001: printf (in /lib/libc.so.7)
|
||||
==14615== by 0x40101E: phe (in ./prog)
|
||||
==14615== by 0x400A9F: main (in ./prog)
|
||||
==14615==
|
||||
==14615== LEAK SUMMARY:
|
||||
==14615== definitely lost: 0 bytes in 0 blocks
|
||||
==14615== indirectly lost: 0 bytes in 0 blocks
|
||||
==14615== possibly lost: 0 bytes in 0 blocks
|
||||
==14615== still reachable: 4,096 bytes in 1 blocks
|
||||
==14615== suppressed: 0 bytes in 0 blocks
|
||||
==14615==
|
||||
==14615== For counts of detected and suppressed errors, rerun with: -v
|
||||
==14615== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)</code></pre>
|
||||
<p>From which I concluded that <code>printf(3)</code> allocated a single 4K block for
|
||||
which no matching <code>free(3)</code> existed. But how to free memory allocated deep
|
||||
down in the guts of the Standard I/O library? After some serious head
|
||||
@@ -533,30 +532,30 @@ and any buffer set by the <code>setbuf</code> or <code>setvbuf</code> function i
|
||||
(and deallocated if it was automatically allocated).</p>
|
||||
</blockquote>
|
||||
<p>So I <code>fclose(stdout)</code> before returning and now:</p>
|
||||
<pre><code>valgrind --leak-check=full --show-leak-kinds=all ./prog 6
|
||||
==14571== Memcheck, a memory error detector
|
||||
==14571== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
|
||||
==14571== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
|
||||
==14571== Command: ./prog 6
|
||||
==14571==
|
||||
0000000000000006
|
||||
0000000000000003 1
|
||||
000000000000000A 2
|
||||
0000000000000005 3
|
||||
0000000000000010 4
|
||||
0000000000000008 5
|
||||
0000000000000004 6
|
||||
0000000000000002 7
|
||||
0000000000000001 8
|
||||
==14571==
|
||||
==14571== HEAP SUMMARY:
|
||||
==14571== in use at exit: 0 bytes in 0 blocks
|
||||
==14571== total heap usage: 4 allocs, 4 frees, 4,120 bytes allocated
|
||||
==14571==
|
||||
==14571== All heap blocks were freed -- no leaks are possible
|
||||
==14571==
|
||||
==14571== For counts of detected and suppressed errors, rerun with: -v
|
||||
==14571== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)</code></pre>
|
||||
<pre><code> valgrind --leak-check=full --show-leak-kinds=all ./prog 6
|
||||
==14571== Memcheck, a memory error detector
|
||||
==14571== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
|
||||
==14571== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
|
||||
==14571== Command: ./prog 6
|
||||
==14571==
|
||||
0000000000000006
|
||||
0000000000000003 1
|
||||
000000000000000A 2
|
||||
0000000000000005 3
|
||||
0000000000000010 4
|
||||
0000000000000008 5
|
||||
0000000000000004 6
|
||||
0000000000000002 7
|
||||
0000000000000001 8
|
||||
==14571==
|
||||
==14571== HEAP SUMMARY:
|
||||
==14571== in use at exit: 0 bytes in 0 blocks
|
||||
==14571== total heap usage: 4 allocs, 4 frees, 4,120 bytes allocated
|
||||
==14571==
|
||||
==14571== All heap blocks were freed -- no leaks are possible
|
||||
==14571==
|
||||
==14571== For counts of detected and suppressed errors, rerun with: -v
|
||||
==14571== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)</code></pre>
|
||||
<p>A squeaky clean valgrind result!</p>
|
||||
<h4 id="flexelint">FlexeLint</h4>
|
||||
<p>FlexeLint is a commercial lint tool by <a href="http://www.gimpel.com/html/index.htm">Gimpel
|
||||
@@ -676,7 +675,7 @@ use of character values.” This forbids using character constants in
|
||||
expressions other than assignments to <code>char</code> objects. A consequence is
|
||||
that printing digits with <code>'0' + digit</code> is not allowed (even though
|
||||
<code>'0'</code> is technically an <code>int</code>!) so I am forced to output hex digits with</p>
|
||||
<div class="sourceCode" id="cb24"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a>printf<span class="op">(</span><span class="st">"</span><span class="sc">%c</span><span class="st">"</span><span class="op">,</span> <span class="op">(</span>met<span class="op">)</span>tyr <span class="op">+</span> <span class="dv">32</span> <span class="op">+</span> <span class="dv">16</span> <span class="op">+</span> <span class="op">((</span><span class="dv">8</span> <span class="op">+</span> EOF<span class="op">)</span> <span class="op">*</span> <span class="op">((</span>met<span class="op">)</span>tyr <span class="op">/</span> <span class="op">(</span><span class="dv">8</span> <span class="op">+</span> <span class="dv">2</span><span class="op">))));</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb24"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a> printf<span class="op">(</span><span class="st">"</span><span class="sc">%c</span><span class="st">"</span><span class="op">,</span> <span class="op">(</span>met<span class="op">)</span>tyr <span class="op">+</span> <span class="dv">32</span> <span class="op">+</span> <span class="dv">16</span> <span class="op">+</span> <span class="op">((</span><span class="dv">8</span> <span class="op">+</span> EOF<span class="op">)</span> <span class="op">*</span> <span class="op">((</span>met<span class="op">)</span>tyr <span class="op">/</span> <span class="op">(</span><span class="dv">8</span> <span class="op">+</span> <span class="dv">2</span><span class="op">))));</span></span></code></pre></div>
|
||||
<p>because of the “no magic numbers other than powers of two” rule. How is this
|
||||
an improvement over <code>printf("%c", '0' + tyr + 7 * (tyr / 10)</code>, MISRA?</p>
|
||||
<p>MISRA 6.3: “<code>typedef</code>s that indicate size and signedness should be used in
|
||||
@@ -692,8 +691,8 @@ redundant casting ensues. It gets worse with the next rule…</p>
|
||||
precedence rules in expressions.” This requires parentheses for almost
|
||||
all expressions involving more than one operator, especially those for which
|
||||
a cast is required, leading to hard to understand expressions such as</p>
|
||||
<div class="sourceCode" id="cb25"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a><span class="dt">const</span> ser glx <span class="op">=</span> <span class="op">(</span>ser<span class="op">)((</span>asx <span class="op">></span> <span class="op">(</span>ser<span class="op">)</span><span class="dv">64</span><span class="bu">u</span><span class="op">)</span> <span class="op">?</span> <span class="op">(</span>ser<span class="op">)((</span>ser<span class="op">)</span>asx <span class="op">+</span> <span class="op">(</span>ser<span class="op">)</span><span class="dv">8</span><span class="bu">u</span> <span class="op">+</span> <span class="op">(</span>ser<span class="op">)</span><span class="dv">1</span><span class="bu">u</span><span class="op">)</span> <span class="op">:</span> <span class="op">(</span>ser<span class="op">)</span>asx<span class="op">);</span></span>
|
||||
<span id="cb25-2"><a href="#cb25-2" aria-hidden="true" tabindex="-1"></a>not<span class="op">.</span>not<span class="op">[</span>leu<span class="op">]</span> <span class="op">=</span> <span class="op">(</span>and<span class="op">)((</span>and<span class="op">)</span>not<span class="op">.</span>not<span class="op">[</span>leu<span class="op">]</span> <span class="op">|</span> <span class="op">(</span>and<span class="op">)(((</span>and<span class="op">)</span>glx <span class="op">%</span> <span class="op">(</span>and<span class="op">)</span><span class="dv">16</span><span class="bu">u</span><span class="op">)</span> <span class="op"><<</span> <span class="op">(</span>and<span class="op">)</span>lys<span class="op">));</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb25"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a> <span class="dt">const</span> ser glx <span class="op">=</span> <span class="op">(</span>ser<span class="op">)((</span>asx <span class="op">></span> <span class="op">(</span>ser<span class="op">)</span><span class="dv">64</span><span class="bu">u</span><span class="op">)</span> <span class="op">?</span> <span class="op">(</span>ser<span class="op">)((</span>ser<span class="op">)</span>asx <span class="op">+</span> <span class="op">(</span>ser<span class="op">)</span><span class="dv">8</span><span class="bu">u</span> <span class="op">+</span> <span class="op">(</span>ser<span class="op">)</span><span class="dv">1</span><span class="bu">u</span><span class="op">)</span> <span class="op">:</span> <span class="op">(</span>ser<span class="op">)</span>asx<span class="op">);</span></span>
|
||||
<span id="cb25-2"><a href="#cb25-2" aria-hidden="true" tabindex="-1"></a> not<span class="op">.</span>not<span class="op">[</span>leu<span class="op">]</span> <span class="op">=</span> <span class="op">(</span>and<span class="op">)((</span>and<span class="op">)</span>not<span class="op">.</span>not<span class="op">[</span>leu<span class="op">]</span> <span class="op">|</span> <span class="op">(</span>and<span class="op">)(((</span>and<span class="op">)</span>glx <span class="op">%</span> <span class="op">(</span>and<span class="op">)</span><span class="dv">16</span><span class="bu">u</span><span class="op">)</span> <span class="op"><<</span> <span class="op">(</span>and<span class="op">)</span>lys<span class="op">));</span></span></code></pre></div>
|
||||
<p>MISRA 14.7: “A function shall have a single point of exit at the end of
|
||||
the function.” Sigh. Since I must use eloquent prototypes (8.1, 16.3,
|
||||
16.4) and static functions (8.10, 8.11), I can only use a few functions.
|
||||
@@ -704,22 +703,22 @@ too high for a sane function.</p>
|
||||
<p>MISRA 16.10: “If a function returns error information, then that error
|
||||
information shall be tested.” A cast to <code>void</code> would draw a lint warning, so
|
||||
I use the <code>printf(3)</code> result in expressions,</p>
|
||||
<div class="sourceCode" id="cb26"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a>lys <span class="op">-=</span> <span class="dv">4</span> <span class="op">*</span> printf<span class="op">(</span><span class="st">"</span><span class="sc">%c</span><span class="st">"</span><span class="op">,</span> <span class="op">(</span>met<span class="op">)</span>tyr <span class="op">+</span> <span class="dv">32</span> <span class="op">+</span> <span class="dv">16</span> <span class="op">+</span> <span class="op">((</span><span class="dv">8</span> <span class="op">+</span> EOF<span class="op">)</span> <span class="op">*</span> <span class="op">((</span>met<span class="op">)</span>tyr <span class="op">/</span> <span class="op">(</span><span class="dv">8</span> <span class="op">+</span> <span class="dv">2</span><span class="op">))));</span></span>
|
||||
<span id="cb26-2"><a href="#cb26-2" aria-hidden="true" tabindex="-1"></a>val <span class="op">+=</span> printf<span class="op">(</span><span class="st">"</span><span class="sc">\n</span><span class="st">"</span><span class="op">)</span> <span class="op">/</span> <span class="op">((</span>__LINE__ <span class="op">*</span> L_tmpnam<span class="op">)</span> <span class="op">+</span> TMP_MAX<span class="op">);</span></span>
|
||||
<span id="cb26-3"><a href="#cb26-3" aria-hidden="true" tabindex="-1"></a>val <span class="op">-=</span> <span class="op">(</span>printf<span class="op">(</span><span class="st">" </span><span class="sc">%d\n</span><span class="st">"</span><span class="op">,</span> val<span class="op">)</span> <span class="op">></span> BUFSIZ<span class="op">)</span> <span class="op">?</span> FILENAME_MAX <span class="op">:</span> EOF<span class="op">;</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb26"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a> lys <span class="op">-=</span> <span class="dv">4</span> <span class="op">*</span> printf<span class="op">(</span><span class="st">"</span><span class="sc">%c</span><span class="st">"</span><span class="op">,</span> <span class="op">(</span>met<span class="op">)</span>tyr <span class="op">+</span> <span class="dv">32</span> <span class="op">+</span> <span class="dv">16</span> <span class="op">+</span> <span class="op">((</span><span class="dv">8</span> <span class="op">+</span> EOF<span class="op">)</span> <span class="op">*</span> <span class="op">((</span>met<span class="op">)</span>tyr <span class="op">/</span> <span class="op">(</span><span class="dv">8</span> <span class="op">+</span> <span class="dv">2</span><span class="op">))));</span></span>
|
||||
<span id="cb26-2"><a href="#cb26-2" aria-hidden="true" tabindex="-1"></a> val <span class="op">+=</span> printf<span class="op">(</span><span class="st">"</span><span class="sc">\n</span><span class="st">"</span><span class="op">)</span> <span class="op">/</span> <span class="op">((</span>__LINE__ <span class="op">*</span> L_tmpnam<span class="op">)</span> <span class="op">+</span> TMP_MAX<span class="op">);</span></span>
|
||||
<span id="cb26-3"><a href="#cb26-3" aria-hidden="true" tabindex="-1"></a> val <span class="op">-=</span> <span class="op">(</span>printf<span class="op">(</span><span class="st">" </span><span class="sc">%d\n</span><span class="st">"</span><span class="op">,</span> val<span class="op">)</span> <span class="op">></span> BUFSIZ<span class="op">)</span> <span class="op">?</span> FILENAME_MAX <span class="op">:</span> EOF<span class="op">;</span></span></code></pre></div>
|
||||
<p>which are, in the absence of errors, equivalent to</p>
|
||||
<div class="sourceCode" id="cb27"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a>lys <span class="op">-=</span> <span class="dv">4</span><span class="op">;</span></span>
|
||||
<span id="cb27-2"><a href="#cb27-2" aria-hidden="true" tabindex="-1"></a><span class="co">/*nop*/</span></span>
|
||||
<span id="cb27-3"><a href="#cb27-3" aria-hidden="true" tabindex="-1"></a><span class="op">++</span>val<span class="op">;</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb27"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a> lys <span class="op">-=</span> <span class="dv">4</span><span class="op">;</span></span>
|
||||
<span id="cb27-2"><a href="#cb27-2" aria-hidden="true" tabindex="-1"></a> <span class="co">/*nop*/</span></span>
|
||||
<span id="cb27-3"><a href="#cb27-3" aria-hidden="true" tabindex="-1"></a> <span class="op">++</span>val<span class="op">;</span></span></code></pre></div>
|
||||
<p>MISRA 13.1: “Assignment operators shall not be used in expressions that
|
||||
yield a Boolean value.” Forbids the idiomatic <code>if ((p = malloc(n)) == NULL)</code> and requires separate statements, in other words, bloat.</p>
|
||||
<p>MISRA 16.7: “A pointer parameter in a function prototype should be
|
||||
declared as pointer to <code>const</code> if the pointer is not used to modify the
|
||||
addressed object.” in conjunction with lint’s “Note 952: Parameter could
|
||||
be declared <code>const</code>” causes <code>const</code>-poisoning for all functions,</p>
|
||||
<div class="sourceCode" id="cb28"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb28-1"><a href="#cb28-1" aria-hidden="true" tabindex="-1"></a><span class="dt">static</span> <span class="dt">void</span> phe<span class="op">(</span><span class="dt">const</span> ala not<span class="op">);</span></span>
|
||||
<span id="cb28-2"><a href="#cb28-2" aria-hidden="true" tabindex="-1"></a><span class="dt">static</span> <span class="dt">void</span> gly<span class="op">(</span>ala <span class="op">*</span><span class="dt">const</span> not<span class="op">,</span> <span class="dt">const</span> and his<span class="op">);</span></span>
|
||||
<span id="cb28-3"><a href="#cb28-3" aria-hidden="true" tabindex="-1"></a>met main<span class="op">(</span>met val<span class="op">,</span> <span class="dt">const</span> pro <span class="op">*</span><span class="dt">const</span> his<span class="op">[]);</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb28"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb28-1"><a href="#cb28-1" aria-hidden="true" tabindex="-1"></a> <span class="dt">static</span> <span class="dt">void</span> phe<span class="op">(</span><span class="dt">const</span> ala not<span class="op">);</span></span>
|
||||
<span id="cb28-2"><a href="#cb28-2" aria-hidden="true" tabindex="-1"></a> <span class="dt">static</span> <span class="dt">void</span> gly<span class="op">(</span>ala <span class="op">*</span><span class="dt">const</span> not<span class="op">,</span> <span class="dt">const</span> and his<span class="op">);</span></span>
|
||||
<span id="cb28-3"><a href="#cb28-3" aria-hidden="true" tabindex="-1"></a> met main<span class="op">(</span>met val<span class="op">,</span> <span class="dt">const</span> pro <span class="op">*</span><span class="dt">const</span> his<span class="op">[]);</span></span></code></pre></div>
|
||||
<p>and quite a number of automatic variables.</p>
|
||||
<h3 id="why-the-laugh-and-throw-up-messages">Why the “laugh” and “throw up” messages?</h3>
|
||||
<p>The guidelines state “We like programs that: make us laugh and/or throw
|
||||
@@ -727,13 +726,13 @@ up :-) (humor really helps!)”</p>
|
||||
<h3 id="if-you-have-a-128-bit-type">If you have a 128 bit type</h3>
|
||||
<p>If your compiler supports a 128 bit wide type (e.g. clang, gcc) then
|
||||
you can use it via the <code>typ</code> macro:</p>
|
||||
<div class="sourceCode" id="cb29"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a><span class="fu">clang</span> <span class="at">-Dtyp</span><span class="op">=</span>__uint128_t <span class="at">-o</span> prog prog.c</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb29"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">clang</span> <span class="at">-Dtyp</span><span class="op">=</span>__uint128_t <span class="at">-o</span> prog prog.c</span></code></pre></div>
|
||||
<p>Indeed, the program can use (and lints clean for) all of</p>
|
||||
<div class="sourceCode" id="cb30"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb30-1"><a href="#cb30-1" aria-hidden="true" tabindex="-1"></a><span class="fu">clang</span> <span class="at">-Dtyp</span><span class="op">=</span>uint8_t <span class="at">-o</span> prog8 prog.c</span>
|
||||
<span id="cb30-2"><a href="#cb30-2" aria-hidden="true" tabindex="-1"></a><span class="fu">clang</span> <span class="at">-Dtyp</span><span class="op">=</span>uint16_t <span class="at">-o</span> prog16 prog.c</span>
|
||||
<span id="cb30-3"><a href="#cb30-3" aria-hidden="true" tabindex="-1"></a><span class="fu">clang</span> <span class="at">-Dtyp</span><span class="op">=</span>uint32_t <span class="at">-o</span> prog32 prog.c</span>
|
||||
<span id="cb30-4"><a href="#cb30-4" aria-hidden="true" tabindex="-1"></a><span class="fu">clang</span> <span class="at">-Dtyp</span><span class="op">=</span>uint64_t <span class="at">-o</span> prog64 prog.c</span>
|
||||
<span id="cb30-5"><a href="#cb30-5" aria-hidden="true" tabindex="-1"></a><span class="fu">clang</span> <span class="at">-std</span><span class="op">=</span>c89 <span class="at">-Dtyp</span><span class="op">=</span><span class="st">"unsigned long"</span> <span class="at">-o</span> prog89 prog.c</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb30"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb30-1"><a href="#cb30-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">clang</span> <span class="at">-Dtyp</span><span class="op">=</span>uint8_t <span class="at">-o</span> prog8 prog.c</span>
|
||||
<span id="cb30-2"><a href="#cb30-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">clang</span> <span class="at">-Dtyp</span><span class="op">=</span>uint16_t <span class="at">-o</span> prog16 prog.c</span>
|
||||
<span id="cb30-3"><a href="#cb30-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">clang</span> <span class="at">-Dtyp</span><span class="op">=</span>uint32_t <span class="at">-o</span> prog32 prog.c</span>
|
||||
<span id="cb30-4"><a href="#cb30-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">clang</span> <span class="at">-Dtyp</span><span class="op">=</span>uint64_t <span class="at">-o</span> prog64 prog.c</span>
|
||||
<span id="cb30-5"><a href="#cb30-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">clang</span> <span class="at">-std</span><span class="op">=</span>c89 <span class="at">-Dtyp</span><span class="op">=</span><span class="st">"unsigned long"</span> <span class="at">-o</span> prog89 prog.c</span></code></pre></div>
|
||||
<p>This works because the program has no need for corresponding <code>SCN</code> or <code>PRI</code>
|
||||
macros to do the scanning and printing of variables of these types. With a 128
|
||||
bit type the program can represent numbers up to
|
||||
|
||||
+13
-13
@@ -1,21 +1,21 @@
|
||||
## To build:
|
||||
|
||||
```sh
|
||||
make
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
echo Some text | ./prog
|
||||
echo Some text | ./prog
|
||||
```
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./try.sh
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -38,24 +38,24 @@ so you need not worry about this.
|
||||
her some input through `stdin` to get lots of sea star patterns on `stdout`.
|
||||
|
||||
```sh
|
||||
cc -O3 -std=c90 fuuko.c -lm -o fuuko_c90
|
||||
echo IOCCC | ./fuuko_c90 > output_c90.c
|
||||
cc -O3 -std=c90 fuuko.c -lm -o fuuko_c90
|
||||
echo IOCCC | ./fuuko_c90 > output_c90.c
|
||||
```
|
||||
|
||||
If you compile with a C99 compiler instead of C90, the sea stars will
|
||||
have eyes.
|
||||
|
||||
```sh
|
||||
cc -O3 -std=c99 fuuko.c -lm -o fuuko_c99
|
||||
echo IOCCC | ./fuuko_c99 > output_c99.c
|
||||
cc -O3 -std=c99 fuuko.c -lm -o fuuko_c99
|
||||
echo IOCCC | ./fuuko_c99 > output_c99.c
|
||||
```
|
||||
|
||||
Don't like [sea stars](https://en.wikipedia.org/wiki/Starfish)? Use a C++98
|
||||
compiler to get a [dango](https://en.wikipedia.org/wiki/Dango) instead.
|
||||
|
||||
```sh
|
||||
g++ -O3 -std=c++98 fuuko.c -lm -o fuuko_cpp98
|
||||
echo IOCCC | ./fuuko_cpp98 > output_cpp98.c
|
||||
g++ -O3 -std=c++98 fuuko.c -lm -o fuuko_cpp98
|
||||
echo IOCCC | ./fuuko_cpp98 > output_cpp98.c
|
||||
```
|
||||
|
||||
Don't like [dango](https://en.wikipedia.org/wiki/Dango) either? Use a C++11
|
||||
@@ -64,16 +64,16 @@ cheese](https://en.wikipedia.org/wiki/Swiss_cheeses_and_dairy_products), if you
|
||||
prefer that).
|
||||
|
||||
```sh
|
||||
g++ -O3 -std=c++11 fuuko.c -lm -o fuuko_cpp11
|
||||
echo IOCCC | ./fuuko_cpp11 > output_cpp11.c
|
||||
g++ -O3 -std=c++11 fuuko.c -lm -o fuuko_cpp11
|
||||
echo IOCCC | ./fuuko_cpp11 > output_cpp11.c
|
||||
```
|
||||
|
||||
Don't like any of these patterns? Use a C11 compiler and there will be
|
||||
no extra pattern.
|
||||
|
||||
```sh
|
||||
cc -O3 -std=c11 fuuko.c -lm -o fuuko_c11
|
||||
echo IOCCC | ./fuuko_c11 > output_c11.c
|
||||
cc -O3 -std=c11 fuuko.c -lm -o fuuko_c11
|
||||
echo IOCCC | ./fuuko_c11 > output_c11.c
|
||||
```
|
||||
|
||||
Regardless of which of these C/C++ dialects you choose, the output
|
||||
|
||||
+14
-15
@@ -132,8 +132,7 @@
|
||||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||||
<ul>
|
||||
<li>Name: <a href="../../authors.html#Don_Yang">Don Yang</a><br>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)
|
||||
<br><br></li>
|
||||
Location: <a href="../../location.html#US">US</a> - <em>United States of America</em> (<em>United States</em>)</li>
|
||||
</ul>
|
||||
|
||||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||||
@@ -142,11 +141,11 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></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></span></code></pre></div>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> Some text <span class="kw">|</span> <span class="ex">./prog</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> Some text <span class="kw">|</span> <span class="ex">./prog</span></span></code></pre></div>
|
||||
<h2 id="try">Try:</h2>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">./try.sh</span></span></code></pre></div>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>Before analysing the code in detail we were able to guess two out of four tests
|
||||
this entry uses to tell the 5 languages/flavors apart. Can you find all four?</p>
|
||||
@@ -158,26 +157,26 @@ so you need not worry about this.</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<p><code>Fuuko</code> is a <a href="https://en.wikipedia.org/wiki/Starfish">sea star</a> generator. Feed
|
||||
her some input through <code>stdin</code> to get lots of sea star patterns on <code>stdout</code>.</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> <span class="at">-O3</span> <span class="at">-std</span><span class="op">=</span>c90 fuuko.c <span class="at">-lm</span> <span class="at">-o</span> fuuko_c90</span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> IOCCC <span class="kw">|</span> <span class="ex">./fuuko_c90</span> <span class="op">></span> output_c90.c</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cc</span> <span class="at">-O3</span> <span class="at">-std</span><span class="op">=</span>c90 fuuko.c <span class="at">-lm</span> <span class="at">-o</span> fuuko_c90</span>
|
||||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> IOCCC <span class="kw">|</span> <span class="ex">./fuuko_c90</span> <span class="op">></span> output_c90.c</span></code></pre></div>
|
||||
<p>If you compile with a C99 compiler instead of C90, the sea stars will
|
||||
have eyes.</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> <span class="at">-O3</span> <span class="at">-std</span><span class="op">=</span>c99 fuuko.c <span class="at">-lm</span> <span class="at">-o</span> fuuko_c99</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> IOCCC <span class="kw">|</span> <span class="ex">./fuuko_c99</span> <span class="op">></span> output_c99.c</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cc</span> <span class="at">-O3</span> <span class="at">-std</span><span class="op">=</span>c99 fuuko.c <span class="at">-lm</span> <span class="at">-o</span> fuuko_c99</span>
|
||||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> IOCCC <span class="kw">|</span> <span class="ex">./fuuko_c99</span> <span class="op">></span> output_c99.c</span></code></pre></div>
|
||||
<p>Don’t like <a href="https://en.wikipedia.org/wiki/Starfish">sea stars</a>? Use a C++98
|
||||
compiler to get a <a href="https://en.wikipedia.org/wiki/Dango">dango</a> instead.</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">g++</span> <span class="at">-O3</span> <span class="at">-std</span><span class="op">=</span>c++98 fuuko.c <span class="at">-lm</span> <span class="at">-o</span> fuuko_cpp98</span>
|
||||
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> IOCCC <span class="kw">|</span> <span class="ex">./fuuko_cpp98</span> <span class="op">></span> output_cpp98.c</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">g++</span> <span class="at">-O3</span> <span class="at">-std</span><span class="op">=</span>c++98 fuuko.c <span class="at">-lm</span> <span class="at">-o</span> fuuko_cpp98</span>
|
||||
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> IOCCC <span class="kw">|</span> <span class="ex">./fuuko_cpp98</span> <span class="op">></span> output_cpp98.c</span></code></pre></div>
|
||||
<p>Don’t like <a href="https://en.wikipedia.org/wiki/Dango">dango</a> either? Use a C++11
|
||||
compiler to get just <a href="https://en.wikipedia.org/wiki/Circle">circles</a> (or <a href="https://en.wikipedia.org/wiki/Swiss_cheeses_and_dairy_products">Swiss
|
||||
cheese</a>, if you
|
||||
prefer that).</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ex">g++</span> <span class="at">-O3</span> <span class="at">-std</span><span class="op">=</span>c++11 fuuko.c <span class="at">-lm</span> <span class="at">-o</span> fuuko_cpp11</span>
|
||||
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> IOCCC <span class="kw">|</span> <span class="ex">./fuuko_cpp11</span> <span class="op">></span> output_cpp11.c</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a> <span class="ex">g++</span> <span class="at">-O3</span> <span class="at">-std</span><span class="op">=</span>c++11 fuuko.c <span class="at">-lm</span> <span class="at">-o</span> fuuko_cpp11</span>
|
||||
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> IOCCC <span class="kw">|</span> <span class="ex">./fuuko_cpp11</span> <span class="op">></span> output_cpp11.c</span></code></pre></div>
|
||||
<p>Don’t like any of these patterns? Use a C11 compiler and there will be
|
||||
no extra pattern.</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cc</span> <span class="at">-O3</span> <span class="at">-std</span><span class="op">=</span>c11 fuuko.c <span class="at">-lm</span> <span class="at">-o</span> fuuko_c11</span>
|
||||
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> IOCCC <span class="kw">|</span> <span class="ex">./fuuko_c11</span> <span class="op">></span> output_c11.c</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a> <span class="fu">cc</span> <span class="at">-O3</span> <span class="at">-std</span><span class="op">=</span>c11 fuuko.c <span class="at">-lm</span> <span class="at">-o</span> fuuko_c11</span>
|
||||
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="bu">echo</span> IOCCC <span class="kw">|</span> <span class="ex">./fuuko_c11</span> <span class="op">></span> output_c11.c</span></code></pre></div>
|
||||
<p>Regardless of which of these C/C++ dialects you choose, the output
|
||||
will all be valid C90 code that reproduces original input on <code>stdout</code>,
|
||||
filled with pointer dereferences (C stars).</p>
|
||||
|
||||
Reference in new issue
Block a user