add rules, guidelines, fix HTML code, move compressed tarball in inventory
By changing the _inventory_order_ of the compressed tarball from
**100000** to **1415926535**, the compressed tarball will land at
the top of the secondary file list and remain still easy to find.
Updated the `manifest.numbers` spreadsheet and rebuilt
the `.entry.json` files.
Added `next/` directory to hold the next IOCCC rules and guidelines.
Added `next/README.md` that `bin/gen-top-html.sh` uses to form
the `next/index.html` file.
Added _Rules and Guidelines_ link to the sidenav bar to link to the
`next/index.html` file.
Added _IOCCC Rules_ as `next/rules.md` that `bin/gen-top-html.sh`
uses to form the `next/rules.html` file.
Added _IOCCC Guidelines_ as `next/guidelines.md` that `bin/gen-top-html.sh`
uses to form the `next/guidelines.html` file.
Changed `bin/gen-top-html.sh` VERSION from "1.2.4 2024-04-13"
to "1.3 2024-04-14".
Prevent `pandoc(1)` from interpreting the commented out language
of a markdown code block as a code class. So a markdown such as:
````
``` <!---sh-->
...
```
````
that produced HTML of the form:
```html
<pre class="<!---sh-->"><code>...</code></pre>
```
will now produce HTML of the form:
```html
<pre><code>...</code></pre>
```
NOTE: Before when the language of a markdown code block
was not commented, the HTML produced by `pandoc(1)` was
oddly indented with extra whitespace on the first line
of the code block. While commenting out the language
of the code block removed some of the odd intending,
it left a weird class in the HTML pre block that
surrounded the HTML code block. This hack prevents
`pandoc(1)` from assigning a class to the HTML pre block.
Changed `in/md2html.sh` VERSION from "1.2.1 2024-04-13"
to "1.3 2024-04-14".
Added `make gen_sitemap` to end of both `make www` and `make
quick_www` in top level Makefile.
Ram `make www` to test under macOS and to perform the above.
**IMPORTANT NOTE**: The current `next/rules.md` and `next/guidelines.md`
are simply the 2020 IOCCC Rules and Guidelines converted into
markdown form. There are **NOT** the Rules and Guidelines that
will be used the IOCCC MOCK, nor the next IOCCC.
TODO: Improve the `bin/gen-status.sh` tool to modify the top of the
`next/rules.md` and `next/guidelines.md` files to keep them
in sync with the _contest_status_ as found in `status.json`.
TODO: Improve the look and feel of the `next/rules.md` and
`next/guidelines.md` markdown files.
This commit is contained in:
1 parent
a672335d2d
commit
518a6336d0
734 files changed
+7919
-4119
No files matched your search
@@ -67,7 +67,7 @@
|
||||
},
|
||||
{
|
||||
"file_path" : "2020_burton.tar.bz2",
|
||||
"inventory_order" : 100000,
|
||||
"inventory_order" : 1415926535,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "tbz2",
|
||||
"display_via_github" : false,
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -141,15 +142,15 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<pre class="<!---sh-->"><code> make</code></pre>
|
||||
<pre><code> make</code></pre>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<p>For more detailed information see <a href="../../bugs.html#2020_burton">2020 burton bugs</a>.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<pre class="<!---sh-->"><code> ./prog arg ...</code></pre>
|
||||
<pre><code> ./prog arg ...</code></pre>
|
||||
<h2 id="try">Try:</h2>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<pre><code> ./try.sh</code></pre>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<p>By default, the program works for Little Endian machines. This alternate build
|
||||
is for Big Endian machines (that works whether you have LE or BE).</p>
|
||||
@@ -170,7 +171,7 @@ value that results when the two magic constants are <code>XOR</code>ed.</p>
|
||||
choosing new constants, but using the same computation generate a reversed
|
||||
result?</p>
|
||||
<p>This code may be tested by:</p>
|
||||
<pre class="<!---sh-->"><code> make test</code></pre>
|
||||
<pre><code> make test</code></pre>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<p>Invoke this with a single non-negative integer less than 256, and a useful
|
||||
transformation occurs.</p>
|
||||
@@ -189,11 +190,11 @@ display strange results with more than one argument.</p>
|
||||
<p>Compiles cleanly under <code>clang -Wall -Weverything -pedantic</code>, but you need to add
|
||||
<code>--include stdio.h --include stdlib.h</code> for the <code>printf(3)</code> and <code>atoi(3)</code>.</p>
|
||||
<p>On a little-endian machine:</p>
|
||||
<pre class="<!---sh-->"><code> clang -include stdio.h -include stdlib.h -Wall -Weverything -pedantic -DB=6945503773712347754LL -DI=5859838231191962459LL -DT=0 -DS=7 -o prog prog.c</code></pre>
|
||||
<pre><code> clang -include stdio.h -include stdlib.h -Wall -Weverything -pedantic -DB=6945503773712347754LL -DI=5859838231191962459LL -DT=0 -DS=7 -o prog prog.c</code></pre>
|
||||
<p>On a big-endian machine:</p>
|
||||
<pre class="<!---sh-->"><code> clang -include stdio.h -include stdlib.h -Wall -Weverything -pedantic -DB=7091606191627001958LL -DI=6006468689561538903LL -DT=1 -DS=0 -o prog_be prog.c</code></pre>
|
||||
<pre><code> clang -include stdio.h -include stdlib.h -Wall -Weverything -pedantic -DB=7091606191627001958LL -DI=6006468689561538903LL -DT=1 -DS=0 -o prog_be prog.c</code></pre>
|
||||
<p>You might be interested to compile it both ways on the same host, and try:</p>
|
||||
<pre class="<!---sh-->"><code> ./prog 1; ./prog_be 1</code></pre>
|
||||
<pre><code> ./prog 1; ./prog_be 1</code></pre>
|
||||
<!--
|
||||
|
||||
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
|
||||
@@ -224,10 +225,10 @@ display strange results with more than one argument.</p>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/burton/check_be.sh">check_be.sh</a> - test suite support file</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/burton/check_le.sh">check_le.sh</a> - test suite support file</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/burton/correct">correct</a> - test suite comparison data</li>
|
||||
<li><a href="2020_burton.tar.bz2">2020_burton.tar.bz2</a> - download entry tarball</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
<li><a href="2020_burton.tar.bz2">2020_burton.tar.bz2</a> - download entry tarball</li>
|
||||
<li><a href="index.html">index.html</a> - this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/burton/README.md">README.md</a> - markdown source for this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/burton/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
},
|
||||
{
|
||||
"file_path" : "2020_carlini.tar.bz2",
|
||||
"inventory_order" : 100000,
|
||||
"inventory_order" : 1415926535,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "tbz2",
|
||||
"display_via_github" : false,
|
||||
|
||||
+25
-24
@@ -88,6 +88,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -141,17 +142,17 @@ 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>
|
||||
<pre class="<!---sh-->"><code> make</code></pre>
|
||||
<pre><code> make</code></pre>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<p>For more detailed information see <a href="../../bugs.html#2020_carlini">2020 carlini bugs</a>.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<pre class="<!---sh-->"><code> ./prog</code></pre>
|
||||
<pre><code> ./prog</code></pre>
|
||||
<h2 id="try">Try:</h2>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<pre><code> ./try.sh</code></pre>
|
||||
<p>Or if you actually want to play:</p>
|
||||
<pre class="<!---sh-->"><code> # Play with a friend, real or imagined, P1 and P2, squares are numbered 1..9
|
||||
<pre><code> # Play with a friend, real or imagined, P1 and P2, squares are numbered 1..9
|
||||
./prog</code></pre>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>This program consists of a single <code>printf(3)</code> statement wrapped in a <code>while</code>
|
||||
@@ -161,7 +162,7 @@ ASCII art of the program source.</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<p>HOW ABOUT A NICE GAME OF <strike>CHESS</strike>TIC-TAC-TOE?</p>
|
||||
<h3 id="usage">USAGE</h3>
|
||||
<pre class="<!---sh-->"><code> cc -o prog prog.c
|
||||
<pre><code> cc -o prog prog.c
|
||||
./prog</code></pre>
|
||||
<p>Alternates between P1 and P2. Enter a digit [1-9] to move:</p>
|
||||
<pre><code> 1 | 2 | 3
|
||||
@@ -187,10 +188,10 @@ patient.</p>
|
||||
<p>After macro expansion the format string is roughly 100K. This makes some
|
||||
compilers unhappy, and others slow. (For example, passing GCC the flags <code>-Wall -Wextra -pedantic</code> will result in a warning about oversized strings.)</p>
|
||||
<p>Under some terminals the program may exit early. The following should always work:</p>
|
||||
<pre class="<!---sh-->"><code> echo "1 2 3 4 5 6 7" | ./prog</code></pre>
|
||||
<pre><code> echo "1 2 3 4 5 6 7" | ./prog</code></pre>
|
||||
<h3 id="obfuscation">OBFUSCATION</h3>
|
||||
<p>The entirety of the program consists of a single iterated call to <code>printf(3)</code>.</p>
|
||||
<pre class="<!---c-->"><code> int main() {
|
||||
<pre><code> int main() {
|
||||
while(*d) printf(fmt, arg);
|
||||
}</code></pre>
|
||||
<p>Here, <code>fmt</code> is a single string, and <code>arg</code> is a series of arguments to
|
||||
@@ -218,9 +219,9 @@ this one <code>printf(3)</code> call (and a call to <code>scanf(3)</code> to rea
|
||||
<li><p><code>"%3$.*4$d"</code>: print argument 3 to <code>printf(3)</code> with as many zeros as in argument 4.</p></li>
|
||||
</ul>
|
||||
<p>For example, the following expression</p>
|
||||
<pre class="<!---c-->"><code> printf("%1$.*2$d%3$hhn", 5, 10, &x)</code></pre>
|
||||
<pre><code> printf("%1$.*2$d%3$hhn", 5, 10, &x)</code></pre>
|
||||
<p>will have the same effect as if we had written</p>
|
||||
<pre class="<!---c-->"><code> x = 10;</code></pre>
|
||||
<pre><code> x = 10;</code></pre>
|
||||
<p>because it will print out <code>0000000005</code> (5 padded to size 10) and then write the
|
||||
number of bytes written to <code>x</code>.</p>
|
||||
<h4 id="printf3-oriented-programming"><code>printf(3)</code> Oriented Programming</h4>
|
||||
@@ -233,17 +234,17 @@ array–one bit per pair of bytes:</p>
|
||||
</ul>
|
||||
<p>We can use format strings to compute the OR/NOT of arbitrary “bits”.</p>
|
||||
<p>We’ll start with the simplest, OR:</p>
|
||||
<pre class="<!---c-->"><code> printf("%1$s%2$s%3$hhn", a, b, c)</code></pre>
|
||||
<pre><code> printf("%1$s%2$s%3$hhn", a, b, c)</code></pre>
|
||||
<p>will compute</p>
|
||||
<pre class="<!---c-->"><code> *c = strlen(a) + strlen(b)</code></pre>
|
||||
<pre><code> *c = strlen(a) + strlen(b)</code></pre>
|
||||
<p>but given that <code>strlen(x)</code> is <code>1</code> for a 1-bit and <code>0</code> for a 0-bit, we have</p>
|
||||
<pre class="<!---c-->"><code> *c = a | b</code></pre>
|
||||
<pre><code> *c = a | b</code></pre>
|
||||
<p>Computing the NOT of a single value is also easy:</p>
|
||||
<pre class="<!---c-->"><code> printf("%1$255d%1$s%hhn", a, b)</code></pre>
|
||||
<pre><code> printf("%1$255d%1$s%hhn", a, b)</code></pre>
|
||||
<p>will compute</p>
|
||||
<pre class="<!---c-->"><code> *b = (strlen(a)+255)%256 = strlen(a)-1</code></pre>
|
||||
<pre><code> *b = (strlen(a)+255)%256 = strlen(a)-1</code></pre>
|
||||
<p>and again, because <code>strlen(x)</code> is either <code>1</code> or <code>0</code> we have</p>
|
||||
<pre class="<!---c-->"><code> *c = !b</code></pre>
|
||||
<pre><code> *c = !b</code></pre>
|
||||
<p>From here we can compute any binary circuit. Doing something efficient,
|
||||
though, still takes work.</p>
|
||||
<h4 id="tic-tac-toe">Tic-Tac-Toe</h4>
|
||||
@@ -252,7 +253,7 @@ with a turn counter that alternates between player 1 and player 2.</p>
|
||||
<p>To detect who has won, we implement the following logic. Let <code>A</code>, <code>B</code>, and <code>C</code> be
|
||||
pointers to three squares in a row to test, and <code>D</code> be where to save if there is a
|
||||
win or not.</p>
|
||||
<pre class="<!---c-->"><code> "%A$s%B$s%C$s%1$253d%11$hhn" // r11 = !(*A & *B & *C)
|
||||
<pre><code> "%A$s%B$s%C$s%1$253d%11$hhn" // r11 = !(*A & *B & *C)
|
||||
ZERO
|
||||
"%11$s%1$255d%11hhn" // r11 = !r11
|
||||
ZERO
|
||||
@@ -261,7 +262,7 @@ win or not.</p>
|
||||
possible three-in-a-row configurations, for both players.</p>
|
||||
<p>The ZERO macro ensures that the number of bytes written out is 0 mod 256 with
|
||||
the following expression</p>
|
||||
<pre class="<!---c-->"><code> "%1$hhn%1$s" (repeated 256 times)</code></pre>
|
||||
<pre><code> "%1$hhn%1$s" (repeated 256 times)</code></pre>
|
||||
<p>where argument 1 is a pointer to a temporary variable followed by a NUL byte.</p>
|
||||
<p>This works because if the current count is 0 mod 256, then <code>"%1$hhn"</code> will write
|
||||
zero to argument 1 and then <code>"%1$s"</code> will never emit any text. If, on the other
|
||||
@@ -273,15 +274,15 @@ times we’re eventually going to reach 0 mod 256.</p>
|
||||
bits to Xs and Os to print out. This is actually rather straightforward. Given
|
||||
in <code>1$</code> the pointer to player 1’s square, and <code>2$</code> the pointer to player 2’s, and
|
||||
in <code>3$</code> the pointer to the board string, we can compute</p>
|
||||
<pre class="<!---c-->"><code> "%1$s" (repeated 47 times) "%2$s" (repeated 56 times) %1$32d%3$hhn"</code></pre>
|
||||
<pre><code> "%1$s" (repeated 47 times) "%2$s" (repeated 56 times) %1$32d%3$hhn"</code></pre>
|
||||
<p>which will, in effect, compute</p>
|
||||
<pre class="<!---c-->"><code> *r3 = (*r1) * 47 + (*r2) * 56 + 32</code></pre>
|
||||
<pre><code> *r3 = (*r1) * 47 + (*r2) * 56 + 32</code></pre>
|
||||
<p>which will output <code>' '</code> if neither are true, <code>'X'</code> if <code>r1</code> is true, or <code>'O'</code> if
|
||||
<code>r2</code> is true.</p>
|
||||
<h4 id="further-obfuscations">Further Obfuscations</h4>
|
||||
<p>In order to be able to finally display the board, while still only using one
|
||||
<code>printf(3)</code> statement, we finish the statement with</p>
|
||||
<pre class="<!---c-->"><code> "\n\033[2J\n%26$s"</code></pre>
|
||||
<pre><code> "\n\033[2J\n%26$s"</code></pre>
|
||||
<p>which is the escape sequence to clear the screen, and then prints argument 26.
|
||||
Argument 26 is a pointer to a <code>char*</code> in memory, that initially is undefined,
|
||||
but within the <code>printf(3)</code> statement we will construct this string to look like a
|
||||
@@ -297,7 +298,7 @@ tic-tac-toe board.</p>
|
||||
won, or the game is over and it is a draw.</p>
|
||||
<p>This turns out not to be as hard as it might look. Using the same trick as
|
||||
before, we set byte four to be</p>
|
||||
<pre class="<!---c-->"><code> *byte4 = is_win * 'W' + is_tie * 'T'</code></pre>
|
||||
<pre><code> *byte4 = is_win * 'W' + is_tie * 'T'</code></pre>
|
||||
<p>The byte <code>'I'</code> and <code>'S'</code> can always be the same, and we do the same for <code>'E'</code>/<code>'N'</code>.</p>
|
||||
<p>We do this same on-the-fly creation of the <code>scanf(3)</code> format string, but for a
|
||||
different reason. We first want to run <code>printf(3)</code> to show the first board, and
|
||||
@@ -305,14 +306,14 @@ then alternate between runs to <code>scanf(3)</code> and <code>printf(3)</code>
|
||||
displaying moves. Importantly, we <em>do not</em> want a final <code>scanf(3)</code> when the game
|
||||
ends. It should just exit.</p>
|
||||
<p>One option would be to implement the logic as</p>
|
||||
<pre class="<!---c-->"><code> printf()
|
||||
<pre><code> printf()
|
||||
while (*ok) {
|
||||
scanf();
|
||||
printf();
|
||||
}</code></pre>
|
||||
<p>but this would DOUBLE the number of calls to <code>printf(3)</code> we require. So instead we
|
||||
implement it like this</p>
|
||||
<pre class="<!---c-->"><code> while (*ok) {
|
||||
<pre><code> while (*ok) {
|
||||
scanf();
|
||||
printf();
|
||||
}</code></pre>
|
||||
@@ -349,10 +350,10 @@ string so that it returns right away without blocking. The first time the
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/carlini/Makefile">Makefile</a> - entry Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/carlini/prog.orig.c">prog.orig.c</a> - original source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/carlini/try.sh">try.sh</a> - how to run</li>
|
||||
<li><a href="2020_carlini.tar.bz2">2020_carlini.tar.bz2</a> - download entry tarball</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
<li><a href="2020_carlini.tar.bz2">2020_carlini.tar.bz2</a> - download entry tarball</li>
|
||||
<li><a href="index.html">index.html</a> - this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/carlini/README.md">README.md</a> - markdown source for this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/carlini/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
},
|
||||
{
|
||||
"file_path" : "2020_endoh1.tar.bz2",
|
||||
"inventory_order" : 100000,
|
||||
"inventory_order" : 1415926535,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "tbz2",
|
||||
"display_via_github" : false,
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -141,15 +142,15 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<pre class="<!---sh-->"><code> make</code></pre>
|
||||
<pre><code> make</code></pre>
|
||||
<p>There is an alternate version provided by the author. See <a href="#alternate-code">Alternate
|
||||
code</a> below.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<pre class="<!---sh-->"><code> # IMPORTANT for macOS: run under Terminal.app
|
||||
<pre><code> # IMPORTANT for macOS: run under Terminal.app
|
||||
|
||||
./prog</code></pre>
|
||||
<h2 id="try">Try:</h2>
|
||||
<pre class="<!---sh-->"><code> # IMPORTANT for macOS: run under Terminal.app
|
||||
<pre><code> # IMPORTANT for macOS: run under Terminal.app
|
||||
|
||||
# Try resizing the terminal window before the first click.
|
||||
|
||||
@@ -163,7 +164,7 @@ code</a> below.</p>
|
||||
alternate code lacks the additional rule to flag all unprobed cells. See the
|
||||
Author’s remarks for more details.</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<pre class="<!---sh-->"><code> make alt</code></pre>
|
||||
<pre><code> make alt</code></pre>
|
||||
<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>
|
||||
@@ -194,7 +195,7 @@ such a boring task!</p>
|
||||
All you have to do is (0). You can test if you are lucky or not.</p>
|
||||
<h3 id="how-to-use">How to use:</h3>
|
||||
<p>It uses ncurses:</p>
|
||||
<pre class="<!---sh-->"><code> gcc -o prog prog.c -lncurses
|
||||
<pre><code> gcc -o prog prog.c -lncurses
|
||||
./prog</code></pre>
|
||||
<p>You will see a terminal-wide field of a minesweeper. Probe a cell by mouse
|
||||
click.</p>
|
||||
@@ -255,7 +256,7 @@ are flagged.</p>
|
||||
Analyze the code.</p>
|
||||
<h3 id="one-more-thing">One more thing</h3>
|
||||
<p>You can also play with a prepared map.</p>
|
||||
<pre class="<!---sh-->"><code> ./prog ioccc.txt</code></pre>
|
||||
<pre><code> ./prog ioccc.txt</code></pre>
|
||||
<p>The format of the text is:</p>
|
||||
<pre><code> width height number-of-mines priorities-of-each-cell...</code></pre>
|
||||
<p>There are mines in a cell whose “priorities-of-each-cell” is less than
|
||||
@@ -307,10 +308,10 @@ code a little to pretend to use the return value of <code>fscanf(3)</code>.</p>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh1/ioccc.txt">ioccc.txt</a> - gameplay map</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh1/megumin.txt">megumin.txt</a> - gameplay map</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh1/unwinnable.txt">unwinnable.txt</a> - gameplay map</li>
|
||||
<li><a href="2020_endoh1.tar.bz2">2020_endoh1.tar.bz2</a> - download entry tarball</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
<li><a href="2020_endoh1.tar.bz2">2020_endoh1.tar.bz2</a> - download entry tarball</li>
|
||||
<li><a href="index.html">index.html</a> - this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh1/README.md">README.md</a> - markdown source for this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh1/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
},
|
||||
{
|
||||
"file_path" : "2020_endoh2.tar.bz2",
|
||||
"inventory_order" : 100000,
|
||||
"inventory_order" : 1415926535,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "tbz2",
|
||||
"display_via_github" : false,
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -141,13 +142,13 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<pre class="<!---sh-->"><code> make</code></pre>
|
||||
<pre><code> make</code></pre>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<pre class="<!---sh-->"><code> ./prog</code></pre>
|
||||
<pre><code> ./prog</code></pre>
|
||||
<h2 id="try">Try:</h2>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<pre><code> ./try.sh</code></pre>
|
||||
<p>What happens if you do</p>
|
||||
<pre class="<!---sh-->"><code> ./prog prog.c</code></pre>
|
||||
<pre><code> ./prog prog.c</code></pre>
|
||||
<p>?</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>Clever use of the C99 complex data type. The <a href="spoiler/">spoiler</a> directory
|
||||
@@ -157,7 +158,7 @@ shapes.</p>
|
||||
render for a larger terminal window? How about adding more glyphs?</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<p>No! Try not. Do, or do not. There is no try.</p>
|
||||
<pre class="<!---sh-->"><code> cc -std=c99 prog.c
|
||||
<pre><code> cc -std=c99 prog.c
|
||||
./a.out
|
||||
./a.out hello.txt
|
||||
./a.out yoda.txt
|
||||
@@ -200,10 +201,10 @@ render for a larger terminal window? How about adding more glyphs?</p>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/spoiler/prog.c">spoiler/prog.c</a> - SPOILER WARNING - generated source</li>
|
||||
<li><a href="spoiler/spoiler.html">spoiler/spoiler.html</a> - SPOILER WARNING - about the spoiler</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/spoiler/tmpl.txt">spoiler/tmpl.txt</a> - SPOILER WARNING - template for the program</li>
|
||||
<li><a href="2020_endoh2.tar.bz2">2020_endoh2.tar.bz2</a> - download entry tarball</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
<li><a href="2020_endoh2.tar.bz2">2020_endoh2.tar.bz2</a> - download entry tarball</li>
|
||||
<li><a href="index.html">index.html</a> - this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/README.md">README.md</a> - markdown source for this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../../news.html">IOCCC News</a>
|
||||
<a href="../../../status.html">Contest status</a>
|
||||
<a href="../../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../../faq.html">FAQ</a>
|
||||
</div>
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
},
|
||||
{
|
||||
"file_path" : "2020_endoh3.tar.bz2",
|
||||
"inventory_order" : 100000,
|
||||
"inventory_order" : 1415926535,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "tbz2",
|
||||
"display_via_github" : false,
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -141,23 +142,23 @@ Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<pre class="<!---sh-->"><code> make</code></pre>
|
||||
<pre><code> make</code></pre>
|
||||
<p>An alternate version of this program exists. See <a href="#alternate-code">Alternate
|
||||
code</a> below.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<pre class="<!---sh-->"><code> ./prog</code></pre>
|
||||
<pre><code> ./prog</code></pre>
|
||||
<h2 id="try">Try:</h2>
|
||||
<pre class="<!---sh-->"><code> ./run_clock
|
||||
<pre><code> ./run_clock
|
||||
# And watch closely for 15-20 seconds</code></pre>
|
||||
<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 uses Unicode letters.</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<pre class="<!---sh-->"><code> make alt</code></pre>
|
||||
<pre><code> make alt</code></pre>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./run_clock.alt
|
||||
<pre><code> ./run_clock.alt
|
||||
# And watch closely for 15-20 seconds</code></pre>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>You may be tempted to use a mirror. Resist the temptation! Try figuring out how
|
||||
@@ -167,7 +168,7 @@ familiar (non-mirrored) clock face? Can you add the second hand?</p>
|
||||
time might depend on what time it is.</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<p>Prepare a mirror!</p>
|
||||
<pre class="<!---sh-->"><code> make clock</code></pre>
|
||||
<pre><code> make clock</code></pre>
|
||||
<p>Note: You need to recompile it each run.</p>
|
||||
<!--
|
||||
|
||||
@@ -198,10 +199,10 @@ time might depend on what time it is.</p>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh3/prog.orig.c">prog.orig.c</a> - original source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh3/run_clock.alt.sh">run_clock.alt.sh</a> - how to run alternate code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh3/run_clock.sh">run_clock.sh</a> - how to run</li>
|
||||
<li><a href="2020_endoh3.tar.bz2">2020_endoh3.tar.bz2</a> - download entry tarball</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
<li><a href="2020_endoh3.tar.bz2">2020_endoh3.tar.bz2</a> - download entry tarball</li>
|
||||
<li><a href="index.html">index.html</a> - this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh3/README.md">README.md</a> - markdown source for this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh3/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
|
||||
@@ -179,7 +179,7 @@
|
||||
},
|
||||
{
|
||||
"file_path" : "2020_ferguson1.tar.bz2",
|
||||
"inventory_order" : 100000,
|
||||
"inventory_order" : 1415926535,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "tbz2",
|
||||
"display_via_github" : false,
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -146,7 +147,7 @@ matters; I only have Intel CPUs and arm64 (MacBook Pro M1).</p>
|
||||
<p>I imagine that it works for 32-bit systems but I do not know for sure.</p>
|
||||
<h1 id="portability-macos">Portability: macOS</h1>
|
||||
<p>You should be able to get the compiler with:</p>
|
||||
<pre class="<!---sh-->"><code> sudo xcode-select --install</code></pre>
|
||||
<pre><code> sudo xcode-select --install</code></pre>
|
||||
<p>You don’t need Xcode itself and it appears that the command line tools (as above
|
||||
should install) already has ncurses so there shouldn’t be anything else that
|
||||
needs to be done. But I’m not actually sure of this - I’m seeing conflicting
|
||||
@@ -159,20 +160,20 @@ so that you don’t need sudo because … Well never mind.</p>
|
||||
you want to use the Makefile) to compile and link this entry. With Fedora more
|
||||
recent versions there’s the <code>dnf</code> package manager but I cannot help with any of
|
||||
the GUI installers since I don’t use them. Something like:</p>
|
||||
<pre class="<!---sh-->"><code> sudo dnf install ncurses-devel ncurses make gcc</code></pre>
|
||||
<pre><code> sudo dnf install ncurses-devel ncurses make gcc</code></pre>
|
||||
<p>or</p>
|
||||
<pre class="<!---sh-->"><code> # dnf install ncurses-devel ncurses make gcc</code></pre>
|
||||
<pre><code> # dnf install ncurses-devel ncurses make gcc</code></pre>
|
||||
<h1 id="portability-centos">Portability: CentOS</h1>
|
||||
<p>Just like Fedora you will need <code>gcc</code>, <code>ncurses</code>, <code>ncurses-devel</code> (and if you
|
||||
want to use the Makefile <code>make</code>). CentOS uses <code>yum</code> and CentOS 8 uses <code>dnf</code>.
|
||||
So:</p>
|
||||
<pre class="<!---sh-->"><code> sudo yum install ncurses-devel ncurses make gcc</code></pre>
|
||||
<pre><code> sudo yum install ncurses-devel ncurses make gcc</code></pre>
|
||||
<p>or</p>
|
||||
<pre class="<!---sh-->"><code> # yum install ncurses-devel ncurses make gcc</code></pre>
|
||||
<pre><code> # yum install ncurses-devel ncurses make gcc</code></pre>
|
||||
<p>or</p>
|
||||
<pre class="<!---sh-->"><code> sudo dnf install ncurses-devel ncurses make gcc</code></pre>
|
||||
<pre><code> sudo dnf install ncurses-devel ncurses make gcc</code></pre>
|
||||
<p>or</p>
|
||||
<pre class="<!---sh-->"><code> # dnf install ncurses-devel ncurses make gcc</code></pre>
|
||||
<pre><code> # dnf install ncurses-devel ncurses make gcc</code></pre>
|
||||
<p>You can also use clang to compile (which is what gcc actually is under macOS).</p>
|
||||
<h1 id="compilation-notes">Compilation notes</h1>
|
||||
<p>As long as you have the dependencies above the only thing that comes to mind is
|
||||
|
||||
+14
-13
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -192,12 +193,12 @@ defaults if you don’t want to change the colour.</p>
|
||||
initialise a pair (make it 5 so as to not interfere with the script
|
||||
customisability) and then you use the bkgd() function with the colour pair.
|
||||
Something like this:</p>
|
||||
<pre class="<!---c-->"><code> init_pair(5, COLOR_BLACK, COLOR_WHITE);
|
||||
<pre><code> init_pair(5, COLOR_BLACK, COLOR_WHITE);
|
||||
bkgd(COLOR_PAIR(5));</code></pre>
|
||||
<p>I played with this after winning and I came across some problems with colours
|
||||
but that changes the background of the program anyway.</p>
|
||||
<p>The standard colour identifiers are:</p>
|
||||
<pre class="<!---c-->"><code> COLOR_BLACK
|
||||
<pre><code> COLOR_BLACK
|
||||
COLOR_RED
|
||||
COLOR_GREEN
|
||||
COLOR_YELLOW
|
||||
@@ -220,16 +221,16 @@ source code (<strong>include the single quotes!</strong>) respectively:</p>
|
||||
<p>Let’s say you don’t want to use arrow keys or you don’t have arrow keys. Instead
|
||||
you might want the keys <code>l</code>, <code>r</code>, <code>u</code> and <code>d</code> for the directions. Find the case
|
||||
statements:</p>
|
||||
<pre class="<!---c-->"><code> case KEY_LEFT:
|
||||
<pre><code> case KEY_LEFT:
|
||||
case KEY_RIGHT:
|
||||
case KEY_UP:
|
||||
case KEY_DOWN:</code></pre>
|
||||
<p>Replace <code>KEY_LEFT</code> with:</p>
|
||||
<pre class="<!---c-->"><code> 'l'</code></pre>
|
||||
<pre><code> 'l'</code></pre>
|
||||
<p>and do the same thing for the other directions too. If you want more than one
|
||||
key e.g. the arrow keys and the letters just add another case statement e.g. for
|
||||
left it might be:</p>
|
||||
<pre class="<!---c-->"><code> case KEY_LEFT: case 'l':</code></pre>
|
||||
<pre><code> case KEY_LEFT: case 'l':</code></pre>
|
||||
<p>Yes the single quotes matter. You can do similar for the other input keys.
|
||||
Please note that modifier keys like ctrl aren’t detectable or at least I’m
|
||||
unaware of how to do so.</p>
|
||||
@@ -245,9 +246,9 @@ end of the game; I leave that as an exercise to the reader to implement two
|
||||
different sets. Please also be aware that if you don’t want any information you
|
||||
must set it to the below at the very least; defining it without a value is not
|
||||
enough (it amounts to the parameters to a printf call):</p>
|
||||
<pre class="<!---c-->"><code> #define J " " );</code></pre>
|
||||
<pre><code> #define J " " );</code></pre>
|
||||
<p>If you don’t care about brief displays of ‘o’ at 0,0 you can just have:</p>
|
||||
<pre class="<!---c-->"><code> #define J "");</code></pre>
|
||||
<pre><code> #define J "");</code></pre>
|
||||
<p>That’s the bare minimum. Notice also that it’s been a long while since I’ve
|
||||
tested this part but I think this is right.</p>
|
||||
<p>Anyway as I said the score line has basic statistics that’s relatively easy to
|
||||
@@ -262,7 +263,7 @@ bug. This however was something I didn’t quite like: I like having the
|
||||
coordinates of where the snake is plus the other things that are there (a number
|
||||
of which were added over time). Obviously this would take many bug sized bytes
|
||||
(bites) even once let alone twice! Thus I made it into a define:</p>
|
||||
<pre class="<!---c-->"><code> #define J Z(X:%d/%d Y:%d/%d S:%zu/%zu B:%zu\n), Y, y[-2], X,*y,A,g, c);</code></pre>
|
||||
<pre><code> #define J Z(X:%d/%d Y:%d/%d S:%zu/%zu B:%zu\n), Y, y[-2], X,*y,A,g, c);</code></pre>
|
||||
<p>With the table below you can show a variety of other variables/statistics.</p>
|
||||
<p>There’s another reason for changing this line though: depending on the terminal
|
||||
width the line could cover the top wall; this can even happen only part of the
|
||||
@@ -280,7 +281,7 @@ so if this line wasn’t there it would require changes to make it work right.</
|
||||
<p>For an example this would only include the size of the snake and the number of
|
||||
bugs eaten (I think I have this correct; I’ve made many changes to the point of
|
||||
not wanting to mess with anything that’s unnecessary):</p>
|
||||
<pre class="<!---c-->"><code> #define J Z(SIZE: %zu BUGS: %zu\n), A, c);</code></pre>
|
||||
<pre><code> #define J Z(SIZE: %zu BUGS: %zu\n), A, c);</code></pre>
|
||||
<p>More generally the following expressions and data types (with format specifiers)
|
||||
come to mind as information that might be of interest.</p>
|
||||
<pre><code> DESCRIPTION EXPRESSION TYPE FORMAT SPECIFIER
|
||||
@@ -307,9 +308,9 @@ come to mind as information that might be of interest.</p>
|
||||
bug)</code></pre>
|
||||
<h2 id="make-it-so-the-snake-starts-at-a-random-location">Make it so the snake starts at a random location</h2>
|
||||
<p>Quite simply change:</p>
|
||||
<pre class="<!---c-->"><code> X = H / 2; Y = *x / 2;</code></pre>
|
||||
<pre><code> X = H / 2; Y = *x / 2;</code></pre>
|
||||
<p>To be something like:</p>
|
||||
<pre class="<!---c-->"><code> X = R(1,H-1);
|
||||
<pre><code> X = R(1,H-1);
|
||||
Y = R(2,*x-1);</code></pre>
|
||||
<p>Or whatever you might want it to be… (question to answer: will this work at
|
||||
all? You decide!)</p>
|
||||
@@ -407,7 +408,7 @@ their ruddy phone instead of where they’re walking (even when crossing a busy
|
||||
street!).</p>
|
||||
<p>If you look at the walls code you will see a ternary operator for both <code>X</code> and <code>Y</code>
|
||||
coordinates. This of course is very different now but the idea remains the same:</p>
|
||||
<pre class="<!---c-->"><code> if (p && !(*O>=O[1]||H>=M(1)))
|
||||
<pre><code> if (p && !(*O>=O[1]||H>=M(1)))
|
||||
{
|
||||
if (X<1||X>=H)
|
||||
X = X<1?H-1:1;
|
||||
@@ -420,7 +421,7 @@ the walls (off screen). Depending on where the snake is it will set the
|
||||
coordinates to the correct new location.</p>
|
||||
<p>If however you wanted the walls to act as a barrier you could do something like
|
||||
this instead (omitting the inner if statements here):</p>
|
||||
<pre class="<!---c-->"><code> X=X<1?1:*H-1;
|
||||
<pre><code> X=X<1?1:*H-1;
|
||||
|
||||
Y=Y<2?2:*O-1;</code></pre>
|
||||
<p>Again though that’s just the idea; the code is dramatically different. The above
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -141,7 +142,7 @@ like some of the other features this was not intentionally designed but is
|
||||
simply a fun consequence of the features I did implement.</p>
|
||||
<p>Let’s say you want to verify that the evade mode is at the right count. How
|
||||
can you verify it without modifying the code? Try:</p>
|
||||
<pre class="<!---sh-->"><code> SIZE=0 SHED=1 SHEDS=1 EVADE=10 ./prog</code></pre>
|
||||
<pre><code> SIZE=0 SHED=1 SHEDS=1 EVADE=10 ./prog</code></pre>
|
||||
<p>Since you start out at size 0 and you shed every movement then when you’re
|
||||
size 10 (as long as you don’t eat a bug of course!) the bug should evade.</p>
|
||||
<p>If you set it to <code>SIZE=10</code> there would be a difference of 10. Now every
|
||||
@@ -154,7 +155,7 @@ don’t at this time remember any I might have done.</p>
|
||||
<h1 id="the-snake-doesnt-seem-to-be-moving"><a name="stillsnake" href="#toc">The snake doesn’t seem to be moving</a></h1>
|
||||
<p>One way to show this is in full is to set the initial size and growth size to a
|
||||
high value; then try each one individually. For example:</p>
|
||||
<pre class="<!---sh-->"><code> SIZE=100 ./prog</code></pre>
|
||||
<pre><code> SIZE=100 ./prog</code></pre>
|
||||
<p>In this case after you make the first move the snake will keep growing and
|
||||
so the snake tail stays in the same spot until after it’s the ‘full size’.
|
||||
When it has reached the full size then the entire body of the snake will
|
||||
@@ -201,23 +202,23 @@ way negative size will force a win.</p>
|
||||
<p>Here’s a fun output:</p>
|
||||
<pre><code> < <<<+</code></pre>
|
||||
<p>That’s from:</p>
|
||||
<pre class="<!---sh-->"><code> SHED=1 SHEDS=-1 ./prog</code></pre>
|
||||
<pre><code> SHED=1 SHEDS=-1 ./prog</code></pre>
|
||||
<p>And right after that you would see:</p>
|
||||
<pre><code> YOU WIN!
|
||||
X:72/156 Y:20/41 S:997/997 B:0</code></pre>
|
||||
<p>Try this though:</p>
|
||||
<pre class="<!---sh-->"><code> SHEDS=-1 SHED=25 ./prog</code></pre>
|
||||
<pre><code> SHEDS=-1 SHED=25 ./prog</code></pre>
|
||||
<p>And you’ll see that you start to be the normal size but then you leave your
|
||||
head several places until you end up getting to the max size (by way of it
|
||||
being unsigned). This isn’t a bug even if it might seem like one. In fact
|
||||
this is the basis of the grow/shrink mode of play that I talk about in the
|
||||
<a href="gameplay.html">gameplay.html</a> (<a href="gameplay.md">gameplay.md</a> on GitHub) file.</p>
|
||||
<p>Here’s another thing to be aware of. Let’s say you do:</p>
|
||||
<pre class="<!---sh-->"><code> SIZE=1 GROW=-1 ./prog</code></pre>
|
||||
<pre><code> SIZE=1 GROW=-1 ./prog</code></pre>
|
||||
<p>How many bugs will it take before you win? In fact it’s two: you would see the
|
||||
head twice: the second time once you ‘shrink’ down to size 0; it would then be
|
||||
that if you get another bug you will be at the ‘max size’:</p>
|
||||
<pre class="<!---sh-->"><code> YOU WIN!
|
||||
<pre><code> YOU WIN!
|
||||
X:81/156 Y:35/41 S:997/997 B:2</code></pre>
|
||||
<h1 id="i-was-a-few-places-behind-my-tail-and-i-ran-into-it"><a name="bitetail" href="#toc">‘I was a few places behind my tail and I ran into it!’</a></h1>
|
||||
<p>I.e. what happens if you’re growing - for example after just eating a bug - and
|
||||
@@ -271,7 +272,7 @@ how it’s done in Snake and works well). The minimum terminal size I require in
|
||||
the game is 10 x 10. This includes the walls and score line.</p>
|
||||
<p>Now the default max snake size is 997 but when the terminal is too small it
|
||||
adjusts the max snake size. For 10 lines and 10 columns you would see:</p>
|
||||
<pre class="<!---sh-->"><code> $ make test
|
||||
<pre><code> $ make test
|
||||
terminal supports cursor movement
|
||||
terminal supports making cursor invisible
|
||||
terminal supports bold
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -274,7 +275,7 @@ most of them.</p>
|
||||
<h2 id="example-5-snake-moving-left-with-snake-inside-itsself">Example 5: snake moving left with snake inside itsself</h2>
|
||||
<p>Another example invocation where the snake head is in the snake and where the snake
|
||||
hadn’t yet moved (that is it was still growing):</p>
|
||||
<pre class="<!---sh-->"><code> CANNIBAL=1 SIZE=1500 GROW=2 MAXSIZE=1600 ./prog</code></pre>
|
||||
<pre><code> CANNIBAL=1 SIZE=1500 GROW=2 MAXSIZE=1600 ./prog</code></pre>
|
||||
<p>It looked like:</p>
|
||||
<pre><code> X:55/89 Y:11/25 S:1564/1600 B:32
|
||||
##########################################################################################
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -123,7 +124,7 @@
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<p>The following are a few screen dumps of:</p>
|
||||
<pre class="<!---sh-->"><code> SIZE=100 SHEDS=5 GROW=-10 SHED=50 MAXSIZE=250 ./prog</code></pre>
|
||||
<pre><code> SIZE=100 SHEDS=5 GROW=-10 SHED=50 MAXSIZE=250 ./prog</code></pre>
|
||||
<p>As you will see it took 17 bugs to get down to below 0. Notice how I had to get
|
||||
down to 0 more than once: because I moved enough times before I got the last
|
||||
bug that I grew by 5 in size. I then however moved a bit more and ate a bug
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -451,7 +452,7 @@ setting the max size to a smaller value than the size you specify (or the
|
||||
default) or setting the size to higher than the default (or < 0 which will end
|
||||
up being > the max size though I suppose there might be some value that makes it
|
||||
less than again - I’m not going to try and figure that out however). Anyway:</p>
|
||||
<pre class="<!---sh-->"><code> SIZE=-1 ./prog
|
||||
<pre><code> SIZE=-1 ./prog
|
||||
YOU WIN!
|
||||
X:24/49 Y:8/16 S:658/658 B:0</code></pre>
|
||||
<p>Observe that the size isn’t the default 997: because the screen size is too
|
||||
@@ -499,22 +500,22 @@ you have any form of epilepsy. Thank you.</strong></p>
|
||||
<p>If you want to draw the snake wherever you like on the screen you can do this by
|
||||
modifying the wait time (for input) to -1 (or any value < 0): then the snake
|
||||
does not move until you press a movement key. For example:</p>
|
||||
<pre class="<!---sh-->"><code> WAIT=-1 ./prog</code></pre>
|
||||
<pre><code> WAIT=-1 ./prog</code></pre>
|
||||
<p>When you eat a bug the snake will grow and you can draw more. If you want to
|
||||
make it so you can go through yourself:</p>
|
||||
<pre class="<!---sh-->"><code> WAIT=-1 CANNIBAL=1 ./prog</code></pre>
|
||||
<pre><code> WAIT=-1 CANNIBAL=1 ./prog</code></pre>
|
||||
<p>If you don’t want to start out so small (i.e. you want to be able to draw more
|
||||
quickly) you can just set the size to a bigger number (and you could do the same
|
||||
with growth and moult/shed):</p>
|
||||
<pre class="<!---sh-->"><code> SIZE=50 CANNIBAL=1 WAIT=-1 ./prog</code></pre>
|
||||
<pre><code> SIZE=50 CANNIBAL=1 WAIT=-1 ./prog</code></pre>
|
||||
<p>Do note that although you’re a bigger size you still grow one movement at a
|
||||
time.</p>
|
||||
<p>Okay but then if you get too many bugs the drawing will be over. If this proves
|
||||
to be a problem simply do:</p>
|
||||
<pre class="<!---sh-->"><code> SIZE=100 CANNIBAL=1 WAIT=-1 GROW=0 ./prog</code></pre>
|
||||
<pre><code> SIZE=100 CANNIBAL=1 WAIT=-1 GROW=0 ./prog</code></pre>
|
||||
<p>Or something like that (maybe make the size bigger but that’s up to you). You
|
||||
could also set the max size to be the highest possible by saying</p>
|
||||
<pre class="<!---sh-->"><code> MAXSIZE=-1</code></pre>
|
||||
<pre><code> MAXSIZE=-1</code></pre>
|
||||
<p>Which I’ve done in the <a href="play.sh">play.sh</a> script.</p>
|
||||
<p>I discuss how this mode works in [spoilers.markdown][].</p>
|
||||
<p>Here’s an example run where I spelt ‘SNAKE’. As you can see it’s far from
|
||||
@@ -536,7 +537,7 @@ different colours and depending on the exact parameters you specify it could
|
||||
easily be in the trigger range for epilepsy but potentially stimulation overload
|
||||
too.</p>
|
||||
<p>If you’re still here you can create this effect like:</p>
|
||||
<pre class="<!---sh-->"><code> WAIT=0 WALLS=1 CANNIBAL=1 ./prog</code></pre>
|
||||
<pre><code> WAIT=0 WALLS=1 CANNIBAL=1 ./prog</code></pre>
|
||||
<p>As long as the bug evades you’ll find that the snake is growing because it’s
|
||||
actually eating bugs; the computer is actually playing the game by itself! You
|
||||
can still move the snake though it won’t seem like you have much control over
|
||||
@@ -553,14 +554,14 @@ happen because the bug has to find a X and Y coordinate that’s not occupied an
|
||||
so with fewer available it has a harder time finding a place in that one line.</p>
|
||||
<h3 id="computer-player-variations"><a name="auto-variations" href="#toc">Computer player variations</a></h3>
|
||||
<p>Here’s how to make the bug move every time the snake moves:</p>
|
||||
<pre class="<!---sh-->"><code> CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 ./prog</code></pre>
|
||||
<pre><code> CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 ./prog</code></pre>
|
||||
<h4 id="help-the-computer-win-fairly-quickly">Help the computer win fairly quickly</h4>
|
||||
<p>If you want to see the game ‘win’ try something like:</p>
|
||||
<pre class="<!---sh-->"><code> CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 MAXSIZE=10 ./prog</code></pre>
|
||||
<pre><code> CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 MAXSIZE=10 ./prog</code></pre>
|
||||
<h4 id="negative-growth-shrink-automatic-mode">Negative growth (Shrink) Automatic mode</h4>
|
||||
<p>Here’s a fun one I just thought of (a long time after these other modes were
|
||||
thought of):</p>
|
||||
<pre class="<!---sh-->"><code> WAIT=0 EVADE=1 GROW=-1 SIZE=9 MAXSIZE=10 CANNIBAL=1 ./prog</code></pre>
|
||||
<pre><code> WAIT=0 EVADE=1 GROW=-1 SIZE=9 MAXSIZE=10 CANNIBAL=1 ./prog</code></pre>
|
||||
<p>What you’ll see is that first the snake will get to the size of 9 - whether it
|
||||
shows to be 10 characters depends on whether or not it gets a bug before it can
|
||||
get to that length - and then it’ll start shrinking until it’s just the head
|
||||
@@ -568,7 +569,7 @@ then the head again (i.e. 1 then 0 in size) and then win! This is also in the
|
||||
<a href="play.sh">play.sh</a> script.</p>
|
||||
<h4 id="adjusting-the-timespeed">Adjusting the time/speed</h4>
|
||||
<p>Of course you can also do something like:</p>
|
||||
<pre class="<!---sh-->"><code> WAIT=5 WALLS=1 CANNIBAL=1 ./prog</code></pre>
|
||||
<pre><code> WAIT=5 WALLS=1 CANNIBAL=1 ./prog</code></pre>
|
||||
<p>Which although might not seem like it is significantly slower.</p>
|
||||
<h4 id="moving-the-snake-about-to-create-patterns">Moving the snake about to create patterns</h4>
|
||||
<p>If you press different direction keys in some pattern you will see a pattern
|
||||
@@ -578,7 +579,7 @@ suppose also how much the bug moves and the chance of being eaten also).</p>
|
||||
<p>Here’s an idea: how many moves is needed to make it possible to have some sort
|
||||
of success in catching bugs? Obviously the dimensions will affect this value.</p>
|
||||
<p>How long will it take for the snake to run into itself? For instance by doing:</p>
|
||||
<pre class="<!---sh-->"><code> WAIT=0 ./prog</code></pre>
|
||||
<pre><code> WAIT=0 ./prog</code></pre>
|
||||
<p>On my 13” MacBook Pro (replaced later by a 16”) at the default settings going
|
||||
horizontally the snake ran into itself at:</p>
|
||||
<pre><code> OW!
|
||||
@@ -592,7 +593,7 @@ or growing to the full size directly. This is how it works:</p>
|
||||
<p>You have a negative shedding growth and a positive growth size: negative and
|
||||
positive winning. Depending on the parameters specified it might go one way over
|
||||
the other. Try:</p>
|
||||
<pre class="<!---sh-->"><code> SIZE=150 SHEDS=-5 GROW=10 SHED=50 MAXSIZE=250 ./prog</code></pre>
|
||||
<pre><code> SIZE=150 SHEDS=-5 GROW=10 SHED=50 MAXSIZE=250 ./prog</code></pre>
|
||||
<p>What this does is set the size to 150 (to make it not go down so quickly) and
|
||||
then for each bug you eat it adds 5 to the size; for every 50 moves (that you
|
||||
don’t get the bug) you shrink by 5. You will find that at times you might only
|
||||
@@ -608,7 +609,7 @@ dumps with this idea.</p>
|
||||
<p>You could also have it so that eating a bug makes you shrink and moving so many
|
||||
moves you grow. I tried this and for me it was far more fun. The <a href="play.sh">play.sh</a>
|
||||
also has this mode:</p>
|
||||
<pre class="<!---sh-->"><code> SIZE=100 SHEDS=5 GROW=-10 SHED=50 MAXSIZE=250 ./prog</code></pre>
|
||||
<pre><code> SIZE=100 SHEDS=5 GROW=-10 SHED=50 MAXSIZE=250 ./prog</code></pre>
|
||||
<p>Obviously there are many other variations. The <a href="play.sh">play.sh</a> script has some
|
||||
of them (the above is option 5; others are 4, 15 and 16 but only options 4 and 5
|
||||
are called Grow / Shrink).</p>
|
||||
@@ -622,7 +623,7 @@ typical range of seizures is 3 to 30 flashes per seconds (but can be higher) and
|
||||
that means that at <strong>EVADE=1</strong> every 231ms there will be a flash in addition to the
|
||||
snake moving too.</p>
|
||||
<p>Anyway this might sound absurd but it can be somewhat hypnotic by doing:</p>
|
||||
<pre class="<!---sh-->"><code> EVADE=1 CANNIBAL=1 ./prog</code></pre>
|
||||
<pre><code> EVADE=1 CANNIBAL=1 ./prog</code></pre>
|
||||
<p>And just moving the snake about not trying to catch any bugs - just let whatever
|
||||
happens happen.</p>
|
||||
<h2 id="gameplay-mode-stimulation-calming-mode"><a name="stim" href="#toc">Gameplay mode: Stimulation / Calming mode</a></h2>
|
||||
@@ -631,7 +632,7 @@ want to play a game without having to worry about winning or losing you can set
|
||||
the growth size to 0 and then just move the snake round and round eating bugs
|
||||
until you want to quit. You can enable cannibalism so that you don’t have to
|
||||
worry about even running into yourself and losing:</p>
|
||||
<pre class="<!---sh-->"><code> GROW=0 CANNIBAL=1 ./prog</code></pre>
|
||||
<pre><code> GROW=0 CANNIBAL=1 ./prog</code></pre>
|
||||
<h2 id="gameplay-mode-expansibility"><a name="expansibility" href="#toc">Gameplay mode: Expansibility</a></h2>
|
||||
<p>As I was writing this document and the game modes I have thought of other game
|
||||
modes (they were added) and I have come back to this document to add more modes.
|
||||
@@ -650,9 +651,9 @@ reason as well as I simply enjoy it and thinking up new modes.</p>
|
||||
this file discusses as well as allowing to easily change the colours.</p>
|
||||
<h2 id="colours-selection-snake-colours"><a name="colours" href="#toc">Colours selection: snake-colours</a></h2>
|
||||
<p>To do this use the <a href="snake-colours">snake-colours</a> script like so:</p>
|
||||
<pre class="<!---sh-->"><code> ./snake-colours</code></pre>
|
||||
<pre><code> ./snake-colours</code></pre>
|
||||
<p>If you want to pass in specific variables you can do that too e.g.:</p>
|
||||
<pre class="<!---sh-->"><code> CANNIBAL=1 ./snake-colours</code></pre>
|
||||
<pre><code> CANNIBAL=1 ./snake-colours</code></pre>
|
||||
<p>The script will prompt you for the colour of the walls, snake head, body and the
|
||||
bug.</p>
|
||||
<h2 id="automate-the-above-gameplay-modes"><a name="preset" href="#toc">Automate the above gameplay modes</a></h2>
|
||||
@@ -664,9 +665,9 @@ snake-colours above) and then gives you a list of game modes to play. You can
|
||||
pass in the game variables but note that if you pass in a variable that the mode
|
||||
you choose uses then the script will override what you pass in.</p>
|
||||
<p>To use you can do something like:</p>
|
||||
<pre class="<!---sh-->"><code> ./play.sh</code></pre>
|
||||
<pre><code> ./play.sh</code></pre>
|
||||
<p>Or to make it so walls are an obstacle:</p>
|
||||
<pre class="<!---sh-->"><code> WALLS=0 ./play.sh</code></pre>
|
||||
<pre><code> WALLS=0 ./play.sh</code></pre>
|
||||
<h1 id="notes-about-some-of-the-game-variables">6. <a name="variables" href="#toc">Notes about some of the game variables</a></h1>
|
||||
<p>The game variables can be used for a variety of things including different
|
||||
gameplay modes (as shown above) but here are some general notes about a few of them.</p>
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -141,13 +142,13 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<pre class="<!---sh-->"><code> make</code></pre>
|
||||
<pre><code> make</code></pre>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<p>For more detailed information see <a href="../../bugs.html#2020_ferguson1">2020 ferguson1 bugs</a>.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<pre class="<!---sh-->"><code> WAIT=N WALLS=[01] EVADE=N SIZE=N MAXSIZE=N GROW=N SHEDS=N SHED=N CANNIBAL=[01] ./prog
|
||||
<pre><code> WAIT=N WALLS=[01] EVADE=N SIZE=N MAXSIZE=N GROW=N SHEDS=N SHED=N CANNIBAL=[01] ./prog
|
||||
# start pressing some arrow keys</code></pre>
|
||||
<p>where <code>N</code> is a number and <code>[01]</code> is either <code>1</code> or <code>0</code> (or more correctly zero
|
||||
and non-zero).</p>
|
||||
@@ -202,7 +203,7 @@ whether you can go through the Snake or not. Default is 0
|
||||
(cannot - die if you try).</p></li>
|
||||
</ul>
|
||||
<h2 id="try">Try:</h2>
|
||||
<pre class="<!---sh-->"><code> make test
|
||||
<pre><code> make test
|
||||
|
||||
WAIT=75 WALLS=1 CANNIBAL=1 ./prog
|
||||
|
||||
@@ -306,7 +307,7 @@ look like bugs but aren’t as well as documenting a built-in test unit for some
|
||||
features.</p>
|
||||
<p>Because all IOCCC entries should have a man page I have included one (even
|
||||
though much of it is what’s also above). To render try:</p>
|
||||
<pre class="<!---sh-->"><code> man ./snake.1</code></pre>
|
||||
<pre><code> man ./snake.1</code></pre>
|
||||
<p>The <a href="COMPILING.html">COMPILING.html</a> file has a few portability
|
||||
notes and the <a href="HACKING.html">HACKING.html</a> file has some
|
||||
information on how one might modify things, things that could be implemented
|
||||
@@ -640,10 +641,10 @@ email but I’m more likely to respond to mastodon messages.</p>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/prog.3-j.c">prog.3-j.c</a> - source with artistic layout and shorter j macro</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/snake.1">snake.1</a> - snake game man page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/termcaps.c">termcaps.c</a> - terminal capability test source code</li>
|
||||
<li><a href="2020_ferguson1.tar.bz2">2020_ferguson1.tar.bz2</a> - download entry tarball</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
<li><a href="2020_ferguson1.tar.bz2">2020_ferguson1.tar.bz2</a> - download entry tarball</li>
|
||||
<li><a href="index.html">index.html</a> - this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/COMPILING.md">COMPILING.md</a> - markdown source for COMPILING.html</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson1/HACKING.md">HACKING.md</a> - markdown source for HACKING.html</li>
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -762,9 +763,9 @@ returning <code>E()</code> I am returning 1 but if the end of main() is reached
|
||||
returned. In either case curses is ended.</p>
|
||||
<p>One of these optimisations saved four bytes simply by taking advantage of the
|
||||
value of a loop iterator after the loop. The loop is:</p>
|
||||
<pre class="<!---c-->"><code> for (I = 0; A && I < A - 1; ++I)</code></pre>
|
||||
<pre><code> for (I = 0; A && I < A - 1; ++I)</code></pre>
|
||||
<p>However after the loop I had this:</p>
|
||||
<pre class="<!---c-->"><code> A > 1 && q(n[A - 1],e[A - 1], 'o');</code></pre>
|
||||
<pre><code> A > 1 && q(n[A - 1],e[A - 1], 'o');</code></pre>
|
||||
<p>When I was considering moving that line to before the loop it occurred to me
|
||||
that as long as <code>A > 0</code> then <code>A - 1 == I</code> after the loop. I still had to check
|
||||
for <code>A > 1</code> but I could refer to just <code>I</code> instead of <code>A - 1</code>!</p>
|
||||
@@ -779,31 +780,31 @@ place at this point) I was looking at the code to see if I could figure out how
|
||||
to save even more bytes. Here are some that I found interesting ways to go about
|
||||
the problem.</p>
|
||||
<p>First, the function that turns on colours looked like:</p>
|
||||
<pre class="<!---c-->"><code> if (h) attron(m(PAIR(L)));
|
||||
<pre><code> if (h) attron(m(PAIR(L)));
|
||||
else attroff(m(PAIR(L)));</code></pre>
|
||||
<p>But I thought is that else actually needed? If I were to switch the order so
|
||||
that the <code>attroff()</code> is called first then I could just do an <code>if (h)</code> -
|
||||
therefore getting rid of the <code>else</code>! But then I thought why not do what I’ve
|
||||
done elsewhere? I had:</p>
|
||||
<pre class="<!---c-->"><code> attroff(m(PAIR(L)));
|
||||
<pre><code> attroff(m(PAIR(L)));
|
||||
if (h) attron(m(PAIR(L)));</code></pre>
|
||||
<p>But I then saved an extra byte by making it:</p>
|
||||
<pre class="<!---c-->"><code> attroff(m(PAIR(L)));
|
||||
<pre><code> attroff(m(PAIR(L)));
|
||||
h && attron(m(PAIR(L)));</code></pre>
|
||||
<p>That saved two bytes.</p>
|
||||
<p>Second let’s look at the <code>B()</code> function: there were two things I thought of that
|
||||
would save some bytes (I no longer know how many but a few at least possibly six
|
||||
or even more). I had the following code:</p>
|
||||
<pre class="<!---c-->"><code> if (V && U && o) { S(N); b(1); }</code></pre>
|
||||
<pre><code> if (V && U && o) { S(N); b(1); }</code></pre>
|
||||
<p>This made sure that only if the snake has caught a bug should it grow by the
|
||||
growth size and increase the bug count. But was checking for the <code>V</code> or <code>U</code>
|
||||
necessary? I gave it a look over and it occurred to me: the only time <code>B()</code> is
|
||||
called with <code>1</code> (thus <code>o</code> is 1 so the if is true) was if the bug actually is
|
||||
caught. That means I could remove the <code>V && U &&</code> part of the if! Thus it became
|
||||
instead:</p>
|
||||
<pre class="<!---c-->"><code> if (o) { S(N); b(1); }</code></pre>
|
||||
<pre><code> if (o) { S(N); b(1); }</code></pre>
|
||||
<p>Then this</p>
|
||||
<pre class="<!---c-->"><code> !o && V && U && q U,V,' ');</code></pre>
|
||||
<pre><code> !o && V && U && q U,V,' ');</code></pre>
|
||||
<p>…is to make sure to only clear the spot the bug is (or was) at if
|
||||
the bug was NOT eaten. Why not eaten? Because if it was eaten it means the
|
||||
snake’s head will be there!</p>
|
||||
@@ -818,7 +819,7 @@ unfortunately the snake has to be placed first since the bug cannot be placed
|
||||
where the snake already is. So if I had to make sure the game had started (the
|
||||
snake has moved at least once) what could I check? In fact that means the
|
||||
direction is not 0! So I could just replace it with:</p>
|
||||
<pre class="<!---c-->"><code> !o && D && q *U,*V,' ');</code></pre>
|
||||
<pre><code> !o && D && q *U,*V,' ');</code></pre>
|
||||
<p>That reduced the count further. But then I wondered if even that much is needed.
|
||||
The condition is that the bug has evaded which means the snake has moved already
|
||||
(so game started). What calls to this function happen before the game starts
|
||||
@@ -831,7 +832,7 @@ to check for is that <code>!o</code>: because after this call before the game ev
|
||||
the score line is updated: so the empty space will be overwritten anyway. And if
|
||||
the score line is made an empty string it doesn’t matter because it’ll appear as
|
||||
all spaces anyway. Thus I could save another three bytes by changing it to:</p>
|
||||
<pre class="<!---c-->"><code> !o && q *U,*V,' ');</code></pre>
|
||||
<pre><code> !o && q *U,*V,' ');</code></pre>
|
||||
<p>Technically it would be a <code>" "</code> (see <a href="HACKING.html">HACKING.html</a> or on GitHub
|
||||
<a href="HACKING.md">HACKING.md</a>) else for N (not referring to the variable though it might very
|
||||
well matter here too) movements (i.e. due to sizes) you will at times (e.g.
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -151,7 +152,7 @@ movement is required) I have provided a source file that can test your terminal
|
||||
for the capabilities I use in the entry.</p>
|
||||
<p>It also tries to determine the minimum number of columns to play without the
|
||||
status line overflowing - even with the dynamic length. Try:</p>
|
||||
<pre class="<!---sh-->"><code> $ make test</code></pre>
|
||||
<pre><code> $ make test</code></pre>
|
||||
<p>This compiles the program <a href="termcaps.c">termcaps.c</a> and runs it; you should see something like:</p>
|
||||
<pre><code> terminal supports cursor movement
|
||||
terminal supports making cursor invisible
|
||||
@@ -178,7 +179,7 @@ maximum (capped) snake size.</p>
|
||||
<p>If I pass in any of the variables <strong>GROW</strong>, <strong>MAXSIZE</strong>, <strong>SIZE</strong> and/or
|
||||
<strong>LINES</strong> or <strong>COLUMNS</strong> it bases its calculations on those variables. For
|
||||
example:</p>
|
||||
<pre class="<!---sh-->"><code> terminal supports cursor movement
|
||||
<pre><code> terminal supports cursor movement
|
||||
terminal supports making cursor invisible
|
||||
terminal supports bold
|
||||
terminal supports colours
|
||||
@@ -224,12 +225,12 @@ resize the window with first. But what if you want exacts?</p>
|
||||
<p>To specify the lines/columns of curses program per instance use the <code>LINES</code> and
|
||||
<code>COLUMNS</code> environmental variables.</p>
|
||||
<p>For demonstration consider the following:</p>
|
||||
<pre class="<!---sh-->"><code> $ echo $LINES $COLUMNS
|
||||
<pre><code> $ echo $LINES $COLUMNS
|
||||
42 157</code></pre>
|
||||
<p>Note: I subtract 1 from the max y/x and the max coords in the game output
|
||||
include the walls and score line but these values are for the terminal itself.</p>
|
||||
<p>Say you want 55 columns:</p>
|
||||
<pre class="<!---sh-->"><code> $ COLUMNS=55 ./prog</code></pre>
|
||||
<pre><code> $ COLUMNS=55 ./prog</code></pre>
|
||||
<p>This will force curses to detect the max columns (X) of your terminal (for the
|
||||
game dimensions) - to be 55; it might look like this instead:</p>
|
||||
<pre><code> X:27/54 Y:20/41 S:5/997 B:0</code></pre>
|
||||
@@ -245,7 +246,7 @@ etc. For the game you might not see the final score.</p>
|
||||
<p>In my tests there is one thing that at least allows you to see the final score
|
||||
and that is by running <code>clear</code> before running the program. That’s what the
|
||||
prog.alt version does. You might run it as one of:</p>
|
||||
<pre class="<!---sh-->"><code> LINES=20 ./prog.alt
|
||||
<pre><code> LINES=20 ./prog.alt
|
||||
LINES=20 ./snake.alt</code></pre>
|
||||
<p>Even if the final score is visible though the terminal may very well still be
|
||||
messed up. There are numerous things you might try but probably the easiest is
|
||||
@@ -259,7 +260,7 @@ even just the <code>reset</code> command.</p>
|
||||
(the line-feed character is normally control-J) to get the terminal
|
||||
to work, as carriage-return may no longer work in the abnormal state.</code></pre>
|
||||
<p>If you don’t have the reset utility you can try:</p>
|
||||
<pre class="<!---sh-->"><code> echo -e \\033c</code></pre>
|
||||
<pre><code> echo -e \\033c</code></pre>
|
||||
<p>Otherwise try <code>clear; stty sane</code> (that will turn on echo also) or if all else
|
||||
fails log out and back in.</p>
|
||||
<p>For more information on this subject generally see the <a href="https://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO.html">Linux keyboard and
|
||||
@@ -271,10 +272,10 @@ outside what’s actually possible with their screen. But then player 4 comes
|
||||
along and thinks he/she will be clever and mess with the dimensions a bit. Let’s
|
||||
say they have a 13” monitor and they think it’d be funny to see how 997 lines
|
||||
would work; they might try something like:</p>
|
||||
<pre class="<!---sh-->"><code> LINES=997 ./prog</code></pre>
|
||||
<pre><code> LINES=997 ./prog</code></pre>
|
||||
<p>What then? Well expect trouble; curses will not know any better and the max
|
||||
number of lines will be 997. If they were to do:</p>
|
||||
<pre class="<!---sh-->"><code> COLUMNS=997 ./prog</code></pre>
|
||||
<pre><code> COLUMNS=997 ./prog</code></pre>
|
||||
<p>Then they will see a different effect. Again the same reason: the player trying
|
||||
to be funny.</p>
|
||||
<p>The game will try and be funny in return and you can expect it to not function
|
||||
@@ -306,7 +307,7 @@ GitHub) file).</p>
|
||||
<p>According to my tests for monochrome terminals the screen has the white and
|
||||
black background; if terminal is configured to be black background white
|
||||
foreground that is the order it is too. You can try that like:</p>
|
||||
<pre class="<!---sh-->"><code> TERM=linux-m ./prog</code></pre>
|
||||
<pre><code> TERM=linux-m ./prog</code></pre>
|
||||
<p>But I do not specifically check if the terminal has colours. Is there a curses
|
||||
implementation that has a problem here? Below I explain what to comment out
|
||||
should you need colours to be disabled but I personally have not run into any
|
||||
@@ -328,7 +329,7 @@ support in the source code itself.</p>
|
||||
<p>Based on the two as well as the fact that monochrome terminals (I’ve tried under
|
||||
both Linux and macOS) seem to work fine I believe I am fine here too. And to
|
||||
confirm this I wrote the following code with the output below:</p>
|
||||
<pre class="<!---c-->"><code> #include <curses.h>
|
||||
<pre><code> #include <curses.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -338,7 +339,7 @@ confirm this I wrote the following code with the output below:</p>
|
||||
getch();
|
||||
endwin();
|
||||
}</code></pre>
|
||||
<pre class="<!---sh-->"><code> TERM=linux-m ./colour_pairs
|
||||
<pre><code> TERM=linux-m ./colour_pairs
|
||||
COLORS: 0
|
||||
COLOR_PAIRS: 0</code></pre>
|
||||
<p>Without specifying the TERM I get:</p>
|
||||
@@ -348,7 +349,7 @@ confirm this I wrote the following code with the output below:</p>
|
||||
possible colour pairs than I have used so that’s not a problem either. Perhaps
|
||||
even it would only be a runtime error if the colours are supported and the
|
||||
number is out of the range? To try and figure this out I did another test:</p>
|
||||
<pre class="<!---c-->"><code> int main()
|
||||
<pre><code> int main()
|
||||
{
|
||||
initscr();
|
||||
start_color();
|
||||
@@ -363,7 +364,7 @@ number is out of the range? To try and figure this out I did another test:</p>
|
||||
endwin();
|
||||
}</code></pre>
|
||||
<p>Running it like</p>
|
||||
<pre class="<!---sh-->"><code> TERM=linux-m ./colour_pairs</code></pre>
|
||||
<pre><code> TERM=linux-m ./colour_pairs</code></pre>
|
||||
<p>I got the output as if colours weren’t used: 0 and 0. With coloured terminals
|
||||
however it was not visible. If I however comment out the call to <code>bkgd()</code> I get
|
||||
instead:</p>
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -372,7 +373,7 @@ hit a key every time to move because it is blocking.</p></li>
|
||||
</ul>
|
||||
<h2 id="on-environmental-variables-more-generally-and-string-to-int-conversions"><a name="envvars" href="#toc">On environmental variables more generally and string to int conversions</a></h2>
|
||||
<p>What happens if you do:</p>
|
||||
<pre class="<!---sh-->"><code> WALLS= ./prog</code></pre>
|
||||
<pre><code> WALLS= ./prog</code></pre>
|
||||
<p>Can you run into the wall since you didn’t specify a value and the default is 1?
|
||||
No. That’s not the way it works. By saying WALLS= you have told the system that
|
||||
there is that environmental variable. However the way the <code>strtoul()</code> functions
|
||||
@@ -381,12 +382,12 @@ it’s wasteful (iocccsize wise) and I have never felt that having invalid input
|
||||
for a number could have a better value than 0.</p>
|
||||
<p>If however you were to give valid input followed by invalid input the valid
|
||||
input would be parsed. For example:</p>
|
||||
<pre class="<!---sh-->"><code> WALLS=1test ./prog</code></pre>
|
||||
<pre><code> WALLS=1test ./prog</code></pre>
|
||||
<p>would let you go through the walls. On the other hand</p>
|
||||
<pre class="<!---sh-->"><code> WALLS=test1 ./prog</code></pre>
|
||||
<pre><code> WALLS=test1 ./prog</code></pre>
|
||||
<p>would not. Furthermore if you specify the same variable more than once it’s the
|
||||
last one that counts. For example:</p>
|
||||
<pre class="<!---sh-->"><code> WALLS=0 WALLS=1 CANNIBAL=1 CANNIBAL=0 ./prog</code></pre>
|
||||
<pre><code> WALLS=0 WALLS=1 CANNIBAL=1 CANNIBAL=0 ./prog</code></pre>
|
||||
<p>would allow you to go through walls but you could not cannibalise.</p>
|
||||
<p>Also note that I specify base 0 which means that you can also have it in hex and
|
||||
octal. These are all the same:</p>
|
||||
@@ -421,7 +422,7 @@ will end (yes things that haven’t begun can be ended).</p>
|
||||
<p>If <code>calloc()</code> fails to obtain the needed memory you’ll see something like (here it
|
||||
was before I added proper - to make the perfect and obvious pun - capsizing
|
||||
so that by setting the size to -1 it went to the max unsigned value):</p>
|
||||
<pre class="<!---sh-->"><code> $ MAXSIZE=-1 ./prog
|
||||
<pre><code> $ MAXSIZE=-1 ./prog
|
||||
memory error
|
||||
X:0/157 Y:0/42 S:3/18446744073709551614 B:0</code></pre>
|
||||
<p>BTW: There are two arrays that have to be <strong>MAXSIZE</strong> (technically + 1).</p>
|
||||
@@ -429,7 +430,7 @@ so that by setting the size to -1 it went to the max unsigned value):</p>
|
||||
not know but what I do know is that because it’s unsigned it can’t be negative;
|
||||
if the max size is 0 then the array size will be 1 but it won’t matter because
|
||||
the snake size will be >= that max anyway. But here’s a curious output:</p>
|
||||
<pre class="<!---sh-->"><code> SIZE=1 MAXSIZE=0 ./prog
|
||||
<pre><code> SIZE=1 MAXSIZE=0 ./prog
|
||||
YOU WIN!
|
||||
X:78/156 Y:20/41 S:0/0 B:0</code></pre>
|
||||
<p>Why does it show snake size as 0 when I specified 1? It’s because the max size
|
||||
|
||||
@@ -147,7 +147,7 @@
|
||||
},
|
||||
{
|
||||
"file_path" : "2020_ferguson2.tar.bz2",
|
||||
"inventory_order" : 100000,
|
||||
"inventory_order" : 1415926535,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "tbz2",
|
||||
"display_via_github" : false,
|
||||
|
||||
+26
-25
@@ -88,6 +88,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -141,12 +142,12 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<pre class="<!---sh-->"><code> make</code></pre>
|
||||
<pre><code> make</code></pre>
|
||||
<p>The author provided alternate code that prints the output one character at a
|
||||
time to make it a bit more like the real thing in that it isn’t dumped out all
|
||||
at once. See <a href="#alternate-code">Alternate code</a> below.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<pre class="<!---sh-->"><code> ./prog
|
||||
<pre><code> ./prog
|
||||
|
||||
# get recode help:
|
||||
./recode -h
|
||||
@@ -178,9 +179,9 @@ at once. See <a href="#alternate-code">Alternate code</a> below.</p>
|
||||
<p><strong>NOTE</strong>: in <a href="recode.c">recode</a> no spaces between options and option arguments
|
||||
are allowed.</p>
|
||||
<h2 id="try">Try:</h2>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<pre><code> ./try.sh</code></pre>
|
||||
<p>What does:</p>
|
||||
<pre class="<!---sh-->"><code> echo | ./recode
|
||||
<pre><code> echo | ./recode
|
||||
echo | ./recode -v</code></pre>
|
||||
<p>do?</p>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
@@ -188,15 +189,15 @@ are allowed.</p>
|
||||
after each character, so that one can read it more easily (for longer output)
|
||||
and to make it a bit more like the real thing.</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<pre class="<!---sh-->"><code> make alt</code></pre>
|
||||
<pre><code> make alt</code></pre>
|
||||
<p>The default time to sleep is 400000 microseconds but you can change this by
|
||||
doing:</p>
|
||||
<pre class="<!---sh-->"><code> make clobber SLEEP=600000 alt</code></pre>
|
||||
<pre><code> make clobber SLEEP=600000 alt</code></pre>
|
||||
<p>to change it to 600000 microseconds. It guards against negative numbers.</p>
|
||||
<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>
|
||||
<pre class="<!---sh-->"><code> ./try.alt.sh</code></pre>
|
||||
<pre><code> ./try.alt.sh</code></pre>
|
||||
<p>Notice how only the last part should use the <code>prog.alt</code>. Why? Try it and find
|
||||
out! Can you figure out why this works this way?</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
@@ -205,7 +206,7 @@ out! Can you figure out why this works this way?</p>
|
||||
<ul>
|
||||
<li><a href="enigma.1">enigma.1</a> - A useful man page for this entry. To render, try:</li>
|
||||
</ul>
|
||||
<pre class="<!---sh-->"><code> man ./enigma.1</code></pre>
|
||||
<pre><code> man ./enigma.1</code></pre>
|
||||
<ul>
|
||||
<li><a href="recode.html">recode.html</a> (or <a href="recode.html">recode.html</a> if reading on GitHub)
|
||||
<ul>
|
||||
@@ -317,7 +318,7 @@ leave this in for historical purposes.</p>
|
||||
for input (end with EOF). At that point it’ll process the input string and print
|
||||
the result (after finishing the enciphering).</p>
|
||||
<p>If you run it like:</p>
|
||||
<pre class="<!---sh-->"><code> ./prog -</code></pre>
|
||||
<pre><code> ./prog -</code></pre>
|
||||
<p>It will prompt you for the settings of the machine (example below).</p>
|
||||
<p>The first group is in the order of
|
||||
<a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm">rotor</a> (number),
|
||||
@@ -338,7 +339,7 @@ on GitHub see <a href="chocolate-cake.html">here</a>) though one might need a di
|
||||
of exercise after taking up the challenge! :-) These however show the general
|
||||
program as well as how to use the two winning entries of the <a href="https://en.wikipedia.org/wiki/Morse_code">Morse
|
||||
code</a> that I referred to earlier:</p>
|
||||
<pre class="<!---sh-->"><code> $ ./prog -
|
||||
<pre><code> $ ./prog -
|
||||
Ring 1: 3
|
||||
Setting 1: I
|
||||
Position 1: O
|
||||
@@ -366,39 +367,39 @@ code</a> that I referred to earlier:</p>
|
||||
<p>If I didn’t specify the <code>-</code> by e.g. <code>echo IOCCC | ./prog</code> then it will use the
|
||||
default settings; as the judges suggest this invocation I will not show it here.</p>
|
||||
<p>But you can also type it out like this:</p>
|
||||
<pre class="<!---sh-->"><code> $ ./prog
|
||||
<pre><code> $ ./prog
|
||||
IOCCC
|
||||
UUMMX</code></pre>
|
||||
<p>The IOCCC comes from stdin; the <code>UUMMX</code> is written to stdout.</p>
|
||||
<p>If I compile the 2014 entry and copy it to my local directory as
|
||||
<code>vik</code> I might do:</p>
|
||||
<pre class="<!---sh-->"><code> $ echo TEST|./prog |./vik | mplayer -demuxer rawaudio -</code></pre>
|
||||
<pre><code> $ echo TEST|./prog |./vik | mplayer -demuxer rawaudio -</code></pre>
|
||||
<p>And you would hear <a href="https://en.wikipedia.org/wiki/Morse_code">Morse code</a> of the
|
||||
<a href="https://www.ciphermachinesandcryptology.com/en/enigmatech.htm">Enigma</a> output
|
||||
of ‘TEST’ (i.e. <code>KCWV</code>)! Or perhaps not in this case. I’m not sure: I discovered
|
||||
a bug in that entry (Fedora, CentOS and macOS all affected).</p>
|
||||
<p>For example I can use the syntax provided in the winning remarks along with my
|
||||
entry to write it to a file. Say:</p>
|
||||
<pre class="<!---sh-->"><code> $ echo TEST|./prog |./vik > test.raw
|
||||
<pre><code> $ echo TEST|./prog |./vik > test.raw
|
||||
$ ./vik e < test.raw | ./prog
|
||||
LEST</code></pre>
|
||||
<p>Why did that happen? This shows more details:</p>
|
||||
<pre class="<!---sh-->"><code> $ ./vik e < test.raw
|
||||
<pre><code> $ ./vik e < test.raw
|
||||
SCWV</code></pre>
|
||||
<p>However as can be seen the first char is wrong:</p>
|
||||
<pre class="<!---sh-->"><code> $ echo TEST|./prog
|
||||
<pre><code> $ echo TEST|./prog
|
||||
KCWV</code></pre>
|
||||
<p>And piping the original output to my entry itself you get the original input:</p>
|
||||
<pre class="<!---sh-->"><code> $ echo TEST | ./prog | ./prog
|
||||
<pre><code> $ echo TEST | ./prog | ./prog
|
||||
TEST</code></pre>
|
||||
<p>I’m not sure what causes that or if there’s a way to fix it but that’s the
|
||||
idea anyway. Neither do I know if the original transcoding is correct.</p>
|
||||
<p>What if I use the input string <code>LEST</code> instead? In that case it worked fine:</p>
|
||||
<pre class="<!---sh-->"><code> $ echo LEST | ./prog | ./vik > lest.raw
|
||||
<pre><code> $ echo LEST | ./prog | ./vik > lest.raw
|
||||
$ ./vik e < lest.raw | ./prog
|
||||
LEST</code></pre>
|
||||
<p>But there’s one obvious question, right? Let’s try the most important one:</p>
|
||||
<pre class="<!---sh-->"><code> $ echo IOCCC | ./prog | ./vik > ioccc.raw
|
||||
<pre><code> $ echo IOCCC | ./prog | ./vik > ioccc.raw
|
||||
$ ./vik e < ioccc.raw
|
||||
UUMMX
|
||||
$ ./vik e < ioccc.raw | ./prog
|
||||
@@ -408,7 +409,7 @@ idea anyway. Neither do I know if the original transcoding is correct.</p>
|
||||
is with some of the things I pasted in the other file and maybe others here
|
||||
too. Notice also how it showed the same output that my program gave it - <code>UUMMX</code>.)</p>
|
||||
<p>What about the other <a href="../../1998/dorssel/dorssel.c">Morse code entry</a>?</p>
|
||||
<pre class="<!---sh-->"><code> $ echo IOCCC | ./prog | ./dorssel
|
||||
<pre><code> $ echo IOCCC | ./prog | ./dorssel
|
||||
..- ..- -- -- -..-</code></pre>
|
||||
<h3 id="the-recode.c-configurator"><a name="recode" href="#toc">The recode.c configurator</a></h3>
|
||||
<p>I have included a supplementary program <a href="recode.c">recode.c</a> that can do a number of
|
||||
@@ -440,7 +441,7 @@ make it more flexible by a wrapper program.</p>
|
||||
<p>The parser is in a sense rather rudimentary but allows for both interactive and
|
||||
automatic (e.g. via the <a href="recode.c">recode</a> program) input. This does mean that
|
||||
something like the following can happen:</p>
|
||||
<pre class="<!---sh-->"><code> $ ./prog -
|
||||
<pre><code> $ ./prog -
|
||||
Ring 1: 1AB
|
||||
Setting 1: Position 1: Ring 2: 2CD
|
||||
Setting 2: Position 2: Ring 3: 3
|
||||
@@ -493,7 +494,7 @@ GitHub).</p>
|
||||
should help you remember (though not at this time in our world it might help you
|
||||
later on?). This might become even more useful after the challenge is accepted,
|
||||
accomplished and made use of! :)</p>
|
||||
<pre class="<!---sh-->"><code> $ echo ABC | ./prog
|
||||
<pre><code> $ echo ABC | ./prog
|
||||
GYM
|
||||
$ echo ABC | ./prog | ./prog
|
||||
ABC</code></pre>
|
||||
@@ -516,7 +517,7 @@ which was exactly 75 years from the day that the person responsible for the
|
||||
<a href="https://en.wikipedia.org/wiki/World_War_II">Second World War</a>, Adolf Hitler,
|
||||
ended his life. (I later made a bug fix but I consider this inconsequential).</p>
|
||||
<p>As for <a href="recode.c">recode.c</a> though I really love this:</p>
|
||||
<pre class="<!---c-->"><code> /\
|
||||
<pre><code> /\
|
||||
/ This is *not* what you think:</code></pre>
|
||||
<p>…because it seems so wrong in C code at first glance. Also what does the
|
||||
‘this’ refer to?</p>
|
||||
@@ -524,9 +525,9 @@ ended his life. (I later made a bug fix but I consider this inconsequential).</p
|
||||
<p>It’s an <a href="https://en.wikipedia.org/wiki/Enigma_machine">Enigma machine</a> simulator! Isn’t
|
||||
that proof that it’s obfuscated itself?! :) Silliness aside <a href="obfuscation.txt">obfuscation.txt</a>
|
||||
has some of the ways I think this entry is obfuscated. To decipher try:</p>
|
||||
<pre class="<!---sh-->"><code> ./recode -Robfuscation.key -fobfuscation.txt | ./prog - 2>/dev/null > obfuscation.md</code></pre>
|
||||
<pre><code> ./recode -Robfuscation.key -fobfuscation.txt | ./prog - 2>/dev/null > obfuscation.md</code></pre>
|
||||
<p>To encipher:</p>
|
||||
<pre class="<!---sh-->"><code> ./recode -Robfuscation.key -fobfuscation.md | ./prog - 2>/dev/null > obfuscation.txt</code></pre>
|
||||
<pre><code> ./recode -Robfuscation.key -fobfuscation.md | ./prog - 2>/dev/null > obfuscation.txt</code></pre>
|
||||
<p>The file <a href="obfuscation.key">obfuscation.key</a> is the key to decipher/encipher
|
||||
<a href="obfuscation.txt">obfuscation.txt</a>.</p>
|
||||
<p>For the lazy <a href="obfuscation.html">obfuscation.html</a> has the deciphered version. I am afraid I’m not
|
||||
@@ -832,10 +833,10 @@ email but I’m more likely to respond to mastodon messages.</p>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/key.txt">key.txt</a> - key to decipher or encipher IOCCC</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/obfuscation.key">obfuscation.key</a> - key to decipher or encipher obfuscation.txt</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/recode.1">recode.1</a> - configuration tool man page</li>
|
||||
<li><a href="2020_ferguson2.tar.bz2">2020_ferguson2.tar.bz2</a> - download entry tarball</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
<li><a href="2020_ferguson2.tar.bz2">2020_ferguson2.tar.bz2</a> - download entry tarball</li>
|
||||
<li><a href="index.html">index.html</a> - this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/README.md">README.md</a> - markdown source for this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/ferguson2/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -140,9 +141,9 @@ there is an aesthetic appeal to my eyes too).</p></li>
|
||||
Y<:19:><:27:> but it’s not the only example. Here the compound literal of 13
|
||||
ints:</p></li>
|
||||
</ul>
|
||||
<pre class="<!---c-->"><code> int *z=(int[13]) { 0 } , *e, *g;</code></pre>
|
||||
<pre><code> int *z=(int[13]) { 0 } , *e, *g;</code></pre>
|
||||
<p>Then in main:</p>
|
||||
<pre class="<!---c-->"><code> e = z + 10;
|
||||
<pre><code> e = z + 10;
|
||||
g = e + 1;
|
||||
|
||||
for (j=-3; j < 0; ++j)
|
||||
@@ -152,12 +153,12 @@ expect to start out with index < 0 but to then compare that that index < 0
|
||||
and increment until 0 along with setting the value of the array to j + 3 is
|
||||
more confusing still. There are at least two other ways that are much easier
|
||||
to read that could accomplish the same thing. It continues on:</p>
|
||||
<pre class="<!---c-->"><code> /* ... */
|
||||
<pre><code> /* ... */
|
||||
e<:i-3:> = (j < 1 ? 1 : (j > 5 ? 5 : j))-1;</code></pre>
|
||||
<ul>
|
||||
<li>Observe these two functions:</li>
|
||||
</ul>
|
||||
<pre class="<!---c-->"><code> void w(char *s, int k, int v)
|
||||
<pre><code> void w(char *s, int k, int v)
|
||||
{
|
||||
for(e<:2:> = 0; s<:*P:>; ++e<:2:>)
|
||||
{
|
||||
@@ -200,7 +201,7 @@ temporary variable instead of a regular int in the function (so make it global);
|
||||
and (2) I didn’t want to risk changing all the offsets: thus I just made that
|
||||
address <code>e[1]</code>. Thus I also have:</li>
|
||||
</ul>
|
||||
<pre class="<!---c-->"><code> for (*g = 0 ; *g < 10; ++*g)
|
||||
<pre><code> for (*g = 0 ; *g < 10; ++*g)
|
||||
{
|
||||
r<:-2:> = Y<:14:><:*(e+1):>; r<:-3:> = Y<:15:><:1<:e:>:>;
|
||||
if (r<:-3:> && r<:-2:> == r<:-1:>)
|
||||
@@ -218,7 +219,7 @@ which I use as the two chars to compare (this is the plugboard function).</p>
|
||||
<li>The above function Z() takes a <code>char x</code> but you won’t notice it being used
|
||||
at all. Why? In fact I call it like so:</li>
|
||||
</ul>
|
||||
<pre class="<!---c-->"><code> k = Z(r<:-1:>=k);</code></pre>
|
||||
<pre><code> k = Z(r<:-1:>=k);</code></pre>
|
||||
<p>The char is just used as a way to be able to call the function and assign to
|
||||
the proper variable at the same time: in the function Z I don’t care about x
|
||||
because it’s the same value as r[-1] (which I do care about). Why is it
|
||||
@@ -230,7 +231,7 @@ again negative offsets to cause more confusion.</p>
|
||||
refer to the same variable in more than one way (or in some cases maybe more
|
||||
correct to say ‘same location’). In the Z() function for example:</li>
|
||||
</ul>
|
||||
<pre class="<!---c-->"><code> r<:-2:> = Y<:14:><:*(e+1):>; r<:-3:> = Y<:15:><:1<:e:>:>;</code></pre>
|
||||
<pre><code> r<:-2:> = Y<:14:><:*(e+1):>; r<:-3:> = Y<:15:><:1<:e:>:>;</code></pre>
|
||||
<p>I refer to e[1] as both: *(e+1) and 1[e].</p>
|
||||
<ul>
|
||||
<li><p>Replacing a number of <code>if ..</code>s with <code>... && (...)</code>s (in one case at least
|
||||
@@ -245,7 +246,7 @@ index (sort of).</p></li>
|
||||
<li><p>Another set of char arrays in one: the five rotors as well as the two
|
||||
reflectors in one <code>char [][27]</code>. This makes for some fun code like:</p></li>
|
||||
</ul>
|
||||
<pre class="<!---c-->"><code> (Y<:e<:-10:>+5:><:k-'A':>) && (k = Y<:e<:-10:>+5:><:k-'A':>);</code></pre>
|
||||
<pre><code> (Y<:e<:-10:>+5:><:k-'A':>) && (k = Y<:e<:-10:>+5:><:k-'A':>);</code></pre>
|
||||
<p>(Of course this also removes an if statement by joining with a &&).</p>
|
||||
<ul>
|
||||
<li><p>In fact I decided that the above two arrays in arrays needed to be merged
|
||||
@@ -275,18 +276,18 @@ enough because as they rightly point out they can just use the C preprocessor
|
||||
itself. But although I have quite a few cpp directives I am not using them for
|
||||
obfuscation but rather to save bytes. For examples:</p></li>
|
||||
</ul>
|
||||
<pre class="<!---c-->"><code> %:define J(x) do(*x)=getchar(); while((*x)=='\n')</code></pre>
|
||||
<pre><code> %:define J(x) do(*x)=getchar(); while((*x)=='\n')</code></pre>
|
||||
<p>Is used quite a number of times and although it could be a function that
|
||||
takes a pointer to an int it was more convenient this way (I believe it used
|
||||
more bytes but I no longer know that). There are many others and they all
|
||||
save bytes (or at least most of them do if not all). There is one in
|
||||
particular I want to bring up though because I think it’s a curious one and
|
||||
it ties in to another point above:</p>
|
||||
<pre class="<!---c-->"><code> %:define A(y) *(&Y<:7:><:1:>+(y))</code></pre>
|
||||
<pre><code> %:define A(y) *(&Y<:7:><:1:>+(y))</code></pre>
|
||||
<p>What is special about this one: Above I noted how I sort of refer directly
|
||||
to the notch settings (I think it was the notch settings anyway). Now I
|
||||
could have done say</p>
|
||||
<pre class="<!---c-->"><code> char a = Y[7][1], b = Y[7][3], c = Y[7][5];</code></pre>
|
||||
<pre><code> char a = Y[7][1], b = Y[7][3], c = Y[7][5];</code></pre>
|
||||
<p>But I felt that doing instead the pointer arithmetic was worth doing.
|
||||
However it used significantly more bytes even as a macro: 17 if I recall
|
||||
right. That’s with the macro. If I were to include it three times by itself
|
||||
@@ -314,7 +315,7 @@ differently (and separated) so that one cannot easily replace the <code>char</co
|
||||
variables in recode.c, move them to prog.c, compile and expect it to work right.</p></li>
|
||||
<li><p>Also what is this about ?</p></li>
|
||||
</ul>
|
||||
<pre class="<!---c-->"><code> /\
|
||||
<pre><code> /\
|
||||
/ This is *not* what you think:
|
||||
void D(char*x){ /* ... */ }</code></pre>
|
||||
<p>Is that valid and if so how does it function? Yes it’s valid but I’ll leave
|
||||
|
||||
+22
-21
@@ -83,6 +83,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -170,7 +171,7 @@ with the Roman numeral, showing their actual orders etc.), the reflectors
|
||||
<p>In this file I will show an example of each feature and then get to the
|
||||
wonderful ‘challenge’ for everyone.</p>
|
||||
<h1 id="options"><a name="options" href="#toc">Options</a></h1>
|
||||
<pre class="<!---sh-->"><code> ./recode -h
|
||||
<pre><code> ./recode -h
|
||||
usage: ./recode [options]
|
||||
-v display selected settings
|
||||
-r pseudo-randomly select settings
|
||||
@@ -180,7 +181,7 @@ wonderful ‘challenge’ for everyone.</p>
|
||||
<p><code>-r</code> randomises settings. It won’t prompt you for settings but it will for input
|
||||
if you don’t give the option to read in a file for input.</p>
|
||||
<p><code>-v</code> shows selected settings. For example combining <code>-r</code> and <code>-v</code>:</p>
|
||||
<pre class="<!---sh-->"><code> $ echo IOCCC | ./recode -r -v
|
||||
<pre><code> $ echo IOCCC | ./recode -r -v
|
||||
Ring 1: ( I) EKMFLGDQVZNTOWYHXUSPAIBRCJ
|
||||
Ring 2: ( V) VZBRGITYUPSDNHLXAWMJQOFECK
|
||||
Ring 3: ( IV) ESOVPZJAYQUIRHXLNFTGKDCMWB
|
||||
@@ -207,7 +208,7 @@ encipherment/decipherment). If the file cannot be opened it sets back to stdin.<
|
||||
<p><code>-o</code> outputs the settings to the file. If the file cannot be opened for writing
|
||||
or is the same file name (see below) then only stdout will be used. Example of
|
||||
randomised output going to a file:</p>
|
||||
<pre class="<!---sh-->"><code> $ ./recode -r -oconfig
|
||||
<pre><code> $ ./recode -r -oconfig
|
||||
IOCCC
|
||||
3PP4UB5GG1ELGTKFCOPVBNUYXJAWSDIOCCC
|
||||
$ cat config
|
||||
@@ -236,7 +237,7 @@ what about if one exists but the other does not?</p>
|
||||
<h2 id="file-options-parser-limitation"><a name="fileoptions" href="#toc">File options parser limitation</a></h2>
|
||||
<p>Due to the way the parsing of options is done (no spaces between option char and
|
||||
argument) shell expansion will not work right so for example doing:</p>
|
||||
<pre class="<!---sh-->"><code> $ ./recode -R~/config</code></pre>
|
||||
<pre><code> $ ./recode -R~/config</code></pre>
|
||||
<p>will <em>not</em> read the file ‘config’ in the home directory. I show another way to
|
||||
achieve this later.</p>
|
||||
<p>This limitation also applies to the <code>-f</code> and <code>-o</code> options!</p>
|
||||
@@ -246,7 +247,7 @@ the program interactively.</p>
|
||||
<h1 id="piping-commands-to-recode"><a name="pipingtorecode" href="#toc">Piping commands to recode</a></h1>
|
||||
<p>If stdin is not a tty (<code>!isatty(0)</code>) and neither randomised mode nor reading in
|
||||
from a file is specified then you might just see something like:</p>
|
||||
<pre class="<!---sh-->"><code> $ echo testing test tests | ./recode
|
||||
<pre><code> $ echo testing test tests | ./recode
|
||||
1AB2BB3CC1testing test tests
|
||||
|
||||
$ echo testing test tests | ./recode | ./prog - 2>/dev/null
|
||||
@@ -265,7 +266,7 @@ job at this anyway).</p>
|
||||
input manually (if you randomise or read in from previously saved file no input
|
||||
need be done at all) then make sure to redirect stderr to /dev/null. If you
|
||||
don’t you might see something like:</p>
|
||||
<pre class="<!---sh-->"><code> $ ./recode -r | ./prog -
|
||||
<pre><code> $ ./recode -r | ./prog -
|
||||
Ring 1: IOCCC
|
||||
Setting 1: Position 1: Ring 2: Setting 2: Position 2: Ring 3: Setting 3: Position 3: Reflector: Plugboard pair 1: Plugboard pair 2: Plugboard pair 3: Plugboard pair 4: Plugboard pair 5: Plugboard pair 6: Plugboard pair 7: Plugboard pair 8: Plugboard pair 9: Plugboard pair 10: DEVIY</code></pre>
|
||||
<p>What happened is that <code>Ring 1:</code> is printed to stderr but since it’s not been
|
||||
@@ -274,7 +275,7 @@ input. Why or how it shows the first prompt instead of later on I do not know.
|
||||
Anyway at this point the simulator is already expecting input to en/decipher.
|
||||
That’s why after I sent EOF it printed out the remaining strings to stderr.</p>
|
||||
<h1 id="manually-test-the-recode-program-with-the-enigma-program"><a name="manuallytest" href="#toc">Manually test the recode program with the Enigma program</a></h1>
|
||||
<pre class="<!---sh-->"><code> $ cat input
|
||||
<pre><code> $ cat input
|
||||
IOCCC
|
||||
|
||||
$ ./recode -finput
|
||||
@@ -314,7 +315,7 @@ a number of ways but two dots is one. Notice also that it’s in a different ord
|
||||
than the simulator: because with the size restrictions on my entry I saved bytes
|
||||
by using the same loop where I could. It just felt more natural to have them
|
||||
grouped together in a configurator for the <a href="prog.c">simulator</a>.</p>
|
||||
<pre class="<!---sh-->"><code> $ echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC | ./prog - 2>/dev/null
|
||||
<pre><code> $ echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC | ./prog - 2>/dev/null
|
||||
HQNVO
|
||||
$ echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRIOCCC | ./prog - 2>/dev/null | echo 1AA2AA3AA2ABCD..EFGHIJKLMNOPQRHQNVO | ./prog - 2>/dev/null
|
||||
IOCCC</code></pre>
|
||||
@@ -330,13 +331,13 @@ part again; I could have just done the latter part but I wanted to show the way
|
||||
the pipeline works with settings etc.</p>
|
||||
<p>What happens if the plugboard pairs are the same but in a different order? It’s
|
||||
the same output:</p>
|
||||
<pre class="<!---sh-->"><code> $ echo 1AA2AA3AA2AB..CDEFGHIJKLMNOPQRIOCCC|./prog - 2>/dev/null
|
||||
<pre><code> $ echo 1AA2AA3AA2AB..CDEFGHIJKLMNOPQRIOCCC|./prog - 2>/dev/null
|
||||
HQNVO</code></pre>
|
||||
<p>Also if you flip the order of the letters in the pair e.g. the AB as BA instead:</p>
|
||||
<pre class="<!---sh-->"><code> $ echo 1AA2AA3AA2BA..CDEFGHIJKLMNOPQRIOCCC|./prog - 2>/dev/null
|
||||
<pre><code> $ echo 1AA2AA3AA2BA..CDEFGHIJKLMNOPQRIOCCC|./prog - 2>/dev/null
|
||||
HQNVO</code></pre>
|
||||
<h1 id="only-write-config-file"><a name="onlyconfig" href="#toc">Only write config file</a></h1>
|
||||
<pre class="<!---sh-->"><code> $ ./recode -v -oconfig -finput >/dev/null
|
||||
<pre><code> $ ./recode -v -oconfig -finput >/dev/null
|
||||
Rotors:
|
||||
(1) I: EKMFLGDQVZNTOWYHXUSPAIBRCJ
|
||||
(2) II: AJDKSIRUXBLHWTMCQGZNPYFVOE
|
||||
@@ -389,7 +390,7 @@ and it didn’t report an error. Neither did it complain about <code>IJ</code> i
|
||||
pair. This is because it consumes input overflow.</p>
|
||||
<p>It shouldn’t be this way for the simulator though because that could cause
|
||||
inconsistent number of characters expected before the text to encipher.</p>
|
||||
<pre class="<!---sh-->"><code> $ cat config
|
||||
<pre><code> $ cat config
|
||||
1AB2CD3EF2ABCDEFGHIJKLMNOPQRST
|
||||
|
||||
$ ( cat config ; cat input ) | ./prog - 2>/dev/null
|
||||
@@ -402,7 +403,7 @@ settings written? You can do that too by either sending a newline or else
|
||||
directly type ctrl-d (or whatever you have EOF set to) or give it an empty file.</p>
|
||||
<p>The following are all equivalent in that they will write to a settings file (the
|
||||
first one will print a newline with the echo but that won’t matter):</p>
|
||||
<pre class="<!---sh-->"><code> $ echo | ./recode -r -osettings
|
||||
<pre><code> $ echo | ./recode -r -osettings
|
||||
$ echo -n | ./recode -r -osettings
|
||||
$ > empty
|
||||
$ ./recode -r -osettings < empty
|
||||
@@ -414,7 +415,7 @@ the buffer remains <code>NULL</code> and so I don’t print it but still do prin
|
||||
file. (Actually even if <code>getdelim()</code> fails you’re supposed to free the buffer so I
|
||||
set another variable to indicate if it should be printed.)</p>
|
||||
<h1 id="reusing-a-configuration"><a name="reuseconfig" href="#toc">Reusing a configuration</a></h1>
|
||||
<pre class="<!---sh-->"><code> $ echo -n|./recode -r -oconfig
|
||||
<pre><code> $ echo -n|./recode -r -oconfig
|
||||
4UH5II1RJ1SPIFEJLYGZWRTBHVCAMN$
|
||||
|
||||
$ cat input.txt
|
||||
@@ -435,7 +436,7 @@ set another variable to indicate if it should be printed.)</p>
|
||||
$ diff io input.txt
|
||||
$</code></pre>
|
||||
<p>Alternatively you can just use the <code>-R</code> and <code>-f</code> options:</p>
|
||||
<pre class="<!---sh-->"><code> $ ./recode -finput.txt -Rconfig | ./prog - 2>/dev/null > output2
|
||||
<pre><code> $ ./recode -finput.txt -Rconfig | ./prog - 2>/dev/null > output2
|
||||
$ diff output output2
|
||||
$</code></pre>
|
||||
<h1 id="write-config-file-read-data-file-and-pass-to-enigma-simulator"><a name="passtoenigma" href="#toc">Write config file, read data file and pass to Enigma simulator</a></h1>
|
||||
@@ -476,7 +477,7 @@ set another variable to indicate if it should be printed.)</p>
|
||||
Cody?) there’s also a reference to code which I also love (just as all
|
||||
participants of the IOCCC do). Other things there don’t mean anything but what
|
||||
does is the output:</p>
|
||||
<pre class="<!---sh-->"><code> $ cat output
|
||||
<pre><code> $ cat output
|
||||
DBFAF 2020 Ittejg ltblwriac uqdfqvr dhqh ghhf
|
||||
|
||||
Jsjy ce v pxdmullo.
|
||||
@@ -491,21 +492,21 @@ does is the output:</p>
|
||||
This is another sentence.</code></pre>
|
||||
<h1 id="piping-directly-to-the-enigma-code-once-with-randomised-settings-saved"><a name="directlytoenigma" href="#toc">Piping directly to the Enigma code once (with randomised settings, saved)</a></h1>
|
||||
<p>This is like the above only randomised:</p>
|
||||
<pre class="<!---sh-->"><code> $ ./recode -r -oconfig|./prog - 2>/dev/null
|
||||
<pre><code> $ ./recode -r -oconfig|./prog - 2>/dev/null
|
||||
IOCCC
|
||||
UGEVP</code></pre>
|
||||
<p>Note that I typed in <code>IOCCC</code> and sent <code>EOF</code> (ctrl-d); the settings were written to
|
||||
the config file (for deciphering later) and then all of it was piped to the
|
||||
Enigma entry resulting in the line below IOCCC. But let’s verify it worked out
|
||||
okay:</p>
|
||||
<pre class="<!---sh-->"><code> $ cat config
|
||||
<pre><code> $ cat config
|
||||
2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ</code></pre>
|
||||
<p>Without having to copy/paste intermediate results:</p>
|
||||
<pre class="<!---sh-->"><code> $ echo IOCCC | ./recode -Rconfig | ./prog - 2>/dev/null | ./recode -Rconfig | ./prog - 2>/dev/null
|
||||
<pre><code> $ echo IOCCC | ./recode -Rconfig | ./prog - 2>/dev/null | ./recode -Rconfig | ./prog - 2>/dev/null
|
||||
IOCCC</code></pre>
|
||||
<p>You can also use a string for the <code>-R</code> option. I’ll use command substitution and
|
||||
actual pasting to demonstrate:</p>
|
||||
<pre class="<!---sh-->"><code> $ echo IOCCC | ./recode -R$(cat config) | ./prog - 2>/dev/null | ./recode -R2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ | ./prog - 2>/dev/null
|
||||
<pre><code> $ echo IOCCC | ./recode -R$(cat config) | ./prog - 2>/dev/null | ./recode -R2BM4GJ3HK1LNCBXWRMGKSYIAZUTPVJ | ./prog - 2>/dev/null
|
||||
IOCCC</code></pre>
|
||||
<h1 id="usage-conclusion"><a name="conclusion" href="#toc">Usage conclusion</a></h1>
|
||||
<p>That should give you an idea of how to use the <code>recode</code> program. I leave it as
|
||||
@@ -585,7 +586,7 @@ think that I would give too much away? :)</p>
|
||||
the key you wish to select is</p>
|
||||
<pre><code> 0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI</code></pre>
|
||||
<p>you can do:</p>
|
||||
<pre class="<!---sh-->"><code> ./recode -R0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI -fencrypted.html | ./prog - 2>/dev/null > decrypted.html</code></pre>
|
||||
<pre><code> ./recode -R0EZ4PC1CC0PGTAQSOXWNMDRYKFUZEI -fencrypted.html | ./prog - 2>/dev/null > decrypted.html</code></pre>
|
||||
<p>Then open <code>decrypted.html</code> in your browser.</p>
|
||||
<!--
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
},
|
||||
{
|
||||
"file_path" : "2020_giles.tar.bz2",
|
||||
"inventory_order" : 100000,
|
||||
"inventory_order" : 1415926535,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "tbz2",
|
||||
"display_via_github" : false,
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -141,13 +142,13 @@ Location: <a href="../../location.html#AU">AU</a> - <em>Commonwealth of Australi
|
||||
<!-- 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>
|
||||
<pre class="<!---sh-->"><code> make</code></pre>
|
||||
<pre><code> make</code></pre>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<p>For more detailed information see <a href="../../bugs.html#2020_giles">2020 giles bugs</a>.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<pre class="<!---sh-->"><code> ./prog < dtmf.wav
|
||||
<pre><code> ./prog < dtmf.wav
|
||||
|
||||
./prog [digits] > digits.wav</code></pre>
|
||||
<p>where <code>dtmf.wav</code> is a WAV file of the dialling of a number being dialled with
|
||||
@@ -156,7 +157,7 @@ frequency)</a>
|
||||
(more commonly known as Touch-Tone) and <code>[digits]</code> is a sequence of digits that
|
||||
will be converted to the DTMF sound!</p>
|
||||
<h2 id="try">Try:</h2>
|
||||
<pre class="<!---sh-->"><code> ./try.sh
|
||||
<pre><code> ./try.sh
|
||||
./prog < pi.wav
|
||||
|
||||
# See
|
||||
@@ -180,12 +181,12 @@ standard input, decode the touch-tones in the file, and output the corresponding
|
||||
digits to standard output. This program only supports WAV files that have
|
||||
exactly 16 bits per sample, but it allows any sample rate and any number of
|
||||
audio channels.</p>
|
||||
<pre class="<!---sh-->"><code> $ ./prog < pi.wav
|
||||
<pre><code> $ ./prog < pi.wav
|
||||
31415926</code></pre>
|
||||
<p>If the program is executed with a command-line argument, it will generate the
|
||||
tones corresponding to the specified characters, writing them to standard output
|
||||
as a WAV file.</p>
|
||||
<pre class="<!---sh-->"><code> $ ./prog 867-5309 | aplay</code></pre>
|
||||
<pre><code> $ ./prog 867-5309 | aplay</code></pre>
|
||||
<h3 id="interesting-features">Interesting Features</h3>
|
||||
<ul>
|
||||
<li>When compiled with <code>gcc -pedantic -Wall -Wextra</code> there are no compiler
|
||||
@@ -287,10 +288,10 @@ single pure sine wave.</p>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/giles/prog.orig.c">prog.orig.c</a> - original source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/giles/try.sh">try.sh</a> - how to run</li>
|
||||
<li><a href="pi.wav">pi.wav</a> - touch tone for leading decimal digits of pi</li>
|
||||
<li><a href="2020_giles.tar.bz2">2020_giles.tar.bz2</a> - download entry tarball</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
<li><a href="2020_giles.tar.bz2">2020_giles.tar.bz2</a> - download entry tarball</li>
|
||||
<li><a href="index.html">index.html</a> - this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/giles/README.md">README.md</a> - markdown source for this web page</li>
|
||||
<li><a href="dtmf.bin">dtmf.bin</a> - binary support file</li>
|
||||
|
||||
@@ -86,6 +86,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../news.html">IOCCC News</a>
|
||||
<a href="../status.html">Contest status</a>
|
||||
<a href="../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../faq.html">FAQ</a>
|
||||
</div>
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
},
|
||||
{
|
||||
"file_path" : "2020_kurdyukov1.tar.bz2",
|
||||
"inventory_order" : 100000,
|
||||
"inventory_order" : 1415926535,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "tbz2",
|
||||
"display_via_github" : false,
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -141,18 +142,18 @@ Location: <a href="../../location.html#RU">RU</a> - <em>Russian Federation</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>
|
||||
<pre class="<!---sh-->"><code> make</code></pre>
|
||||
<pre><code> make</code></pre>
|
||||
<p>There are alternate versions of this entry. See <a href="#alternate-code">Alternate
|
||||
code</a> below for more details.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<pre class="<!---sh-->"><code> ./prog
|
||||
<pre><code> ./prog
|
||||
# input some text
|
||||
|
||||
echo text | ./prog
|
||||
|
||||
./prog < file</code></pre>
|
||||
<h2 id="try">Try:</h2>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<pre><code> ./try.sh</code></pre>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<p>There are a number of alternate versions for this program, some in C and some in
|
||||
assembly.</p>
|
||||
@@ -164,7 +165,7 @@ different social media profile covers as well as different shapes.</p>
|
||||
are the program in assembly for x86_64 linux and x86 linux respectively.</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<p>To build <a href="prog.alt.c">prog.alt.c</a>:</p>
|
||||
<pre class="<!---sh-->"><code> make alt</code></pre>
|
||||
<pre><code> make alt</code></pre>
|
||||
<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>
|
||||
@@ -244,10 +245,10 @@ the binary code is larger due to fewer registers and lack of 64-bit multiply.</l
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov1/prog.extra.c">prog.extra.c</a> - variant of entry source with sine function</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov1/prog.x86_64.asm">prog.x86_64.asm</a> - assembly source code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov1/prog.x86.asm">prog.x86.asm</a> - assembly source code</li>
|
||||
<li><a href="2020_kurdyukov1.tar.bz2">2020_kurdyukov1.tar.bz2</a> - download entry tarball</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
<li><a href="2020_kurdyukov1.tar.bz2">2020_kurdyukov1.tar.bz2</a> - download entry tarball</li>
|
||||
<li><a href="index.html">index.html</a> - this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov1/README.md">README.md</a> - markdown source for this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov1/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
},
|
||||
{
|
||||
"file_path" : "2020_kurdyukov2.tar.bz2",
|
||||
"inventory_order" : 100000,
|
||||
"inventory_order" : 1415926535,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "tbz2",
|
||||
"display_via_github" : false,
|
||||
|
||||
+15
-14
@@ -88,6 +88,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -141,11 +142,11 @@ Location: <a href="../../location.html#RU">RU</a> - <em>Russian Federation</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>
|
||||
<pre class="<!---sh-->"><code> make</code></pre>
|
||||
<pre><code> make</code></pre>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<pre class="<!---sh-->"><code> ./prog</code></pre>
|
||||
<pre><code> ./prog</code></pre>
|
||||
<h2 id="try">Try:</h2>
|
||||
<pre class="<!---sh-->"><code> # Take a selfie
|
||||
<pre><code> # Take a selfie
|
||||
./prog 1000 selfie.jpg output.jpg
|
||||
# Admire your portrait in cubist style
|
||||
|
||||
@@ -161,7 +162,7 @@ rectangles. What is the complexity? Is it obvious from the source code?</p>
|
||||
<p>This program divides the image into a specified number of rectangles. This
|
||||
process is content aware, so the algorithm tries to match most of the information.
|
||||
However, it doesn’t find the best theoretically possible layout.</p>
|
||||
<pre class="<!---sh-->"><code> ./prog 1000 input.jpg output.jpg</code></pre>
|
||||
<pre><code> ./prog 1000 input.jpg output.jpg</code></pre>
|
||||
<h3 id="building">Building</h3>
|
||||
<p>You can build three versions, depending on the image format.</p>
|
||||
<p>Default is JPEG version; if you have the <code>libjpeg</code> development package installed
|
||||
@@ -169,9 +170,9 @@ in your system, then <code>make</code> without arguments should do the right thi
|
||||
<p>If you want to use <code>libjpeg</code> compiled from sources, then use the <code>LIBJPEG</code> define to
|
||||
specify the path to includes and the library. For example using
|
||||
<a href="https://mac-dev-env.patrickbougie.com/libjpeg/">libjpeg source</a> version 9c:</p>
|
||||
<pre class="<!---sh-->"><code> make prog LIBJPEG="-Ijpeg-9c jpeg-9c/libjpeg.a"</code></pre>
|
||||
<pre><code> make prog LIBJPEG="-Ijpeg-9c jpeg-9c/libjpeg.a"</code></pre>
|
||||
<p>Use this command to build a PNG version (you need <code>libpng</code>):</p>
|
||||
<pre class="<!---sh-->"><code> make prog_png LIBPNG="-lpng"</code></pre>
|
||||
<pre><code> make prog_png LIBPNG="-lpng"</code></pre>
|
||||
<p>And the PPM version (no additional dependencies, can read raw/ASCII PPM, writes
|
||||
raw PPM):</p>
|
||||
<pre><code> make prog_ppm</code></pre>
|
||||
@@ -179,22 +180,22 @@ raw PPM):</p>
|
||||
<p>Thanks to <a href="../../authors.html#Cody_Boone_Ferguson">Cody Boone Ferguson</a> for this
|
||||
information!</p>
|
||||
<p>First, make sure you have the compiler tools installed e.g. by:</p>
|
||||
<pre class="<!---sh-->"><code> sudo xcode-select --install</code></pre>
|
||||
<pre><code> sudo xcode-select --install</code></pre>
|
||||
<p>Make sure you install <a href="https://www.macports.org/install.php">MacPorts</a>. Then do:</p>
|
||||
<pre class="<!---sh-->"><code> sudo port install jpeg libpng ImageMagick</code></pre>
|
||||
<pre><code> sudo port install jpeg libpng ImageMagick</code></pre>
|
||||
<p>The program itself doesn’t need ImageMagick, install it only if you plan to make
|
||||
GIFs from the results using <code>makegif.sh</code>.</p>
|
||||
<p>After that’s installed you need to run make with these options:</p>
|
||||
<pre class="<!---sh-->"><code> make LDFLAGS="-I/opt/local/include -L/opt/local/lib"</code></pre>
|
||||
<pre><code> make LDFLAGS="-I/opt/local/include -L/opt/local/lib"</code></pre>
|
||||
<h3 id="building-on-macos-with-homebrew">Building on macOS with Homebrew</h3>
|
||||
<p>First, make sure you have the compiler tools installed e.g. by:</p>
|
||||
<pre class="<!---sh-->"><code> sudo xcode-select --install</code></pre>
|
||||
<pre><code> sudo xcode-select --install</code></pre>
|
||||
<p>Make sure you install <a href="https://brew.sh">Homebrew</a>.</p>
|
||||
<p>Then:</p>
|
||||
<pre class="<!---sh-->"><code> brew install libjpeg libpng
|
||||
<pre><code> brew install libjpeg libpng
|
||||
eval "$(brew shellenv)"</code></pre>
|
||||
<p>You are now ready to compile this entry:</p>
|
||||
<pre class="<!---sh-->"><code> make clobber all</code></pre>
|
||||
<pre><code> make clobber all</code></pre>
|
||||
<h3 id="notes">Notes</h3>
|
||||
<p>Made this thing while experimenting with the idea of representing an image with
|
||||
rectangles (lossy compression). It’s not very good in that sense, but the
|
||||
@@ -206,7 +207,7 @@ the picture data is split (halves may have different size) horizontally or
|
||||
vertically to get the minimum difference.</p>
|
||||
<p>You can use this command to make a GIF from output images (uses ImageMagick).
|
||||
For instance after running the command suggested by the judges:</p>
|
||||
<pre class="<!---sh-->"><code> convert -delay 10 -dither none -loop 0 $(find . -maxdepth 1 -type f -name '*jpg' | sort -V) $(find . -maxdepth 1 -type f -name '*jpg' | sort -rV) +map out.gif</code></pre>
|
||||
<pre><code> convert -delay 10 -dither none -loop 0 $(find . -maxdepth 1 -type f -name '*jpg' | sort -V) $(find . -maxdepth 1 -type f -name '*jpg' | sort -rV) +map out.gif</code></pre>
|
||||
<p>NOTE: the above is done in the <a href="try.sh">try.sh</a> script.</p>
|
||||
<p>Also provided <code>makegif.sh</code> to aid with GIF creation.</p>
|
||||
<!--
|
||||
@@ -240,10 +241,10 @@ For instance after running the command suggested by the judges:</p>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov2/prog.png.c">prog.png.c</a> - build a PNG version</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov2/prog.ppm.c">prog.ppm.c</a> - build a PPM version</li>
|
||||
<li><a href="sample.jpg">sample.jpg</a> - sample image data</li>
|
||||
<li><a href="2020_kurdyukov2.tar.bz2">2020_kurdyukov2.tar.bz2</a> - download entry tarball</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
<li><a href="2020_kurdyukov2.tar.bz2">2020_kurdyukov2.tar.bz2</a> - download entry tarball</li>
|
||||
<li><a href="index.html">index.html</a> - this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov2/README.md">README.md</a> - markdown source for this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov2/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
},
|
||||
{
|
||||
"file_path" : "2020_kurdyukov3.tar.bz2",
|
||||
"inventory_order" : 100000,
|
||||
"inventory_order" : 1415926535,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "tbz2",
|
||||
"display_via_github" : false,
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -141,17 +142,17 @@ Location: <a href="../../location.html#RU">RU</a> - <em>Russian Federation</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>
|
||||
<pre class="<!---sh-->"><code> make</code></pre>
|
||||
<pre><code> make</code></pre>
|
||||
<p>There is an alternate version of this program. See <a href="#alternate-code">Alternate
|
||||
code</a> below.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<pre class="<!---sh-->"><code> ./prog</code></pre>
|
||||
<pre><code> ./prog</code></pre>
|
||||
<h2 id="try">Try:</h2>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<pre><code> ./try.sh</code></pre>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<p>The alternate version, <a href="prog.alt.c">prog.alt.c</a>, has the main code as a macro.</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<pre class="<!---sh-->"><code> make alt</code></pre>
|
||||
<pre><code> make alt</code></pre>
|
||||
<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>
|
||||
@@ -169,7 +170,7 @@ exactly what it says nonetheless.</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<h3 id="letter-mixer">Letter Mixer</h3>
|
||||
<p>Compile and try this:</p>
|
||||
<pre class="<!---sh-->"><code> cat input.txt | ./prog</code></pre>
|
||||
<pre><code> cat input.txt | ./prog</code></pre>
|
||||
<p>The program can work with letters that are not represented in English, as long
|
||||
as these letters are encoded in the higher part of the single-byte character set
|
||||
(use <code>iconv</code> to convert from UTF-8 and back).</p>
|
||||
@@ -203,10 +204,10 @@ as these letters are encoded in the higher part of the single-byte character set
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov3/input.txt">input.txt</a> - sample input</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov3/prog.extra.c">prog.extra.c</a> - alternative source with extra functionality</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov3/try.sh">try.sh</a> - how to run</li>
|
||||
<li><a href="2020_kurdyukov3.tar.bz2">2020_kurdyukov3.tar.bz2</a> - download entry tarball</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
<li><a href="2020_kurdyukov3.tar.bz2">2020_kurdyukov3.tar.bz2</a> - download entry tarball</li>
|
||||
<li><a href="index.html">index.html</a> - this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov3/README.md">README.md</a> - markdown source for this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov3/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
},
|
||||
{
|
||||
"file_path" : "2020_kurdyukov4.tar.bz2",
|
||||
"inventory_order" : 100000,
|
||||
"inventory_order" : 1415926535,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "tbz2",
|
||||
"display_via_github" : false,
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -141,13 +142,13 @@ Location: <a href="../../location.html#RU">RU</a> - <em>Russian Federation</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>
|
||||
<pre class="<!---sh-->"><code> make</code></pre>
|
||||
<pre><code> make</code></pre>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<pre class="<!---sh-->"><code> ./prog text_file output_length context_length random_seed</code></pre>
|
||||
<pre><code> ./prog text_file output_length context_length random_seed</code></pre>
|
||||
<h2 id="try">Try:</h2>
|
||||
<p>When running this, ask yourself why it gets progressively slower when the
|
||||
context length decreases:</p>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<pre><code> ./try.sh</code></pre>
|
||||
<blockquote>
|
||||
<p>Performance depends on the number of same hashes found.
|
||||
Too many identical strings if the context length is small.
|
||||
@@ -183,11 +184,11 @@ Middle-earth (HoMe)</a>.
|
||||
Now can you appreciate the award title a bit better?</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<h3 id="building">Building:</h3>
|
||||
<pre class="<!---sh-->"><code> cc prog.c -o prog</code></pre>
|
||||
<pre><code> cc prog.c -o prog</code></pre>
|
||||
<h3 id="usage">Usage:</h3>
|
||||
<p>This program generates random text from the provided dictionary using a Markov
|
||||
chain, outputting to <code>stdout</code>.</p>
|
||||
<pre class="<!---sh-->"><code> ./prog input.txt 2000 10 12345</code></pre>
|
||||
<pre><code> ./prog input.txt 2000 10 12345</code></pre>
|
||||
<p>Parameters are:</p>
|
||||
<ol type="1">
|
||||
<li><p>dictionary filename
|
||||
@@ -209,7 +210,7 @@ the output of this size in bytes exists somewhere in the dictionary.</p></li>
|
||||
<h3 id="example">Example</h3>
|
||||
<p>You can try this with the inputs provided with
|
||||
<a href="../../2019/mills/index.html">2019/mills</a> from the IOCCC entries.</p>
|
||||
<pre class="<!---sh-->"><code> $ ./prog Shakespeare.txt 2001 10 12345</code></pre>
|
||||
<pre><code> $ ./prog Shakespeare.txt 2001 10 12345</code></pre>
|
||||
<p>produces:</p>
|
||||
<pre><code> r sons, wives for them, as the hope I had it. This is the way they be not too ra
|
||||
sh a trial of you only. Therefore will not out of door? Nurse: Marry, bachelor,
|
||||
@@ -266,10 +267,10 @@ the output of this size in bytes exists somewhere in the dictionary.</p></li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov4/Shakespeare.txt">Shakespeare.txt</a> - Shakespeare text</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov4/rand.c">rand.c</a> - randomize a file</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov4/try.sh">try.sh</a> - how to run</li>
|
||||
<li><a href="2020_kurdyukov4.tar.bz2">2020_kurdyukov4.tar.bz2</a> - download entry tarball</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
<li><a href="2020_kurdyukov4.tar.bz2">2020_kurdyukov4.tar.bz2</a> - download entry tarball</li>
|
||||
<li><a href="index.html">index.html</a> - this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov4/README.md">README.md</a> - markdown source for this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/kurdyukov4/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
},
|
||||
{
|
||||
"file_path" : "2020_otterness.tar.bz2",
|
||||
"inventory_order" : 100000,
|
||||
"inventory_order" : 1415926535,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "tbz2",
|
||||
"display_via_github" : false,
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -141,15 +142,15 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<pre class="<!---sh-->"><code> make</code></pre>
|
||||
<pre><code> make</code></pre>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code> STATUS: INABIAF - please **DO NOT** fix</code></pre>
|
||||
<p>For more detailed information see <a href="../../bugs.html#2020_otterness">2020 otterness bugs</a>.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<pre class="<!---sh-->"><code> ./prog</code></pre>
|
||||
<pre><code> ./prog</code></pre>
|
||||
<h2 id="try">Try:</h2>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<pre><code> ./try.sh</code></pre>
|
||||
<p>Now play <code>output.mid</code> and <code>output2.mid</code> in an audio player that can play MIDI
|
||||
files.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
@@ -179,7 +180,7 @@ for most of my testing (see <a href="cvikl.mid">cvikl.mid</a>).</p>
|
||||
<h3 id="usage">Usage</h3>
|
||||
<p>Compile the program using the following command (I tested this using both
|
||||
<code>clang</code> and <code>gcc</code>):</p>
|
||||
<pre class="<!---sh-->"><code> cc -pedantic -Wall -Werror -Wextra -O3 -o prog prog.c</code></pre>
|
||||
<pre><code> cc -pedantic -Wall -Werror -Wextra -O3 -o prog prog.c</code></pre>
|
||||
<p>The program expects a MIDI on <code>stdin</code>, and writes a modified MIDI to <code>stdout</code>:</p>
|
||||
<pre><code> ./prog <input.mid >output.mid</code></pre>
|
||||
<p>If the program encounters an error, no output will generally be produced, and
|
||||
@@ -271,10 +272,10 @@ very thoroughly).</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/otterness/try.sh">try.sh</a> - how to run</li>
|
||||
<li><a href="cvikl.mid">cvikl.mid</a> - sample input sound</li>
|
||||
<li><a href="entertainer.mid">entertainer.mid</a> - sample input sound</li>
|
||||
<li><a href="2020_otterness.tar.bz2">2020_otterness.tar.bz2</a> - download entry tarball</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
<li><a href="2020_otterness.tar.bz2">2020_otterness.tar.bz2</a> - download entry tarball</li>
|
||||
<li><a href="index.html">index.html</a> - this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/otterness/README.md">README.md</a> - markdown source for this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/otterness/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
},
|
||||
{
|
||||
"file_path" : "2020_tsoj.tar.bz2",
|
||||
"inventory_order" : 100000,
|
||||
"inventory_order" : 1415926535,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "tbz2",
|
||||
"display_via_github" : false,
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -141,22 +142,22 @@ 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>
|
||||
<pre class="<!---sh-->"><code> make</code></pre>
|
||||
<pre><code> make</code></pre>
|
||||
<p>There is an alternate version which has controls that will make much more sense
|
||||
to those familiar with vi. See <a href="#alternate-code">Alternate code</a> below.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<pre class="<!---sh-->"><code> ./prog</code></pre>
|
||||
<pre><code> ./prog</code></pre>
|
||||
<h2 id="try">Try:</h2>
|
||||
<pre class="<!---sh-->"><code> # Make your terminal as large as possible, possibly reduce your font size
|
||||
<pre><code> # Make your terminal as large as possible, possibly reduce your font size
|
||||
# then...
|
||||
./prog</code></pre>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<p>This version has the difference of moving forwards, left, backwards and right,
|
||||
where instead of <code>w</code>, <code>a</code>, <code>s</code> and <code>d</code>, you can use <code>k</code>, <code>h</code>, <code>j</code> and <code>l</code>.</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<pre class="<!---sh-->"><code> make alt</code></pre>
|
||||
<pre><code> make alt</code></pre>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<pre class="<!---sh-->"><code> # Make your terminal as large as possible, possibly reduce your font size
|
||||
<pre><code> # Make your terminal as large as possible, possibly reduce your font size
|
||||
# then...
|
||||
./prog.alt</code></pre>
|
||||
<p>..and maybe curse less than you might otherwise, but still probably curse (see
|
||||
@@ -257,10 +258,10 @@ it.</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/tsoj/Makefile">Makefile</a> - entry Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/tsoj/prog.alt.c">prog.alt.c</a> - alternative source</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/tsoj/prog.orig.c">prog.orig.c</a> - original source</li>
|
||||
<li><a href="2020_tsoj.tar.bz2">2020_tsoj.tar.bz2</a> - download entry tarball</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
<li><a href="2020_tsoj.tar.bz2">2020_tsoj.tar.bz2</a> - download entry tarball</li>
|
||||
<li><a href="index.html">index.html</a> - this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/tsoj/README.md">README.md</a> - markdown source for this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/tsoj/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
},
|
||||
{
|
||||
"file_path" : "2020_yang.tar.bz2",
|
||||
"inventory_order" : 100000,
|
||||
"inventory_order" : 1415926535,
|
||||
"OK_to_edit" : false,
|
||||
"display_as" : "tbz2",
|
||||
"display_via_github" : false,
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
<div class="sidenav">
|
||||
<a href="../../news.html">IOCCC News</a>
|
||||
<a href="../../status.html">Contest status</a>
|
||||
<a href="../../next/index.html">Rules and Guidelines</a>
|
||||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||||
<a href="../../faq.html">FAQ</a>
|
||||
</div>
|
||||
@@ -141,14 +142,14 @@ Location: <a href="../../location.html#US">US</a> - <em>United States of America
|
||||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||||
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<pre class="<!---sh-->"><code> make</code></pre>
|
||||
<pre><code> make</code></pre>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<pre class="<!---sh-->"><code> ./prog [PIN] < input.txt > output.c</code></pre>
|
||||
<pre><code> ./prog [PIN] < input.txt > output.c</code></pre>
|
||||
<h2 id="try">Try:</h2>
|
||||
<pre class="<!---sh-->"><code> ./try.sh</code></pre>
|
||||
<pre><code> ./try.sh</code></pre>
|
||||
<p>The author provided the file <a href="cppp.cc">cppp.cc</a> which can preprocess the
|
||||
generated output to make them more acceptable to typical compilers. To build:</p>
|
||||
<pre class="<!---sh-->"><code> make cppp</code></pre>
|
||||
<pre><code> make cppp</code></pre>
|
||||
<p>See the author’s remarks for more details.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>You might think of this entry as code obfuscater with a code.
|
||||
@@ -159,7 +160,7 @@ What is compiling this entry about?
|
||||
spoiler</a> that shows how this entry was written.</p>
|
||||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||||
<h3 id="synopsis">Synopsis</h3>
|
||||
<pre class="<!---sh-->"><code> echo "Hello world" | ./prog 12345 > encoded.c
|
||||
<pre><code> echo "Hello world" | ./prog 12345 > encoded.c
|
||||
|
||||
gcc -DPIN=12345 encoded.c -o ./decoded && ./decoded</code></pre>
|
||||
<h3 id="details">Details</h3>
|
||||
@@ -169,10 +170,10 @@ spoiler</a> that shows how this entry was written.</p>
|
||||
where [PIN] is an integer in the range of 1..65535</code></pre>
|
||||
<p>When run with an encoding PIN (first command line argument), Mile will
|
||||
read bytes from <code>stdin</code> and generate C code on <code>stdout</code>. Example:</p>
|
||||
<pre class="<!---sh-->"><code> echo "Hello, world!" | ./prog 56789 > encoded.c</code></pre>
|
||||
<pre><code> echo "Hello, world!" | ./prog 56789 > encoded.c</code></pre>
|
||||
<p>This generated code will reproduce the same input bytes on <code>stdout</code> when
|
||||
executed, if it was compiled with the same encoding PIN.</p>
|
||||
<pre class="<!---sh-->"><code> gcc -DPIN=56789 encoded.c -o decoded</code></pre>
|
||||
<pre><code> gcc -DPIN=56789 encoded.c -o decoded</code></pre>
|
||||
<p>The generated code reconstructs all data at compile time by seeding a
|
||||
random number generator with the given PIN to reproduce the input bytes,
|
||||
and simply does one <code>fwrite(3)</code> call at run time to print those bytes. Not
|
||||
@@ -260,10 +261,10 @@ then compile it with a c++ compiler of your choice.</p>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/yang/try.sh">try.sh</a> - how to run</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/yang/cppp.cc">cppp.cc</a> - encode large file C Pre-PreProcessor source</li>
|
||||
<li><a href="spoiler.html">spoiler.html</a> - SPOILER WARNING</li>
|
||||
<li><a href="2020_yang.tar.bz2">2020_yang.tar.bz2</a> - download entry tarball</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
<li><a href="2020_yang.tar.bz2">2020_yang.tar.bz2</a> - download entry tarball</li>
|
||||
<li><a href="index.html">index.html</a> - this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/yang/README.md">README.md</a> - markdown source for this web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/yang/.entry.json">.entry.json</a> - description of entry in JSON</li>
|
||||
|
||||
Reference in new issue
Block a user