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,142 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most GIFted expressions</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most GIFted expressions</h1>
|
||||
|
||||
<p>Philip Blakely<br>
|
||||
Cambridge, UK<br>
|
||||
<a href="mailto:pmblakely@gmail.com">pmblakely@gmail.com</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make blakely
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./blakely "RPN formula" resolution > output.gif
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./blakely "xx*yy*+" 64 > paraboloid.gif
|
||||
|
||||
./blakely 9 32 > empty.gif
|
||||
|
||||
time ./blakely 0 250 > flat.gif
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>Several IOCCC themes (RPN calculator, animated GIF generator, ray tracing) in one package! Very impressive!</p>
|
||||
|
||||
<p>The checkerboard pattern in the output can be broken. Could you figure out how?</p>
|
||||
|
||||
<p>Larger GIF files confuse some image viewers.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h2>Remarks</h2>
|
||||
|
||||
<p>This program renders a generic RPN expression in ray-traced animated GIF form.
|
||||
The expression in spatial variables x and y is specified on the command-line with the required resolution,
|
||||
and an animated GIF showing a fly-around of the resulting surface is output to stdout.</p>
|
||||
|
||||
<h2>Usage</h2>
|
||||
|
||||
<p>The program should be run as:</p>
|
||||
|
||||
<pre><code>./blakely xy* 32 > pic.gif
|
||||
</code></pre>
|
||||
|
||||
<p>where the first parameter is a RPN expression, and the second is the width of the required GIF, up to a maximum of 250.</p>
|
||||
|
||||
<p>The expressions are written in Reverse Polish Notation with the following characters recognised:</p>
|
||||
|
||||
<ul>
|
||||
<li>+,-,*,/ - usual arithmetic operations</li>
|
||||
<li>^ - Exponentiation - valid for constant exponent only</li>
|
||||
<li>s - sin</li>
|
||||
<li>c - cos</li>
|
||||
<li>0-9 - single digit integers</li>
|
||||
<li>d - duplicate number on stack</li>
|
||||
<li>t - transpose top two elements on stack</li>
|
||||
<li>x - x coordinate value</li>
|
||||
<li>y - y coordinate value</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>NB all arithmetic is done in double precision, so 23/ is two-thirds, rather than 0</p>
|
||||
|
||||
<p>The surface plotted corresponds to -1 <= x,y <= 1 and for best results, the generated z value should lie between -1 and 1.</p>
|
||||
|
||||
<p>If there is a division by zero, square-root of a negative number, or similar operation, then the results are undefined.</p>
|
||||
|
||||
<h2>Examples</h2>
|
||||
|
||||
<p>For test-runs, use a resolution of 32. For simple expressions, the GIF generation should take only
|
||||
a few seconds with a modern processor and full optimization. Run-time scales as O(N<sup>3</sup>) with resolution N,
|
||||
and more complex expressions take longer to compute. For example, increasing the resolution of ripple.gif
|
||||
to 250 took ~35 minutes to render on an i7 processor.</p>
|
||||
|
||||
<pre><code>./blakely xy* 32 > saddle.gif
|
||||
|
||||
./blakely xx*yy*1++d5*ct/ 64 > ripple.gif
|
||||
</code></pre>
|
||||
|
||||
<h2>Algorithm</h2>
|
||||
|
||||
<p>A generic root-finding algorithm to find the point of intersection between a ray
|
||||
and the surface is done using a simple forward search from the eye.
|
||||
In order to make the rendering realistic, both the value of the expression, and its derivative with respect to x and y must be tracked.
|
||||
This is done using an obvious stack-based approach.</p>
|
||||
|
||||
<h2>Obfuscations</h2>
|
||||
|
||||
<p>Much of the obfuscation is achieved through the use of single-letter variables and #defines.
|
||||
The characters output for the GIF format are generated in myriad and wonderful ways, making use
|
||||
of XOR, return values from putchar, and odd expressions.
|
||||
The layout is in the form of X Y Z.</p>
|
||||
|
||||
<h2>Limitations</h2>
|
||||
|
||||
<p>ASCII is assumed since many bytes for the GIF output are generated from characters given in the source code.
|
||||
On compilation a few warnings about parentheses come up when using gcc 4.6.3, and one about no return value from main() (who uses exit codes anyway?),
|
||||
but clang 3.1 emits no warnings.</p>
|
||||
|
||||
<h2>Questions</h2>
|
||||
|
||||
<ul>
|
||||
<li>Apart from their appearance when computing the RPN expression, sin and cos are not used.
|
||||
How do we then get the correct angles for rotation?</li>
|
||||
<li>Exactly how many times will the animation repeat?</li>
|
||||
<li>Why is there an upper limit of 250x250 for the resolution?</li>
|
||||
<li>What is the point of b[0]?</li>
|
||||
<li>Where are the words NETSCAPE and GIF hidden in the source?</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>(Note that the author may or may not be able to answer all of the above questions.)</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,114 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most notable and best tool</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most notable and best tool</h1>
|
||||
|
||||
<p>Alex Deckmyn<br>
|
||||
<a href="mailto:alex.deckmyn@gmail.com">alex.deckmyn@gmail.com</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make deckmyn
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code># A shell interpreter with proper backtick interpolation is required
|
||||
./deckmyn "`cat deckmyn.c`" "`cat musicfile.txt`" > sheetmusic.pbm
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./deckmyn "`cat deckmyn.c`" "`cat example_greensleeves`" > greensleeves.pbm
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>The C of this entry is definitely sharp. The program cleverly uses its own
|
||||
source at runtime to define the notes, time signature and accidental bitmaps.</p>
|
||||
|
||||
<p>In addition to sheet music, this program is also able, given the right input,
|
||||
to generate an image of a 10-pin DIP chip (a sound processor?).</p>
|
||||
|
||||
<p>Ironically, the way this entry is called from the command line is an abuse of C Shell.
|
||||
Please use Bourne-family shells to run this entry.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h1>Example use</h1>
|
||||
|
||||
<p>You need the source code and example input (either one of the example files, or manual input as below) ready. And a program capable of showing .pbm bitmap format.</p>
|
||||
|
||||
<pre><code>./deckmyn "`cat deckmyn.c`" "`cat example_greensleeves`" > greensleeves.pbm
|
||||
display greensleeves.pbm
|
||||
|
||||
./deckmyn "`cat deckmyn.c`" "KF m44c4 c4 g4 g4 : a4 a4 g2 :; " > short_bass.pbm
|
||||
display short_bass.pbm
|
||||
</code></pre>
|
||||
|
||||
<h1>Description</h1>
|
||||
|
||||
<p>Every major C competition should have an entry capable of producing C major.
|
||||
This is a music notation program. It produces bitmaps (.pbm) of music based on ASCII input. A full manual is added as a separate file. Some musical examples are also included.</p>
|
||||
|
||||
<p>The program is capable of printing notes, rests, (double) bar lines and accidentals on a single melodic line (multiple staves). No chords, polyphony etc.</p>
|
||||
|
||||
<p>The program expects <em>two command line arguments</em>. The first is a (very long) string that contains the complete music font. Note that it should <em>not</em> be given as a file name! The default music font is encoded in the (whitespace of the) source code deckmyn.c itself. Therefore, the first argument should be “<code>cat deckmyn.c</code>”.</p>
|
||||
|
||||
<p>The second command line argument is the music itself. This is, again, a string, not a file name. All music signs are entered as tokens of exactly 3 characters. The code is very sensitive to bad spacing! So for instance, if you use a file to write the music (e.g. example_greensleeves), you should keep in mind that newline is also a character!</p>
|
||||
|
||||
<h1>Internals</h1>
|
||||
|
||||
<p>To minimise the memory footprint, this program has <em>no variable declarations at all</em>, except for the arguments to main(). The only available memory space is from the command line arguments and count (argv and argc). Parts of argv are cast as integer when values under 0 or beyond 127 are expected.</p>
|
||||
|
||||
<p>The “music font” is defined by the source code itself. The first few lines are not part of the font definition, as this memory space will modified by the program. (So as required by the rules, it is only a (memory) copy of the source code that is modified.)</p>
|
||||
|
||||
<p>As there is no memory available, output is directly to stdout, byte by byte, from the top left to the bottom right pixel.</p>
|
||||
|
||||
<h1>LIMITATIONS</h1>
|
||||
|
||||
<p>The memory locations of argv are used for various purposes. Therefore, the program name (default “deckmyn”) must be <em>at least 4 characters long</em>, including possibly the path. This, along with the ending ‘\0’, gives minimum 5 bytes of useful memory space. Otherwise, the program may attempt to write outside the string.</p>
|
||||
|
||||
<p>The code is quite sensitive. Errors in the input can lead to strange results. The code does not read beyond the end of the music input, but that is about the only error checking available. Any input that is not according to the rules in the MANUAL, may cause errors.</p>
|
||||
|
||||
<p>The program has no special hardware limitations or requirements, other than 8bit char (signed or unsigned) and two’s complement negatives.</p>
|
||||
|
||||
<p>The limitations of using char as counters for e.g. the number of music staves are minor. 127 staves to a page is rather a lot.</p>
|
||||
|
||||
<h1>Obfuscations</h1>
|
||||
|
||||
<p>The code has no declared variables other than the command line variables. Not even pointers (we all know how messy code can get with too many pointers!). As more than one variable needs values beyond 127, parts of the command line memory are cast as integer using a macro.</p>
|
||||
|
||||
<ul>
|
||||
<li>The formatting of the code is in fact necessary, as this is the definition of the music font. It is therefore not an obfuscation.</li>
|
||||
<li>The use of only argv/argc as memory locations is a matter of reducing the memory footprint. Again, it is not an obfuscation.</li>
|
||||
<li>Calling the only remaining variables, and the two defined macros, c and C, is merely a matter of conforming to the standard WYSIWYG paradigm common in commercial notation programs (What You C is What You Get). So once again it is not an obfuscation. Anyway, it’s a C coding contest, right?</li>
|
||||
<li>Randomly using the numerical (ASCII) value for characters is compensated for by replacing some numbers by a character representation. On average, therefore, it is not an obfuscation.</li>
|
||||
<li>Randomly changing the way the elements of argv are addressed is a matter of maintaining a diversified code base. It is therefore not… Oh allright.</li>
|
||||
<li>The actual output of the music is done by one print command including a 800+ character nested conditional expression.</li>
|
||||
<li>printf is also used for its return value.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,145 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Best way to lose a life</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best way to lose a life</h1>
|
||||
|
||||
<ol type="a">
|
||||
<li>David Lowe<br>
|
||||
434 Tenney Drive<br>
|
||||
Rogue River, OR<br>
|
||||
97537<br>
|
||||
<a href="mailto:j.david.lowe@gmail.com">j.david.lowe@gmail.com</a><br>
|
||||
<a href="http://www.pootpoot.net/">http://www.pootpoot.net/</a></li>
|
||||
</ol>
|
||||
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make dlowe
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./dlowe
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./dlowe
|
||||
# Watch for a while if you like, then press a key within the window
|
||||
# Use up and down keys to escape death
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>The judges lose playing this game. This entry wins!</p>
|
||||
|
||||
<p>OS X users running Mountain Lion and later will need to download and install:</p>
|
||||
|
||||
<pre><code>http://xquartz.macosforge.org/landing/
|
||||
</code></pre>
|
||||
|
||||
<p>Q: How did we get past the variadic macro problem on a Mac?</p>
|
||||
|
||||
<p>A: Don’t use -pedantic-errors in the Makefile.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h1>Conway’s Game of DEATH</h1>
|
||||
|
||||
<p>This is a challenging, fast-paced arcade game, based on the famous Game of
|
||||
Life.</p>
|
||||
|
||||
<h2>Story</h2>
|
||||
|
||||
<p>In the game, you are Mr.C, a lightweight spaceship making a futile dash for
|
||||
escape from the rigid rules and predictability of life in the B3/S23 universe.</p>
|
||||
|
||||
<p>Use the up and down arrow keys to steer: collisions are fatal for Mr.C! Learn
|
||||
to spot incoming gliders, skim the surfaces of beehives and blocks, and give
|
||||
blinkers plenty of space. Things get crazier as Mr.C picks up speed… can he
|
||||
escape?</p>
|
||||
|
||||
<p>No. There is no winning. Sadly for Mr.C, this universe goes on forever. Just
|
||||
see how far you can make it!</p>
|
||||
|
||||
<p>Press ‘q’ any time to quit.</p>
|
||||
|
||||
<h2>Features</h2>
|
||||
|
||||
<ul>
|
||||
<li>casual gameplay</li>
|
||||
<li>infinite, procedurally generated universe</li>
|
||||
<li>progressive difficulty</li>
|
||||
<li>animated splash screens</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Limitations</h2>
|
||||
|
||||
<ul>
|
||||
<li>Flicker, especially at high speeds, and in spite of “double-buffering” (X11
|
||||
doesn’t make it possible to lock drawing to the display refresh rate.)</li>
|
||||
<li>Cannot be run outside of the directory containing the data files (splash.d,
|
||||
dead.d and sprites.d).</li>
|
||||
<li>Cannot build or run without X11 (or an X11 compatibility layer).</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Wish List</h2>
|
||||
|
||||
<ul>
|
||||
<li>Score keeping</li>
|
||||
<li>Color</li>
|
||||
<li>In-game instructions</li>
|
||||
<li>Sound</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Hosts Tested</h2>
|
||||
|
||||
<ul>
|
||||
<li>Darwin 10.8.0 i386 (clang 1.6 and gcc 4.2.1)</li>
|
||||
<li>Linux 2.6.32 i686 (clang 1.1 and gcc 4.4.3)</li>
|
||||
<li>Linux 3.2.0 x86_64 (clang 3.0 and gcc 4.6.3)</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Obfuscations</h2>
|
||||
|
||||
<p>The code is formatted into a 14-cell shape which will evolve into a glider in
|
||||
19 generations.</p>
|
||||
|
||||
<p>Lots of globals, including a global struct whose members have the same names
|
||||
as global variables.</p>
|
||||
|
||||
<p>Global variables getting reused in different contexts.</p>
|
||||
|
||||
<p>Huge and convoluted expressions, abusing ternary operators and operator
|
||||
precedence.</p>
|
||||
|
||||
<p>Lots of magic numbers, abuse of the relationships between magic numbers, and
|
||||
abuse of the arithmetic properties of magic numbers.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,203 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most complex ASCII fluid - Honorable mention</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most complex ASCII fluid - Honorable mention</h1>
|
||||
|
||||
<p>Yusuke Endoh<br>
|
||||
<a href="mailto:mame@ruby-lang.org">mame@ruby-lang.org</a><br>
|
||||
<a href="https://github.com/mame/">https://github.com/mame/</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make endoh1
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./endoh1 < configuration.txt
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./endoh1 < endoh1.c
|
||||
|
||||
./endoh1 < pour-out.txt
|
||||
|
||||
./endoh1 < fountain.txt
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>Let’s play Jeopardy!</p>
|
||||
|
||||
<ul>
|
||||
<li>A: An obfuscated program that deals with complex numbers and produces animated ASCII graphics.</li>
|
||||
<li>Q: What is a Mandelbrot simulator?</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Bzzzt!</p>
|
||||
|
||||
<p>Such heavily squeezed fluid simulation (this is parsed uniquely
|
||||
as fluids are not squeezable) has a few quirks that the judges were
|
||||
happy to experiment with.</p>
|
||||
|
||||
<p>One configuration file was inspired by an <a href="http://whatif.xkcd.com/6/">XKCD what if? entry</a>.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Synopsis</h3>
|
||||
|
||||
<p><strong>DO NOT FORGET “-DG=1 -DP=4 -DV=8”</strong> and make your terminal window larger
|
||||
than 80 x 25.</p>
|
||||
|
||||
<pre><code>gcc endoh1.c -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -o endoh1 -lm
|
||||
./endoh1 < endoh1.c
|
||||
./endoh1 < logo.txt
|
||||
./endoh1 < column.txt
|
||||
./endoh1 < pour-out.txt
|
||||
./endoh1 < tanada.txt
|
||||
</code></pre>
|
||||
|
||||
<h3>What it is</h3>
|
||||
|
||||
<pre><code>,___. ,. ,. ,. ,___. ,. ,. ,.
|
||||
|/--' || `' || |/--' `' || |\_.
|
||||
|\__. || ,. ,. ,. ,__/| |\__. ,. ,____. ,. ,. || ,_. |/-' ,_. ,__.
|
||||
|/--' || || || || |/-\| `--\| || |/\/\| || || || ,/-\. || ,/-\. |/-\.
|
||||
|| || `\_/| || |\_/| ,__/| || |||||| `\_/| || `\_/\.`\_. `\_/' || `'
|
||||
`' `' `--' `' `---' `---' `' `'`'`' `--' `' `-'`' `-' `-' `'
|
||||
|
||||
|
||||
,.,. ,.,.
|
||||
,/\/\. ,. ,. ,. ,/\/\. ,. ,. ,__.
|
||||
|||#/' || `' ,_.|| |||#/' `',_.,__. || ||\\. ,.
|
||||
|||#\. || ,. ,. ,.,/#||| |\//\. ,.|#||##| ,. ,. || ,.,. |\/-' ,.,. ,.|\.
|
||||
|\/--' ||,/\.|| |||#/\/| `\#||| |||#||/\|,/\.|| ||,/'`\.|#| ,/'`\.|\/-\.
|
||||
`\| ||`\#||| |||#||\| ,//\/| ||`\|||||`\#||| ||`\.,/\/\|,.`\.,/'`\| `'
|
||||
`' `' `-'`' `'`-'`-' `-'`-' `' `'`'`' `-'`' `' `'`--'`'`' `'`' `'
|
||||
|
||||
|
||||
,_.,_. ,. ,. ,. ,_.,_. ,. ,. ,.
|
||||
|#||#| || `' || |#||#| `' || ||,_.
|
||||
||\/#| ||,. ,. ,.,_.,/| |\||#| ,.,_.,__.,. ,. || ,.,. |||#| ,.,. ,.,_.
|
||||
|||##| |||| || |||#||#| |#||#| |||#||##||| || ||,/||\.||`-',/||\.|||#\.
|
||||
||`--' ||`\_.|| |||\||#| |#||#| ||||'||\|`\_.|| ||`\||#|`\.,.`\||/'||`--'
|
||||
`' `' |#||| `'|#||#| |#||#| `'`' `'`' |#||| `' |||/' |||| |||| `'
|
||||
`-'`' `-'`-' `-'`-' `-'`' `'`' `'`' `'`'
|
||||
</code></pre>
|
||||
|
||||
<p>This program is a fluid simulator using “Smoothed-particle hydrodynamics (SPH)”
|
||||
method.</p>
|
||||
|
||||
<p><a href="http://en.wikipedia.org/wiki/Smoothed-particle_hydrodynamics">http://en.wikipedia.org/wiki/Smoothed-particle_hydrodynamics</a></p>
|
||||
|
||||
<p>The SPH particles represent the fluid flow. Particles have information about
|
||||
the position, density, and velocity. In every simulation step, they are
|
||||
changed by pressure force, viscosity force, and external force (i.e., gravity).</p>
|
||||
|
||||
<p>This program reads a text from standard input, and uses it as an initial
|
||||
configuration of the particles. The character <code>#</code> represents “wall particle” (a
|
||||
particle with fixed position), and any other non-space characters represent
|
||||
free particles.</p>
|
||||
|
||||
<p>The compilation options <code>-DG=1 -DP=4 -DV=8</code> represent, respectively, the factor
|
||||
of gravity, pressure, and viscosity. By changing their values, you can see
|
||||
different fluid behavior.</p>
|
||||
|
||||
<p>“Marching square”-like algorithm is used to render the particles.</p>
|
||||
|
||||
<p><a href="http://en.wikipedia.org/wiki/Marching_squares">http://en.wikipedia.org/wiki/Marching_squares</a></p>
|
||||
|
||||
<h3>Portability</h3>
|
||||
|
||||
<p>The program requires a C99 compiler; it uses <code>complex</code> types and one-line
|
||||
comments. It also uses <code>usleep</code>, which may require <code>-D_BSD_SOURCE</code> or somewhat
|
||||
to build with no warning. Under these conditions, it should be portable.
|
||||
At least, recent compilers with <code>-std=c99 -Wall -W -Wextra -pedantic</code> says
|
||||
nothing.</p>
|
||||
|
||||
<pre><code>gcc -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -std=c99 -Wall -W -Wextra -pedantic endoh1.c
|
||||
clang -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -std=c99 -Wall -W -Wextra -pedantic endoh1.c
|
||||
</code></pre>
|
||||
|
||||
<p>I expect it to work in any Unix-like environment. VTxxx/ANSI sequences are
|
||||
used to clear screen and move cursor to home.</p>
|
||||
|
||||
<p>I’ve tested with gcc-4.6.3 and clang-3.0 on Linux (Ubuntu 12.04)
|
||||
and gcc-4.5.3 and clang-3.1 on Cygwin. On Cygwin, gcc and clang complain about
|
||||
a usage of <code>I</code> (complex’s imaginary unit), but I bet this is cygwin’s issue;
|
||||
it is surely a C99 feature.</p>
|
||||
|
||||
<h3>Obfuscation w/ Spoiler</h3>
|
||||
|
||||
<p>First of all, the source code itself serves as an initial configuration.
|
||||
Preprocessing directives (such as <code>#include</code>)’s <code>#</code> serve as walls.</p>
|
||||
|
||||
<p>This program uses <code>double complex</code> to represent any 2D vector. But, note that
|
||||
x-axis and y-axis is swapped (real axis = y-axis, imaginary axis = x-axis).
|
||||
The purpose of swapping is not only obfuscation, but also short coding: for
|
||||
example, to add gravity to total force, <code>force += G</code> suffices, rather than
|
||||
<code>force += G*I</code>.
|
||||
(Incidentally, you can exert horizontal gravity by using, such as, <code>-DG=I</code>)</p>
|
||||
|
||||
<p>Every five entries of <code>double complex a[]</code> contain information of one particle:
|
||||
position, wall-flag, density, force, and velocity, in turn.</p>
|
||||
|
||||
<p>You can use <code>G</code>, <code>P</code>, and <code>V</code> as a guide to find the calculation code of
|
||||
gravity, pressure, and viscosity forces.</p>
|
||||
|
||||
<p>Though some assignments may look meaningless, it is actually meaningful; it
|
||||
extracts “integer part of real part” from a complex value by assigning (and
|
||||
casting) it to an integer-type variable.</p>
|
||||
|
||||
<h3>Notes about Additional Files</h3>
|
||||
|
||||
<p>“logo.txt” is a source of the logo in this remark file.</p>
|
||||
|
||||
<p>“column.txt” is a water column collapse, which is a popular demo of SPH.</p>
|
||||
|
||||
<p>“pour-out.txt” pours you a cup of tea.</p>
|
||||
|
||||
<p>“tanada.txt” simulates “Terrace farming”. (“Tanada” means a “terraced rice
|
||||
fields” in Japanese.)</p>
|
||||
|
||||
<p>“clock.txt” is a “water” clock created by HAMANO Tsukasa.</p>
|
||||
|
||||
<p>Other *.txt files are due to the judges.</p>
|
||||
|
||||
<p>“endoh1_color.c” is a variant that shows the density by using terminal 256
|
||||
colors.</p>
|
||||
|
||||
<h3>Acknowledgment</h3>
|
||||
|
||||
<p>I would like to thank my wife @hirekoke for her teaching me the SPH method.</p>
|
||||
|
||||
<p>The judges <strike>ordered</strike> suggested creating a color version
|
||||
after the judgment.</p>
|
||||
|
||||
<p>The judges and HAMANO Tsukasa (The silver medalist at this IOCCC) kindly
|
||||
provided many configuration files.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,166 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>PiE in the sky award</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>PiE in the sky award</h1>
|
||||
|
||||
<p>Yusuke Endoh<br>
|
||||
<a href="mailto:mame@ruby-lang.org">mame@ruby-lang.org</a><br>
|
||||
<a href="https://github.com/mame/">https://github.com/mame/</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make endoh2
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./endoh2 > pi.c
|
||||
gcc -o pi pi.c
|
||||
./pi > 314.c
|
||||
...
|
||||
|
||||
./endoh2 e > e.c
|
||||
gcc -o e e.c
|
||||
./e > 271.c
|
||||
...
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>make pi
|
||||
make e
|
||||
make everything
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>A pi/e printing quasi-quine in ASCII art with a compressed font in it;
|
||||
what else to wish for in this program? Virtual machine emulation?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<p>Yeah, “Again”. Sorry. But I don’t feel guilty or uncomfortable.</p>
|
||||
|
||||
<p>This entry is based on ‘over-used themes’ such as self reproducing
|
||||
program and pi or e computation. I know you’re tired of them.</p>
|
||||
|
||||
<p>But have you ever seen <strong>all-in-one</strong>?</p>
|
||||
|
||||
<h3>What it is</h3>
|
||||
|
||||
<p>This program generates a new program in the shape of the Greek letter
|
||||
<code>pi</code>. Then, the generated program:</p>
|
||||
|
||||
<ul>
|
||||
<li>computes 3 digits of pi and prints it as a ASCII-art program that:</li>
|
||||
<li>computes 4 digits of pi and prints it as a ASCII-art program that:</li>
|
||||
<li>computes 5 digits of pi and prints it as a ASCII-art program that:</li>
|
||||
<li>computes 6 digits of pi and prints it as a ASCII-art program that:</li>
|
||||
<li>etc.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>One more thing… When you give a command line option “e” to the
|
||||
first program, the generated one will compute Napier’s constant
|
||||
rather than pi.</p>
|
||||
|
||||
<h3>Obfuscation</h3>
|
||||
|
||||
<p>This program itself is in the shape of a spigot. This is derived
|
||||
from analogy with “spigot algorithm” which infinitely computes the
|
||||
value of a mathematical constant such as <code>pi</code> or <code>e</code>.</p>
|
||||
|
||||
<p><a href="http://en.wikipedia.org/wiki/Spigot_algorithm">http://en.wikipedia.org/wiki/Spigot_algorithm</a></p>
|
||||
|
||||
<p>The two sets of programs, 314*.c and 271*.c, are almost the same
|
||||
except its shape and constant computation part. I tailored the
|
||||
common part to parse in both shapes (“3.14…” and “2.71…”), by
|
||||
tweaking the computation order and adding meaningless code fragment.</p>
|
||||
|
||||
<p>On the other hand, to make it fit inside one screen (80 x 25), my
|
||||
program is shortened properly, more than it looks. (As you may
|
||||
know, Quine needs to make its program size doubled.)
|
||||
For example, this program involves 3x5 bitmap font data of ten
|
||||
characters (‘0’ – ‘9’), as just 20 bytes: “G1%xJ{;Q7wunmuGuu%uu”.
|
||||
We can decode character n as <code>275*s[n+10] - 8*s[n] - 8</code>. I solved the
|
||||
system of Bezout’s identities to find the magic string, with the
|
||||
aid of a brute force. See <code>find-font-table.rb</code> in detail.</p>
|
||||
|
||||
<p><a href="http://en.wikipedia.org/wiki/B%C3%A9zout's_identity">http://en.wikipedia.org/wiki/B%C3%A9zout's_identity</a></p>
|
||||
|
||||
<p>I used many other tricks for short coding.</p>
|
||||
|
||||
<p>I’m sorry that many ASCII-art-style winning entries of IOCCCs
|
||||
ignore preprocessor directives. In my program, #include is a part
|
||||
of ASCII-art with comment padded.</p>
|
||||
|
||||
<p>These design requirements made my program well-obfuscated
|
||||
willy-nilly.</p>
|
||||
|
||||
<h3>Portability</h3>
|
||||
|
||||
<p>I expect it to work in any major environment and C compiler.
|
||||
To build with no warning, it requires two C99 features: string
|
||||
literal more than 509 characters and omissible return in main
|
||||
function. In fact, recent compilers with “-std=c99 -Wall -W
|
||||
-Wextra -pedantic” would say nothing.</p>
|
||||
|
||||
<pre><code>gcc -std=c99 -Wall -W -Wextra -pedantic spigot.c
|
||||
clang -std=c99 -Wall -W -Wextra -pedantic spigot.c
|
||||
</code></pre>
|
||||
|
||||
<p>I’ve tested with gcc-4.6.3 and clang-3.0 on Linux (Ubuntu 12.04)
|
||||
and gcc-4.5.3 and clang-3.1 on Cygwin.</p>
|
||||
|
||||
<h3>Synopsis</h3>
|
||||
|
||||
<pre><code>gcc endoh2.c -o endoh2
|
||||
|
||||
./endoh2 > pi.c
|
||||
cat pi.c
|
||||
|
||||
gcc pi.c -o pi ; ./pi > 314.c ; cat 314.c
|
||||
gcc 314.c -o 314 ; ./314 > 3141.c ; cat 3141.c
|
||||
gcc 3141.c -o 3141 ; ./3141 > 31415.c ; cat 31415.c
|
||||
gcc 31415.c -o 31415 ; ./31415 > 314159.c ; cat 314159.c
|
||||
gcc 314159.c -o 314159 ; ./314159 > 3141592.c ; cat 3141592.c
|
||||
etc...
|
||||
|
||||
./endoh2 e > e.c
|
||||
cat e.c
|
||||
|
||||
gcc e.c -o e ; ./e > 271.c ; cat 271.c
|
||||
gcc 271.c -o 271 ; ./271 > 2718.c ; cat 2718.c
|
||||
gcc 2718.c -o 2718 ; ./2718 > 27182.c ; cat 27182.c
|
||||
gcc 27182.c -o 27182 ; ./27182 > 271828.c ; cat 271828.c
|
||||
gcc 271828.c -o 271828 ; ./271828 > 2718281.c ; cat 2718281.c
|
||||
etc...
|
||||
</code></pre>
|
||||
|
||||
<p>You can do <code>make everything</code> for the process (with no <code>cat</code>).</p>
|
||||
|
||||
<p>Note: The executable may return a failure (non-zero) exit status
|
||||
unless -std=c99 option is given.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,152 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most conspiratorial</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most conspiratorial</h1>
|
||||
|
||||
<p>Aaron Grothe<br>
|
||||
2205 South 51st Street<br>
|
||||
Omaha, NE 68106<br>
|
||||
US<br>
|
||||
<a href="mailto:ajgrothe@yahoo.com">ajgrothe@yahoo.com</a></p>
|
||||
|
||||
<p>David Madore<br>
|
||||
<a href="http://www.madore.org/~david/">http://www.madore.org/~david/</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make grothe
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code># To create a shared secret shared among M people with N+1 needed to reconstruct
|
||||
./grothe -secret 1-/dev/urandom 2-/dev/urandom ... N-/dev/urandom \
|
||||
1+shared1 2+shared2 ... M+sharedM
|
||||
|
||||
# To reconstruct the original (an arbitrary combination of N+1 or
|
||||
# more shared files with their proper numbers)
|
||||
./grothe I-sharedI J-sharedJ K-sharedK ... +reconstructed
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./grothe -grothe.c 1+grothe.c.1 2+grothe.c.2
|
||||
|
||||
./grothe -cookie_recipe.txt 1-/dev/urandom 2-/dev/urandom \
|
||||
1+cookie_piece1.dat 2+cookie_piece2.dat 3+cookie_piece3.dat 4+cookie_piece4.dat
|
||||
|
||||
./grothe 1-cookie_piece1.dat 2-cookie_piece2.dat 4-cookie_piece4.dat
|
||||
+cookie_recipe_restore.txt
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>Also known as Best abuse of the judging process.</p>
|
||||
|
||||
<p>The IOCCC 2012 submission page didn’t enforce the 2048 meaningful
|
||||
character limit. This entry, as submitted, weighed in at 2222 chars
|
||||
but was, luckily for it, extremely easy to bring down below the
|
||||
limit. There were a number of strings that when concatenated allowed
|
||||
the program to slide under the limit.</p>
|
||||
|
||||
<p>It was clear to the judges that the extra size was an entry
|
||||
beautification step. Had it not, this entry would have been
|
||||
rejected in round 0.</p>
|
||||
|
||||
<p>The judges also took some liberty obfuscating this entry a litte more.</p>
|
||||
|
||||
<p>How does this entry work? The only place multiplication is used is
|
||||
to perform the atoi conversion.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<p><strong>Description</strong></p>
|
||||
|
||||
<p>This program implements a version of Shamir’s Secret Sharing. Shamir’s Secret
|
||||
Sharing allows you to encrypt a file into N parts where it will take M parts to
|
||||
recreate the original file. E.g. you can split the secret recipe for Crystal Pepsi
|
||||
into 3 parts and require two of them be available to extract the original recipe.</p>
|
||||
|
||||
<p>Actually surprisingly useful for an IOCCC entry :-)</p>
|
||||
|
||||
<p><strong>Usage</strong></p>
|
||||
|
||||
<p>To share a secret</p>
|
||||
|
||||
<p>E.g.</p>
|
||||
|
||||
<p>file to be shared - cookie_recipe.txt
|
||||
number of pieces - 2 + file to be shared
|
||||
total number of pieces created by program 4
|
||||
pieces needed to reassemble recipe 3 or greater</p>
|
||||
|
||||
<p><strong>example usage</strong></p>
|
||||
|
||||
<p># to share secret into 4 pieces of which at least 3 will be needed to get back the recipe</p>
|
||||
|
||||
<pre><code>./grothe \
|
||||
-cookie_recipe.txt
|
||||
1-/dev/urandom 2-/dev/urandom
|
||||
1+cookie_piece1.dat 2+cookie_piece2.dat 3+cookie_piece3.dat 4+cookie_piece4.dat
|
||||
</code></pre>
|
||||
|
||||
<p># put recipe back together using 1, 2 and 4th piece</p>
|
||||
|
||||
<pre><code>./grothe \
|
||||
1-cookie_piece1.dat 2-cookie_piece2.dat 4-cookie_piece4.dat
|
||||
+cookie_recipe_restore.txt
|
||||
</code></pre>
|
||||
|
||||
<p><strong>Limitations</strong></p>
|
||||
|
||||
<ul>
|
||||
<li>program is limited to 256 input and output files and will slow down dramatically when you get past 20-50 inputs and outputs</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p><strong>Obfuscations</strong></p>
|
||||
|
||||
<ul>
|
||||
<li>nothing is done consistently throughout the program E.g i+=1, i=i+1, i++ and ++i are all used in the program. The mark of true code buggery. - “A foolish consistency is the hobgoblin of little minds” - Ralph Waldo Emerson</li>
|
||||
<li>uses the most powerful obfuscation of all “Math”. “Any sufficiently advanced cryptography is indistinguasble from magic” - Apologies to Arthur C. Clarke</li>
|
||||
<li>shadows variables by using brackets in main program to create local copies of variables that are the same as global scope variables. -Wshadow should probably be a part of -Wall in gcc</li>
|
||||
<li>uses array_index[array_name] instead of array_name[array_index] in several places. Still don’t know why C continues to allow this
|
||||
( error strings are encoded with offsets that are also used to select them in the case statement. All strings are located in one function for easy localization</li>
|
||||
<li>liberal use of octal numbers, hexadecimal numbers and regular decimal numbers throughout program</li>
|
||||
<li>variables and function names are semi-random and upper and lower case characters are used</li>
|
||||
<li>use of #defines from stdio.h, stdlib.h for values _STDIO_H and EXIT_SUCCESS used to represent 1 and 0 respectively in the program</li>
|
||||
<li>arrays only need to be 256x256 most are set to greater values than they need to be so trying to figure it out can be a bit tough</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p><strong>References</strong></p>
|
||||
|
||||
<ul>
|
||||
<li>Shamir’s Secret Sharing - <a href="http://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing">http://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing</a></li>
|
||||
<li>David Madore’s implementation of Shamir’s Secret Sharing - <a href="http://www.madore.org/~david/programs/programs-1.36.html">http://www.madore.org/~david/programs/programs-1.36.html</a></li>
|
||||
<li>Steve’s Recipe Database - source for the $25k Cookie Recipe - <a href="http://recipes.stevex.net/">http://recipes.stevex.net/</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,114 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most elementary use of C - Silver award</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most elementary use of C - Silver award</h1>
|
||||
|
||||
<p>Tsukasa Hamano<br>
|
||||
<a href="mailto:hamano@cuspy.org">hamano@cuspy.org</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make hamano
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./hamano < textfile > output.pdf
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./hamano < hint.text > hint.pdf
|
||||
|
||||
# You can read output.pdf with PDF reader
|
||||
acroread hint.pdf
|
||||
# or
|
||||
evince hint.pdf
|
||||
|
||||
# deobfuscate
|
||||
gcc -xc hint.pdf -o hint
|
||||
./hint
|
||||
|
||||
# Of course, You can obfuscate c code
|
||||
echo 'void main(){puts("Hello World!");}' | ./hamano > hello.pdf
|
||||
gcc -xc hello.pdf -o hello2
|
||||
./hello2 | gcc -xc - -o ./hello3
|
||||
./hello3
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This entry treads into a new territory for IOCCC - generating PDF files.</p>
|
||||
|
||||
<p>The originally submitted entry could have been thought of as a “Best abuse of
|
||||
Ghostscript” winner. :-)</p>
|
||||
|
||||
<p>The source code and rendered pages are obfuscated for humans (where
|
||||
is the font?), and the submitted entry created PDF files that left Ghostscript
|
||||
confused.</p>
|
||||
|
||||
<p>The results can be viewed with Acrobat Reader,
|
||||
<a href="http://en.wikipedia.org/wiki/Evince">evince</a> and Apple’s Preview.</p>
|
||||
|
||||
<p>The updated version can also be viewed using Ghostscript.</p>
|
||||
|
||||
<p>There is something strange about the little flags in the output.
|
||||
A search of English literature will provide a hint. The conclusion
|
||||
you might draw is too elementary. :-)</p>
|
||||
|
||||
<p>So what do those flags really mean?</p>
|
||||
|
||||
<p>The [Dancing men algorithm][1] might be useful.</p>
|
||||
|
||||
<p>Don’t forget to take a look at the generated PDF, perhaps you might even want
|
||||
to compile the output with a C compiler. When you run it, what does it
|
||||
output?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<p>This program obfuscate text file into PDF file with Dancing men
|
||||
algorithm.</p>
|
||||
|
||||
<p><a href="http://en.wikipedia.org/wiki/The_Adventure_of_the_Dancing_Men">http://en.wikipedia.org/wiki/The_Adventure_of_the_Dancing_Men</a></p>
|
||||
|
||||
<p>Probably, the output PDF file is compliant with PDF 1.3. And also
|
||||
available to compile as C code.</p>
|
||||
|
||||
<p>I’ve been tested with GCC 4.7 and Clang 3.0 on Linux, and following
|
||||
PDF Reader:</p>
|
||||
|
||||
<ul>
|
||||
<li>Adobe Acrobat Reader</li>
|
||||
<li>Evince</li>
|
||||
<li>Ghostscript</li>
|
||||
<li>Xpdf</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Obfuscations</h3>
|
||||
|
||||
<p>This program is obfuscated by using classical methods.
|
||||
But can you find out the embedded font from fragmented glyph?</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,124 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most useful obfuscation</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most useful obfuscation</h1>
|
||||
|
||||
<p>Qiming Hou<br>
|
||||
<a href="mailto:hqm03ster@gmail.com">hqm03ster@gmail.com</a><br>
|
||||
<a href="http://www.houqiming.net">http://www.houqiming.net</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make hou
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./hou syntax-file file-to-process
|
||||
</code></pre>
|
||||
|
||||
<h3>Try (Unix):</h3>
|
||||
|
||||
<p>The results are best viewed in a 80x25 console with ANSI colors.</p>
|
||||
|
||||
<pre><code>less hou.c
|
||||
|
||||
./hou ansi.txt hou.c | less -r
|
||||
|
||||
./hou chk.txt hou.c | wc
|
||||
|
||||
./hou markdown.txt remarks.markdown > remarks.htm
|
||||
your-browser remarks.htm
|
||||
</code></pre>
|
||||
|
||||
<h3>Try (Windows):</h3>
|
||||
|
||||
<pre><code>copy header.htm hou.htm /y
|
||||
hou html.txt hou.c >> hou.htm
|
||||
start hou.htm
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>What a versatile entry! It can be used to check the size of IOCCC entries <em>and</em> to publish them as HTML.</p>
|
||||
|
||||
<p>For extra credit: what is the meaning of the number 2321237?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Disclaimer</h3>
|
||||
|
||||
<p>The reviewer may have already noticed that the 2nd page of this program is a dense blob, which is discouraged by the contest rules. We wish to point out that a majority of state-of-art programming editors support syntax highlighting, which should be enabled when reading this entry. Anticipating that the reviewer’s preferred color setting may produce a suboptimal visual effect, a few syntax files are provided to highlight the source code under an author-provided setting, using the submitted program itself. Syntax highlighting would also visually improve the 3rd page.</p>
|
||||
|
||||
<p>The code may throw a few warnings due to formating constraints. The author did try to remove warnings under gcc and Visual Studio, though.</p>
|
||||
|
||||
<p>The author does not own the original anime series where the embedded ASCII arts come from. For comparison, original non-ASCII art depictions of the relevant characters and objects can be found by googling the embedded text messages.</p>
|
||||
|
||||
<h3>Syntax files</h3>
|
||||
|
||||
<p>The syntax file consists of a number of rewriting rules. Each rule consists of a regular expression, a space, a format string, and a newline. All text matching the regular expression would be replaced by the format string. In case of a conflict, rules appearing earlier would take precedence. One can refer to the original text in the format string using “%s”. Other “%” characters in the format string must be escaped with another “%”. The space character can be used in the regular expression by escaping it with [] or “”.</p>
|
||||
|
||||
<p>The following regular expression operators are supported:</p>
|
||||
|
||||
<pre><code>() [] * + ? | ""
|
||||
</code></pre>
|
||||
|
||||
<p>For example, one can use the following expression to match a certain declaration statement in hou.c:</p>
|
||||
|
||||
<pre><code>"char"[ *]*[a-zA-Z_][0-9a-zA-Z_]*[ ]*((=[0-9a-zA-Z_ ]+)|(\[[0-9a-zA-Z_ ]*\]))?[ ]*(,[ *]*[a-zA-Z_][0-9a-zA-Z_]*[ ]*((=[0-9a-zA-Z_ ]+)|(\[[0-9a-zA-Z_ ]*\]))?[ ]*)*;
|
||||
</code></pre>
|
||||
|
||||
<p>The regex engine is also algorithmically efficient. To illustrate the point, ansi.txt contains a pathological expression [2] that guarantees a hang for the competing Perl engine while matching itself. Try to compare these two engines:</p>
|
||||
|
||||
<pre><code>./hou ansi.txt ansi.txt
|
||||
perl patho.pl < ansi.txt
|
||||
</code></pre>
|
||||
|
||||
<p>Finally, there are a few limitations…</p>
|
||||
|
||||
<ul>
|
||||
<li>The only escape sequence supported is \n and it doesn’t work in [].</li>
|
||||
<li>The maximum file/rule size is a linear function of the hard-coded constant M.</li>
|
||||
<li>Single-character matches at the end of file may be missed.</li>
|
||||
<li>The operator | doesn’t obey precedence rules and some extra ()s may be required.</li>
|
||||
<li>Incorrect syntax files are not tolerated.</li>
|
||||
<li>The program relies on ASCII.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Why obfuscated</h3>
|
||||
|
||||
<p>The first layer of obfuscation comes from the challenge of embedding a large ASCII art in a dense blob. The entire art is composed using only keywords, strings and character constants. That results in a number of otherwise useless defines and quite a number of unconventionally written constants. While the preprocessor may remove the former, the later would remain regardless of beautification and preprocessing.</p>
|
||||
|
||||
<p>The second layer of obfuscation comes from the need to squeeze a reasonably powerful regex engine into the remaining area that isn’t occupied by excessive keywords and useless constants. To achieve this, the regex compiler is written using the same threaded virtual machine [1] that parses the regex. Due to compiler limitations, the generated VM code also ends up obscured by a large amount of spaghetti branches and virtual thread creations. Finally, the VM in [1] is extended to track multiple expression matches for the actual formating.</p>
|
||||
|
||||
<p>As an extra tweak, the text message actually does something useful. Remove the “Make a contract with me” catch line and the program would cease to function.</p>
|
||||
|
||||
<h3>References</h3>
|
||||
|
||||
<p>[1] <a href="http://swtch.com/~rsc/regexp/regexp2.html">Russ Cox, Regular Expression Matching: the Virtual Machine Approach</a></p>
|
||||
|
||||
<p>[2] <a href="http://swtch.com/~rsc/regexp/regexp1.html">Regular Expression Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, Ruby, …)</a></p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,193 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Best short program</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best short program</h1>
|
||||
|
||||
<p>Seonghoon Kang<br>
|
||||
<a href="mailto:kang.seonghoon@mearie.org">kang.seonghoon@mearie.org</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make kang
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>echo "full spelling of an English cardinal numeral less than a quadrillion" | ./kang
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>echo Nineteen hundred and eighty-four | ./kang
|
||||
echo uno | ./kang
|
||||
echo trois | ./kang
|
||||
echo fier | ./kang
|
||||
echo "shest'" | ./kang
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>The judges were able to appreciate the Indo-European language family
|
||||
relation by making this entry successfully recognize <em>some</em> French,
|
||||
German, Italian, Russian, and Spanish numerals.</p>
|
||||
|
||||
<p>Also worth mentioning is this entry’s ability to understand the
|
||||
colloquial year numbers of the last millennium.</p>
|
||||
|
||||
<p>We’ve added a linefeed to the print format for convenience.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h2>Synopsis</h2>
|
||||
|
||||
<p>This short program reads a spelt number (e.g. <code>forty-two</code>) and writes a
|
||||
corresponding decimal number (e.g. <code>42</code>). Too long for one-liners, alas,
|
||||
but it still qualifies as a <em>short</em> program as it has less than 0x100 bytes.</p>
|
||||
|
||||
<p>It accepts a variety of spelt numbers:</p>
|
||||
|
||||
<ul>
|
||||
<li>It correctly handles <code>zero</code>.</li>
|
||||
<li>Hyphen does not make a difference: <code>forty-two</code> and <code>forty two</code> are same.
|
||||
So does period or comma.</li>
|
||||
<li>Cases do not make a difference either: <code>TWO</code>, <code>Two</code>, <code>two</code> are same.</li>
|
||||
<li><code>one</code> and <code>a</code> are interchangeable: <code>one hundred</code> and <code>a hundred</code> are same.</li>
|
||||
<li><code>and</code> is optional: <code>one hundred twenty-three</code> and <code>one hundred and twenty-three</code>
|
||||
are same.</li>
|
||||
<li>It supports every non-negative integer less than 10<sup>15</sup>-1. It uses
|
||||
the small scale (i.e. American): <code>billion</code> is 10<sup>9</sup> and <code>trillion</code> is
|
||||
10<sup>12</sup>.</li>
|
||||
<li>Sometimes, it can magically correct typos.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>It does <em>not</em> accept some spelt numbers, which I found mostly irrelevant:</p>
|
||||
|
||||
<ul>
|
||||
<li>A bare <code>hundred</code>, <code>thousand</code> etc. do not work.</li>
|
||||
<li><code>one million million</code> does not work. Get used to <code>one trillion</code>!</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Requirements</h2>
|
||||
|
||||
<p>This program is quite portable, only requiring the following:</p>
|
||||
|
||||
<ul>
|
||||
<li>The signature <code>int main(int, int)</code> should be accepted by the linker. (Original
|
||||
version only)</li>
|
||||
<li><code>char</code> should be at least 8 bits long (as dictated by the standard), <code>int</code>
|
||||
should be at least 32 bits long, <code>long long</code> should be at least 64 bits long.</li>
|
||||
<li>Both the compiler and execution environment should use an ASCII-compatible
|
||||
character set and two’s complement representation.</li>
|
||||
<li>Overflow and underflow on <code>char</code> should wrap around, if your <code>char</code> is unsigned.</li>
|
||||
<li><a href="http://cm.bell-labs.com/who/ken/trust.html">A trustworthy compiler</a>.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>The design of the program explicitly allows for <code>EOF</code> which does not equal to -1
|
||||
(it has to be negative per the standard) and both signed and unsigned <code>char</code>,
|
||||
for example. Furthermore it is endian-independent.</p>
|
||||
|
||||
<h2>Obfuscations (SPOILERS!)</h2>
|
||||
|
||||
<p>Many obfuscations used are typical for standard IOCCC entries:</p>
|
||||
|
||||
<ul>
|
||||
<li>Two arguments from <code>main</code> function are reused as normal variables.</li>
|
||||
<li>Every conditional has been replaced with <code>?:</code> ternary operator and <code>||</code>
|
||||
short-circuiting operator.</li>
|
||||
<li>It has exactly three nested <code>for</code> loops and nothing else.</li>
|
||||
<li>Common two’s complement tricks: <code>~-a</code> instead of <code>a-1</code>,
|
||||
<code>~a?...:...</code> instead of <code>a!=-1?...:...</code>, etc.</li>
|
||||
<li>Comma operators (<code>,</code>) for multiple statements. The number of them is
|
||||
minimized, however, as it is too easy to (ab)use them.</li>
|
||||
<li>It lacks most parentheses around bitwise and arithmetic operators. It was
|
||||
originally written for shortness so parentheses were <strong>EVIL</strong>.</li>
|
||||
<li><code>n["string"]</code> instead of <code>"string"[n]</code>. Both are fine for this program but
|
||||
I went to the former just for fun.</li>
|
||||
<li>Utter lack of any kind of layouts. (Oh, except for the first column.)</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Other obfuscations are more subtle:</p>
|
||||
|
||||
<ul>
|
||||
<li>The string <code>"1+DIY/.K430x9G(kC["</code> is 18 bytes long, but actually 19 bytes
|
||||
including the final null character are used.</li>
|
||||
<li>It internally represents numbers as hexadecimal. When the input is <code>two
|
||||
hundred and three</code>, it actually writes 0x203 as hexadecimal.</li>
|
||||
<li>Some variables (notably, <code>n</code>) have dual uses.</li>
|
||||
<li>The magic number <a href="http://en.wikipedia.org/wiki/Answer_to_The_Ultimate_Question_of_Life,_the_Universe,_and_Everything">42</a> makes an appearance.</li>
|
||||
<li>It has a long long numb-<code>main</code>-er within it!</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>But the most important obfuscation is the clever construction of lookup table.
|
||||
The program uses 11 different characters required for recognizing 22 lexemes:</p>
|
||||
|
||||
<pre><code>zero one tw- th(i)r- fo(u)r- fi- six-
|
||||
seven- eigh- nin- ten eleven twelve
|
||||
hundred(s) thousand(s) million(s) billion(s) trillion(s)
|
||||
a and -teen -ty
|
||||
</code></pre>
|
||||
|
||||
<p>So that they are internally represented as like:</p>
|
||||
|
||||
<pre><code>r n tw- tr- fr- f- s-
|
||||
sn- g- nn- tn ln twl
|
||||
nr(s) tsan(s) lln(s) blln(s) trlln(s)
|
||||
a an -tn -ty
|
||||
</code></pre>
|
||||
|
||||
<p>The stemmer recognizes the longest matching prefix, so every lexeme can be
|
||||
recognized by at most three characters (e.g. <code>trl</code> instead of <code>trlln</code>). This is
|
||||
also handy for ignoring plurals. But that would make that the table does not fit
|
||||
in the printable byte—11<sup>2</sup> is already almost 2<sup>7</sup>!</p>
|
||||
|
||||
<p>The trick is to use octal; three characters (<code>a</code>, <code>b</code> and <code>g</code>) are interpreted
|
||||
as sequences of two characters (<code>ny</code>, <code>nn</code> and <code>nw</code> respectively). Asides from
|
||||
a smaller lookup table, it has many good consequences:</p>
|
||||
|
||||
<ul>
|
||||
<li>Both <code>a</code> and <code>and</code> share the common prefix, <code>ny</code>, and can be discarded
|
||||
altogether. Note that <code>ny</code> itself does not appear from other entries.</li>
|
||||
<li><code>thousand</code> is interpreted as <code>tsan</code>, which is equivalent to <code>tfyn</code> in the
|
||||
octal scheme. As it is the only entry with <code>tf</code> prefix, it can be shorten by
|
||||
one character.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Having said this important trick, other details should be relatively easier to
|
||||
follow. The order of lookup table, for example, is very important,
|
||||
and the biggest constant 6177 is not arbitrarily chosen.</p>
|
||||
|
||||
<h2>Acknowledgement</h2>
|
||||
|
||||
<p>The cleaner (size-optimized) version of this program was originally published
|
||||
in my website in July 2011. Sun Park and others have reviewed it and let me
|
||||
aware of possible improvements. I’d also like to thank Seo Sanghyeon for
|
||||
proof-reading remarks.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,89 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Best one liner</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best one liner</h1>
|
||||
|
||||
<p>Taketo Konno<br>
|
||||
Tokyo, Japan<br>
|
||||
<a href="mailto:inaniwa3@gmail.com">inaniwa3@gmail.com</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make konno
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./konno N
|
||||
# where N is 0 to 255
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./konno 30
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This entry is a good one-liner to analyze completely.</p>
|
||||
|
||||
<p>For extra credit, what are the minimal changes to convert it to
|
||||
64-bit integers so that it could print 32 lines?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Remarks</h3>
|
||||
|
||||
<p>This program outputs <a href="http://mathworld.wolfram.com/ElementaryCellularAutomaton.html">elementary cellular automaton</a> patterns.</p>
|
||||
|
||||
<p>Try:</p>
|
||||
|
||||
<pre><code>./konno 30
|
||||
./konno 90
|
||||
./konno 102
|
||||
./konno 109
|
||||
./konno 165
|
||||
</code></pre>
|
||||
|
||||
<p>There are 256 (from 0 to 255) possible rules.</p>
|
||||
|
||||
<h3>Obfuscation</h3>
|
||||
|
||||
<p>This program uses bit operations. I think</p>
|
||||
|
||||
<pre><code>7&O<<!o>>!o+29
|
||||
</code></pre>
|
||||
|
||||
<p>is an intersting operation. This isn’t equal to</p>
|
||||
|
||||
<pre><code>7&O>>29
|
||||
</code></pre>
|
||||
|
||||
<p>operation. What is the operation doing?</p>
|
||||
|
||||
<h3>Limitation</h3>
|
||||
|
||||
<p>This program assumes that the size of int is 4.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,176 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most surreptitious</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most surreptitious</h1>
|
||||
|
||||
<p>Don Yang<br>
|
||||
<a href="mailto:omoikane@uguu.org">omoikane@uguu.org</a><br>
|
||||
<a href="http://uguu.org/">http://uguu.org/</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make nyaruko
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./nyaruko [seed.txt] < original.bin > output.c
|
||||
bash output.c > key.c
|
||||
perl output.c > data.c
|
||||
|
||||
cat key.c data.c > output.c
|
||||
|
||||
gcc output.c -o output
|
||||
./output > regenerated.bin
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>echo "A quick brown fox jumps over the lazy dog" | ./nyaruko > output.c
|
||||
perl output.c > data.c
|
||||
gcc -o data data.c
|
||||
./data
|
||||
gcc -o output output.c
|
||||
./output
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>The judges have nothing to add that has not already been written
|
||||
about in the spoiler.html.gz file! :-)</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h1>Usage</h1>
|
||||
|
||||
<p>Nyaruko is a binary to text filter. Given some input on stdin,
|
||||
Nyaruko will produce C code that reproduces this input on stdout:</p>
|
||||
|
||||
<pre><code>./nyaruko < original.bin > output.c
|
||||
gcc output.c -o output
|
||||
./output > regenerated.bin
|
||||
</code></pre>
|
||||
|
||||
<p>Output is encrypted, but both key and data are included in the output.
|
||||
To separate the key from the data, run these commands:</p>
|
||||
|
||||
<pre><code>bash output.c > key.c
|
||||
perl output.c > data.c
|
||||
</code></pre>
|
||||
|
||||
<p>The key-less data.c still compiles, but produces a different message
|
||||
on stdout instead of the original input. This message is a hint to
|
||||
why the code is formatted the way it is.</p>
|
||||
|
||||
<p>To combine the key and data, concatenate them together in either
|
||||
order:</p>
|
||||
|
||||
<pre><code>cat key.c data.c > output.c
|
||||
cat data.c key.c > output.c
|
||||
</code></pre>
|
||||
|
||||
<p>By default, Nyaruko generates a unique random key for every message,
|
||||
using /dev/urandom as the seed. If given an extra command line
|
||||
argument, Nyaruko will seed using that file instead of /dev/urandom:</p>
|
||||
|
||||
<pre><code>./nyaruko seed.txt < input.bin > output.c
|
||||
</code></pre>
|
||||
|
||||
<p>This makes the output key deterministic, allowing the same key to be
|
||||
shared across different files. On operating systems that do not have
|
||||
/dev/urandom, users should always specify this extra seed argument to
|
||||
avoid deterministic keys.</p>
|
||||
|
||||
<h1>Features</h1>
|
||||
|
||||
<p>Implementation details that makes Nyaruko more obfuscated than usual
|
||||
programs:</p>
|
||||
|
||||
<ul>
|
||||
<li> Nyaruko recycles variables and buffers to reduce internal state.
|
||||
The variable names are also carefully chosen for mixed-case
|
||||
madness.</li>
|
||||
<li> Nyaruko employs some preprocessor magic to share much of the same
|
||||
code and state between the encoder and decoder, and to increase
|
||||
occurrences of smileys ;)</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Output code has these features:</p>
|
||||
|
||||
<ul>
|
||||
<li> Fits nicely under 80 columns, and does not contain any trigraphs.</li>
|
||||
<li> Uses a fairly efficient encoding scheme, better than uuencode for
|
||||
files larger than ~13K, and better than base64 for files larger
|
||||
than 20K.</li>
|
||||
<li> Encryption with ISAAC, a cryptographically secure pseudorandom
|
||||
number generator.</li>
|
||||
<li> Trivial 3 language polyglot.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Code layout is meant to resemble Nyaruko, also known as Nyarlathotep,
|
||||
the Crawling Chaos. The most obvious thing to do with chaos is to
|
||||
make a random number generator, and the most obvious thing to do with
|
||||
a random number generator is to make one-time-pads for encryption.</p>
|
||||
|
||||
<h1>Compatibility</h1>
|
||||
|
||||
<p>Nyaruko has these environment dependencies:</p>
|
||||
|
||||
<ul>
|
||||
<li> Requires ASCII character set.</li>
|
||||
<li> Assumes sizeof(unsigned int) == 4.</li>
|
||||
<li> Best viewed with tab stops set to 8 spaces.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Output code has the same dependencies, with the additional
|
||||
requirement that the compiler must support arbitrarily long string
|
||||
literals. Maximum input size that can be encoded while still
|
||||
producing standard-compliant output is ~276 bytes for C89, and ~3168
|
||||
bytes for C99.</p>
|
||||
|
||||
<p>Nyaruko has been to verified to work with these compiler/OS
|
||||
combinations:</p>
|
||||
|
||||
<ul>
|
||||
<li> gcc 4.4.5 on Linux (32bit and 64bit)</li>
|
||||
<li> clang 3.1 on Windows (Cygwin)</li>
|
||||
<li> gcc 4.5.3 on Windows (Cygwin)</li>
|
||||
<li> gcc 4.5.3 on Windows (MingW)</li>
|
||||
<li> gcc 4.3.5 on JSLinux</li>
|
||||
<li> tcc 0.9.25 on JSLinux</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Note that on MingW, stdin and stdout are not opened in binary mode by
|
||||
default, this means Nyaruko may not faithfully encode files on MingW.</p>
|
||||
|
||||
<h1>Extra files</h1>
|
||||
|
||||
<p>spoiler.html.gz - Contains full recording of how the code went from
|
||||
blank state to an obfuscated program, gzipped to fit under 1MB.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,486 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most functional</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most functional</h1>
|
||||
|
||||
<p>John Tromp<br>
|
||||
<a href="mailto:john.tromp@gmail.com">john.tromp@gmail.com</a><br>
|
||||
<a href="http://tromp.github.io/">http://tromp.github.io/</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<p>On a 32-bit machine:</p>
|
||||
|
||||
<pre><code>make tromp
|
||||
</code></pre>
|
||||
|
||||
<p>On a 64-bit machine:</p>
|
||||
|
||||
<pre><code>make tromp64
|
||||
# And mentally substitute ./tromp64 for ./tromp everywhere below
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>cat ascii-prog.blc data | ./tromp -b
|
||||
cat binary-prog.Blc data | ./tromp
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>(cat hilbert.Blc; echo -n 1234) | ./tromp
|
||||
(cat oddindices.Blc; echo; cat primes.blc | ./tromp -b) | ./tromp
|
||||
cat primes.blc | ./tromp -b | ./primes.pl
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>The judges dare to say that the data files this entry is processing
|
||||
are more obfuscated than the entry itself.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<p>This program celebrates the close connection between obfuscation and conciseness,
|
||||
by implementing the most concise language known, Binary Lambda Calculus (BLC).</p>
|
||||
|
||||
<p>BLC was developed to make Algorithmic Information Theory, the theory of smallest programs,
|
||||
more concrete. It starts with the simplest model of computation, the lambda calculus,
|
||||
and adds the minimum amount of machinery to enable binary input and output.</p>
|
||||
|
||||
<p>More specifically, it defines a universal machine, which, from an input stream of bits,
|
||||
parses the binary encoding of a lambda calculus term, applies that to the remainder
|
||||
of input (translated to a lazy list of booleans,
|
||||
which have a standard representation in lambda calculus),
|
||||
and translates the evaluated result back into a stream of bits to be output.</p>
|
||||
|
||||
<p>Lambda is encoded as 00, application as 01, and the variable bound by the n'th
|
||||
enclosing lambda (denoted n in so-called De Bruijn notation) as 1^{n}0.
|
||||
That’s all there is to BLC!</p>
|
||||
|
||||
<p>For example the encoding of lambda term S = \x \y \z (x z) (y z),
|
||||
with De Bruijn notation \ \ \ (3 1) (2 1),
|
||||
is 00 00 00 01 01 1110 10 01 110 10</p>
|
||||
|
||||
<p>In the closely related BLC8 language, IO is byte oriented,
|
||||
translating between a stream of bytes and a list of length-8 lists of booleans.</p>
|
||||
|
||||
<p>The submission implements the universal machine in the most concise manner conceivable.
|
||||
It lacks #defines and #includes, and compiles to a (stripped) executable of under 6K in size.</p>
|
||||
|
||||
<p>Without arguments, it runs in byte mode, using standard in- and output.
|
||||
With one (arbitrary) argument, it runs in bit mode, using only the least significant
|
||||
bit of input, and using characters ‘0’ and ‘1’ for output.</p>
|
||||
|
||||
<p>The program uses the following exit codes:
|
||||
0: OK; result is a finite list
|
||||
5: Out of term space
|
||||
6: Out of memory
|
||||
1,2,3,4,8,9: result not in list form</p>
|
||||
|
||||
<p>The size of the term space is fixed at compile time with -DA</p>
|
||||
|
||||
<h1>A half byte `cat'</h1>
|
||||
|
||||
<p>The shortest (closed) lambda calculus term is \x x (\ 1 in De Bruijn notation)
|
||||
which is the identity function. When its encoding 0010 is fed
|
||||
into the universal machine, it will simply copy the input to the output.
|
||||
(well, not that simply, since each byte is smashed to bits and rebuilt from scratch)
|
||||
Voila: a half byte cat:</p>
|
||||
|
||||
<pre><code> echo " Hello, world" | ./tromp
|
||||
Hello, world
|
||||
</code></pre>
|
||||
|
||||
<p>Since the least significant 4 bits of the first byte are just arbitrary padding
|
||||
that is ignored by the program,
|
||||
any character from ASCII 32 (space) through 47 (/) will do, e.g.:</p>
|
||||
|
||||
<pre><code> echo "*Hello, world" | ./tromp
|
||||
Hello, world
|
||||
</code></pre>
|
||||
|
||||
<h1>Bad programs</h1>
|
||||
|
||||
<p>If the input doesn’t start with a valid program, that is,
|
||||
if the interpreter reaches end-of-file during program parsing,
|
||||
it will crash in some way:</p>
|
||||
|
||||
<pre><code> echo -n "U" | ./tromp
|
||||
Segmentation fault
|
||||
</code></pre>
|
||||
|
||||
<p>Furthermore, the interpreter requires the initial encoded lambda term to be closed,
|
||||
that is, variable n can only appear within at least n enclosing lambdas.
|
||||
For instance the term \ 5 is not closed,
|
||||
causing the interpreter to crash when looking into a null-pointer environment:</p>
|
||||
|
||||
<pre><code> echo ">Hello, world" | ./tromp
|
||||
Segmentation fault
|
||||
</code></pre>
|
||||
|
||||
<p>Since these properties can be checked when creating BLC programs,
|
||||
the interpreter doesn’t bother checking for it.</p>
|
||||
|
||||
<h1>A Self Interpreter</h1>
|
||||
|
||||
<p>The BLC universal machine may be small at 650 bytes of C
|
||||
(952 bytes including layout), but written
|
||||
as a self interpreter in BLC it is downright minuscule at 232 bits (29 bytes):</p>
|
||||
|
||||
<pre><code> 01010001
|
||||
10100000
|
||||
00010101
|
||||
10000000
|
||||
00011110
|
||||
00010111
|
||||
11100111
|
||||
10000101
|
||||
11001111
|
||||
000000111
|
||||
10000101101
|
||||
1011100111110
|
||||
000111110000101
|
||||
11101001 11010010
|
||||
11001110 00011011
|
||||
00001011 11100001
|
||||
11110000 11100110
|
||||
11110111 11001111
|
||||
01110110 00011001
|
||||
00011010 00011010
|
||||
</code></pre>
|
||||
|
||||
<p>The byte oriented BLC8 version weighs in at 43 bytes (shown in hexadecimal).</p>
|
||||
|
||||
<pre><code> 19468
|
||||
05580
|
||||
05f00
|
||||
bfe5f
|
||||
85f3f
|
||||
03c2d
|
||||
b9fc3f8
|
||||
5e9d65e5f
|
||||
0decb f0fc3
|
||||
9befe 185f7
|
||||
0b7fb 00cf6
|
||||
7bb03 91a1a
|
||||
|
||||
(cat uni8.Blc; echo " Ni hao") | ./tromp
|
||||
Ni hao
|
||||
</code></pre>
|
||||
|
||||
<h1>A prime number sieve</h1>
|
||||
|
||||
<p>Even shorter than the self-interpreter is this prime number sieve in 167 bits (under 21 bytes):</p>
|
||||
|
||||
<pre><code>000100011001100101000110100
|
||||
000000101100000100100010101
|
||||
11110111 101001000
|
||||
11010000 111001101
|
||||
000000000010110111001110011
|
||||
11111011110000000011111001
|
||||
10111000
|
||||
00010110
|
||||
0000110110
|
||||
</code></pre>
|
||||
|
||||
<p>The n'th bit in the output indicates whether n is prime:</p>
|
||||
|
||||
<pre><code> cat primes.blc | ./tromp -b | head -c 70
|
||||
0011010100010100010100010000010100000100010100010000010000010100000100
|
||||
</code></pre>
|
||||
|
||||
<p>For those who prefer to digest their primes in decimal, there is oddindices.Blc,
|
||||
which will print the indices of all odd characters (with lsb = 1)
|
||||
separated by a given character:</p>
|
||||
|
||||
<pre><code> (cat oddindices.Blc; echo -n " "; cat primes.blc | ./tromp -b) | ./tromp | head -c 70
|
||||
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
|
||||
</code></pre>
|
||||
|
||||
<h1>A Space filling program</h1>
|
||||
|
||||
<p>Program hilbert.Blc, at 143 bytes, is a very twisty “one-liner” (shown in hexadecimal):</p>
|
||||
|
||||
<pre><code>1818181 8111154 6806041 55ff041
|
||||
9d f9 de 16 ff fe 5f 3f
|
||||
ef f615ff9 46 84 058117e 05
|
||||
cb fe bc bf
|
||||
ee86cb9 4681600 5c0bfac bfbf71a
|
||||
85 e0 5c f4
|
||||
14d5fe0 8180b048d0800e078 016445f
|
||||
fe 5f
|
||||
f7 ffffe5fff2fc 02f7ad97f5bf ff
|
||||
ff bf ff ca af ff
|
||||
7817ffa df76695 4680601 57f7e16
|
||||
05 c1
|
||||
3fe80b2 2c18581 bfe5c10 42ff805
|
||||
de ec 06 c2 c0 c0
|
||||
60 8191a00167fb cbcfdf65f7c0 a20
|
||||
</code></pre>
|
||||
|
||||
<p>It expects n arbitrary characters of input, and draws a space filling Hilbert curve of order n:</p>
|
||||
|
||||
<pre><code> (cat hilbert.Blc; echo -n "1") | ./tromp
|
||||
_
|
||||
| |
|
||||
|
||||
(cat hilbert.Blc; echo -n "12") | ./tromp
|
||||
_ _
|
||||
| |_| |
|
||||
|_ _|
|
||||
_| |_
|
||||
|
||||
(cat hilbert.Blc; echo -n "123") | ./tromp
|
||||
_ _ _ _
|
||||
| |_| | | |_| |
|
||||
|_ _| |_ _|
|
||||
_| |_____| |_
|
||||
| ___ ___ |
|
||||
|_| _| |_ |_|
|
||||
_ |_ _| _
|
||||
| |___| |___| |
|
||||
|
||||
(cat hilbert.Blc; echo -n "1234") | ./tromp
|
||||
_ _ _ _ _ _ _ _
|
||||
| |_| | | |_| | | |_| | | |_| |
|
||||
|_ _| |_ _| |_ _| |_ _|
|
||||
_| |_____| |_ _| |_____| |_
|
||||
| ___ ___ | | ___ ___ |
|
||||
|_| _| |_ |_| |_| _| |_ |_|
|
||||
_ |_ _| _ _ |_ _| _
|
||||
| |___| |___| |_| |___| |___| |
|
||||
|_ ___ ___ ___ ___ _|
|
||||
_| |_ |_| _| |_ |_| _| |_
|
||||
| _ | _ |_ _| _ | _ |
|
||||
|_| |_| | |___| |___| | |_| |_|
|
||||
_ _ | ___ ___ | _ _
|
||||
| |_| | |_| _| |_ |_| | |_| |
|
||||
|_ _| _ |_ _| _ |_ _|
|
||||
_| |___| |___| |___| |___| |_
|
||||
</code></pre>
|
||||
|
||||
<h1>A BrainFuck interpreter</h1>
|
||||
|
||||
<p>The smallest known BF interpreter is written in… you guessed it, BLC,
|
||||
coming in at 112 bytes (including 3 bits of padding):</p>
|
||||
|
||||
<pre><code> od -t x4 bf.Blc
|
||||
0000000 01a15144 02d55584 223070b7 00f032ff
|
||||
0000020 7f85f9bf 956fe15e c0ee7d7f 006854e5
|
||||
0000040 fbfd5558 fd5745e0 b6f0fbeb 07d62ff0
|
||||
0000060 d7736fe1 c0bc14f1 1f2eff0b 17666fa1
|
||||
0000100 2fef5be8 ff13ffcf 2034cae1 0bd0c80a
|
||||
0000120 e51fee99 6a5a7fff ff0fff1f d0049d87
|
||||
0000140 db0500ab 3bb74023 b0c0cc28 10740e6c
|
||||
0000160
|
||||
</code></pre>
|
||||
|
||||
<p>It expects its input to consist of a Brainfuck program
|
||||
(looking only at bits 0,1,4 to distinguish among ,-.+<>][ )
|
||||
followed by a ], followed by the input for the Brainfuck program.</p>
|
||||
|
||||
<pre><code> more hw.bf
|
||||
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.]
|
||||
cat bf.Blc hw.bf | ./tromp
|
||||
Hello World!
|
||||
</code></pre>
|
||||
|
||||
<p>Curiously, the interpreter bf.Blc is the exact same size as hw.bf.</p>
|
||||
|
||||
<h1>A BLC assembler</h1>
|
||||
|
||||
<p>Writing BLC programs can be made slightly less painful with this parser that
|
||||
translates single-letter-variable lambda calculus into BLC:</p>
|
||||
|
||||
<pre><code> echo "\f\x f (f (f x))" > three
|
||||
cat parse.Blc three | ./tromp
|
||||
000001110011100111010
|
||||
</code></pre>
|
||||
|
||||
<h1>Converting between bits and bytes</h1>
|
||||
|
||||
<p>THe program inflate.Blc and its inverse deflate.Blc allow us to translate between
|
||||
BLC and BLC8.
|
||||
If you assemble a byte oriented program, you’ll need to compact it into BLC8:</p>
|
||||
|
||||
<p>So we could assemble an input reversing program as</p>
|
||||
|
||||
<pre><code> echo "\a a ((\b b b) (\b \c \d \e d (b b) (\f f c e))) (\b \c c)" > reverse
|
||||
cat parse.Blc reverse | ./tromp > reverse.blc
|
||||
</code></pre>
|
||||
|
||||
<p>and change it to BLC8 with</p>
|
||||
|
||||
<pre><code> cat deflate.Blc reverse.blc | ./tromp > rev.Blc
|
||||
wc rev.Blc
|
||||
0 1 9 rev.Blc
|
||||
</code></pre>
|
||||
|
||||
<p>and then try it out with:</p>
|
||||
|
||||
<pre><code> cat rev.Blc - | ./tromp
|
||||
Hello, world!
|
||||
^D
|
||||
!dlrow ,olleH
|
||||
</code></pre>
|
||||
|
||||
<h1>Symbolic Lambda Calculus reduction </h1>
|
||||
|
||||
<p>BLC8 program symbolic.Blc shows individual reduction steps on symbolic lambda terms.
|
||||
Here it is used to show the calculation of 2<sup>3</sup> in Church numerals:</p>
|
||||
|
||||
<pre><code> echo "(\f\x f (f (f x))) (\f\x f (f x))" > threetwo
|
||||
cat parse.Blc threetwo | ./tromp > threetwo.blc
|
||||
cat symbolic.Blc threetwo.blc | ./tromp
|
||||
(\a \b a (a (a b))) (\a \b a (a b))
|
||||
\a (\b \c b (b c)) ((\b \c b (b c)) ((\b \c b (b c)) a))
|
||||
\a \b (\c \d c (c d)) ((\c \d c (c d)) a) ((\c \d c (c d)) ((\c \d c (c d)) a) b)
|
||||
\a \b (\c (\d \e d (d e)) a ((\d \e d (d e)) a c)) ((\c \d c (c d)) ((\c \d c (c d)) a) b)
|
||||
\a \b (\c \d c (c d)) a ((\c \d c (c d)) a ((\c \d c (c d)) ((\c \d c (c d)) a) b))
|
||||
\a \b (\c a (a c)) ((\c \d c (c d)) a ((\c \d c (c d)) ((\c \d c (c d)) a) b))
|
||||
\a \b a (a ((\c \d c (c d)) a ((\c \d c (c d)) ((\c \d c (c d)) a) b)))
|
||||
\a \b a (a ((\c a (a c)) ((\c \d c (c d)) ((\c \d c (c d)) a) b)))
|
||||
\a \b a (a (a (a ((\c \d c (c d)) ((\c \d c (c d)) a) b))))
|
||||
\a \b a (a (a (a ((\c (\d \e d (d e)) a ((\d \e d (d e)) a c)) b))))
|
||||
\a \b a (a (a (a ((\c \d c (c d)) a ((\c \d c (c d)) a b)))))
|
||||
\a \b a (a (a (a ((\c a (a c)) ((\c \d c (c d)) a b)))))
|
||||
\a \b a (a (a (a (a (a ((\c \d c (c d)) a b))))))
|
||||
\a \b a (a (a (a (a (a ((\c a (a c)) b))))))
|
||||
\a \b a (a (a (a (a (a (a (a b)))))))
|
||||
</code></pre>
|
||||
|
||||
<p>As expected, the resulting normal form is Church numeral 8.</p>
|
||||
|
||||
<p>Taking only the first line of output gives us a sort of BLC disassembler,
|
||||
an exact inverse of the above assembler. The prime number sieve disassembles as follows:</p>
|
||||
|
||||
<pre><code> cat symbolic.Blc primes.blc | ./tromp | head -1
|
||||
\a (\b b (b ((\c c c) (\c \d \e e (\f \g g) ((\f c c f ((\g g g) (\g f (g g)))) (\f \g \h \i i g (h (d f))))) (\c \d \e b (e c))))) (\b \c c (\d \e d) b)
|
||||
</code></pre>
|
||||
|
||||
<p>Hardly any less obfuscated…</p>
|
||||
|
||||
<p>The last line of
|
||||
cat symbolic.Blc primes.blc | ./tromp | head -16
|
||||
starts out as
|
||||
\a \b b (\c \d c) (\c c (\d \e d) (\d d (\e \f f) (\e e (\f \g g) ((\f (\g \h \i</p>
|
||||
|
||||
<p>The \a is for ignoring the rest of the input (to which the universal machine
|
||||
applies the decoded lambda term). The \b b (..) (…) is the list constructor,
|
||||
usually called cons, applied to a head (a list element) and a tail (another list).
|
||||
In this case the element is (\c \d c), which represents the boolean true, and
|
||||
which we use to represent a 0 bit. This is the bit that says 0 is not prime.
|
||||
The next list element (following another cons) is (\d \e d). Another 0 bit,
|
||||
this time saying that 1 is not prime. The third list element is (\e \f f),
|
||||
a 1 bit, confirming our suspicion that 2 is prime. As is the next number,
|
||||
according to (\f \g g). We can see that the tail after the first 4 elements
|
||||
is still subject to further reduction. The bit for number 4 will show up
|
||||
for the first time in line 30, as (\g \h g), or 0, as the result of zeroing
|
||||
out all multiples of the first prime, 2.
|
||||
Since my computer reaches swap hell before line 40, we can’t see the next bit arriving,
|
||||
at least not in this symbolic reduction.</p>
|
||||
|
||||
<h1>Performance</h1>
|
||||
|
||||
<p>Performance is quite decent, and amazingly good for such a tiny implementation,
|
||||
being roughly 50% slower than a Haskell implementation of the universal machine
|
||||
using so-called Higher Order Abstract Syntax which relies on the highly optimized
|
||||
Haskell runtime system for evaluation. Of course individual blc programs running
|
||||
under the interpreter perform much worse than that same program written in Haskell.</p>
|
||||
|
||||
<p>Our interpreter copes well with extra levels of interpretation:</p>
|
||||
|
||||
<pre><code> time cat primes.blc | ./tromp -b | head -c 210 > /dev/null
|
||||
real 0m0.043s
|
||||
time cat uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
|
||||
real 0m0.191s
|
||||
time cat uni.blc uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
|
||||
real 0m1.919s
|
||||
time cat uni.blc uni.blc uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
|
||||
real 0m23.514s
|
||||
time cat uni.blc uni.blc uni.blc uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
|
||||
real 4m52.700s
|
||||
</code></pre>
|
||||
|
||||
<h1>Obfuscation</h1>
|
||||
|
||||
<p>Obfuscation is due entirely to conciseness. Some questions to ponder:</p>
|
||||
|
||||
<p>Which of the term space codes 0,1,2,3 serves multiple purposes?</p>
|
||||
|
||||
<p>Why is the environment pointer pointing into the term space?</p>
|
||||
|
||||
<p>What does the test u+m&1? do?</p>
|
||||
|
||||
<p>How does the program reach exit code 0?</p>
|
||||
|
||||
<p>And how do any of those blc programs work?</p>
|
||||
|
||||
<h1>Portability</h1>
|
||||
|
||||
<p>The program freely (without casting) converts between int and int*, causing
|
||||
many warnings;
|
||||
note: expected ‘int *’ but argument is of type ‘int’
|
||||
warning: assignment from incompatible pointer type
|
||||
warning: assignment makes integer from pointer without a cast
|
||||
warning: assignment makes pointer from integer without a cast
|
||||
warning: incompatible implicit declaration of built-in function ‘calloc’
|
||||
warning: incompatible implicit declaration of built-in function ‘exit’
|
||||
warning: passing argument 1 of ‘d’ makes pointer from integer without a cast
|
||||
warning: passing argument 1 of ‘p’ makes pointer from integer without a cast
|
||||
warning: pointer/integer type mismatch in conditional expression</p>
|
||||
|
||||
<p>Avoiding these would make the program substantially longer,
|
||||
and detract from its single minded focus on conciseness.</p>
|
||||
|
||||
<p>It implicitly declares functions read, write, exit and calloc, the latter two incompatibly.
|
||||
32 bit and 64 bit executables are separate Makefile targets, involving a change
|
||||
from int to long and from a hardcoded sizeof of 4 to 8.</p>
|
||||
|
||||
<p>The program has been tested to work correctly on Linux/Solaris/MacOSX both in 32 and 64 bits.</p>
|
||||
|
||||
<h1>How the program works</h1>
|
||||
|
||||
<p>See the file how13.</p>
|
||||
|
||||
<h1>Acknowledgements</h1>
|
||||
|
||||
<p>Christopher Hendrie, Bertram Felgenhauer, Alex Stangl, Seong-hoon Kang,
|
||||
and Yusuke Endoh have contributed ideas and suggestions for improvement.</p>
|
||||
|
||||
<h1>References</h1>
|
||||
|
||||
<p>Binary Lambda Calculus
|
||||
<a href="https://tromp.github.io/cl/Binary_lambda_calculus.html">https://tromp.github.io/cl/Binary_lambda_calculus.html</a></p>
|
||||
|
||||
<p>G J Chaitin, Algorithmic information theory, Volume I,
|
||||
Cambridge Tracts in Theoretical Computer Science, Cambridge University Press, October 1987.
|
||||
<a href="http://www.cs.auckland.ac.nz/~chaitin/cup.html">http://www.cs.auckland.ac.nz/~chaitin/cup.html</a></p>
|
||||
|
||||
<p>Jean-Louis Krivine. 2007.
|
||||
A call-by-name lambda-calculus machine
|
||||
Higher Order Symbol. Comput. 20, 3 (September 2007), 199-207.
|
||||
<a href="http://www.pps.univ-paris-diderot.fr/~krivine/articles/lazymach.pdf">http://www.pps.univ-paris-diderot.fr/~krivine/articles/lazymach.pdf</a></p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,169 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Best use of cocoa - Bronze award</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best use of cocoa - Bronze award</h1>
|
||||
|
||||
<p>Daniel Vik<br>
|
||||
<a href="mailto:daniel@vik.cc">daniel@vik.cc</a><br>
|
||||
<a href="http://danielvik.com/">http://danielvik.com/</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make vik
|
||||
</code></pre>
|
||||
|
||||
<p>This entry requires <a href="http://www.zlib.net/">Zlib</a>.</p>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<h4>Embed text (from file or command line):</h4>
|
||||
|
||||
<pre><code>./vik e base.png filename > encodedimg.png
|
||||
# or
|
||||
./vik e base.png SomeRandomText > encodedimg.png
|
||||
</code></pre>
|
||||
|
||||
<h4>Extract the embedded text:</h4>
|
||||
|
||||
<pre><code>./vik d encodedimg.png
|
||||
</code></pre>
|
||||
|
||||
<h4>Embed a PNG into another</h4>
|
||||
|
||||
<pre><code>./vik e base.png source.png > encodedimg.png
|
||||
</code></pre>
|
||||
|
||||
<h4>Extract the embedded PNG:</h4>
|
||||
|
||||
<pre><code>./vik d encodedimg.png > restored.png
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./vik e ioccc.png chocolate.png > chocolate-in-ioccc.png
|
||||
./vik e chocolate.png ioccc.png > ioccc-in-chocolate.png
|
||||
./vik d chocolate-in-ioccc.png > restored-chocolate.png
|
||||
./vik d ioccc-in-chocolate.png > restored-ioccc.png
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>References to chocolate had no effect on judging this entry. We
|
||||
guarantee it.</p>
|
||||
|
||||
<p>Can you discern hidden pieces of chocolate in chocolate-in-ioccc.png ?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h2>Introduction</h2>
|
||||
|
||||
<p>This program is a steganography application for embedding an image or text
|
||||
into another image as well as extracting the embedded image or text back.
|
||||
The program stores the embedded image or text in the low bits of the RGB
|
||||
values.</p>
|
||||
|
||||
<p>The program supports any 8 bit true color PNG images (RGB, RGBA, grayscale,
|
||||
and grayscale+alpha). The output image is always 8 bit RGB. When embedding
|
||||
one image into another, the width and height needs to be the same.</p>
|
||||
|
||||
<p>The program only updates the IDAT and IHDR chunks of the source image. Any
|
||||
additional chunks are copied into the resulting image.</p>
|
||||
|
||||
<h3>Bonus Extractor:</h3>
|
||||
|
||||
<p>For some reason the chocolate image seems to have some special properties.
|
||||
Apart from being quite big and a little bit noisy, it appears that when
|
||||
embedded into another image and extracted, the bitmap data is also a valid
|
||||
brain$#@$ program. It is of course possible to get the bitmap data from the
|
||||
extracted image, and run it through any of the previous winning brain$#@$
|
||||
interpreters, but I thought it would be easier to include an interpreter in
|
||||
the program to avoid the hassle:</p>
|
||||
|
||||
<pre><code>./vik e ioccc.png chocolate.png > encodedimg.png
|
||||
./vik b encodedimg.png
|
||||
</code></pre>
|
||||
|
||||
<p>It is of course also possible to embed a brain$#@$ program as a text file
|
||||
(as explained above) and decode it, e.g.:</p>
|
||||
|
||||
<pre><code>./vik e ioccc.png .+[.+] > encodedimg.png
|
||||
./vik b encodedimg.png
|
||||
</code></pre>
|
||||
|
||||
<h3>Obfuscation</h3>
|
||||
|
||||
<p>I really wanted to keep the program simple, so instead of adding multiple
|
||||
macros or helper methods that can be confusing, I placed all functionality
|
||||
in the main function. Main is called recursively and quite extensively, but
|
||||
it gives the benefit that all invocations of the function has the same
|
||||
parameters, argv and argc. This really helps readability, as a programmer
|
||||
doesn’t need to remember several variable or function names. I also tried
|
||||
to reduce the number of keywords, and the program only has four for-loops
|
||||
followed by a single return statement. There is a little bit of use of the
|
||||
question mark operator, but this is really there to keep the program as
|
||||
simple as possible.</p>
|
||||
|
||||
<h3>Portability</h3>
|
||||
|
||||
<p>The program is portable to most platforms that have zlib available. The
|
||||
only system dependency is that the program relies on writing binary data to
|
||||
stdout.</p>
|
||||
|
||||
<p>By default, Microsoft compilers adds carriage returns to new lines, and to
|
||||
compile the program on this platform, the following line can be added after
|
||||
the variable declarations in the main declaration in order to run
|
||||
correctly:</p>
|
||||
|
||||
<pre><code>_setmode(_fileno(stdout), 0x8000);
|
||||
</code></pre>
|
||||
|
||||
<h3>Limitations</h3>
|
||||
|
||||
<p>The program doesn’t have many error checks so passing in invalid arguments
|
||||
or images of mismatching sizes, or unsupported pixel formats will cause the
|
||||
program to crash.</p>
|
||||
|
||||
<h3>Extendability</h3>
|
||||
|
||||
<p>Since a lot of care was taken to keep the code simple, it turned out to be
|
||||
quite easy to extend functionality. I did include a small brain$#@$ after I
|
||||
realized that the chocolate image had some interesting properties.</p>
|
||||
|
||||
<p>But there is more functionality I added that didn’t fit within the size
|
||||
limits and could not remain included. For example, I added a method to
|
||||
format source code based on a PNG image. So the format of the program is
|
||||
actually done by the program itself.</p>
|
||||
|
||||
<p>And to be honest, the chocolate image did not have a brain$#@$ program
|
||||
embedded to begin with. I added functionality to the program to embed a
|
||||
brain$#@$ into a PNG image and used it to create the image provided with
|
||||
the entry.</p>
|
||||
|
||||
<p>I also added a method to analyze PNG images, to print the size and format,
|
||||
as well as the scan line filters.</p>
|
||||
|
||||
<p>All these features were quite easy to add, much thanks to the (actually
|
||||
pretty good) design of the code.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://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.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Balanced use of obfuscation - Gold award</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Balanced use of obfuscation - Gold award</h1>
|
||||
|
||||
<p>Adar Zeitak<br>
|
||||
<a href="mailto:aa4z2@walla.co.il">aa4z2@walla.co.il</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make zeitak
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./zeitak < file.c
|
||||
</code></pre>
|
||||
|
||||
<p>where file.c is the file to be checked for nesting errors. For example, you may
|
||||
try incorrect.c and the program itself.</p>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./zeitak < zeitak.c
|
||||
./zeitak < incorrect.c
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This is an extremely subtle and twisted piece of Gold award winning code!</p>
|
||||
|
||||
<p>The judges had spent a considerable amount of time analyzing this entry.
|
||||
At one point we spent
|
||||
<a href="https://twitter.com/ioccc/status/252162898800033792">18 minutes</a>
|
||||
just to understand 18 key characters of this code.</p>
|
||||
|
||||
<p>The file zeitak_deobfucate.c provides a version that has been slightly
|
||||
deobfuscated. You may find reading that file helpful in your attempt
|
||||
to understand this extremely subtle entry.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Nesting Errors Detector</h3>
|
||||
|
||||
<h4>What does it do</h4>
|
||||
|
||||
<p>As you have probably understood by looking at the source*, this program has
|
||||
something to do with parenthesis (and equality of opening and closing
|
||||
parenthesis, if you look close enough). It goes over the file given to it and
|
||||
checks that every opening (, [, or { has a matching closing one and
|
||||
vice versa. It also checks that every “ or ‘ is closed.</p>
|
||||
|
||||
<p>If an error is detected, an error message will be printed. If the problem
|
||||
is a superfluous closing bracket, it will even print a few characters
|
||||
around it’s position.</p>
|
||||
|
||||
<ul>
|
||||
<li>Make sure you view the source with 4 spaces tab width.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h4>Features</h4>
|
||||
|
||||
<ul>
|
||||
<li><p>Ignores parenthesis inside strings or character constants, so no errors
|
||||
will be detected in the following line:</p>
|
||||
|
||||
<pre><code> printf(")");
|
||||
</code></pre></li>
|
||||
<li><p>Doesn’t get confused by the 1984/anonymous entry!</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h4>Mis-Features</h4>
|
||||
|
||||
<ul>
|
||||
<li><p>Escapes (e.g. <code>\"</code>) are ignored, so the following line will produce
|
||||
an error:</p>
|
||||
|
||||
<pre><code>printf("\"");
|
||||
</code></pre></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h4>Obfuscation</h4>
|
||||
|
||||
<p>IOCCC winners already contain entries without digits, control-flow
|
||||
keywords and certain operators in their source. This entry has an
|
||||
even more limited source, that is:</p>
|
||||
|
||||
<ul>
|
||||
<li>Without any digits.</li>
|
||||
<li>Without any character constants.</li>
|
||||
<li>Without using functions from headers other than stdio.</li>
|
||||
<li>Without any control-flow keywords (not even the ?: operator).</li>
|
||||
<li>Without any arithmetic or logic operators!</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>So, what’s left? Parenthesis, and lots of them, as looking at the source will
|
||||
reveal immediately. The main obfuscation is building the whole algorithm using
|
||||
only function calls, typecasts, array lookups and pointer operators.</p>
|
||||
|
||||
<p>Additional obfuscations include:</p>
|
||||
|
||||
<ul>
|
||||
<li>Extensive reuse of identifiers: Macros share names with variables, inner
|
||||
curly braces scopes contain variables with names identical to those in the
|
||||
outer scopes and some of the variables have different uses in different
|
||||
parts of the program. Even the large array has more than one use.</li>
|
||||
<li>A complicated data structure with “unused” fields.</li>
|
||||
<li>Mostly one-letter identifiers.</li>
|
||||
<li>Complex recursion: A function might call itself once, twice, or not at all.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h4>Compilation/Running Notes</h4>
|
||||
|
||||
<ul>
|
||||
<li><p>The program requires <code>char</code> to be one byte and pointers to be
|
||||
at least two bytes long.</p></li>
|
||||
<li><p>The program was tested on the following platforms:</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p><strong> Ubuntu 9.04 32-bit with GCC
|
||||
</strong> Windows 7 32-bit with GCC
|
||||
** Windows 7 32-bit with OpenWatcom</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<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="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://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