Remove hint.html and index.html
As per discussions on GitHub the index.html and hint.html files should be deleted in favour of README.md files (from any .text/.txt/.markdown/.md files which will be turned into README.md in an upcoming commit).
This commit is contained in:
1 parent
ee8a36310f
commit
77fb0f11a2
143 files changed
-28606
No files matched your search
@@ -1,122 +0,0 @@
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.2.2">
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=utf-8"> <link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css" />
|
||||
<title></title>
|
||||
<title>Best one-liner</title>
|
||||
</head>
|
||||
<body>
|
||||
<CENTER>
|
||||
<IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
|
||||
<P><FONT size="6"><I>The International Obfuscated C Code Contest</I></FONT></P>
|
||||
<div id="bar">
|
||||
<ul>
|
||||
<li><a href="../index.html">About the 27th IOCCC</a></li>
|
||||
<li><a href="../whowon.html">27th IOCCC Winners</a></li>
|
||||
<li><a href="/index.html">IOCCC home</a></li>
|
||||
<li><a href="/winners.html">List of All Winners</a></li>
|
||||
<li><a href="/judges.html">The Judges</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<P><FONT size="6"><B>A 27<sup>th</sup> IOCCC Winner</B></FONT></P>
|
||||
</CENTER>
|
||||
|
||||
|
||||
<h1>Best one-liner</h1>
|
||||
|
||||
<p>Dave Burton<br/>
|
||||
<a href="http://snox.net/ioccc">http://snox.net/ioccc</a><br/>
|
||||
Twitter: @lv2jmp</p>
|
||||
|
||||
<p>The code for this entry can be found in <a href="prog.c">prog.c</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make
|
||||
./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./prog 128
|
||||
|
||||
./prog_be 128
|
||||
|
||||
./prog 170
|
||||
|
||||
./prog 85
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This tiny one-liner is a bit-twiddlers delight! It does all of the work
|
||||
without looping.</p>
|
||||
|
||||
<p>To understand how it works, a good place to start is to look at the hex
|
||||
value that results when the two magic constants are XOR'ed.</p>
|
||||
|
||||
<p>Once you’ve figured out what happens with one set of constants, how can
|
||||
choosing new constants, but using the same computation generate a reversed
|
||||
result?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<p>Invoke this with a single non-negative integer less than 256, and a useful transformation occurs.</p>
|
||||
|
||||
<h3>Rule 2-ish</h3>
|
||||
|
||||
<p>Exporting the constants B,I,T,S to the makefile allows the code
|
||||
to be compiled for either LE (little-endian) or BE (big-endian) machines(!!),
|
||||
so they are truly configuration parameters, not logic.</p>
|
||||
|
||||
<h3>Notes</h3>
|
||||
|
||||
<p>One <strike>ping</strike> argument only. It will SEGV on zero arguments, and
|
||||
display strange results if more than one argument.</p>
|
||||
|
||||
<p>Small, non-negative integers only. Useful range is 0 .. 511, sorta, for LE; 0 .. 255 for BE.
|
||||
Bonus points if you can explain why the limits work this way.</p>
|
||||
|
||||
<p>ASCII character set, 64-bit long longs are required.</p>
|
||||
|
||||
<p>v,a,r,i,a,b,l,e,s_NAME the operation.</p>
|
||||
|
||||
<p>No loops, no branches?!?</p>
|
||||
|
||||
<h3>Compilation</h3>
|
||||
|
||||
<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</code>(3) and <code>atoi</code>(3).</p>
|
||||
|
||||
<p>On a little-endian machine:</p>
|
||||
|
||||
<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><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><code>./prog 1; ./prog.be 1
|
||||
</code></pre>
|
||||
<BR>
|
||||
<HR>
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2020,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,326 +0,0 @@
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.2.2">
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=utf-8"> <link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css" />
|
||||
<title></title>
|
||||
<title>Best of show - abuse of libc</title>
|
||||
</head>
|
||||
<body>
|
||||
<CENTER>
|
||||
<IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
|
||||
<P><FONT size="6"><I>The International Obfuscated C Code Contest</I></FONT></P>
|
||||
<div id="bar">
|
||||
<ul>
|
||||
<li><a href="../index.html">About the 27th IOCCC</a></li>
|
||||
<li><a href="../whowon.html">27th IOCCC Winners</a></li>
|
||||
<li><a href="/index.html">IOCCC home</a></li>
|
||||
<li><a href="/winners.html">List of All Winners</a></li>
|
||||
<li><a href="/judges.html">The Judges</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<P><FONT size="6"><B>A 27<sup>th</sup> IOCCC Winner</B></FONT></P>
|
||||
</CENTER>
|
||||
|
||||
|
||||
<h1>Best of show - abuse of libc</h1>
|
||||
|
||||
<p>Nicholas Carlini <a href="mailto:nicholas@carlini.com">nicholas@carlini.com</a><br/>
|
||||
<a href="https://nicholas.carlini.com">https://nicholas.carlini.com</a></p>
|
||||
|
||||
<p>The code for this entry can be found in <a href="prog.c">prog.c</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make
|
||||
./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code># Play with a friend, P1 and P2, squares are numbered 1..9
|
||||
./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This program consists of a single print statement wrapped in a while loop. You
|
||||
would not think that this would amount to much, but you would be very, very
|
||||
wrong. A clue to what is happening and how this works is encoded in the
|
||||
ASCII art of the program source.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<p>HOW ABOUT A NICE GAME OF <strike>CHESS</strike>TIC-TAC-TOE?</p>
|
||||
|
||||
<h3>USAGE</h3>
|
||||
|
||||
<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
|
||||
---------
|
||||
4 | 5 | 6
|
||||
---------
|
||||
7 | 8 | 9
|
||||
</code></pre>
|
||||
|
||||
<p>The game ends if:</p>
|
||||
|
||||
<ul>
|
||||
<li>A player completes three in a row; that player wins</li>
|
||||
<li>All squares are taken; neither player wins</li>
|
||||
<li>A player makes an illegal move; their opponent wins</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>LIMITATIONS</h3>
|
||||
|
||||
<p>Bad things may happen if the entered move is outside of the range [1..9]</p>
|
||||
|
||||
<p>While the game will stop if one player tries to overwrite another player’s move,
|
||||
it will happily allow a player to move on top of themself. However, given that
|
||||
this is an effective no-op and guarantees a loss to a competent opponent, if you
|
||||
do this you probably deserve to lose.</p>
|
||||
|
||||
<p>Your terminal may beep at you every turn. We’ll call this a feature that …
|
||||
the program … is hard at work processing your move! That is! Please be
|
||||
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 -Wall
|
||||
-Wextra -pedantic 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><code>echo "1 2 3 4 5 6 7" | ./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>OBFUSCATION</h3>
|
||||
|
||||
<p>The entirety of the program consists of a single iterated call to printf.</p>
|
||||
|
||||
<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 printf.</p>
|
||||
|
||||
<p>While its primary purpose is to serve as The One True Debugger, printf also happens
|
||||
to be Turing complete. (See “Control-Flow Bending: On the Effectiveness of Control-Flow
|
||||
Integrity” where we introduced this in an actual, published, academic paper. The
|
||||
things you can get away with sometimes.)</p>
|
||||
|
||||
<p>We <strike>ab</strike>use this fact to implement the logic of tic-tac-toe entirely within
|
||||
this one printf call (and a call to scanf() to read user input).</p>
|
||||
|
||||
<p>Here’s (briefly) how it works.</p>
|
||||
|
||||
<h4>Preliminaries</h4>
|
||||
|
||||
<p>This program uses three printf format specifiers.
|
||||
- <code>%d</code> takes an integer argument and prints it
|
||||
- <code>%s</code> takes a string argument and prints it
|
||||
- <code>%n</code> takes a pointer and writes (!!) the number of bytes printed so far.</p>
|
||||
|
||||
<p>Okay, everyone probably knows this. Let’s get a bit more advanced.</p>
|
||||
|
||||
<p>Format specifiers can take extra “arguments”.
|
||||
- <code>"%hhn"</code>: store the number of bytes written mod 256 to the char pointer
|
||||
- <code>"%2$d"</code>: print argument 2 to printf (and not the sequentially next argument)
|
||||
- <code>"%8d"</code>: pad the printed integer to 8 characters
|
||||
- <code>"%3$.*4$d"</code>: print argument 3 to printf with as many zeros as in argument 4.</p>
|
||||
|
||||
<p>For example, the following expression</p>
|
||||
|
||||
<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><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 x.</p>
|
||||
|
||||
<h4>Printf Oriented Programming</h4>
|
||||
|
||||
<p>Alright, now we can get to the real fun.</p>
|
||||
|
||||
<p>We perform arbitrary computation with printf treating memory as a binary
|
||||
array—one bit per pair of bytes:
|
||||
- The zero bit is represented by the sequence <code>00 00</code>
|
||||
- The one-bit is represented by the sequence <code>xx 00</code> where <code>xx</code> is any non-zero byte.</p>
|
||||
|
||||
<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><code>printf("%1$s%2$s%3$hhn", a, b, c)
|
||||
</code></pre>
|
||||
|
||||
<p>will compute</p>
|
||||
|
||||
<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><code>*c = a | b
|
||||
</code></pre>
|
||||
|
||||
<p>Computing the NOT of a single value is also easy:</p>
|
||||
|
||||
<pre><code>printf("%1$255d%1$s%hhn", a, b)
|
||||
</code></pre>
|
||||
|
||||
<p>will compute</p>
|
||||
|
||||
<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><code>*c = !b
|
||||
</code></pre>
|
||||
|
||||
<p>From here we can compute any binary circuit. Doing something efficient,
|
||||
though, still takes work.</p>
|
||||
|
||||
<h4>Tic-Tac-Toe</h4>
|
||||
|
||||
<p>The game itself is represented as a board of 18 bits, 9 bits per player, along
|
||||
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 A, B, and C be
|
||||
pointers to three squares in a row to test, and D be where to save if there is a
|
||||
win or not.</p>
|
||||
|
||||
<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
|
||||
"%11$s%D$s%D$hhn" // *D = *D | r11
|
||||
</code></pre>
|
||||
|
||||
<p>That is, we set <code>*D</code> to <code>1</code> if there is a three-in-a-row. We repeat this for all
|
||||
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><code>"%1$hhn%1$s" (repeated 256 times)
|
||||
</code></pre>
|
||||
|
||||
<p>where argument 1 is a pointer to a temporary variable followed by a null byte.</p>
|
||||
|
||||
<p>This works because if the current count is 0 mod 256, then “%1$hhn” will write
|
||||
zero to argument 1 and then “%1$s” will never emit any text. If, on the other
|
||||
hand, the count is not 0 mod 256, a length-1 string will be written to argument
|
||||
1, and then “%1$s” will increment the count by one. By repeating this 256
|
||||
times we’re eventually going to reach 0 mod 256.</p>
|
||||
|
||||
<p>Checking if there has been an invalid move is achieved similarly.</p>
|
||||
|
||||
<p>In order to decide what to print out, we have to cast the “in-memory” array of
|
||||
bits to Xs and Os to print out. This is actually rather straightforward. Given
|
||||
in 1$ the pointer to player 1’s square, and 2$ the pointer to player 2’s, and
|
||||
in 3$ the pointer to the board string, we can compute</p>
|
||||
|
||||
<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><code>*r3 = (*r1) * 47 + (*r2) * 56 + 32
|
||||
</code></pre>
|
||||
|
||||
<p>which will output ‘ ’ if neither are true, ‘X’ if r1 is, or ‘O’ if r2 is.</p>
|
||||
|
||||
<h4>Further Obfuscations</h4>
|
||||
|
||||
<p>In order to be able to finally display the board, while still only using one
|
||||
printf statement, we finish the statement with</p>
|
||||
|
||||
<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 char* in memory, that initially is undefined,
|
||||
but within the printf statement we will construct this string to look like a
|
||||
tic-tac-toe board.</p>
|
||||
|
||||
<p>After the board, we need to print one of the following strings:</p>
|
||||
|
||||
<pre><code>P1>_
|
||||
P2>_
|
||||
P1 WINS
|
||||
P2 WINS
|
||||
P1 TIES
|
||||
P2 TIES
|
||||
</code></pre>
|
||||
|
||||
<p>Depending on if it’s P1 or P2’s turn to move, the game is over and someone
|
||||
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><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()</code> format string, but for a
|
||||
different reason. We first want to run <code>printf()</code> to show the first board, and
|
||||
then alternate between runs to <code>scanf()</code> and <code>printf()</code> reading and then
|
||||
displaying moves. importantly, we <em>do not</em> want a final scanf when the game
|
||||
ends. It should just exit.</p>
|
||||
|
||||
<p>One option would be to implement the logic as</p>
|
||||
|
||||
<pre><code>printf()
|
||||
while (*ok) {
|
||||
scanf();
|
||||
printf();
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
<p>but this would DOUBLE the number of calls to printf we require. So instead we
|
||||
implement it like this</p>
|
||||
|
||||
<pre><code>while (*ok) {
|
||||
scanf();
|
||||
printf();
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
<p>(In reality we actually pass <code>scanf()</code> as an argument to avoid the extra
|
||||
statement, but it has the same effect.)</p>
|
||||
|
||||
<p>Notice there is now no initial <code>printf()</code>. In order make sure the program doesn’t
|
||||
block before the first <code>printf()</code>, but we initialize the <code>scanf()</code> format to the null
|
||||
string so that it returns right away without blocking. The first time the <code>printf()</code>
|
||||
call runs, it writes out “%hhd” to create the <code>scanf()</code> format string.</p>
|
||||
<BR>
|
||||
<HR>
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2020,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,191 +0,0 @@
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.2.2">
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=utf-8"> <link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css" />
|
||||
<title></title>
|
||||
<title>Most explosive</title>
|
||||
</head>
|
||||
<body>
|
||||
<CENTER>
|
||||
<IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
|
||||
<P><FONT size="6"><I>The International Obfuscated C Code Contest</I></FONT></P>
|
||||
<div id="bar">
|
||||
<ul>
|
||||
<li><a href="../index.html">About the 27th IOCCC</a></li>
|
||||
<li><a href="../whowon.html">27th IOCCC Winners</a></li>
|
||||
<li><a href="/index.html">IOCCC home</a></li>
|
||||
<li><a href="/winners.html">List of All Winners</a></li>
|
||||
<li><a href="/judges.html">The Judges</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<P><FONT size="6"><B>A 27<sup>th</sup> IOCCC Winner</B></FONT></P>
|
||||
</CENTER>
|
||||
|
||||
|
||||
<h1>Most explosive</h1>
|
||||
|
||||
<p>Yusuke Endoh<br/>
|
||||
Twitter: @mametter</p>
|
||||
|
||||
<p>The code for this entry can be found in <a href="prog.c">prog.c</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make
|
||||
./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code># Try resizing the terminal window before the first click.
|
||||
|
||||
# Try resizing the terminal window after the first click.
|
||||
|
||||
./prog ioccc.txt
|
||||
|
||||
./prog unwinnable.txt
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>When playing Minesweeper, a misclick might ruin a game, so why not leave the routine to the computer?
|
||||
This program automatically uncovers mines according to several rules, and leaves guessing (and applying
|
||||
the most straightforward of the rules – just for fun, perhaps?) to the user.</p>
|
||||
|
||||
<p>Try creating your own input files according to the author’s remarks. Did you encounter any problems?</p>
|
||||
|
||||
<p>The submission was in violation of the “2053” size rule by one character, likely a late typo. It was easy to fix.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Semi-automatic Minesweeper</h3>
|
||||
|
||||
<p>Minesweeper is a game to sweep mines, as you know. The task consists of two parts:</p>
|
||||
|
||||
<p>A) choose a random cell based on your sixth sense
|
||||
B) identify a non-mine cell based on logical inference</p>
|
||||
|
||||
<p>However, (B) is error-prone, and a waste of time. You must use a computer to do such a boring task!</p>
|
||||
|
||||
<p>This program is a semi-automatic minesweeper which does Part (B) automatically.
|
||||
All you have to do is (A). You can test if you are lucky or not.</p>
|
||||
|
||||
<h4>How to use</h4>
|
||||
|
||||
<p>It uses ncurses:</p>
|
||||
|
||||
<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.
|
||||
If a cell turns out to have a mine (or not), the program determines whether its neighbors have a mine or not, and automatically probes (or flags) the cell.</p>
|
||||
|
||||
<ul>
|
||||
<li><code>R</code>: new game (You can also click the smiley face at the top line.)</li>
|
||||
<li><code>Q</code>: quit</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h4>Internal</h4>
|
||||
|
||||
<p>The program uses four types of local inference:</p>
|
||||
|
||||
<h4>Rule 1</h4>
|
||||
|
||||
<p>If the number of a cell is equal to the count of the flagged neighbors, all the unprobed neighbors are probed.</p>
|
||||
|
||||
<p>Example:</p>
|
||||
|
||||
<p><code>
|
||||
? ? ? . . .
|
||||
? 3 ? => . 3 .
|
||||
! ! ! ! ! !
|
||||
</code></p>
|
||||
|
||||
<p>Note that <code>?</code> is a unprobed cell (it is unknown whether the cell has a mine or not); <code>!</code> is a flagged cell (it is already known that the cell has a mine); and <code>.</code> is a probed cell (it is already known that the cell has no mine).</p>
|
||||
|
||||
<h4>Rule 2</h4>
|
||||
|
||||
<p>If the number of a cell is equal to the count of the unprobed or flagged neighbors, all the unprobed neighbors are flagged,</p>
|
||||
|
||||
<p>Example:</p>
|
||||
|
||||
<p><code>
|
||||
. ? ? . ! !
|
||||
. 4 ? => . 4 !
|
||||
. 2 ! . 2 !
|
||||
</code></p>
|
||||
|
||||
<h4>Rule 3</h4>
|
||||
|
||||
<p>Consider two number cells A and B. If A is equal to the difference of B and the count of B’s unprobed and flagged neighbors that are not A’s neighbors, all A’s unprobed neighbors that are not B’s neighbors are probed.</p>
|
||||
|
||||
<p>Example:</p>
|
||||
|
||||
<p><code>
|
||||
? ? ? . . .
|
||||
? 1 ? ? => . 1 ? ?
|
||||
? ? 4 . . ? 4 .
|
||||
? . ! ? . !
|
||||
</code></p>
|
||||
|
||||
<p>A and B are probed cells whose numbers are, respectively, 1 and 4. The count of B’s unprobed and flagged neighbors that are not A’s neighbors is three (one <code>!</code> and two <code>?</code>s). Since A (1) == B (4) - the count (3), the left and top unprobed cells are probed.</p>
|
||||
|
||||
<h4>Rule 4</h4>
|
||||
|
||||
<p>Consider two number cells A and B. If B is equal to the difference of A and the count of A’s unprobed and flagged neighbors that are not B’s neighbors, all A’s unprobed neighbors that are not B’s neighbors are flagged.</p>
|
||||
|
||||
<p><code>
|
||||
? ? ? ? ! ? ? ?
|
||||
? 3 1 2 => ! 3 1 2
|
||||
2 2 . . 2 2 . .
|
||||
</code></p>
|
||||
|
||||
<p>A and B are probed cells whose numbers are, respectively, 3 and 1. The count of A’s unprobed and flagged neighbors that are not B’s neighbors is two (left <code>?</code>s). Since B (1) == A (3) - the count (2), the left unprobed cells are flagged.</p>
|
||||
|
||||
<h4>Note</h4>
|
||||
|
||||
<p>Interestingly, these complex rules can be integrated to one simple rule. Analyze the code.</p>
|
||||
|
||||
<h4>One more thing</h4>
|
||||
|
||||
<p>You can also play with a prepared map.</p>
|
||||
|
||||
<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 “number-of-mines”.
|
||||
(But the mine in the first-clicked cell is removed.)</p>
|
||||
|
||||
<h4>Bug fixes and Credits</h4>
|
||||
|
||||
<p>The judges pointed out a bug of the original version that I submitted (prog.orig.c). Because this program does not provide a feature to flag unprobed cells manually, we can do nothing if the number of unprobed cells are equal to the number of mines remaining; unwinnable.txt is an example for such a case.
|
||||
Thus, I implemented an additional rule to flag all unprobed cells in such a case into the final version (prog.c).</p>
|
||||
|
||||
<p>Ilya Kurdyukov also pointed out a warning “ignoring return value of ‘fscanf’” only when “-O3” is used. So I changed the code a little to pretend to use the return value of fscanf.</p>
|
||||
|
||||
<p>Don Yang (omoikane) contributed another example map “megumin.txt” which is the Explosion Arch-Wizard.</p>
|
||||
<BR>
|
||||
<HR>
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2020,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,87 +0,0 @@
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.2.2">
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=utf-8"> <link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css" />
|
||||
<title></title>
|
||||
<title>Best perspective</title>
|
||||
</head>
|
||||
<body>
|
||||
<CENTER>
|
||||
<IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
|
||||
<P><FONT size="6"><I>The International Obfuscated C Code Contest</I></FONT></P>
|
||||
<div id="bar">
|
||||
<ul>
|
||||
<li><a href="../index.html">About the 27th IOCCC</a></li>
|
||||
<li><a href="../whowon.html">27th IOCCC Winners</a></li>
|
||||
<li><a href="/index.html">IOCCC home</a></li>
|
||||
<li><a href="/winners.html">List of All Winners</a></li>
|
||||
<li><a href="/judges.html">The Judges</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<P><FONT size="6"><B>A 27<sup>th</sup> IOCCC Winner</B></FONT></P>
|
||||
</CENTER>
|
||||
|
||||
|
||||
<h1>Best perspective</h1>
|
||||
|
||||
<p>Yusuke Endoh<br/>
|
||||
Twitter: @mametter</p>
|
||||
|
||||
<p>The code for this entry can be found in <a href="prog.c">prog.c</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make
|
||||
./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./prog
|
||||
|
||||
./prog hello.txt
|
||||
|
||||
./prog yoda.txt
|
||||
|
||||
./prog bear.txt
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>Clever use of the C99 complex data type. The spoiler.zip file contains clues
|
||||
as to how some winning authors create / edit programs into ASCII shapes.</p>
|
||||
|
||||
<p>With the source from the spoiler.zip file could you make the code render for a
|
||||
larger terminal window? How about adding more glyphs?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<p>No! Try not. Do, or do not. There is no try.</p>
|
||||
|
||||
<pre><code>$ gcc -std=c99 prog.c
|
||||
$ a.out
|
||||
$ a.out hello.txt
|
||||
$ a.out yoda.txt
|
||||
$ a.out bear.txt
|
||||
</code></pre>
|
||||
|
||||
<p>See spoiler.zip for the source code.
|
||||
<a href="https://en.wikipedia.org/wiki/List_of_the_most_common_passwords">The 16th most common password on the Internet in 2017 (according to Splash Data)</a> the password is.</p>
|
||||
<BR>
|
||||
<HR>
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2020,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,80 +0,0 @@
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.2.2">
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=utf-8"> <link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css" />
|
||||
<title></title>
|
||||
<title>Most head-turning</title>
|
||||
</head>
|
||||
<body>
|
||||
<CENTER>
|
||||
<IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
|
||||
<P><FONT size="6"><I>The International Obfuscated C Code Contest</I></FONT></P>
|
||||
<div id="bar">
|
||||
<ul>
|
||||
<li><a href="../index.html">About the 27th IOCCC</a></li>
|
||||
<li><a href="../whowon.html">27th IOCCC Winners</a></li>
|
||||
<li><a href="/index.html">IOCCC home</a></li>
|
||||
<li><a href="/winners.html">List of All Winners</a></li>
|
||||
<li><a href="/judges.html">The Judges</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<P><FONT size="6"><B>A 27<sup>th</sup> IOCCC Winner</B></FONT></P>
|
||||
</CENTER>
|
||||
|
||||
|
||||
<h1>Most head-turning</h1>
|
||||
|
||||
<p>Yusuke Endoh<br/>
|
||||
Twitter: @mametter</p>
|
||||
|
||||
<p>The code for this entry can be found in <a href="prog.c">prog.c</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make
|
||||
./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./run_clock
|
||||
# And watch closely for 15-20 seconds
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>You may be tempted to use a mirror. Resist the temptation! Try figuring out how the clock hands are drawn.
|
||||
Can you change the program to make it draw a familiar (non-mirrored) clock face? Can you add the second hand?</p>
|
||||
|
||||
<p>When using the <code>run_clock</code> shell script, your perception of time might depend on what time it is.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<p>Prepare a mirror!</p>
|
||||
|
||||
<pre><code>$ make clock
|
||||
</code></pre>
|
||||
|
||||
<p>Note: You need to recompile it each run.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<p>prog.alt.c is an alternate version that uses Unicode letters, which was suggested by the judges.</p>
|
||||
<BR>
|
||||
<HR>
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2020,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,549 +0,0 @@
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.2.2">
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=utf-8"> <link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css" />
|
||||
<title></title>
|
||||
<title>Don't tread on me award</title>
|
||||
</head>
|
||||
<body>
|
||||
<CENTER>
|
||||
<IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
|
||||
<P><FONT size="6"><I>The International Obfuscated C Code Contest</I></FONT></P>
|
||||
<div id="bar">
|
||||
<ul>
|
||||
<li><a href="../index.html">About the 27th IOCCC</a></li>
|
||||
<li><a href="../whowon.html">27th IOCCC Winners</a></li>
|
||||
<li><a href="/index.html">IOCCC home</a></li>
|
||||
<li><a href="/winners.html">List of All Winners</a></li>
|
||||
<li><a href="/judges.html">The Judges</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<P><FONT size="6"><B>A 27<sup>th</sup> IOCCC Winner</B></FONT></P>
|
||||
</CENTER>
|
||||
|
||||
|
||||
<h1>Don’t tread on me award</h1>
|
||||
|
||||
<p>Cody Boone Ferguson <a href="mailto:ioccc@xexyl.net">ioccc@xexyl.net</a><br/>
|
||||
<a href="https://ioccc.xexyl.net">https://ioccc.xexyl.net</a><br/>
|
||||
Twitter: @xexyl</p>
|
||||
|
||||
<p>The code for this entry can be found in <a href="prog.c">prog.c</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make
|
||||
WAIT=100 WALLS=0 CANNIBAL=0 ./prog
|
||||
# Start pressing some arrow keys
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>make test
|
||||
|
||||
WAIT=75 WALLS=1 CANNIBAL=1 ./prog
|
||||
|
||||
./prog
|
||||
|
||||
SIZE=-1 ./prog
|
||||
|
||||
CANNIBAL=1 WALLS=1 WAIT=50 EVADE=200 ./prog
|
||||
|
||||
WAIT=75 GROW=-1 SIZE=5 CANNIBAL=1 ./prog
|
||||
|
||||
CANNIBAL=1 WALLS=1 WAIT=0 EVADE=1 MAXSIZE=10 ./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>As the <a href="https://en.wikipedia.org/wiki/Gadsden_flag">Gadsden flag</a> warns, beware of the snake!
|
||||
This game has a number of configurable pitfalls including walls and snakes.</p>
|
||||
|
||||
<p>There is a good deal of useful documentation that is provided with this entry:</p>
|
||||
|
||||
<ul>
|
||||
<li>gameplay.markdown (<a href="gameplay.html">gameplay.html</a>)</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Documented game <em>features</em>!</p>
|
||||
|
||||
<ul>
|
||||
<li>terminals.markdown (<a href="terminals.html">terminals.html</a>)</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Information about terminal capabilities, dimensions (setting and how to restore sanity if it causes any problems) as well as colours (limitations etc.).</p>
|
||||
|
||||
<ul>
|
||||
<li>troubleshooting.markdown (<a href="troubleshooting.html">troubleshooting.html</a>)</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Workaround for various game <em>features</em></p>
|
||||
|
||||
<ul>
|
||||
<li>bugs.markdown (<a href="bugs.html">bugs.html</a>)</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Bugs and things that might seem like bugs but are not.</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="chocolate-cake.html">chocolate-cake.html</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Because most of us could use some <em>Double-layered Chocolate Fudge Cake</em>!</p>
|
||||
|
||||
<ul>
|
||||
<li>spoilers.markdown (<a href="spoilers.html">spoilers.html</a>)</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Read <strong><em>ONLY</em></strong> if you really must give up trying to de-obfuscate!</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Feature-rich curses implementation of the Snake game (with many gameplay modes and options)</h3>
|
||||
|
||||
<p>Snake has two cheat modes (passable walls and self [cannibalism]), a drawing (or
|
||||
practising) mode, <em>can play by itself (<strong>and win!</strong>)</em>, is coloured (included
|
||||
<a href="snake-colours.sh">snake-colours.sh</a> and <a href="play.sh">play.sh</a> scripts compile in player-selected
|
||||
colours) and there are many other play modes (many more can be devised with the
|
||||
imagination and the environmental variables; see <a href="gameplay.markdown">gameplay.markdown</a> /
|
||||
<a href="gameplay.html">gameplay.html</a> for many examples) and options. You can pause and there’s
|
||||
even a built-in test unit for some features! The following variables change the
|
||||
game in the following ways (all can be combined):</p>
|
||||
|
||||
<ul>
|
||||
<li><p>The speed of the snake (how many milliseconds to <strong>WAIT</strong> for input before
|
||||
moving; <em>default 231 milliseconds</em> and you can move faster by pressing a
|
||||
direction key quicker or even holding it down).</p></li>
|
||||
<li><p>If the bug (to eat) will move (<strong>EVADE</strong>) after user-specified number of snake
|
||||
moves (<em>default 300, 0 disables</em>).</p></li>
|
||||
<li><p>If the snake can go through <strong>WALLS</strong> (coming out at the opposite wall)
|
||||
(<em>default 1, yes</em>).</p></li>
|
||||
<li><p>If the snake can go through itself (<strong>CANNIBAL</strong>) (<em>default 0, no</em>).</p></li>
|
||||
<li><p>The initial <strong>SIZE</strong> of the snake (<em>default 5</em>).</p></li>
|
||||
<li><p>The size the snake must become in order to win the game (<strong>MAXSIZE</strong>, <em>default 997</em>).</p></li>
|
||||
<li><p>How much to <strong>GROW</strong> each time a bug is eaten (<em>default 5</em>, can be negative).</p></li>
|
||||
<li><p>How many moves (<strong>SHED</strong>, <em>default 0, disabled</em>) before ‘stretching’ (grow)
|
||||
(<strong>SHEDS</strong>, <em>default 5</em>; can be negative). This is how snakes grow in the wild so is a
|
||||
misnomer here because snakes don’t grow in the manner that the original
|
||||
Snake game was designed.</p>
|
||||
|
||||
<ul>
|
||||
<li>Exception: if the bug is eaten the counter isn’t incremented.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p>A drawing/practising mode (<strong>WAIT</strong> < 0 makes <code>timeout()</code> set blocking read).</p></li>
|
||||
<li><p>Computer plays the game (<strong>WAIT=0</strong>) <strong>EPILEPSY/STIMULATION OVERLOAD WARNING</strong>
|
||||
included in the relevant section (this goes for a low <strong>EVADE</strong> value too).</p></li>
|
||||
<li><p>Grow-Shrink mode (Positive and Negative Winning) mode (see
|
||||
<a href="gameplay.markdown">gameplay.markdown</a> for more details).</p></li>
|
||||
<li><p>The dimensions of the game (this is actually a terminal thing but I document
|
||||
how to do this and its potential pitfalls) (<strong>LINES</strong> , <strong>COLUMNS</strong>).</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>There are no complicated command line invocations; it’s just a matter of passing
|
||||
into the game descriptively named variables and I include a script that sets up
|
||||
many different gameplay modes (<a href="gameplay.markdown">gameplay.markdown</a> and <a href="play.sh">play.sh</a>).</p>
|
||||
|
||||
<p>The <a href="gameplay.markdown">gameplay.markdown</a> (<a href="gameplay.html">gameplay.html</a>) file has all the information on
|
||||
what the game looks like, how to play, the different types of modes (that I have
|
||||
thought of so far) including all those in the above list. Along with the
|
||||
<a href="play.sh">play.sh</a> and <a href="snake-colours.sh">snake-colours.sh</a> scripts it’s probably the most important
|
||||
file for players.</p>
|
||||
|
||||
<p>The gameplay file is long but it includes game printouts as well as explaining
|
||||
the many different gameplay modes. The <a href="play.sh">play.sh</a> script automates most (if
|
||||
not all) of the gameplay modes described in the gameplay file (it also
|
||||
allows you to change colours like <a href="snake-colours.sh">snake-colours.sh</a>) as well as the judges'
|
||||
suggestions (that I don’t document so as to not spoil them). You can pass in
|
||||
environmental variables to both scripts though obviously some will conflict with
|
||||
different options in play.sh.</p>
|
||||
|
||||
<p>Probably just as important is <a href="chocolate-cake.html">chocolate-cake.html</a> with an old but wonderful
|
||||
recipe (because the judges love chocolate and who can blame them? - also it goes
|
||||
with one of the IAQs I include later).</p>
|
||||
|
||||
<p>The <a href="troubleshooting.markdown">troubleshooting.markdown</a> (<a href="troubleshooting.html">troubleshooting.html</a>) file has some advice
|
||||
on potential problems (and things that might appear to be problems at first
|
||||
glance but are not) that I have thought of or encountered.</p>
|
||||
|
||||
<p>The <a href="terminals.markdown">terminals.markdown</a> (<a href="terminals.html">terminals.html</a>) has a variety of information
|
||||
specific to terminals from input/directions, dimensions, sanity and colours: a
|
||||
sort of troubleshooting guide for terminals with some additional information.</p>
|
||||
|
||||
<p>The <a href="spoilers.markdown">spoilers.markdown</a> has a variety of information including some of the
|
||||
obfuscation techniques and a bit of how it works.</p>
|
||||
|
||||
<p>The <a href="bugs.markdown">bugs.markdown</a> (<a href="bugs.html">bugs.html</a>) has a list of known bugs and things that
|
||||
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><code> man ./snake.1
|
||||
</code></pre>
|
||||
|
||||
<p>The <a href="COMPILING">COMPILING</a> file has a few portability notes and the <a href="HACKING">HACKING</a> file has
|
||||
some information on how one might modify things, things that could be
|
||||
implemented (and how to/how not to go about some of the things) as well as some
|
||||
other information on the entry (some of which is deliberately not true - a
|
||||
variation of misleading comments). These files are probably insignificant.</p>
|
||||
|
||||
<p>I will have more information about this entry at
|
||||
<a href="https://ioccc.xexyl.net/2020/snake">https://ioccc.xexyl.net/2020/snake</a> after the winning entries have been
|
||||
published.</p>
|
||||
|
||||
<p>For the files I recommend looking at the html files with a browser; this
|
||||
particularly goes for the <a href="gameplay.html">gameplay.html</a>, <a href="bugs.html">bugs.html</a>, <a href="terminals.html">terminals.html</a>
|
||||
and <a href="troubleshooting.html">troubleshooting.html</a> - along with the most important one
|
||||
<a href="chocolate-cake.html">chocolate-cake.html</a>.</p>
|
||||
|
||||
<p><a name="toc"></a></p>
|
||||
|
||||
<ul>
|
||||
<li><p><a href="#bugs">‘Bugs’</a></p></li>
|
||||
<li><p><a href="#naqs">NAQs/IAQs (Never/Infrequently Asked Questions)</a></p>
|
||||
|
||||
<ul>
|
||||
<li><a href="#inspirations">Do I have any inspirations for this entry?</a></li>
|
||||
<li><a href="#features">Are there any features I thought of that I wanted to implement but did not get to for some reason or another?</a></li>
|
||||
<li><a href="#easier">Are there ways that one can make this game easier?</a></li>
|
||||
<li><a href="#harder">Are there ways to make it harder?</a></li>
|
||||
<li><a href="#moult">How do snakes grow in real life?</a></li>
|
||||
<li><a href="#other">Any other interesting things about snakes?</a></li>
|
||||
<li><a href="#opposite">Why can you go the opposite direction and so immediately die when not cannibalising?</a></li>
|
||||
<li><a href="#chocolatecake">Do you have any <strong>DELICIOUS CHOCOLATE CAKE</strong> recipes?</a></li>
|
||||
<li><a href="#alt">What are the files prog.orig.c, prog.2.c, prog-j.c and prog.alt.c ?</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p><a href="#winning">Winning thoughts, dedications and thanks</a></p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3><a name="bugs" href="#toc">‘Bugs’</a></h3>
|
||||
|
||||
<ul>
|
||||
<li><p>‘The screen keeps showing bugs!’ Well yes, that’s rather the point! Help out
|
||||
by eating them. Keep eating them until you win! Then you will have the
|
||||
satisfaction of getting rid of the non-bug bugs! :)</p></li>
|
||||
<li><p>The Snake in the game doesn’t fly (yes there are <a href="https://www.bbc.co.uk/news/science-environment-25943693">flying snakes</a>). For
|
||||
other snake madness see the reports of ‘<a href="http://www.macroevolution.net/snake-human-hybrids.html">human snakes</a>’.</p></li>
|
||||
<li><p>Technically walls, snakeskin and the snake itself would not be an obstacle
|
||||
in real life. The shed snakeskin is not an obstacle but walls can be and
|
||||
so can the snake itself. Also snakes grow by moulting (technical term for
|
||||
shedding) so when the snake leaves its snakeskin behind it really ought to
|
||||
grow but instead it shrinks; this means negative shedding ought to have the
|
||||
snake grow and positive shedding have the snake - what? It’s a misnomer: it
|
||||
took fewer bytes and the negative shedding is a positive consequence of
|
||||
unsigned arithmetic.</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>On a more serious note look at <a href="bugs.markdown">bugs.markdown</a> (<a href="bugs.html">bugs.html</a>).</p>
|
||||
|
||||
<h3><a name="naqs" href="#toc">NAQs/IAQs (Never/Infrequently Asked Questions)</a></h3>
|
||||
|
||||
<h4><a name="inspirations" href="#toc">Do I have any inspirations for this entry?</a></h4>
|
||||
|
||||
<p>There are two in particular. First is a long time mate of mine wrote a bash
|
||||
implementation of Snake several years ago (uncoloured, no cheat modes, hardcoded
|
||||
dimensions etc. - in fact everything was hardcoded).</p>
|
||||
|
||||
<p>Back then I had thought of making a curses implementation of it but I never got
|
||||
round to it. When the judges announced that the 2020 IOCCC contest would be open
|
||||
from late December 2019 through 15 March 2020 I started thinking again on what
|
||||
might be a good entry. By chance I thought of the Snake game and so wrote it
|
||||
finishing the implementation of everything on 8 November 2019. Did I say
|
||||
everything? That’s an unintentional lie; I thought it was everything but I
|
||||
implemented many new things after that. In fact I have numerous times thought I
|
||||
was done only to have added yet another feature - or two or three or more!</p>
|
||||
|
||||
<p>Second is the old Atari game <a href="https://en.wikipedia.org/wiki/Surround_(video_game)">Surround</a>. There were a few modes as I recall.
|
||||
The object of the game was to surround your opponent so that they would run into
|
||||
you, the wall or themselves. The opponent was either the computer or another
|
||||
player.</p>
|
||||
|
||||
<p>In one mode you could go through walls (that’s where I got the idea to do
|
||||
likewise). There was also a drawing mode where you could just move round making
|
||||
different designs though that this is in my entry is a happy coincidence
|
||||
(because <code>timeout()</code> will block when it gets a negative value). It’s true that
|
||||
in my Snake it’s not quite the same but it’s close enough. Perhaps it can be
|
||||
made more like Surround if it grows every movement but then depending on the max
|
||||
size of the snake the game might be over fairly quickly (I don’t remember how
|
||||
it was done in Surround).</p>
|
||||
|
||||
<p>In Surround each move you made you would grow in size by one. This is what
|
||||
inspired the shedding mode. Anyway I always loved the game and it’s similar to
|
||||
Snake in several ways.</p>
|
||||
|
||||
<h4><a name="features" href="#toc">Are there any features I thought of that I wanted to implement but did not get to for some reason or another?</a></h4>
|
||||
|
||||
<p>Yes. I thought it would be fun if there were other obstacles for the snake (in
|
||||
my mind I was thinking of barriers like the walls but in the field).</p>
|
||||
|
||||
<p>I also thought it would be fun to have more than one bug at some point after say
|
||||
the snake gets to be some size. One of the reasons I didn’t do this is because I
|
||||
was trying to save iocccsize bytes. I never got round to this though and I feel
|
||||
that the features I have implemented are far more interesting and fun.</p>
|
||||
|
||||
<p>Another idea is having portals or teleportation but there are a number of
|
||||
problems with those that would have to be worked out too.</p>
|
||||
|
||||
<p>I would have loved for it to be practical to support diagonal movement but as I
|
||||
describe elsewhere it’s not. That’s perhaps what I regret most. It would be
|
||||
possible to choose letters instead of arrow keys but even if that fit in the
|
||||
size restrictions how would I show the head? I looked at the extended ncurses
|
||||
character set and I didn’t see any diagonal arrows. I suppose I could have it
|
||||
not show the arrows but then that brings an old problem back.</p>
|
||||
|
||||
<p>Nevertheless I am quite happy with the features in the game and I hope everyone
|
||||
who plays it enjoys it as much as I enjoyed writing/playing it.</p>
|
||||
|
||||
<h4><a name="easier" href="#toc">Are there ways that one can make this game easier?</a></h4>
|
||||
|
||||
<p>I can think of at the least the following:</p>
|
||||
|
||||
<ul>
|
||||
<li>Bigger screen will allow for freer movement (at least for more time?).</li>
|
||||
<li>Increasing the movement (key press) wait to give you more time to choose
|
||||
(though this slows gameplay down).</li>
|
||||
<li>Decrease the size of the snake (and growth size) though over time the size
|
||||
will become more and more problematic. But see the next item.</li>
|
||||
<li>If you set a high growth size you don’t have to worry as much about running
|
||||
into a wall or the snake itself for as long: because the check if you win is
|
||||
done when the snake size is increased: if you’re 15 away from the max and
|
||||
each bug you eat you grow by 11 then it won’t take as many bugs to win as it
|
||||
would if the grow size was 3. This applies to shedding size too.</li>
|
||||
<li>If you want to show off keep walls passable and enable cannibalism. It
|
||||
won’t be a challenge then but at least you could show your final score?</li>
|
||||
<li>Decrease the max size.</li>
|
||||
<li>And the one that applies to learning new things and getting more things done
|
||||
also applies here: remove all sources of distraction; turn the phone off,
|
||||
lock yourself in a soundproof room (refusing to get up for anyone or
|
||||
anything) and delete all your social media accounts for starters. Okay you
|
||||
don’t really have to do the latter one but it can’t be denied that they can
|
||||
be very distracting! As can phone (calls and otherwise). And visitors
|
||||
calling. And being on this planet.</li>
|
||||
<li>If you don’t want a challenge at all you could just set the start size to be
|
||||
the max size or very close to it. In fact if you have the shedding size to be
|
||||
even one on every move even if you normally can’t win with the same size
|
||||
screen you might find it happens much more easily! You could of course play
|
||||
with these paramters in different ways together - there are certainly
|
||||
different combinations than I have given.</li>
|
||||
<li>Of course you could also enable one or both cheat modes. You might be
|
||||
considered a filthy cheat but both modes are quite fun (one being enabled by
|
||||
default; does that mean it’s not actually a cheat mode?).</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h4><a name="harder" href="#toc">Are there ways to make it harder?</a></h4>
|
||||
|
||||
<ul>
|
||||
<li>Decrease the size of the game.</li>
|
||||
<li>Decrease the size of the snake growth (and initial snake size).</li>
|
||||
<li>Make the snake go faster (decrease the time the game waits for input).</li>
|
||||
<li>Hold down the direction keys to move faster; this is something I do often
|
||||
though I have always had extremely fast reflexes and amazing eye hand
|
||||
coordination (at least after glasses and the three eye surgeries?).
|
||||
Admittedly I don’t find this makes it any harder but it does make you have
|
||||
to react faster.</li>
|
||||
<li>Be reckless (i.e. increase the chance of a wreck, a most amusing
|
||||
contradictory idea if you ignore etymology).</li>
|
||||
<li>Look away for a moment every so often or have a conversation with your best
|
||||
mate, partner or family member whilst playing.</li>
|
||||
<li>Make walls impassable and disable cannibalism.</li>
|
||||
<li>Make the bug move more frequently (this can be a real problem when you can’t
|
||||
go through the walls!).</li>
|
||||
<li>Get used to going through walls and then try with it disabled.</li>
|
||||
<li>Set the max size to the maximum (<em><code>MAXSIZE=-1</code></em> should do it).</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>And if you’re a show-off you can try:</p>
|
||||
|
||||
<ul>
|
||||
<li>Closing your eyes (maybe better to practise with one eye open first or even
|
||||
in practice that is drawing mode?).</li>
|
||||
<li>Have someone tickle you.</li>
|
||||
<li>Watch a comedy show or have a laugh with a mate or partner or family member.</li>
|
||||
<li>Have your partner tease you.</li>
|
||||
<li>Speak on the phone with someone (paying attention to both). Come to think of
|
||||
it I have actually done this though not to show off but rather it’s just
|
||||
something I’m capable of…</li>
|
||||
<li>Watch a film at the same time.</li>
|
||||
<li>Sneeze and/or cough.</li>
|
||||
<li>Have breakfast, lunch, afternoon tea, dinner or some other meal.</li>
|
||||
<li>Get pissed out of your mind to make it difficult to think (please do not
|
||||
drive!).</li>
|
||||
<li>Do more than one or all of the above at the same time (the longer the snake
|
||||
becomes the more often you should do these things).</li>
|
||||
<li>Eat a <a href="cake.jpg">great chocolate cake</a>. Actually you should do that whether you’re
|
||||
trying to show off or not. Sleep, bathe, eat chocolate cake, play Snake, eat
|
||||
chocolate cake, play Snake, sleep, … For a great recipe see below.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>But if that’s not enough I don’t know what to tell you other than suggest that
|
||||
you make use of your talents for financial gain or at least a world record.
|
||||
Either way I tip my proverbial snakeskin hat to you (animal cruelty but a pun is
|
||||
a pun and every pun deserves to be shed).</p>
|
||||
|
||||
<h4><a name="moult" href="#toc">How do snakes grow in real life?</a></h4>
|
||||
|
||||
<p>They grow through a process called moulting - shedding their skin (other
|
||||
creatures also moult). This takes place over some days and unlike humans snakes
|
||||
never stop growing (though growth slows down as they mature). I chose the
|
||||
variables <strong>SHED</strong> and <strong>SHEDS</strong> for simplicity and because the words are
|
||||
shorter. I don’t like the words because it’s rather a misnomer but what I had
|
||||
chosen before was longer - STRETCH and STRETCHES.</p>
|
||||
|
||||
<h4><a name="other" href="#toc">Any other interesting things about snakes?</a></h4>
|
||||
|
||||
<p>For the fascinating science behind snake slithering see <a href="https://www.bbc.co.uk/news/science-environment-35563941">Snake walk: The physics
|
||||
of slithering</a>. For the bizarre thought of snake human hybrids see <a href="http://www.macroevolution.net/snake-human-hybrids.html">human
|
||||
snakes</a>. The latter is hard to comprehend and there are some sad tails (tales)
|
||||
in there too because I believe that people actually believe in this (how/why I
|
||||
do not know) and they really do tell the truth as they see it (even if
|
||||
impossible).</p>
|
||||
|
||||
<h4><a name="opposite" href="#toc">Why can you go the opposite direction and so immediately die when not cannibalising?</a></h4>
|
||||
|
||||
<p>When Ilya Kurdyukov was playing with this he questioned why this is possible
|
||||
when other implementations don’t have it this way. There are a few reasons.</p>
|
||||
|
||||
<p>First is that the friend’s implementation had it that way and it had been a long
|
||||
time since I had played it (if I ever did? I don’t know now: I played so many
|
||||
games over the years and the game most alike it that I played is Surround, as
|
||||
below).</p>
|
||||
|
||||
<p>It also is the way it is in Surround.</p>
|
||||
|
||||
<p>It makes cannibalism mode very interesting.</p>
|
||||
|
||||
<p>And I happen to like it the way I have it. In the end a snake isn’t an obstacle
|
||||
for itself but in the game it is and I went all the way instead of only halfway.</p>
|
||||
|
||||
<p>It also would take more bytes and that’s a problem with IOCCC rule 2b.</p>
|
||||
|
||||
<p>But if you have a problem with it you can always enable cannibalism and keep
|
||||
walls passable and not worry about dying.</p>
|
||||
|
||||
<h4><a name="chocolatecake" href="#toc">Do you have any <strong>DELICIOUS CHOCOLATE CAKE</strong> recipes?</a></h4>
|
||||
|
||||
<p>Why yes I do! So good in fact that even my late stepmum who didn’t even like
|
||||
chocolate (except white chocolate) loved this cake. It’s a double-layered
|
||||
chocolate fudge cake. See the file <a href="chocolate-cake.html">chocolate-cake.html</a> for the recipe.
|
||||
Note that it’s a complicated but it’s well worth it!</p>
|
||||
|
||||
<p>I included it in all my entries this year because if any of them won more people
|
||||
can have this recipe; also it might help remind the judges that they really
|
||||
should have their cook bake it so they can all - including the cook should they
|
||||
also like chocolate - enjoy the cake whilst judging (and otherwise - it’s a big
|
||||
cake and very rich). Sadly they didn’t get to enjoy it during their judging due
|
||||
to the pandemic but maybe next time (or they can do on their own).</p>
|
||||
|
||||
<p>Do make sure to pay attention to all notes!</p>
|
||||
|
||||
<h5>A note on the icing and room temperature</h5>
|
||||
|
||||
<p>Please be advised that the note there that talks about the icing being difficult
|
||||
in too warm room is rather significant; unfortunately with SARS-CoV-2 this might
|
||||
be more of a problem depending on how long it lasts and where you reside. If
|
||||
necessary use the refrigerator or else air conditioner to cool down the place.</p>
|
||||
|
||||
<h4><a name="alt" href="#toc">What are the files prog.2.c, prog.3.c, prog.3-j.c and prog.alt.c ?</a></h4>
|
||||
|
||||
<p>I submitted three Snake versions; these are the other layouts for those few
|
||||
(or more likely none) who are interested to see them.</p>
|
||||
|
||||
<p>The prog.2.c has more digraphs but I think no other significant differences.</p>
|
||||
|
||||
<p>The prog.3.c is in a more artistic layout (a backwards S), has at least one
|
||||
additional obfuscation technique (see spoilers) but it also has more digraphs
|
||||
and as the judges said they feel that digraphs are dated so that’s probably why
|
||||
they chose the first layout. The prog.3-j.c version is prog.3.c with a shorter J
|
||||
define.</p>
|
||||
|
||||
<p>The prog.alt.c version is the one that allows for customising the bug colour and
|
||||
it’s used in both <a href="snake-colours.sh">snake-colours.sh</a> and <a href="play.sh">play.sh</a>. It also calls <code>erase()</code>
|
||||
first, clearing the screen, which the play.sh and snake-colours.sh scripts also
|
||||
both do.</p>
|
||||
|
||||
<h2>Author’s dedication:</h2>
|
||||
|
||||
<h3><a name="winning" href="#toc">Winning thoughts, dedications and thanks</a></h3>
|
||||
|
||||
<p>Once again I’m honoured to win along with some of the other veterans who I have
|
||||
a huge amount of respect for; there’s Don Yang, Dave Burton, Yusuke Endoh and
|
||||
Edward Giles all of whom are amazing programmers. I’m especially proud to win
|
||||
besides Dave Burton and Yusuke Endoh but Don Yang and Edward Giles too.</p>
|
||||
|
||||
<p>But there are some others who I don’t remember like Ilya Kurdyukov (who’s
|
||||
offered a lot of interesting thoughts on Snake and who plans to have his own
|
||||
version after the entries are published), Nathan Otterness, Nicholas Carlini
|
||||
(whose entry is an absolutely brilliant abuse of printf - and I totally agree
|
||||
with the judges comments that your entry is so novel that it’ll be worth special
|
||||
mention in the future Best of IOCCC list!) and tsoj too.</p>
|
||||
|
||||
<p>Well done and congratulations to all of you again! Thank you for submitting the
|
||||
wonderful entries and I’m honoured to have my two entries beside yours!</p>
|
||||
|
||||
<p>To Dave Burton I thank you for your wonderful comments as well as pointing out
|
||||
that even with prog.orig.c it probably would be better to make use of the alt
|
||||
target instead of naming prog.c prog.orig.c. You’re quite right, I had thought
|
||||
of it but you brought it up so I could correct it. Much appreciated mate.</p>
|
||||
|
||||
<p>I would like to dedicate this entry to my wonderful mum Dianne Ferguson whom I
|
||||
love with all my heart and soul <3 Thank you for being the best mother
|
||||
imaginable! You’ve been there for me in the darkest of my hours without question
|
||||
without complaint and with all the love, compassion, empathy, sympathy and
|
||||
devotion anyone could ever ask for. Bless you again and again and again dear
|
||||
mother.</p>
|
||||
|
||||
<p>I also want to dedicate this to Vicky Wilmore who has given me a lot of
|
||||
love the past few years and who was there for me in some very dark times. Thank
|
||||
you Vicky sweetheart from the bottom of my heart and soul. Although we have
|
||||
parted ways, whether for now or for ever, you will always always always have a
|
||||
place in my heart and soul xxx</p>
|
||||
|
||||
<p>I would like to thank my dear friend Martijn Schoemaker for encouraging me in my
|
||||
programming over the years and who I owe a great deal to. Thank you for
|
||||
believing in me and my programming abilities (and other abilities) even when I
|
||||
couldn’t believe in myself! Very much appreciated especially coming from an
|
||||
amazing programmer who I have huge admiration for!</p>
|
||||
|
||||
<p>I want to thank Ilya Kurdyukov for his helpful comments, suggestions and
|
||||
reporting the problem about half-width/full-width char spacing. He’s been
|
||||
playing with some versions of his own and will have them on GitHub after the
|
||||
2020 IOCCC winning entries have been published.</p>
|
||||
|
||||
<p>Finally I want to thank Leo Broukhis, Simon Cooper and Landon Curt Noll for
|
||||
continuing to hold the contest after all these years - and for having selected
|
||||
my entries. It’s a huge honour; thank you! I also happen to <strong>love</strong> your
|
||||
comments as well as the award titles. And yes indeed ‘most of us could use
|
||||
<em><a href="chocolate-cake.html">Double-layered Chocolate Fudge Cake</a></em>!’</p>
|
||||
<BR>
|
||||
<HR>
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2020,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,771 +0,0 @@
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.2.2">
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=utf-8"> <link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css" />
|
||||
<title></title>
|
||||
<title>Most enigmatic</title>
|
||||
</head>
|
||||
<body>
|
||||
<CENTER>
|
||||
<IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
|
||||
<P><FONT size="6"><I>The International Obfuscated C Code Contest</I></FONT></P>
|
||||
<div id="bar">
|
||||
<ul>
|
||||
<li><a href="../index.html">About the 27th IOCCC</a></li>
|
||||
<li><a href="../whowon.html">27th IOCCC Winners</a></li>
|
||||
<li><a href="/index.html">IOCCC home</a></li>
|
||||
<li><a href="/winners.html">List of All Winners</a></li>
|
||||
<li><a href="/judges.html">The Judges</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<P><FONT size="6"><B>A 27<sup>th</sup> IOCCC Winner</B></FONT></P>
|
||||
</CENTER>
|
||||
|
||||
|
||||
<h1>Most enigmatic</h1>
|
||||
|
||||
<p>Cody Boone Ferguson <a href="mailto:ioccc@xexyl.net">ioccc@xexyl.net</a><br/>
|
||||
<a href="https://ioccc.xexyl.net">https://ioccc.xexyl.net</a><br/>
|
||||
Twitter: @xexyl</p>
|
||||
|
||||
<p>The code for this entry can be found in <a href="prog.c">prog.c</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make
|
||||
./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code># IOCCC obfuscated!
|
||||
echo IOCCC | ./prog
|
||||
|
||||
# IOCCC obfuscated and de-obfuscated!
|
||||
echo IOCCC | ./prog | ./prog
|
||||
|
||||
# more input fun
|
||||
./prog - < try.this.txt 2>/dev/null
|
||||
|
||||
# more obfuscated fun
|
||||
echo testing test tests | ./recode
|
||||
echo testing test tests | ./recode | ./prog - 2>/dev/null
|
||||
echo testing test tests | ./recode | ./prog - 2>/dev/null | ./recode
|
||||
echo testing test tests | ./recode | ./prog - 2>/dev/null | ./recode | ./prog - 2>/dev/null
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This code is an enigma. Try to decode it!</p>
|
||||
|
||||
<p>There is a good deal of useful documentation that is provided with this entry:</p>
|
||||
|
||||
<ul>
|
||||
<li>enigma.1</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>A useful man page for this entry. To render, try:</p>
|
||||
|
||||
<pre><code>man ./enigma.1
|
||||
</code></pre>
|
||||
|
||||
<ul>
|
||||
<li>recode.markdown (<a href="recode.html">recode.html</a>)</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Some useful information about recode.c</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="chocolate-cake.html">chocolate-cake.html</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Because most of us could use some <em>Double-layered Chocolate Fudge Cake</em>!</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<p>My remarks about my Heer ‘Army’ and Luftwaffe ‘Air Force’ Enigma simulator for
|
||||
the 27th IOCCC.</p>
|
||||
|
||||
<p>I want to dedicate this entry in part to the millions of poor souls that were
|
||||
lost during the tragedy that is the Second World War. There are so many people
|
||||
who are unknown, unloved, unclaimed and even unidentified. And who knows what
|
||||
they might have gone on to do if their lives weren’t - like it is with all other
|
||||
wars - needlessly taken from them? When one considers it was all because the
|
||||
most powerful man in the world at the time felt he should rule all others it
|
||||
makes it somehow even more tragic: there wasn’t even a good reason for the war
|
||||
(is there ever?).</p>
|
||||
|
||||
<p>If one were to write the name of every person who died in the conflict in a
|
||||
book, it would take so many pages that the book would be so heavy, so long, so
|
||||
expensive to print, and it wouldn’t bring anyone back to life nor would it
|
||||
erase the suffering. Nothing will. It’s horrible.</p>
|
||||
|
||||
<p>There really are no words that can truly describe the tragedy but I wish to with
|
||||
my Enigma simulator honour each and every soul who was lost, or suffered, or
|
||||
suffered the loss of friends or loved ones, as well as the world itself, in and
|
||||
from one of the greatest tragedies in the history of mankind.</p>
|
||||
|
||||
<p>I will have more information on this entry at
|
||||
<a href="https://ioccc.xexyl.net/2020/enigma">https://ioccc.xexyl.net/2020/enigma</a> after the winning entries have been
|
||||
published.</p>
|
||||
|
||||
<p><a name="toc"></a>
|
||||
- <a href="#ioccc">IOCCC: An Enigma?</a></p>
|
||||
|
||||
<ul>
|
||||
<li><p><a href="#nathan">The 1992 Nathan entry</a></p></li>
|
||||
<li><p><a href="#usage">Usage</a></p>
|
||||
|
||||
<ul>
|
||||
<li><a href="#example">An example run</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p><a href="#recode">The recode.c configurator</a></p></li>
|
||||
<li><p><a href="#parsersubtlety">A parser subtlety that could cause confusion</a></p></li>
|
||||
<li><p><a href="#layout">On the source code layout</a></p></li>
|
||||
<li><p><a href="#obfuscation">Obfuscation</a></p></li>
|
||||
<li><p><a href="#bugs">Bugs, limitations, differences from the real Enigma machines and general notes</a></p></li>
|
||||
<li><p><a href="#kriegsmarine">Adding Kriegsmarine support</a></p></li>
|
||||
<li><p><a href="#portability">Portability</a></p></li>
|
||||
<li><p><a href="#winning">Winning thoughts, dedications and thanks</a></p></li>
|
||||
<li><p><a href="#resources">Resources</a></p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3><a name="ioccc" href="#toc">IOCCC: An Enigma?</a></h3>
|
||||
|
||||
<p>Is there a better single word that could describe the code that is IOCCC? I’m
|
||||
sure there are some other words that are equally as valid but I believe ‘Enigma’
|
||||
is a great word nonetheless.</p>
|
||||
|
||||
<p>However it’s curious that no winning entry has ever been a simulator of the
|
||||
German Enigma machine. I’m actually quite surprised at that because it’s such a
|
||||
brilliant piece of engineering of the time even though it had a critical flaw:
|
||||
that no letter could be itself; this combined with cribs (known or suspected
|
||||
plaintext) - which was down to carelessness, capturing an Enigma and sometimes
|
||||
settings sheet, as well as known messages the Germans started out with - allowed
|
||||
for cracking the code.</p>
|
||||
|
||||
<p>Combining this entry with two of the Morse code entries is particularly
|
||||
interesting because that’s what the Germans did: the party sending the message
|
||||
would first set up the machine, write down the letters and then transmit by
|
||||
Morse code the encoded message. Then those picking up on the message would note
|
||||
the Morse code, translate it to the alphabet and then input it into their Enigma
|
||||
machine configured in the same way and thus have the original message.</p>
|
||||
|
||||
<p>The <a href="/1998/dorsse/dorssel.hint">1998 ASCII / Morse code translator</a> entry (author Dorssel) prints the
|
||||
Morse code of text; and the <a href="/2014/vik/hint.text">2014 Morse audio transcoder</a> (author Vik) can be
|
||||
used to allow for the actual sound of it. With my entry we can complete the
|
||||
loop!</p>
|
||||
|
||||
<h3><a name="nathan" href="#toc">The 1992 Nathan entry</a></h3>
|
||||
|
||||
<p>The author (Nathan) of the <a href="/1992/nahan/nathan.hint">1992 Worst Abuse of the Rules</a> had this to say:</p>
|
||||
|
||||
<pre><code>This program is a hello world text encrypter/decrypter. It uses an
|
||||
enigma (I think) style encryption algorithm, where the encryption
|
||||
key character is modified by a value, determined from the previous
|
||||
character. Non-printable characters (those with ASCII values < ' '
|
||||
or > 0x7e) are passed unaltered, thus any kind of file may be
|
||||
successfully processed, but if the original is printable, the
|
||||
processed file will be too. The input is read from stdin, and the
|
||||
output presented to stdout. The key, a text string, is presented as
|
||||
a command argument. This is optional, and if omitted, the file is
|
||||
self-{de,en}crypted. To specify decryption, a "-" should be given
|
||||
before the key. (Actually encryption and decryption proper inverse
|
||||
operations, so you can use decrypt to scramble and encrypt to
|
||||
descramble, if you're perverse.)
|
||||
</code></pre>
|
||||
|
||||
<p>But the Enigma algorithm is more complex than that and my entry can encipher and
|
||||
decipher text in the manner of the Enigma machines of the Army (Heer) and Air
|
||||
Force (Luftwaffe); the Kriegsmarine ‘Navy’ was more complex (see section <a href="#kriegsmarine">Adding
|
||||
Kriegsmarine support</a> for more information on that.</p>
|
||||
|
||||
<p>My entry should also work as a non-military grade Enigma as it by default has an
|
||||
empty plugboard (they had none). I explain how to set up the simulator later.</p>
|
||||
|
||||
<p>Yusuke Endoh asked the judges and me if the real 1992 entry source was
|
||||
available. Simon Cooper didn’t have access to it because it was before his time in
|
||||
the IOCCC; but before the other judges could answer Ilya Kurdyukov sent a link to
|
||||
the original 1992 code. However because I do not know the current status of the
|
||||
regulation (though it seems unlikely that it still applies) I am only citing an
|
||||
old version of the IOCCC website:</p>
|
||||
|
||||
<pre><code> nathan - obfuscation by (trivial) encryption (source not exported)
|
||||
|
||||
Brian Westley decided to just ``screw the (US) government'' and make the real nathan.c source available. We also note that Nathan Sidwell who lives outside the US made his own source available as well.
|
||||
</code></pre>
|
||||
|
||||
<p>Anyone who wants to find it I am sure can but I leave that to them.</p>
|
||||
|
||||
<h3><a name="usage" href="#toc">Usage</a></h3>
|
||||
|
||||
<p>If you run the program by itself it’ll use the default settings and prompt you
|
||||
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><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 rotor (number), ring setting (letter) and
|
||||
ring (starting) position (letter). It will do this for the first, second and
|
||||
then third for each.</p>
|
||||
|
||||
<p>Then it will prompt you for the reflector (number). The first one is reflector B
|
||||
and the second is reflector C.</p>
|
||||
|
||||
<p>Finally it’ll prompt you for the plugboard pairs.</p>
|
||||
|
||||
<p>After that you can input the string and it’ll go from there.</p>
|
||||
|
||||
<h4><a name="example" href="#toc">An example run</a></h4>
|
||||
|
||||
<p>BTW: There’s a much more entertaining (and delicious) challenge or exercise in
|
||||
<a href="recode.markdown">recode.markdown</a> (involves <a href="chocolate-cake.html">chocolate-cake.html</a>). These however show
|
||||
the general program as well as how to use the two winning entries of the Morse
|
||||
code that I referred to earlier.</p>
|
||||
|
||||
<pre><code> $ ./prog -
|
||||
Ring 1: 3
|
||||
Setting 1: I
|
||||
Position 1: O
|
||||
Ring 2: 1
|
||||
Setting 2: C
|
||||
Position 2: C
|
||||
Ring 3: 5
|
||||
Setting 3: C
|
||||
Position 3: Z
|
||||
Reflector: 2
|
||||
Plugboard pair 1: CO
|
||||
Plugboard pair 2: DE
|
||||
Plugboard pair 3: SN
|
||||
Plugboard pair 4: XY
|
||||
Plugboard pair 5: MS
|
||||
Plugboard pair 6: AT
|
||||
Plugboard pair 7: VF
|
||||
Plugboard pair 8: UR
|
||||
Plugboard pair 9: KL
|
||||
Plugboard pair 10: BJ
|
||||
IOCCC
|
||||
^D
|
||||
CFDRG
|
||||
</code></pre>
|
||||
|
||||
<p>Notice that all output except the deciphered/enciphered text is sent to stdout.</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>You can also type it out like this though:</p>
|
||||
|
||||
<pre><code> $ ./prog
|
||||
IOCCC
|
||||
UUMMX
|
||||
</code></pre>
|
||||
|
||||
<p>The IOCCC comes from stdin; the UUMMX is 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><code> $ echo TEST|./prog |./vik | mplayer -demuxer rawaudio -
|
||||
</code></pre>
|
||||
|
||||
<p>And you would hear Morse code of the Enigma output of ‘TEST’ (i.e. KCWV). 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><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><code> $ ./vik e < test.raw
|
||||
SCWV
|
||||
</code></pre>
|
||||
|
||||
<p>However as can be seen the first char is wrong:</p>
|
||||
|
||||
<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><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 ‘LEST’ instead? In that case it worked fine:</p>
|
||||
|
||||
<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><code> $ echo IOCCC | ./prog | ./vik > ioccc.raw
|
||||
$ ./vik e < ioccc.raw
|
||||
UUMMX
|
||||
$ ./vik e < ioccc.raw | ./prog
|
||||
IOCCC
|
||||
</code></pre>
|
||||
|
||||
<p>Phew! The program redeemed itself after the test failure! :)</p>
|
||||
|
||||
<p>(Technically above it didn’t print a newline after the output and this is how it
|
||||
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 - UUMMX.)</p>
|
||||
|
||||
<p>What about the other Morse code entry?</p>
|
||||
|
||||
<pre><code> $ echo IOCCC | ./prog | ./dorssel
|
||||
..- ..- -- -- -..-
|
||||
</code></pre>
|
||||
|
||||
<h3><a name="recode" href="#toc">The recode.c configurator</a></h3>
|
||||
|
||||
<p>I have included a supplementary program ‘recode’ (<a href="recode.c">recode.c</a>) that can
|
||||
do a number of things which acts as a kind of wrapper and configurator to my
|
||||
entry. By default it prompts you for the settings (rotors/rings, ring settings,
|
||||
positions, reflector and plugboard pairs), validating input as you go.</p>
|
||||
|
||||
<p>After that it prompts for text that you can pass to the Enigma simulator;
|
||||
alternatively you can specify a file to read in.</p>
|
||||
|
||||
<p>It has a randomise mode and it can save/read the settings to/from a file to
|
||||
allow for duplicity (an archaic term for the state of being double but obviously
|
||||
for Enigma it has to also mean deceitful).</p>
|
||||
|
||||
<p>I recommend using this in a pipeline instead of the simulator itself if you want
|
||||
to change the configuration of the simulator because it offers a much richer
|
||||
experience (and because you can reuse the configuration without having to type
|
||||
it out again every time).</p>
|
||||
|
||||
<p>It does take the effort to try and prevent invalid input (as above) though maybe
|
||||
I didn’t think of everything. My entry was meant to be a simulator only as far
|
||||
as the ciphering goes but I thought this would make it much more interesting:
|
||||
make it more flexible by a wrapper program.</p>
|
||||
|
||||
<p>For examples using it (and a delicious challenge) see <a href="recode.markdown">recode.markdown</a>. See
|
||||
also <a href="recode.1">recode.1</a> and <a href="enigma.1">enigma.1</a> man pages.</p>
|
||||
|
||||
<h3><a name="parsersubtlety" href="#toc">A parser subtlety that could cause confusion</a></h3>
|
||||
|
||||
<p>The parser is in a sense rather rudimentary but allows for both interactive and
|
||||
automatic (e.g. via the recode program) input. This does mean that something
|
||||
like the following can happen:</p>
|
||||
|
||||
<pre><code> $ ./prog -
|
||||
Ring 1: 1AB
|
||||
Setting 1: Position 1: Ring 2: 2CD
|
||||
Setting 2: Position 2: Ring 3: 3
|
||||
Setting 3: A
|
||||
Position 3: B
|
||||
Reflector: 1A
|
||||
Plugboard pair 1: BC
|
||||
Plugboard pair 2: ..
|
||||
Plugboard pair 3: ..
|
||||
Plugboard pair 4: DE
|
||||
Plugboard pair 5: FG
|
||||
Plugboard pair 6: HI
|
||||
Plugboard pair 7: JK
|
||||
Plugboard pair 8: LM
|
||||
Plugboard pair 9: NO
|
||||
Plugboard pair 10: PQ
|
||||
IOCCC
|
||||
WD
|
||||
SIRDK
|
||||
</code></pre>
|
||||
|
||||
<p>First of all: what is that WD? I didn’t type that but it appeared it seems due
|
||||
to too much input that triggers this (it happens when I hit ctrl-d to end
|
||||
input).</p>
|
||||
|
||||
<p>If everything is input correctly it would show nothing except the actual Enigma
|
||||
output (maybe at times ^D - I have noticed this at least when I don’t fill in
|
||||
all plugboard pairs - which might or might not be possible with the Enigma
|
||||
machines that had plugboards, I really do not know). I don’t view this as a bug
|
||||
because the parsing of input is meant to be simple and in fact you can expect
|
||||
the same output from the same input even if there are errors in the input.</p>
|
||||
|
||||
<p>Anyway as you can see the first ‘1AB’ was the first ring, setting and position.
|
||||
After this it wants Ring 2 and I did similar; for ring 3 I did it each variable
|
||||
by itself. However for the reflector I did 1A and it only expects 1 char! So will
|
||||
that mean that the plugboard pairs are off? Yes it does seem to be so. This is
|
||||
buffering at play I believe but it’s useful for allowing the recode program to
|
||||
easily configure the Enigma machine. In the other markdown file I give a hint
|
||||
as to how this could be fixed but the caveat is it would necessitate a need for
|
||||
rewriting recode.c.</p>
|
||||
|
||||
<p>There’s another thing to be aware of and that’s the way the ranges are enforced.
|
||||
There are five rotors which obviously are in C 0-4 but in ‘natural language’
|
||||
1-5 (they were labelled I, II, III, IV and V though).</p>
|
||||
|
||||
<p>There are two reflectors and the same applies: in C 0-1 but in human it’s
|
||||
1-2 (technically these were reflectors B and C in the Enigma machine which I
|
||||
display by name in recode.c just like with the rotors).</p>
|
||||
|
||||
<p>For more information see <a href="recode.markdown">recode.markdown</a> or <a href="recode.html">recode.html</a>.</p>
|
||||
|
||||
<p>BTW: If you need a reminder to go to the gym just do your Enigma ABCs and it
|
||||
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><code> $ echo ABC | ./prog
|
||||
GYM
|
||||
$ echo ABC | ./prog | ./prog
|
||||
ABC
|
||||
</code></pre>
|
||||
|
||||
<h3><a name="layout" href="#toc">On the source code layout</a></h3>
|
||||
|
||||
<p>The layout of recode.c isn’t too significant (but see below) but I want to
|
||||
mention prog.c especially:</p>
|
||||
|
||||
<p>I did think of a more artistic layout but reflecting on it I think that the
|
||||
blankness of it can be another way of honouring all the many people who died
|
||||
in - like all other wars - what was a useless conflict because - again like all
|
||||
other wars - a powerful human being decided that they should rule others.</p>
|
||||
|
||||
<p>The blankness is a reflection of the millions of people who died unknown, uncared
|
||||
for, unloved, without ever being acknowledged in their far too short lives, some
|
||||
even unidentified; it’s the presence of absence.</p>
|
||||
|
||||
<p>I find it somehow fitting that the day I have finished this is 30 April 2020,
|
||||
which was exactly 75 years from the day that the person responsible for the
|
||||
Second World War, Adolf Hitler, ended his life. (I have since then made a bug
|
||||
fix but I consider this inconsequential).</p>
|
||||
|
||||
<p>As for recode.c though I really love this:</p>
|
||||
|
||||
<pre><code> /\
|
||||
/ This is *not* what you think:
|
||||
</code></pre>
|
||||
|
||||
<p>…because it seems so wrong in C code at first glance.</p>
|
||||
|
||||
<h3><a name="obfuscation" href="#toc">Obfuscation</a></h3>
|
||||
|
||||
<p>It’s an Enigma 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><code> ./recode -Robfuscation.key -fobfuscation.txt | ./prog - 2>/dev/null > obfuscation.markdown
|
||||
</code></pre>
|
||||
|
||||
<p>To encipher:</p>
|
||||
|
||||
<pre><code> ./recode -Robfuscation.key -fobfuscation.markdown | ./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.markdown">obfuscation.markdown</a> has the deciphered version. I am afraid
|
||||
I’m not so inclined to do that for the cake recipe: the idea there is to make it
|
||||
a fun exercise that when solved unlocks a wonderful double-layered chocolate
|
||||
fudge cake recipe. But given that my ‘Don’t tread on me award’ entry also
|
||||
has the recipe, not enciphered, one might just go there instead. Still it’s a
|
||||
fun way to explore this entry.</p>
|
||||
|
||||
<p>As for the <a href="obfuscation.key">obfuscation.key</a> file if you observe the contents you’ll find the
|
||||
word OBFUSCATION:</p>
|
||||
|
||||
<pre><code> 2OB5FU1SC2ATIONCDEFGHJKLMPQRYZ
|
||||
OB FU SC ATION
|
||||
</code></pre>
|
||||
|
||||
<h3><a name="bugs" href="#toc">Bugs, limitations, differences from the real Enigma machines and general notes</a></h3>
|
||||
|
||||
<p>Ways that my simulator differs from the real thing. Not all of these are bugs
|
||||
and some could be considered features; others are just differences.</p>
|
||||
|
||||
<ul>
|
||||
<li><p>Does not check for using the same rotor more than once. The real Enigma
|
||||
machines this would not work because they had to choose from a set of rotors and
|
||||
there were no duplicates. This shouldn’t be a problem here however except that
|
||||
it won’t be a possible configuration of the real Enigma machine. The <code>recode</code>
|
||||
program <em>however does validate this</em> (except when reading in settings via the
|
||||
<code>-R</code> option which I explain in the <a href="recode.markdown">recode.markdown</a> / <a href="recode.html">recode.html</a> file).</p></li>
|
||||
<li><p>The way the plugboard - for the machines that had them - is if you connect A
|
||||
to B then no other letters can connect to A or B. Earlier there wasn’t proper
|
||||
detection and this caused invalid output.</p>
|
||||
|
||||
<p> Why only 10 pairs when the German alphabet has 26 letters? It’s
|
||||
theoretically possible to have 13 but the Enigma typically had 10 pairs.
|
||||
It’s easy enough to update my entry to do this once you de-obfuscate it but
|
||||
I’m not helping there (and in fact I don’t think I could any more even if I
|
||||
wanted to - at least not easily!).</p></li>
|
||||
<li><p>It does not obviously have the clicking sound associated with the moving
|
||||
parts of the real machine. I think it would be annoying to have this as it
|
||||
processes each letter. However with the Morse code audio transcoder entry you
|
||||
can at least have the output played in Morse code as the Germans did; I think
|
||||
that is really cool (I think it’s really cool even if there’s a bug in it)! That
|
||||
it pays homage to that (and another) entry is a bonus here.</p></li>
|
||||
<li><p>The simulator doesn’t report errors but tries to gracefully deal with them:
|
||||
if one chooses a value out of range it moves it into the range (if > the max
|
||||
then the max, if < min then the min). If invalid chars are input for the
|
||||
plugboard pairs then it’s not added to the plugboard etc.</p></li>
|
||||
<li><p>The real Enigma machines had only letters: no digits, no punctuation. My
|
||||
entry prints <code>!isalpha()</code> chars untouched. The Germans had different systems for
|
||||
punctuations, numbers etc. (one of the documents I link to has these details).</p></li>
|
||||
<li><p>My entry preserves case of letters. The real Enigma had only one case as it
|
||||
was just a keyboard and they didn’t need case-sensitivity.</p></li>
|
||||
<li><p>Later models introduced a fourth rotor. The Kriegsmarine procedures were
|
||||
also far more complex than the Heer and Luftwaffe. I find this particularly
|
||||
interesting because it was Hermann Goering who was the Supreme Commander of the
|
||||
Luftwaffe and the intelligence agency Forschungsamt (FA) was his; it provided
|
||||
Hitler with invaluable information so one would think the Luftwaffe system would
|
||||
be more complex! See <a href="#kriegsmarine">adding Kriegsmarine support</a> for more
|
||||
information.</p></li>
|
||||
<li><p>I only include reflectors B and C. To have included more would have used too
|
||||
many bytes (each reflector and rotor is 26 characters!) and I could not include
|
||||
them for this reason; I include 5 rotors and 2 reflectors and that’s a total of
|
||||
(<code>5 * 26 + 2 * 26</code> == 182 chars) but there are as you can see many other strings
|
||||
too. It is however feasible to update the rotor and reflector options and you
|
||||
could even make your own versions if you wanted to. Doing this is an exercise to
|
||||
the reader however (the idea of trying this makes me cringe because of how I
|
||||
obfuscated things)!</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>There’s one thing I’m unsure of in my implementation. Because of all the
|
||||
possible settings I used some other simulators as a starting point and more
|
||||
importantly to validate that my code worked right. These other simulators had
|
||||
bugs though and so one thing looked odd and I don’t know if it is right or not.
|
||||
An online simulator appears correct but I don’t see the option to change that
|
||||
part.</p>
|
||||
|
||||
<p>If you notice in the Q() function where I set up specific pointers and other
|
||||
data there is a call to the macro ‘q’ but I only refer to the first ring setting
|
||||
(of which I no longer even know which element it is! Or was it position? I don’t
|
||||
even know that now for certain). That’s because the Python code did that (though
|
||||
very differently of course) but I also had to bug-fix the Python in another
|
||||
part.</p>
|
||||
|
||||
<p>I do not know if this is correct but as I show somewhere my entry does match the
|
||||
online simulator so I presume it is correct. It might be that the Germans tended
|
||||
to have it at A but again I do not know.</p>
|
||||
|
||||
<h3><a name="kriegsmarine" href="#toc">Adding Kriegsmarine support</a></h3>
|
||||
|
||||
<p>I said that one could add the additional rotors used by the Kriegsmarine but
|
||||
looking at this again it appears that it’s not as simple as adding the rotors to
|
||||
the code and updating the references to the array etc.</p>
|
||||
|
||||
<p>This is because rotors VI, VII and VII had two notches and this changes the way
|
||||
things work. The Kriegsmarine M4 also had an additional change which would
|
||||
complicate matters more.</p>
|
||||
|
||||
<p>I looked into trying to do this for another version after winning but some of
|
||||
the obfuscation techniques dramatically complicates even attempting this so I
|
||||
haven’t even tried.</p>
|
||||
|
||||
<p>It is feasible that you could add your own rotors however but I leave this as an
|
||||
exercise to the reader. I will say that the five rotors I, II, III, IV and V can
|
||||
be found in the source code verbatim and you could confirm it by looking them
|
||||
up; however much more would have to be done in order to get them to work, than
|
||||
to just put the strings in. Again the way I set things up complicates this
|
||||
greatly.</p>
|
||||
|
||||
<h3><a name="portability" href="#toc">Portability</a></h3>
|
||||
|
||||
<p>I have tested it under macOS, Fedora and CentOS Linux and all seems okay under
|
||||
these platforms. When I was in the final stages of obfuscation I made an error
|
||||
somehow (or else maybe the vim formatting caused a problem - I have seen this
|
||||
before) and I had to go back and undo some of the obfuscation to figure out what
|
||||
was going on (I had a hunch where and I noted it in the obfuscation I believe)
|
||||
but this made me wonder on if I made any other mistakes since it appeared to be
|
||||
working before that.</p>
|
||||
|
||||
<p>I don’t know if EBCDIC will work but I think it might because it appears that
|
||||
the alphabet is a contiguous sequence. I don’t believe endianness matters but I
|
||||
no longer remember what I’ve done in full and I’ve no way to test it.</p>
|
||||
|
||||
<p>If there are any inconsistencies in input/output one also has to be certain that
|
||||
input was put in correctly because as soon as a letter differs the entire
|
||||
sequence will be off.</p>
|
||||
|
||||
<p>The results of my test script (not included here but I will probably have it on
|
||||
my website) are the same under Fedora, CentOS and macOS.</p>
|
||||
|
||||
<h3><a name="resources" href="#toc">Resources</a></h3>
|
||||
|
||||
<h4>A note on Wehrmacht, its branches and other agencies and their Enigma machines</h4>
|
||||
|
||||
<p>The Wehrmacht was the defence force in full which included the Heer (army),
|
||||
Luftwaffe (air force) and Kriegsmarine (navy). As I said the Kriegsmarine
|
||||
procedures were more complex: they had additional rotors and one of their models
|
||||
had a different reflector system (thin instead of thick - some of the documents
|
||||
below discuss this). The military intelligence agency, the Abwehr, had their own
|
||||
system too. Non-military grade Enigma machines didn’t have the plugboard. And
|
||||
so on.</p>
|
||||
|
||||
<p>However one of the documents below distinguishes the Kriegsmarine from the
|
||||
Wehrmacht; when you see this you can read it as the Kriegsmarine versus the rest
|
||||
of the Wehrmacht rather than the Wehrmacht and the Kriegsmarine.</p>
|
||||
|
||||
<p><a href="http://users.telenet.be/d.rijmenants/en/enigmaproc.htm">Enigma Message Procedures</a>: The Heer, Luftwaffe and Kriegsmarine Enigma
|
||||
procedures.</p>
|
||||
|
||||
<p><a href="http://enigmaco.de/enigma/enigma.html">Interactive Enigma Machine</a>: Shows wiring of the Enigma machine based on the
|
||||
settings and input (unfortunately uses Flash). This was what I used to verify
|
||||
output (as best I could find). To set this up to use the default settings in my
|
||||
simulator make sure to use Rotors I, II and III and the starting positions at B,
|
||||
B and C respectively (as in left, centre, right). To do this click the button at
|
||||
the top right that looks like:</p>
|
||||
|
||||
<pre><code>o->
|
||||
<-o
|
||||
</code></pre>
|
||||
|
||||
<p>And then select the rotors. Next click the button again at the left of the
|
||||
rotor selection ‘screen’. Then use the arrow buttons above each rotor to set
|
||||
from left to right B, B and C. After this you can type your message in the input
|
||||
field and watch the wiring of the rotors change and show the path it takes.</p>
|
||||
|
||||
<p>If I made use of the Enigma code in the recode.c program I would maybe consider
|
||||
doing something like that but I intentionally do not use it there: as cool as it
|
||||
might be it would give a better idea of how the algorithm works (unless I were
|
||||
to make it just as obscure as I do in prog.c but that’s also a bit risky). I
|
||||
don’t believe I could do it now anyway.</p>
|
||||
|
||||
<p>I’m uncertain how to change the rotor settings itself in this simulator to
|
||||
determine if the ring settings being different from ABC would cause a problem
|
||||
(this is the thing I mention I’m uncertain about in the bugs section).</p>
|
||||
|
||||
<p>Going back to the configuring the online simulator try inputting the text IOCCC
|
||||
and you’ll see the resulting text being:</p>
|
||||
|
||||
<pre><code>UUMMX
|
||||
</code></pre>
|
||||
|
||||
<p>Which is exactly as my entry shows! So at least for the starting position BBC
|
||||
and an empty plugboard and the other defaults in my entry (which appear to be
|
||||
consistent with the online simulator too) I can verify it works.</p>
|
||||
|
||||
<p><a href="http://www.codesandciphers.co.uk/enigma/index.htm">Tony Sale’s pages on The Enigma cipher machine</a>: This is many pages on the
|
||||
Enigma machine by the late Tony Sale who was the original curator of the
|
||||
Bletchley Park Museum. There is a wealth of information in these pages on how
|
||||
the Enigma worked and this includes some challenges to do to see how well you
|
||||
understand the algorithm.</p>
|
||||
|
||||
<p>Fun fact: the abbreviation for the Signals Intelligence is that of our
|
||||
wonderful SIGINT.</p>
|
||||
|
||||
<p><a href="http://users.telenet.be/d.rijmenants/en/enigmatech.htm">Technical Details of the Enigma Machine</a>: ‘This page provides the technical
|
||||
details of the Wehrmacht and Luftwaffe Enigma, and the Kriegsmarine Enigma M4.’
|
||||
It is quite a nice document with diagrams, pictures of actual Enigma rotors and
|
||||
other parts and more.</p>
|
||||
|
||||
<p><a href="http://users.telenet.be/d.rijmenants/en/enigma.htm">The German Enigma Cipher Machine</a>: The history of Enigma, its development,
|
||||
use during the war and cryptanalysis.</p>
|
||||
|
||||
<p><a href="http://www.ellsbury.com/enigma3.htm">How the Enigma was Set Up and Operated</a>: This is the third page in a document
|
||||
series on the Enigma that explains the initial set up of the Enigma machine for
|
||||
each day. This is a good introduction to the set up. There is one thing that I
|
||||
was not aware of (or if I was it did not register): the operator would after
|
||||
setting the positions also put in three letters before the actual message (there
|
||||
were several parts to each message but this was another layer of complexity). I
|
||||
did not implement this in the recode program but what would it be anyway? If the
|
||||
user here wants to they could add three letters to their message beginning. I
|
||||
don’t think there need be any addition to the recode program - at least not
|
||||
that.</p>
|
||||
|
||||
<h2>Author’s dedication:</h2>
|
||||
|
||||
<h3><a name="winning" href="#toc">Winning thoughts, dedications and thanks</a></h3>
|
||||
|
||||
<p>Once again I’m honoured to win along with some of the other veterans who I have
|
||||
a huge amount of respect for; there’s Don Yang, Dave Burton, Yusuke Endoh and
|
||||
Edward Giles all of whom are amazing programmers. I’m especially proud to win
|
||||
besides Dave Burton and Yusuke Endoh but Don Yang and Edward Giles too.</p>
|
||||
|
||||
<p>But there are some others who I don’t remember like Ilya Kurdyukov (who’s
|
||||
offered a lot of interesting thoughts on Snake and who plans to have his own
|
||||
version after the entries are published), Nathan Otterness, Nicholas Carlini
|
||||
(whose entry is an absolutely brilliant abuse of printf - and I totally agree
|
||||
with the judges comments that your entry is so novel that it’ll be worth special
|
||||
mention in the future Best of IOCCC list!) and tsoj too.</p>
|
||||
|
||||
<p>Well done and congratulations to all of you again! Thank you for submitting the
|
||||
wonderful entries and I’m honoured to have my two entries beside yours!</p>
|
||||
|
||||
<p>To Yusuke Endoh, Dave Burton and Nicholas Carlini I very much appreciate your
|
||||
wonderful comments on this program. Your comments Yusuke on this entry specially
|
||||
and also Dave’s comments on my double-win are both extremely special to me - it
|
||||
truly takes my pride to another level!</p>
|
||||
|
||||
<p>I would like to dedicate this entry to my wonderful mum Dianne Ferguson whom I
|
||||
love with all my heart and soul <3 Thank you for being the best mother
|
||||
imaginable! You’ve been there for me in the darkest of my hours without question
|
||||
without complaint and with all the love, compassion, empathy, sympathy and
|
||||
devotion anyone could ever ask for. Bless you again and again and again dear
|
||||
mother.</p>
|
||||
|
||||
<p>I also want to dedicate this to Vicky Wilmore who has given me a lot of
|
||||
love the past few years and who was there for me in some very dark times. Thank
|
||||
you Vicky sweetheart from the bottom of my heart and soul. Although we have
|
||||
parted ways, whether for now or for ever, you will always always always have a
|
||||
place in my heart and soul xxx</p>
|
||||
|
||||
<p>Once more besides those two I want to also dedicate this to all the many
|
||||
millions of people whose lives were taken from them in what amounts to - like
|
||||
all other wars - a horrible, pointless conflict and an utter waste of life,
|
||||
something precious that is far too often taken for granted. As I noted before I
|
||||
found it fitting that I finished this on 30 April 2020 - exactly 75 years after
|
||||
Adolf Hitler, he who started the Second World War, ended his life. The blankness
|
||||
of the layout is another way of honouring the poor souls who lost their lives,
|
||||
many of whom we will never know even their name let alone what they might have
|
||||
accomplished if it wasn’t for their tragic and pointless deaths. Always remember
|
||||
that life is precious and never ever take it for granted! Believe in yourselves.
|
||||
Everyone. Do not let anyone ruin that for you ever.</p>
|
||||
|
||||
<p>I would like to thank my dear friend Martijn Schoemaker for encouraging me in my
|
||||
programming over the years and who I owe a great deal to. Thank you for
|
||||
believing in me and my programming abilities (and other abilities) even when I
|
||||
couldn’t believe in myself! Very much appreciated especially coming from an
|
||||
amazing programmer who I have huge admiration for!</p>
|
||||
|
||||
<p>Finally I want to thank Leo Broukhis, Simon Cooper and Landon Curt Noll for
|
||||
continuing to hold the contest after all these years - and for having selected
|
||||
my entries. It’s a huge honour; thank you! I also happen to love your comments
|
||||
as well as the award titles. And yes indeed ‘most of us could use
|
||||
<em><a href="chocolate-cake.html">Double-layered Chocolate Fudge Cake</a></em>!’</p>
|
||||
<BR>
|
||||
<HR>
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2020,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,178 +0,0 @@
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.2.2">
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=utf-8"> <link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css" />
|
||||
<title></title>
|
||||
<title>Most phony</title>
|
||||
</head>
|
||||
<body>
|
||||
<CENTER>
|
||||
<IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
|
||||
<P><FONT size="6"><I>The International Obfuscated C Code Contest</I></FONT></P>
|
||||
<div id="bar">
|
||||
<ul>
|
||||
<li><a href="../index.html">About the 27th IOCCC</a></li>
|
||||
<li><a href="../whowon.html">27th IOCCC Winners</a></li>
|
||||
<li><a href="/index.html">IOCCC home</a></li>
|
||||
<li><a href="/winners.html">List of All Winners</a></li>
|
||||
<li><a href="/judges.html">The Judges</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<P><FONT size="6"><B>A 27<sup>th</sup> IOCCC Winner</B></FONT></P>
|
||||
</CENTER>
|
||||
|
||||
|
||||
<h1>Most phony</h1>
|
||||
|
||||
<p>Edward Giles<br/>
|
||||
<a href="https://id523a.com/">https://id523a.com/</a></p>
|
||||
|
||||
<p>The code for this entry can be found in <a href="prog.c">prog.c</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make
|
||||
./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./prog < pi.wav
|
||||
|
||||
# [https://en.wikipedia.org/wiki/867-5309/Jenny]
|
||||
./prog 867-5309 > jenny.wav
|
||||
|
||||
# Use an audio player to play jenny.wav
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>A cross platform utility for both encoding and decoding tones.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Introduction and Usage</h3>
|
||||
|
||||
<p>This program encodes and decodes <a href="https://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling">dual-tone multiple frequency</a> signals used in telephone systems, more commonly known as Touch-Tones.</p>
|
||||
|
||||
<p>If the program is executed with no arguments, it will read a WAV file from 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><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><code>$ ./prog 867-5309 | aplay
|
||||
</code></pre>
|
||||
|
||||
<h3>Interesting Features</h3>
|
||||
|
||||
<ul>
|
||||
<li>When compiled with <code>gcc -pedantic -Wall -Wextra</code> there are no compiler warnings.</li>
|
||||
<li>This program can be successfully compiled and run on Windows, using both Microsoft’s C compiler and <a href="https://bellard.org/tcc/">TCC</a>.</li>
|
||||
<li>This program resamples the incoming audio, so that it can accept audio data at any sample rate.</li>
|
||||
<li>The code that generates the output sine-waves is the same as the code that looks for sine-waves in the input. (see Algorithm Details for roughly how this works)</li>
|
||||
<li>Despite handling lots of sine waves, the program only uses basic arithmetic operations. It does not depend on <code>libm</code>.</li>
|
||||
<li>All type punning is done with <code>memcpy</code> so there are no strict-aliasing violations.</li>
|
||||
<li>The size of the source code using the IOCCC size tool is 1963, the year the first push-button telephones were made available to customers.</li>
|
||||
<li>The source code is roughly in the shape of a telephone handset.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Assumptions</h3>
|
||||
|
||||
<ul>
|
||||
<li>Code is compiled using the C99 or C11 standard</li>
|
||||
<li><code>CHAR_BIT == 8</code></li>
|
||||
<li>Machine is little-endian</li>
|
||||
<li><code>int16_t</code>, <code>uint16_t</code>, and <code>uint32_t</code> exist</li>
|
||||
<li><code>int16_t</code> is 2’s-complement</li>
|
||||
<li><code>double</code> is an IEEE 754 binary64 floating-point type</li>
|
||||
<li><code>sizeof(double) == 8</code></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Obfuscations</h3>
|
||||
|
||||
<ul>
|
||||
<li>DSP code is inherently somewhat difficult to understand.</li>
|
||||
<li>Lots of identifier reuse. Each identifier is used for about 2.2 different tasks, on average.
|
||||
For example, <code>aa</code> is both a variable and a macro for error handling,
|
||||
and <code>memcpy</code> is both a library function and a goto-label.</li>
|
||||
<li>Most of the identifiers are only 1 or 2 characters long, and are unrelated to their actual function.</li>
|
||||
<li>The <code>f</code> macro is used to unroll some of the loops.</li>
|
||||
<li>Some numerical constants are replaced with character literals, so the actual value is unclear.</li>
|
||||
<li>All of the strings used by the program have been combined into a single string literal.</li>
|
||||
<li>Most of the values used for the actual signal-processing all reside in one array, named <code>l</code>. This array is usually accessed at index <code>z</code> plus a constant. Accesses of this type have been rewritten from, e.g. <code>l[z+17]</code> to <code>17[l+z]</code>. <code>[l+z]</code> ends up occurring quite often, so I created the macro <code>a</code> as a shorthand.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Algorithm Details</h3>
|
||||
|
||||
<p>Each tone in a DTMF signal is a combination of two frequencies. The lower frequency determines which row the digit is in, and the higher frequency determines the column. There are 4 possible row frequencies and 4 possible column frequencies.</p>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th> <strong>1209 Hz</strong> </th>
|
||||
<th> <strong>1336 Hz</strong> </th>
|
||||
<th> <strong>1477 Hz</strong> </th>
|
||||
<th> <strong>1633 Hz</strong> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td> <strong>697 Hz</strong> </td>
|
||||
<td> 1 </td>
|
||||
<td> 2 abc </td>
|
||||
<td> 3 def </td>
|
||||
<td> A </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <strong>770 Hz</strong> </td>
|
||||
<td> 4 ghi </td>
|
||||
<td> 5 jkl </td>
|
||||
<td> 6 mno </td>
|
||||
<td> B </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <strong>852 Hz</strong> </td>
|
||||
<td> 7 pqrs </td>
|
||||
<td> 8 tuv </td>
|
||||
<td> 9 wxyz </td>
|
||||
<td> C </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <strong>941 Hz</strong> </td>
|
||||
<td> * </td>
|
||||
<td> 0 </td>
|
||||
<td> # </td>
|
||||
<td> D </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<p>This program determines which frequencies are present in the input by passing it through a set of 8 virtual resonators, each tuned to one of the frequencies used for DTMF. These can be implemented using only basic arithmetic, and they are able to ‘select’ a specific frequency from the input sound, blocking all other frequencies from reaching the output. The loudness of the sound output from each resonator can therefore be used as a measure of how much of a particular frequency was present in the input. The program then decides, over the course of one tone, which row frequency and which column frequency were most prominent.</p>
|
||||
|
||||
<p>Tones are generated using those same resonators by providing <a href="https://en.wikipedia.org/wiki/Kronecker_delta#Digital_signal_processing">an impulse</a> as input. An impulse can be thought of as consisting of sine-waves at all frequencies, and when it is put through one of the resonators, the result is a single pure sine wave.</p>
|
||||
<BR>
|
||||
<HR>
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2020,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
-117
@@ -1,117 +0,0 @@
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.2.2">
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=utf-8"> <link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="hint.css" />
|
||||
<title></title>
|
||||
<title>README</title>
|
||||
</head>
|
||||
<body>
|
||||
<CENTER>
|
||||
<IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
|
||||
<P><FONT size="6"><I>The International Obfuscated C Code Contest</I></FONT></P>
|
||||
<div id="bar">
|
||||
<ul>
|
||||
<li><a href="index.html">About the 27th IOCCC</a></li>
|
||||
<li><a href="whowon.html">27th IOCCC Winners</a></li>
|
||||
<li><a href="/index.html">IOCCC home</a></li>
|
||||
<li><a href="/winners.html">List of All Winners</a></li>
|
||||
<li><a href="/judges.html">The Judges</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<P><FONT size="6"><B>The 27<sup>th</sup> IOCCC</B></FONT></P>
|
||||
</CENTER>
|
||||
|
||||
|
||||
<h2>2020 marked the “The Twenty Seventh International Obfuscated C Code Contest”</h2>
|
||||
|
||||
<p>Copyright © 2020, Landon Curt Noll, Simon Cooper, and Leonid A.
|
||||
Broukhis. All Rights Reserved. Permission for personal, educational
|
||||
or non-profit use is granted provided this copyright and notice are
|
||||
included in its entirety and remains unaltered. All other uses
|
||||
must receive prior permission from the contest judges.</p>
|
||||
|
||||
<h2>Standard IOCCC stuff</h2>
|
||||
|
||||
The primary site can be found at <b>www.ioccc.org</b>.
|
||||
|
||||
<p>Use make to compile entries. It is possible that on non-Un*x / non-Linux
|
||||
systems the makefile needs to be changed. See the Makefile for details.</p>
|
||||
|
||||
<p>Look at the source and try to figure out what the programs do, and run
|
||||
them with various inputs. If you want to, look at the hints files for
|
||||
spoilers - this year we included most of the information included
|
||||
by the submitter.</p>
|
||||
|
||||
<p>Read over the makefile for compile/build issues. Your system may require
|
||||
certain changes (add or remove a library, add or remove a #define).</p>
|
||||
|
||||
<p>Some C compilers are not quite as good as they should be. If yours is
|
||||
lacking, you may need to compile using clang or gcc instead of your local
|
||||
compiler.</p>
|
||||
|
||||
<h2>Remarks on some of the winners</h2>
|
||||
|
||||
<p>This year’s Best of Show (carlini) is such a novel way of obfuscation that it would be
|
||||
worth of a special mention in the (future) Best of IOCCC list!</p>
|
||||
|
||||
<p>For some reason, this year’s set of winners contains three nostalgic games,
|
||||
Asteroids (tsoj), Minesweeper (endoh1), and Snake (ferguson1).</p>
|
||||
|
||||
<p>An entry (kurdyukov1) pays homage to a previous winner (2015/hou).</p>
|
||||
|
||||
<p>…We’ll stop spouting spoilers now. Have fun exploring all the entries!</p>
|
||||
|
||||
<h2>Remarks on some of submissions that did not win</h2>
|
||||
|
||||
<p>As a rule, we try to compile the entries on a variety of platforms.
|
||||
Quite a few entries this year could not be built or executed on some of them due to reliance on
|
||||
library internals or the system runtime.</p>
|
||||
|
||||
<p>A few entries were violating the “2053 significant bytes” rule. If an entry could not be brought to
|
||||
compliance within a few seconds of looking at the source, it was disqualified.</p>
|
||||
|
||||
<p>One entry tried to get around the size limit by putting the code into
|
||||
makefile variables and using -D. This is already called out as discouraged
|
||||
technique in the guidelines, but it is worth a reminder.</p>
|
||||
|
||||
<p>Several promising entries attempted to make use of the <code>syscall</code> function using literal syscall numbers.
|
||||
This is utterly non-portable.</p>
|
||||
|
||||
<p>A note to the authors: when submitting multiple entries, don’t let us easily correlate them by
|
||||
coding style or documentation content, and definitely don’t submit nearly identical versions
|
||||
of your program separately. As we try to judge the entries anonymously, the similarities will cause such
|
||||
entries to compete against one another, making each less likely to win.</p>
|
||||
|
||||
<p>We hope the authors of non-winning entries will refine their entries and
|
||||
perhaps re-submit them for the next IOCCC.</p>
|
||||
|
||||
<h2>Final Comments</h2>
|
||||
|
||||
<p>One more thing that feels dated is digraphs and trigraphs.</p>
|
||||
|
||||
<p>Please feel free to send us comments and suggestions about the
|
||||
competition, this README or anything else that you would like to see in
|
||||
future contests.</p>
|
||||
|
||||
<p>If you use, distribute or publish these entries in some way, please drop
|
||||
us a line. We enjoy seeing who, where and how the contest is used.</p>
|
||||
|
||||
<p>If you have problems with any of the entries, AND YOU HAVE A FIX, please
|
||||
send us the fix (patch file or the entire changed file).</p>
|
||||
|
||||
<BR>
|
||||
<HR>
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2020,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,109 +0,0 @@
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.2.2">
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=utf-8"> <link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css" />
|
||||
<title></title>
|
||||
<title>Best utility</title>
|
||||
</head>
|
||||
<body>
|
||||
<CENTER>
|
||||
<IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
|
||||
<P><FONT size="6"><I>The International Obfuscated C Code Contest</I></FONT></P>
|
||||
<div id="bar">
|
||||
<ul>
|
||||
<li><a href="../index.html">About the 27th IOCCC</a></li>
|
||||
<li><a href="../whowon.html">27th IOCCC Winners</a></li>
|
||||
<li><a href="/index.html">IOCCC home</a></li>
|
||||
<li><a href="/winners.html">List of All Winners</a></li>
|
||||
<li><a href="/judges.html">The Judges</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<P><FONT size="6"><B>A 27<sup>th</sup> IOCCC Winner</B></FONT></P>
|
||||
</CENTER>
|
||||
|
||||
|
||||
<h1>Best utility</h1>
|
||||
|
||||
<p>Ilya Kurdyukov<br/>
|
||||
<a href="https://github.com/ilyakurdyukov">https://github.com/ilyakurdyukov</a><br/>
|
||||
Twitter: @ilyakurdyukov</p>
|
||||
|
||||
<p>The code for this entry can be found in <a href="prog.c">prog.c</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make
|
||||
./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code># Obfuscated IOCCC
|
||||
echo IOCCC | ./prog
|
||||
|
||||
./prog < prog.x86.asm
|
||||
|
||||
./prog < prog.x86_64.asm
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This hash of a C code makes a hash out of input.
|
||||
Do you understand how?
|
||||
You should get a-round-to-it figuring it out!</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>MD5 with integers</h3>
|
||||
|
||||
<p>Just a tiny MD5 checksum utility. Prints hash string of data from stdin.
|
||||
Work same as <code>(openssl md5 | cut -d' ' -f2)</code> command.</p>
|
||||
|
||||
<h3>My objectives</h3>
|
||||
|
||||
<ol>
|
||||
<li>reduce code size as much as possible</li>
|
||||
<li>avoid warnings from GCC/CLANG <code>-Wall -Wextra -pedantic</code></li>
|
||||
<li>portable (regardless of register size and endianness)</li>
|
||||
<li>fit code in a round shape</li>
|
||||
<li>no macro defines</li>
|
||||
<li>no floating-point arithmetics</li>
|
||||
</ol>
|
||||
|
||||
|
||||
<h3>Notes</h3>
|
||||
|
||||
<p>The main difficulty of making MD5 code smaller is a 64x4 bytes long table with constants. Which will take more than 512 bytes in text hex encoding. This table is a results of a sine function, so can be generated dynamically, but merging floating-point arithmetics with precise integer calculations is not a great idea, because can make portability issues.</p>
|
||||
|
||||
<p>Attempts to satisfy CLANG <code>-Weverything</code> will ruin comma magic, that is so great for obfuscation, so I don’t want to care about that.</p>
|
||||
|
||||
<p>Probably, should work correctly on any machines, but I have nothing exotic (like BE or not 32/64) to try it.</p>
|
||||
|
||||
<p>Added a macro hack to make stdin work in binary mode under Windows (tested under mingw64), otherwise the hashes can be incorrect.</p>
|
||||
|
||||
<h3>Bonus</h3>
|
||||
|
||||
<ul>
|
||||
<li><p><code>prog.extra.c</code> the same with the sine function (so smaller), and in different shapes.</p></li>
|
||||
<li><p><code>prog.x86_64.asm</code> contains same program, but written on assembly for x86_64 Linux, for the sake of less executable size. Which is 500 bytes long (where 120 is for ELF headers) after compilation. Algorithm details is slightly differ (like constants packing), just to make smaller binary code. It’s interesting to compare density of binary code and obfuscated C.</p></li>
|
||||
<li><p><code>prog.x86.asm</code> and for x86, although the headers are smaller, but the binary code is larger due to fewer registers and lack of 64-bit multiply.</p></li>
|
||||
</ul>
|
||||
|
||||
<BR>
|
||||
<HR>
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2020,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,143 +0,0 @@
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.2.2">
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=utf-8"> <link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css" />
|
||||
<title></title>
|
||||
<title>Least detailed</title>
|
||||
</head>
|
||||
<body>
|
||||
<CENTER>
|
||||
<IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
|
||||
<P><FONT size="6"><I>The International Obfuscated C Code Contest</I></FONT></P>
|
||||
<div id="bar">
|
||||
<ul>
|
||||
<li><a href="../index.html">About the 27th IOCCC</a></li>
|
||||
<li><a href="../whowon.html">27th IOCCC Winners</a></li>
|
||||
<li><a href="/index.html">IOCCC home</a></li>
|
||||
<li><a href="/winners.html">List of All Winners</a></li>
|
||||
<li><a href="/judges.html">The Judges</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<P><FONT size="6"><B>A 27<sup>th</sup> IOCCC Winner</B></FONT></P>
|
||||
</CENTER>
|
||||
|
||||
|
||||
<h1>Least detailed</h1>
|
||||
|
||||
<p>Ilya Kurdyukov<br/>
|
||||
<a href="https://github.com/ilyakurdyukov">https://github.com/ilyakurdyukov</a><br/>
|
||||
Twitter: @ilyakurdyukov</p>
|
||||
|
||||
<p>The code for this entry can be found in <a href="prog.c">prog.c</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make prog prog_png prog_ppm
|
||||
./prog Nrect infile outfile
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code># Take a selfie
|
||||
./prog 1000 selfie.jpg output.jpg
|
||||
# Admire your portrait in cubist style
|
||||
|
||||
(echo P6 1024 1024 255; dd if=/dev/urandom bs=3M count=1) > random.ppm
|
||||
# Look at random.ppm. Do you see any patterns?
|
||||
./prog_ppm 1000 random.ppm output.ppm
|
||||
# See which patterns the program has found
|
||||
|
||||
for i in 0001 0002 0004 0008 0016 0032 0064 0128 0256 0512 1024 2048 4096 8192 ; do ./prog $i sample.jpg out$i.jpg; done
|
||||
# Then flip through the out*.jpg pictures and see when you start recognizing the image.
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This entry has reminded us of a winning entry back in the early 90s. Can you guess which one?</p>
|
||||
|
||||
<p>For a given image, try graphing the execution time relative to the number of rectangles.
|
||||
What is the complexity? Is it obvious from the source code?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Usage</h3>
|
||||
|
||||
<p>This program divides the image into a specified number of rectangles. This process is content aware, so algorithm tries to match most of the information. However, it doesn’t finds the best theoretically possible layout.</p>
|
||||
|
||||
<pre><code>./prog 1000 input.jpg output.jpg
|
||||
</code></pre>
|
||||
|
||||
<h3>Building</h3>
|
||||
|
||||
<p>You can build three versions, depending on the image format.</p>
|
||||
|
||||
<p>Default is JPEG version, if you have the <em>libjpeg</em> development package installed in your system, then <code>make</code> without arguments should do the thing.</p>
|
||||
|
||||
<p>If you want to use <em>libjpeg</em> compiled from sources, then use <code>LIBS</code> define to specify the path to includes and the library.</p>
|
||||
|
||||
<pre><code>make prog LIBJPEG="-Ijpeg-6b jpeg-6b/libjpeg.a"
|
||||
</code></pre>
|
||||
|
||||
<p>Use this command to build a PNG version (you need <em>libpng</em>):</p>
|
||||
|
||||
<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>
|
||||
|
||||
<h3>Building on OSX</h3>
|
||||
|
||||
<ul>
|
||||
<li>Thanks to Cody Ferguson for this information!</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>First, make sure you have the compiler tools installed e.g. by:</p>
|
||||
|
||||
<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><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 “makegif.sh”.</p>
|
||||
|
||||
<p>After that’s installed you need to run make with these options:</p>
|
||||
|
||||
<pre><code>$ make LIBS="-I/opt/local/include -L/opt/local/lib"
|
||||
</code></pre>
|
||||
|
||||
<h3>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 results look funny, like a kind of cubism pixelart.</p>
|
||||
|
||||
<p>Do not use values above 50000, it gonna be slow.</p>
|
||||
|
||||
<p>To understand how this works, just try running with 1,2,3,4… number of rectangles. At each iteration, the rectangle with the biggest difference from 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):<br/>
|
||||
<code>convert -delay 10 -dither none -loop 0 $(ls out*.png | sort -V) $(ls out*.png | sort -rV) +map out.gif</code><br/>
|
||||
Also provided <code>makegif.sh</code> to aid with gif creation.</p>
|
||||
<BR>
|
||||
<HR>
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2020,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,83 +0,0 @@
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.2.2">
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=utf-8"> <link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css" />
|
||||
<title></title>
|
||||
<title>Bset slaml prragom</title>
|
||||
</head>
|
||||
<body>
|
||||
<CENTER>
|
||||
<IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
|
||||
<P><FONT size="6"><I>The International Obfuscated C Code Contest</I></FONT></P>
|
||||
<div id="bar">
|
||||
<ul>
|
||||
<li><a href="../index.html">About the 27th IOCCC</a></li>
|
||||
<li><a href="../whowon.html">27th IOCCC Winners</a></li>
|
||||
<li><a href="/index.html">IOCCC home</a></li>
|
||||
<li><a href="/winners.html">List of All Winners</a></li>
|
||||
<li><a href="/judges.html">The Judges</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<P><FONT size="6"><B>A 27<sup>th</sup> IOCCC Winner</B></FONT></P>
|
||||
</CENTER>
|
||||
|
||||
|
||||
<h1>Bset slaml prragom</h1>
|
||||
|
||||
<p>Ilya Kurdyukov<br/>
|
||||
<a href="https://github.com/ilyakurdyukov">https://github.com/ilyakurdyukov</a><br/>
|
||||
Twitter: @ilyakurdyukov</p>
|
||||
|
||||
<p>The code for this entry can be found in <a href="prog.c">prog.c</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make
|
||||
./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code># first input to try
|
||||
echo first input to try | ./prog
|
||||
|
||||
# try reading this output
|
||||
echo International Obfuscated C Code Contest | ./prog
|
||||
|
||||
# try reading this other output
|
||||
./prog < input.txt
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>It is interesting how well smeonoe can raed txet wtih lots of tyops in it.
|
||||
How well can you raed porg.c, C prgoarm that is in the shpae of an SD card (or
|
||||
is it a pnuch crad)?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Letter Mixer</h3>
|
||||
|
||||
<p>Compile and try this:</p>
|
||||
|
||||
<p>cat some.input.txt | ./prog</p>
|
||||
|
||||
<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>
|
||||
<BR>
|
||||
<HR>
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2020,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,149 +0,0 @@
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.2.2">
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=utf-8"> <link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css" />
|
||||
<title></title>
|
||||
<title>Best abuse of lámatyávë</title>
|
||||
</head>
|
||||
<body>
|
||||
<CENTER>
|
||||
<IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
|
||||
<P><FONT size="6"><I>The International Obfuscated C Code Contest</I></FONT></P>
|
||||
<div id="bar">
|
||||
<ul>
|
||||
<li><a href="../index.html">About the 27th IOCCC</a></li>
|
||||
<li><a href="../whowon.html">27th IOCCC Winners</a></li>
|
||||
<li><a href="/index.html">IOCCC home</a></li>
|
||||
<li><a href="/winners.html">List of All Winners</a></li>
|
||||
<li><a href="/judges.html">The Judges</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<P><FONT size="6"><B>A 27<sup>th</sup> IOCCC Winner</B></FONT></P>
|
||||
</CENTER>
|
||||
|
||||
|
||||
<h1>Best abuse of lámatyávë</h1>
|
||||
|
||||
<p>Ilya Kurdyukov<br/>
|
||||
<a href="https://github.com/ilyakurdyukov">https://github.com/ilyakurdyukov</a><br/>
|
||||
Twitter: @ilyakurdyukov</p>
|
||||
|
||||
<p>The code for this entry can be found in <a href="prog.c">prog.c</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make
|
||||
./prog text_file output_length context_length random_seed
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./prog Shakespeare.txt 2000 10 1
|
||||
./prog Shakespeare.txt 2000 9 1
|
||||
./prog Shakespeare.txt 2000 8 1
|
||||
# ... Why does it get progressively slower when the context length decreases?
|
||||
|
||||
./prog Eugene_Onegin.txt 2000 10 1
|
||||
# For those not knowing Russian, just to see how the UTF-8 characters are handled
|
||||
</code></pre>
|
||||
|
||||
<p>(<em>Performance depends on the number of same hashes found.</em>
|
||||
<em>Too many identical strings if the context length is small. author</em>)</p>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>We were able to write our own program performing the same trick
|
||||
using the (still non-standard, for some reason) library function <code>memmem</code>,
|
||||
but that way it works too fast regardless of the context length, and it’s much less fun.</p>
|
||||
|
||||
<p>(<em>Wow, amazing! Very fast, but there is a drawback to randomness.</em>
|
||||
<em>If some string only appears after half the input, the first instance</em>
|
||||
<em>of this string will have a 50% chance of occurrence.</em>
|
||||
<em>Example:</em></p>
|
||||
|
||||
<pre><code>echo "00000000000000000000 01 02 02 02 02 02 02" > test.txt
|
||||
./prog test.txt 1000 2 123
|
||||
# more twos in output
|
||||
./rand test.txt 1000 2 123
|
||||
# more ones in output
|
||||
</code></pre>
|
||||
|
||||
<p><em>But this will happen very rarely on real data. author</em>)</p>
|
||||
|
||||
<p>Try using the same random seed and varying the context size.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Building</h3>
|
||||
|
||||
<pre><code>cc prog.c -o prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Usage</h3>
|
||||
|
||||
<p>This program generates random text from the provided dictionary using a Markov chain, outputs to <code>stdout</code>.</p>
|
||||
|
||||
<pre><code>./prog input.txt 2000 10 12345
|
||||
</code></pre>
|
||||
|
||||
<p>Parameters are:</p>
|
||||
|
||||
<ol>
|
||||
<li><p>dictionary filename
|
||||
Need at least the size of the book, the more the better (1Mb), you can concatenate several books into one file. This should be a text file (not <code>.doc</code>/<code>.pdf</code>). You can feed with books in <code>.fb2</code> format, metadata is filtered. Whitespace characters is also filtered. For languages other than English, it’s better to use ANSI encoding. You can use UTF, but you need to increase chain length (if one ANSI character is encoded as two UTF bytes, then multiply chain length by two).</p></li>
|
||||
<li><p>bytes to generate (limited at 1Mb)</p></li>
|
||||
<li><p>chain length
|
||||
Randomness and performance depend inversely on this parameter and the size of the dictionary. If you feel that bytes are generated too slowly, then you need to increase the length of the chain. This length means that any part of the output of this size in bytes exists somewhere in the dictionary.</p></li>
|
||||
<li><p>random seed</p></li>
|
||||
</ol>
|
||||
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
<p>You can try this with the inputs provided with <code>2019/mills</code> from the IOCCC winners.</p>
|
||||
|
||||
<pre><code>$ ./prog shakespeare.txt 2001 10 12345
|
||||
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,
|
||||
Have other some, he is in Rome: but where is Warwick frowns at his. PRINCE EDWAR
|
||||
D: Where is the light: But I will watch thy waking, what work he makes Amongst y
|
||||
ou? Come, sirs, We shall write to you, fortune and The hazard of much blood. I w
|
||||
ould to heaven, respective lenity, And fire-eyed fury be my convoy in the senten
|
||||
ced; 'tis too horrible, so bloody on the banks If they were created, Would bring
|
||||
them to our presence? FLORIZEL: And those his golden crown, What is six winters
|
||||
? they are but Lewis and Warwick bids you come too late come from the king's fri
|
||||
end, and will do't; for, look you, sir, For still thy true servitor: I will rend
|
||||
an oak And peg thee in his knotty entrails till Thou hast hazel eyes: what eye
|
||||
but such an eye would spy out such a day to-morrow, or next day: He is within th
|
||||
e limit of the like, forsworn to love, Send her a story of more woe Than this is
|
||||
a merry ballad, but a very pretty one. MOPSA: Thou hast amazed me, My name is E
|
||||
lbow: I do lean upon, Now thou art: Thy tears are womanish; thy wild acts denote
|
||||
The unreasonably: come, you must: and there, I then do't to them? VOLUMNIA: Now
|
||||
the red pestilence hangs in our aim, which is yours. What is't your honour, as
|
||||
in war, since then, You have said before: My child is dead; or 'twere not 'long
|
||||
of him; but he, like you, lads; about your ears it is Menenius? Second Officer:
|
||||
Come, come, young wanton and effeminate boy, Takes on the hungry beach Fillip th
|
||||
e stars Shall bitterly begin his wooing that we have in hand are angry And frown
|
||||
ing brow to brow, ourselves, Still your own affections are devised, As blanks, b
|
||||
enevolences, and I thank thee for it. KING HENRY VI: Master lieutenant comes. Ma
|
||||
ster lieutenant comes. Master lieutenant, pray you,-- CORIOLANUS: What's that to
|
||||
him? CHRISTOPHER: At Pembroke, Sir James Blunt, And Rice ap Thomas with a virtu
|
||||
</code></pre>
|
||||
<BR>
|
||||
<HR>
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2020,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,185 +0,0 @@
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.2.2">
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=utf-8"> <link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css" />
|
||||
<title></title>
|
||||
<title>Most percussive</title>
|
||||
</head>
|
||||
<body>
|
||||
<CENTER>
|
||||
<IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
|
||||
<P><FONT size="6"><I>The International Obfuscated C Code Contest</I></FONT></P>
|
||||
<div id="bar">
|
||||
<ul>
|
||||
<li><a href="../index.html">About the 27th IOCCC</a></li>
|
||||
<li><a href="../whowon.html">27th IOCCC Winners</a></li>
|
||||
<li><a href="/index.html">IOCCC home</a></li>
|
||||
<li><a href="/winners.html">List of All Winners</a></li>
|
||||
<li><a href="/judges.html">The Judges</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<P><FONT size="6"><B>A 27<sup>th</sup> IOCCC Winner</B></FONT></P>
|
||||
</CENTER>
|
||||
|
||||
|
||||
<h1>Most percussive</h1>
|
||||
|
||||
<p>Nathan Otterness<br/>
|
||||
<a href="https://github.com/yalue">https://github.com/yalue</a></p>
|
||||
|
||||
<p>The code for this entry can be found in <a href="prog.c">prog.c</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make
|
||||
./prog < input.mid > output.mid
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>wget -O cvikl.mid 'http://www.kunstderfuge.com/-/midi.asp?file=beethoven/symphony_6_1_(c)cvikl.mid'
|
||||
./prog < cvikl.mid > output.mid
|
||||
|
||||
# Play output.mid with your favorite player
|
||||
wget -O entertainer.mid https://www.midiworld.com/download/3857
|
||||
./prog < entertainer.mid > output2.mid
|
||||
# Play output.mid with your favorite player
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>In an entry that boasts not using literals, one would expect to see straightforward ways to produce
|
||||
small integers like <code>!(x^x)<<!(x^x)</code>, etc. but this entry is trickier than that. Deciphering what it does,
|
||||
apart from reading stdin and writing to stdout, would take a while.</p>
|
||||
|
||||
<p>While doing that, you can be audially <em>entertained</em> by a sample of its output.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>MIDI “boots and cats”</h3>
|
||||
|
||||
<p>This program seeks to automatically “improve” standard MIDI files (.mid) by
|
||||
adding an extra track that provides a driving drum beat to bring some
|
||||
excitement into boring video-game music rips or classical music sequences that
|
||||
otherwise only see the light of day when modern musicians import them into FL
|
||||
Studio to copy a few chords.</p>
|
||||
|
||||
<h4>Prerequisites</h4>
|
||||
|
||||
<p>If you’re not using Windows Media Player or already familiar with MIDI files,
|
||||
you may need to install some additional software to be able to listen to them.
|
||||
For example, on Ubuntu, I was able to play them in VLC after installing
|
||||
<code>vlc-plugin-fluidsynth</code> and <code>fluid-soundfont-gm</code>.</p>
|
||||
|
||||
<p>You can obtain MIDIs in many places, but I mostly tested the program using
|
||||
files I found <a href="http://www.kunstderfuge.com/beethoven/variae.htm#Symphonies">here</a>.
|
||||
However, as discussed under the Limitations heading below, not all of them
|
||||
work correctly. I will admit to having used
|
||||
<code>http://www.kunstderfuge.com/-/midi.asp?file=beethoven/symphony_6_1_(c)cvikl.mid</code>
|
||||
for most of my testing.</p>
|
||||
|
||||
<h4>Usage</h4>
|
||||
|
||||
<p>Compile the program using the following command (I tested this using both
|
||||
<code>clang</code> and <code>gcc</code>):
|
||||
<code>
|
||||
$CC -pedantic -Wall -Werror -Wextra -O3 -o prog prog.c
|
||||
</code></p>
|
||||
|
||||
<p>The program expects a MIDI on stdin, and writes a modified MIDI to stdout:
|
||||
<code>
|
||||
./prog <input.mid >output.mid
|
||||
</code></p>
|
||||
|
||||
<p>If the program encounters an error, no output will generally be produced, and
|
||||
it will exit with a specific status code. Meanings of the various status codes
|
||||
are listed below, under the “Program error codes” heading. On success, the
|
||||
program exits with a code of 0.</p>
|
||||
|
||||
<h4>Limitations</h4>
|
||||
|
||||
<ol>
|
||||
<li><p>The program does not support MIDI files over 4 MB (specifically, it will
|
||||
not take input files larger than 2<sup>22</sup> - 1 bytes). This is unlikely to be a
|
||||
big limitation in practice, since even lengthy MIDIs are rarely over a
|
||||
couple hundred KB.</p></li>
|
||||
<li><p>Not all MIDIs set (or <em>correctly</em> set) their timing information, which will
|
||||
lead to the tempo of the drum beat not matching the track. This will be
|
||||
especially true for “live performance” .mid files.</p></li>
|
||||
<li><p>There may be some types of MIDI messages that the program is unable to
|
||||
correctly parse, but I have rarely seen this in practice. The largest
|
||||
cause of program failures, in my experience, has been Limitation 2.</p></li>
|
||||
</ol>
|
||||
|
||||
|
||||
<h4>Obfuscation notes</h4>
|
||||
|
||||
<p>I had one primary goal when writing this program: include no C literals
|
||||
whatsoever. The final C file includes no numerical, string, or character
|
||||
literals. Instead, all literals have been replaced with a handful of global
|
||||
variables, which are occasionally modified throughout the file to prevent
|
||||
simple uses of find-and-replace.</p>
|
||||
|
||||
<p>So, in a sense, this obfuscation is simply an intentional use of global
|
||||
variables' classic problem: absolute spaghetti code. The absence of any sort
|
||||
of literals has the added benefit of forcing any would-be reader to trace the
|
||||
contents of many variables starting from <code>main</code>, since, without literals, very
|
||||
little of the code gives any inherent visual cues as to its purpose.</p>
|
||||
|
||||
<p>I already took the liberty of running <code>prog.c</code> through <code>clang-format</code>, since it
|
||||
still fits in the size limit and the formatting of the code was never intended
|
||||
to be an obfuscation technique here.</p>
|
||||
|
||||
<h4>Other remarks</h4>
|
||||
|
||||
<p>MIDI files are generally divided up into one or more “tracks” that play
|
||||
concurrently. While it is easy to find the positions of each of these tracks
|
||||
in the file, figuring out the amount of time each track is supposed to play is
|
||||
more difficult, and requires parsing every track in its entirety. This means
|
||||
that generating a drum beat that covers the entire piece of music requires
|
||||
parsing every track (the entire file) in order to determine the longest track.</p>
|
||||
|
||||
<p>Once the program has determined the longest track in the file, it generates a
|
||||
new track, containing the simple 4-note percussion sequence, to match the
|
||||
length (in beats) of the longest-running track. It appends the new track onto
|
||||
the end of the file, taking care to update the file header, as well.</p>
|
||||
|
||||
<h3>Program error codes</h3>
|
||||
|
||||
<p>If the program encounters an error, it will exit with a nonzero code. The error
|
||||
codes can be interpreted as follows:</p>
|
||||
|
||||
<ul>
|
||||
<li><code>1</code>: Encountered an invalid MIDI variable-length integer in the input.</li>
|
||||
<li><code>2</code>: Attempted to write an invalid MIDI variable-length integer to output.
|
||||
(This would be an internal error).</li>
|
||||
<li><code>3</code>: Encountered an unsupported MIDI event in the input.</li>
|
||||
<li><code>4</code>: Encountered a bad MIDI track header in the input.</li>
|
||||
<li><code>5</code>: The input MIDI file uses SMPTE time division, which isn’t supported.</li>
|
||||
<li><code>6</code>: Failed allocating a temporary buffer to hold a single copy of our “beat”
|
||||
messages.</li>
|
||||
<li><code>7</code>: Failed allocating a buffer to hold the new track data.</li>
|
||||
<li><code>8</code>: Failed allocating a buffer to hold the input file.</li>
|
||||
<li><code>9</code>: The input file was too large.</li>
|
||||
<li><code>10</code>: The input file’s MIDI header was incorrect (but this isn’t checked
|
||||
very thoroughly).</li>
|
||||
</ul>
|
||||
|
||||
<BR>
|
||||
<HR>
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2020,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,151 +0,0 @@
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.2.2">
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=utf-8"> <link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css" />
|
||||
<title></title>
|
||||
<title>Most misleading indentation</title>
|
||||
</head>
|
||||
<body>
|
||||
<CENTER>
|
||||
<IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
|
||||
<P><FONT size="6"><I>The International Obfuscated C Code Contest</I></FONT></P>
|
||||
<div id="bar">
|
||||
<ul>
|
||||
<li><a href="../index.html">About the 27th IOCCC</a></li>
|
||||
<li><a href="../whowon.html">27th IOCCC Winners</a></li>
|
||||
<li><a href="/index.html">IOCCC home</a></li>
|
||||
<li><a href="/winners.html">List of All Winners</a></li>
|
||||
<li><a href="/judges.html">The Judges</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<P><FONT size="6"><B>A 27<sup>th</sup> IOCCC Winner</B></FONT></P>
|
||||
</CENTER>
|
||||
|
||||
|
||||
<h1>Most misleading indentation</h1>
|
||||
|
||||
<p>tsoj <a href="mailto:tsoj.tsoj@gmx.de">tsoj.tsoj@gmx.de</a><br/>
|
||||
<a href="https://gitlab.com/tsoj">https://gitlab.com/tsoj</a></p>
|
||||
|
||||
<p>The code for this entry can be found in <a href="prog.c">prog.c</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make
|
||||
./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code># Make your terminal as large as possible, possibly reduce your font size
|
||||
# then...
|
||||
./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This game does not use curses, but you may end up cursing.</p>
|
||||
|
||||
<p>The code is made more difficult to read using an innovative, right justified,
|
||||
reverse indentation style.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h4>Controls</h4>
|
||||
|
||||
<ul>
|
||||
<li>Movement:<br/>
|
||||
<code>w</code>, <code>a</code>, <code>s</code>, <code>d</code></li>
|
||||
<li>Fire:<br/>
|
||||
<code>space</code></li>
|
||||
<li>Quit:<br/>
|
||||
<code>q</code></li>
|
||||
<li>Pause:<br/>
|
||||
<code>p</code>, then use any other key to resume</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p><code>
|
||||
/\
|
||||
//\\
|
||||
/ \
|
||||
/______\
|
||||
/\/\
|
||||
</code></p>
|
||||
|
||||
<h4>Compile and run</h4>
|
||||
|
||||
<h6>Linux</h6>
|
||||
|
||||
<p><code>
|
||||
cc -std=c99 -O3 prog.c -o prog
|
||||
./prog
|
||||
</code></p>
|
||||
|
||||
<h6>Windows</h6>
|
||||
|
||||
<p>The only way I found to make it work is to use <a href="https://www.msys2.org">MSYS2</a>. When using the MSYS2 shell you can install gcc via pacman.
|
||||
<code>
|
||||
cc -std=c99 -O3 prog.c -o prog
|
||||
./prog.exe
|
||||
</code></p>
|
||||
|
||||
<h4>Warnings</h4>
|
||||
|
||||
<ul>
|
||||
<li><code>-Wno-missing-prototypes</code></li>
|
||||
<li><code>-Wno-shorten-64-to-32</code></li>
|
||||
<li><code>-Wno-sign-conversion</code></li>
|
||||
<li><code>-Wno-implicit-int-float-conversion</code></li>
|
||||
<li><code>-Wno-missing-field-initializers</code></li>
|
||||
<li><code>-Wno-implicit-float-conversion</code></li>
|
||||
<li><code>-Wno-vla</code></li>
|
||||
<li><code>-Wno-float-conversion</code></li>
|
||||
<li><code>-Wno-comma</code></li>
|
||||
<li><code>-Wno-shadow</code></li>
|
||||
<li><code>-Wno-format</code></li>
|
||||
<li><code>-Wno-empty-body</code></li>
|
||||
<li><code>-Wno-misleading-indentation</code></li>
|
||||
<li><code>-Wno-maybe-uninitialized</code></li>
|
||||
<li>You may experience a mild <a href="https://en.wikipedia.org/wiki/Motion_aftereffect">motion aftereffect</a> when playing for too long
|
||||
|
||||
<h4>Highscore</h4>
|
||||
|
||||
Score will be shown in the top left corner.<br/>
|
||||
My best was <strong>156</strong>. If you beat that I’ll send you the image of a very expensive chocolate.
|
||||
|
||||
<h4>Features</h4></li>
|
||||
<li>Procedural star generation</li>
|
||||
<li>Very space-efficient for-loops</li>
|
||||
<li>No use of <code>!=</code> or <code>==</code></li>
|
||||
<li>Smooth rendering even on slow terminals</li>
|
||||
<li>Advanced ascii-art</li>
|
||||
<li>Cutting edge physics engine and collision detection</li>
|
||||
<li>Probably not many segfaults</li>
|
||||
<li>Every letter in the English alphabet has a variable or function named after it</li>
|
||||
<li>Not a virus</li>
|
||||
<li>Runs on my machine
|
||||
|
||||
<h4>Tips</h4></li>
|
||||
<li>Adjust your terminal size for different experiences</li>
|
||||
<li>Run this program in a virtual console to immerse yourself in the game</li>
|
||||
</ul>
|
||||
|
||||
<BR>
|
||||
<HR>
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2020,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,185 +0,0 @@
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional //EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.2.2">
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=utf-8"> <link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css" />
|
||||
<title></title>
|
||||
<title>Best abuse of CPP</title>
|
||||
</head>
|
||||
<body>
|
||||
<CENTER>
|
||||
<IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
|
||||
<P><FONT size="6"><I>The International Obfuscated C Code Contest</I></FONT></P>
|
||||
<div id="bar">
|
||||
<ul>
|
||||
<li><a href="../index.html">About the 27th IOCCC</a></li>
|
||||
<li><a href="../whowon.html">27th IOCCC Winners</a></li>
|
||||
<li><a href="/index.html">IOCCC home</a></li>
|
||||
<li><a href="/winners.html">List of All Winners</a></li>
|
||||
<li><a href="/judges.html">The Judges</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<P><FONT size="6"><B>A 27<sup>th</sup> IOCCC Winner</B></FONT></P>
|
||||
</CENTER>
|
||||
|
||||
|
||||
<h1>Best abuse of CPP</h1>
|
||||
|
||||
<p>Don Yang<br/>
|
||||
<a href="http://uguu.org/">http://uguu.org/</a></p>
|
||||
|
||||
<p>The code for this entry can be found in <a href="prog.c">prog.c</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make
|
||||
./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>echo "International Obfuscated C Code Contest 2020" | ./prog 23209 > code.c
|
||||
|
||||
# compile without a PIN
|
||||
cc code.c -o decode
|
||||
# yes, you must compile with -DPIN=<number>
|
||||
|
||||
# compile with the wrong pin
|
||||
cc -DPIN=555 code.c -o wrongcoded # wait for it ...
|
||||
./wrongcoded | hexdump -C
|
||||
# Use the wrong PIN: You're gonna have a bad time.
|
||||
|
||||
# compile with a PIN
|
||||
cc -DPIN=23209 code.c -o decoded # wait for it ...
|
||||
./decoded
|
||||
# weeeeeeeeeeeeee! You are having a good time!
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>You might think of this entry as code obfuscater with a code.
|
||||
If you use the wrong code, you’re gonna have a bad time.
|
||||
What is compiling this entry about?
|
||||
<a href="https://southpark.fandom.com/wiki/Asspen/Script">Having a good .. time</a>!</p>
|
||||
|
||||
<p>This winning entry also comes with a <a href="spoiler.html">JavaScript timelapse
|
||||
spoiler</a> that shows how this entry was written.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Synopsis</h3>
|
||||
|
||||
<pre><code>echo "Hello world" | ./mile 12345 > encoded.c
|
||||
|
||||
gcc -DPIN=12345 encoded.c -o ./decoded && ./decoded
|
||||
</code></pre>
|
||||
|
||||
<h3>Details</h3>
|
||||
|
||||
<p>Mile is a C code generator. Run without arguments for the help message below:</p>
|
||||
|
||||
<pre><code>usage: [PIN] < input.txt > output.c
|
||||
|
||||
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 stdin and generate C code on stdout. Example:</p>
|
||||
|
||||
<pre><code>echo "Hello, world!" | ./mile 56789 > encoded.c
|
||||
</code></pre>
|
||||
|
||||
<p>This generated code will reproduce the same input bytes on stdout when
|
||||
executed, if it was compiled with the same encoding PIN.</p>
|
||||
|
||||
<pre><code>gcc -DPIN=56789 encode.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 fwrite() call at run time to print those bytes. Not
|
||||
specifying a PIN is a compile time error. Specify the wrong PIN and
|
||||
output code will still compile, but will likely produce garbage instead of
|
||||
the input bytes. If the original input was empty then any PIN works, but
|
||||
you might get a compile time warning complaining about empty arrays.</p>
|
||||
|
||||
<p>Because all data is reconstructed at compile time, expect the compile time
|
||||
to be excruciatingly long if you try to encode too much data. Code
|
||||
generated by encoding a haiku will probably compile in seconds, a limerick
|
||||
may require tens of seconds, a sonnet will take minutes. Give Mile an
|
||||
epic poem and you can probably write a faster preprocessor before GCC is
|
||||
done (Clang probably already failed long before then).</p>
|
||||
|
||||
<p>I see that there is a lack of preprocessor abuse in recent years, probably
|
||||
because programming in preprocessor is too tedious. Mile is meant to help
|
||||
with that by producing C code filled with at least 98% preprocessor lines
|
||||
for any input. Now you too can enjoy long compile times with minimal
|
||||
effort.</p>
|
||||
|
||||
<h3>Features</h3>
|
||||
|
||||
<ul>
|
||||
<li><p>Output is randomized using system clock, so if you wait a second between
|
||||
runs, you should get a different generated code even for the same
|
||||
encoding PIN.</p></li>
|
||||
<li><p>Customized bytecode encoding of preprocessor boilerplates, mostly for
|
||||
compression but should also make reverse engineering more fun.</p></li>
|
||||
<li><p>CRC32 of the source code is embedded in the source code itself.</p></li>
|
||||
<li><p>Code layout shaped to resemble “Mile” from “Didn’t I Say to Make My
|
||||
Abilities Average in the Next Life?!”. Mile is known to be able to talk
|
||||
to nanomachines directly, which is exactly what programming in
|
||||
preprocessor feels like.</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Compatibility</h3>
|
||||
|
||||
<p>Mile has been verified to work in these environments (also, compiles
|
||||
without warnings on all of these):</p>
|
||||
|
||||
<ul>
|
||||
<li>gcc 9.2.0 on Cygwin</li>
|
||||
<li>gcc 8.3.0 on Linux</li>
|
||||
<li>gcc 7.4.0 on Cygwin</li>
|
||||
<li>gcc 6.1.0 on JSLinux</li>
|
||||
<li>gcc 5.4.0 on Linux</li>
|
||||
<li>clang 8.0.1 on Linux</li>
|
||||
<li>clang 8.0.1 on Cygwin</li>
|
||||
<li>tcc 0.9.27 on Linux</li>
|
||||
<li>tcc 0.9.25 on JSLinux</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Output of Mile is a bit more taxing, and only works with a subset of the
|
||||
above:</p>
|
||||
|
||||
<ul>
|
||||
<li>gcc: works just fine when using 8.3.0 and below, but may trigger warning
|
||||
for large files. gcc 9.2.0 and above may crash with large files.</li>
|
||||
<li>clang: works fine for small files, fails on large files due to
|
||||
<a href="https://bugs.llvm.org/show_bug.cgi?id=44480">preprocessor bug</a>.</li>
|
||||
<li>tcc: works just fine on Linux. Fails silently on JSLinux.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>For people eager to encode large files, an extra utility has been packaged
|
||||
with this entry to preprocess the generated output to make them more
|
||||
acceptable to typical compilers. View the <a href="cppp.cc">cppp.cc</a> source and
|
||||
then compile it with a c++ compiler of your choice.</p>
|
||||
<BR>
|
||||
<HR>
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2020,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user