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,159 +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.3 DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Best of Show - Most Shrinkable</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best of Show - Most Shrinkable</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 akari
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./akari [input_file_or_- [output_file_or_- [even]]]
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./akari < example.ppm > odd_output.ppm
|
||||
./akari - - even < example.ppm > even_output.ppm
|
||||
./akari example.ppm odd_output.ppm
|
||||
|
||||
make akari2.c
|
||||
cat akari2.c
|
||||
|
||||
make akari2
|
||||
|
||||
./akari2 < akari2.c
|
||||
./akari2 rot13 < akari2.c
|
||||
|
||||
make akari3.c
|
||||
cat akari3.c
|
||||
|
||||
make akari3
|
||||
|
||||
./akari3
|
||||
|
||||
make akari4.c
|
||||
cat akari4.c
|
||||
|
||||
./akari4
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>Akari is an image downsampling utility that accepts 3 inout formats:</p>
|
||||
|
||||
<pre><code>* PGM (netpbm grayscale image). Akari only accept PGM files with this
|
||||
header: P5 <width> <height> 255. Images with extra comments such as
|
||||
the ones produced by GIMP will not be parsed properly.
|
||||
|
||||
* PPM (netpbm RGB image). Only PPM files with this header are
|
||||
accepted: P6 <width> <height> 255.
|
||||
|
||||
* ASCII art (with end of lines in LF bytes only, not CR-LF)
|
||||
</code></pre>
|
||||
|
||||
<p>Anything that is not parseable as PGM or PPM will be downsampled as ASCII art.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<p>Akari is an image downsampling utility. She accepts up to 3 arguments:</p>
|
||||
|
||||
<p>First argument is the input image. If it’s “-” or unspecified, Akari
|
||||
will read from stdin.</p>
|
||||
|
||||
<p>Second argument is the output image. If it’s “-” or unspecified,
|
||||
Akari will write to stdout.</p>
|
||||
|
||||
<p>Third argument, if specified, causes Akari to keep even pixels on even
|
||||
scanlines. By default Akari will keep odd pixels on odd scanlines.</p>
|
||||
|
||||
<p>Examples:</p>
|
||||
|
||||
<pre><code>gcc akari.c -o akari
|
||||
./akari < example.ppm > odd_output.ppm
|
||||
./akari - - even < example.ppm > even_output.ppm
|
||||
./akari example.ppm odd_output.ppm
|
||||
</code></pre>
|
||||
|
||||
<p>Akari accepts 3 input formats:
|
||||
* PGM (netpbm grayscale image). Akari only accept PGM files with this
|
||||
header: P5 <width> <height> 255. Images with extra comments such as
|
||||
the ones produced by GIMP will not be parsed properly.
|
||||
* PPM (netpbm RGB image). Only PPM files with this header are
|
||||
accepted: P6 <width> <height> 255.
|
||||
* ASCII art (with end of lines in LF bytes only, not CR-LF)</p>
|
||||
|
||||
<p>This is useful for decoding some curiously interlaced images, such as
|
||||
the included example.ppm</p>
|
||||
|
||||
<p>Anything that is not parseable as PGM or PPM will be downsampled as
|
||||
ASCII art. Since the source code is formatted as ASCII art, it’s only
|
||||
natural to try:</p>
|
||||
|
||||
<pre><code>./akari akari.c akari2.c
|
||||
</code></pre>
|
||||
|
||||
<p>akari2.c is also a valid C program, and accepts up to 1 argument.
|
||||
By default, this second program reads text from stdin and writes
|
||||
expanded output to stdout. If the extra argument is specified, the
|
||||
output text will also pass through a rot13 filter.</p>
|
||||
|
||||
<pre><code>gcc akari2.c -o akari2
|
||||
./akari2 < input.txt > expanded_output.txt
|
||||
./akari2 rot13 < input.txt > expanded_and_rot13_output.txt
|
||||
</code></pre>
|
||||
|
||||
<p>You can combine the two programs together to have just a regular rot13
|
||||
filter:</p>
|
||||
|
||||
<pre><code>./akari2 rot13 < input.txt | ./akari > rot13.txt
|
||||
</code></pre>
|
||||
|
||||
<p>Of course, we wouldn’t stop with just 2 programs, you can downsample
|
||||
the source <em>again</em> and get yet another C program:</p>
|
||||
|
||||
<pre><code>./akari < akari.c | ./akari > akari3.c
|
||||
</code></pre>
|
||||
|
||||
<p>We must go deeper:</p>
|
||||
|
||||
<pre><code>./akari < akari.c | ./akari | ./akari > akari4.c
|
||||
</code></pre>
|
||||
|
||||
<p>akari3.c and akari4.c are still (mostly valid) C programs.
|
||||
“gcc -Wall” will output a few warnings, but still produce output
|
||||
executables. The output executables each print a message to stdout.</p>
|
||||
|
||||
<p>It takes quite a bit of skill and obfuscation to interleave a
|
||||
C program 4 levels deep, it’s much easier to interleave something like
|
||||
a brainf#$% program in a C program, for example. For comparison, a
|
||||
brainf#$% program is embedded inside akari.c</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-2012,
|
||||
<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,246 +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.3 DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most devolving</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most devolving</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># Zoom out and make your terminal window 53 or more lines deep
|
||||
./blakely < blakely.c | head -300
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./blakely < 3.dat | head -100
|
||||
./blakely - < 3.dat | head -40
|
||||
./blakely < evolve_to_3.dat | head -55
|
||||
./blakely < t0_3.dat
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This program plays Life, computes Pi to 16 digits
|
||||
if given its own source as input, and allows to check if your garden
|
||||
is a <a href="http://en.wikipedia.org/wiki/Garden_of_Eden_%28cellular_automaton%29">Garden of Eden</a>, all in one source.</p>
|
||||
|
||||
<p>If you have enough time to spare, put the plan of your garden in a text file,
|
||||
and run:</p>
|
||||
|
||||
<pre><code>./blakely - < garden.txt
|
||||
</code></pre>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h2>Remarks</h2>
|
||||
|
||||
<p>This program uses a well-known algorithm in order to display pi to
|
||||
fifteen decimal places. The source-layout itself demonstrates the importance of
|
||||
using the correct amount of whitespace in code and the clear superiority of spaces over tabs.</p>
|
||||
|
||||
<p>In order to see the main feature of the code, type:</p>
|
||||
|
||||
<pre><code>./blakely < blakely.c
|
||||
</code></pre>
|
||||
|
||||
<p>and wait for about four seconds before using Ctrl-C (or whatever) to end the program. The
|
||||
results are best viewed in a terminal window at least 60 characters
|
||||
high and wide. Alternatively, redirect the output to a separate file
|
||||
(killing when necessary).</p>
|
||||
|
||||
<h2>Overview</h2>
|
||||
|
||||
<p>The program emulates John Conway’s ceullular automaton known as “The
|
||||
Game of Life”, using standard input as a starting grid. The layout of
|
||||
the source-code is such that it evolves to a digital representation of
|
||||
the first 15 decimal places of pi after 4 time steps. This was setup
|
||||
using the other feature of the program which can be demonstrated as follows:</p>
|
||||
|
||||
<pre><code>./blakely - < 3.dat
|
||||
</code></pre>
|
||||
|
||||
<p>The program will first display the grid given in 3.dat, and then three
|
||||
more grids (taking a few minutes to display the last). Waiting for any more grids will
|
||||
take a substantial amount of time. The final grid has been put into
|
||||
evolve_to_3.dat, and if you type</p>
|
||||
|
||||
<pre><code>./blakely < evolve_to_3.dat
|
||||
</code></pre>
|
||||
|
||||
<p>then the 3 will reappear after three time steps.</p>
|
||||
|
||||
<p>As should now be clear, this use of program will attempt to evolve a given setup backwards in
|
||||
time according to the Life rules. The resulting grid is clearly not
|
||||
necessarily unique. The program will evolve backwards given <em>any</em> single
|
||||
command line option.</p>
|
||||
|
||||
<p>When evolving forwards, the code can only be stopped by killing the
|
||||
program. In the reverse direction, the code can either be killed, or
|
||||
will stop if it is unable to find a grid that will evolve to the
|
||||
current layout correctly. This can be seen with the sample grid
|
||||
t0_3.dat, which evolves backwards by only two time-steps.</p>
|
||||
|
||||
<h2>Input file format</h2>
|
||||
|
||||
<p>The input files must encode a square grid, where a space is a dead
|
||||
cell, and any other character (except a newline) is a living cell. Each line must be the same
|
||||
length, and end with a single newline character \n (ASCII 10), including the last line. When
|
||||
designing grids, it may help to type full-stops in place of spaces,
|
||||
and do a global replace afterwards. Any deviation from this format will
|
||||
cause errors in the output.</p>
|
||||
|
||||
<h2>Limitations</h2>
|
||||
|
||||
<p>This is only an approximation to the original Life, as it takes place
|
||||
on a finite grid, with borders that are automatically killed off
|
||||
before each time step. However, when evolving backwards, the resulting
|
||||
grids will not cause any cells on the boundaries to come alive.
|
||||
As the display is performed before killing off the borders, some
|
||||
boundary cells may sometimes appear to be alive, but not be treated as
|
||||
such for the following time-step, although any living cells on the
|
||||
right border will never be displayed.</p>
|
||||
|
||||
<p>The maximum grid size is currently 99 by 99 (exceeding this will cause a
|
||||
seg-fault), but changing the two 9802s to MAX_SIZE*MAX_SIZE+1 will
|
||||
solve this, although some reformatting of the
|
||||
code may have to be done to allow larger numbers.</p>
|
||||
|
||||
<h2>Compiler warnings/assumptions</h2>
|
||||
|
||||
<p>When compiled with the -Wall -pedantic -ansi options of gcc, some
|
||||
warnings suggesting extra parentheses occur (not necessary for anyone
|
||||
fully conversant with operator precedence). There is one unused
|
||||
variable, v, but unnamed function parameters are not permitted in ANSI
|
||||
C, so naming it is necessary, and gcc no longer warns about its
|
||||
existence, although earlier versions did.</p>
|
||||
|
||||
<p>Since the program calculates ASCII character values for display, an
|
||||
ASCII based system is required to run it. Also, as mentioned above,
|
||||
any system that uses anything other than a plain ‘\n’ to end a line will cause
|
||||
problems when reading in files.</p>
|
||||
|
||||
<h2>Obfuscations</h2>
|
||||
|
||||
<p>Given the finely-tuned layout required to evolve into pi, this is one of the
|
||||
main obfuscations used in the code. However, running the code through the
|
||||
preprocessor, expanding the defines, and applying GNU’s indent, although
|
||||
making the location of functions and statements clear, by no means makes the
|
||||
code entirely clear. Note that expanding out the #defines does not take the
|
||||
program over the character limit. The main reason for these is to do with the
|
||||
layout, since there are few places that keywords or tokens of over 2
|
||||
characters can be fitted, and requiring the first few lines to be #includes
|
||||
would cause similar problems.</p>
|
||||
|
||||
<p>Other obfuscations used are:</p>
|
||||
|
||||
<ul>
|
||||
<li>Use of the classic 2[a] syntax to access the third element of the
|
||||
array a</li>
|
||||
<li>Nested ternary operators, combined with shortcut evaluation being
|
||||
required for correct operation</li>
|
||||
<li>Use of the comma operator to embed operations inside one another</li>
|
||||
<li>Calculation of ASCII codes</li>
|
||||
<li>Needlessly recursive functions</li>
|
||||
<li>Use of bitwise-operations.</li>
|
||||
<li>Storing a variable whose value could easily be found from another</li>
|
||||
<li>Use of gotos to emulate a for loop</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Algorithm</h2>
|
||||
|
||||
<p>The forwards evolution of the grid is straightforward.</p>
|
||||
|
||||
<p>The reverse evolution is done using a brute-force method. As far as I
|
||||
know, a brute-force method is the only viable automatic approach for
|
||||
general grids, although more intelligent algorithms would be possible
|
||||
given more space.</p>
|
||||
|
||||
<p>The program starts with an empty “trial” grid and, starting from the
|
||||
top-left, tries all possibilities for the neighbours of the current
|
||||
cell that will cause the cell to evolve to the required state. It then
|
||||
proceeds to the right and down. Thus, it only ever needs to look at
|
||||
the cells below and to the right when testing. However, the already
|
||||
defined cells above and/or to the left of the cell may mean that there
|
||||
are no possibilities that will give the correct state, in which case
|
||||
the code backtracks and tries other possibilities on previous
|
||||
cells. The program knows it has a valid grid if it gets to the last
|
||||
cell. If it cannot find a valid grid, the program exits.</p>
|
||||
|
||||
<p>Since this uses brute-force, it can be very slow. (In fact, the
|
||||
various obfuscations have, at least for the gcc compiler,
|
||||
caused a substantial slowdown.)</p>
|
||||
|
||||
<h2>Program layout</h2>
|
||||
|
||||
<p>The “calculation” of pi was chosen purely because algorithms to find
|
||||
pi are numerous, but the Game of Life is rarely (if ever?) used for
|
||||
this purpose. Also, separate digits made determining the layout somewhat easier.</p>
|
||||
|
||||
<p>Deriving the layout was the most complicated part of the program. As is clear from
|
||||
the final layout featuring pi, the grid was divided into sixteen squares,
|
||||
and layouts that would evolve to each of the nine digits required were
|
||||
found. (This used the three-by-five digit-layout embedded in, at first, a
|
||||
nine-by-nine grid, then in larger grids, until fifteen-by-fifteen was
|
||||
reached.) The fifteen-by-fifteen grids give enough blank cells around
|
||||
them that the digits will not collide when evolving.</p>
|
||||
|
||||
<p>However, this did not allow for sufficient characters to fit the code
|
||||
into. Therefore it was necessary to add some regions that would quickly die off
|
||||
without expanding to collide with the digits' evolution.
|
||||
Groups of cells such as singletons, pairs, and larger groups like</p>
|
||||
|
||||
<pre><code>* * * * * * * * * *
|
||||
*****************
|
||||
* * * * * * * * * *
|
||||
</code></pre>
|
||||
|
||||
<p>were useful in this regard.</p>
|
||||
|
||||
<p>Other problems were given by keywords which need to be all in one
|
||||
string, keywords requiring space after them, and
|
||||
multi-character tokens. Some of these problems were dealt with by
|
||||
using the #defines and #includes given in the build-script, as there
|
||||
was no way to have sufficient separate lines in the code to do this
|
||||
without causing many difficulties. Some rejigging of the grid’s layout
|
||||
as the code was fitted into its format was also done, resorting to
|
||||
trial-and-improvement in some cases. Occasional use of constructs such
|
||||
as f -= -3 was made as f += 3 could not be fitted into the required format.
|
||||
The fact that the borders would be killed off immediately was also helpful.</p>
|
||||
|
||||
<p>It should be noted that evolving a full 60-by-60 grid backwards using
|
||||
this code would probably take us at least up to the heat-death of the
|
||||
universe.</p>
|
||||
|
||||
<p>The command ./blakely - < blakely.c is therefore <em>not</em> recommended.</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-2012,
|
||||
<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,106 +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.3 DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Best data utility</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best data utility</h1>
|
||||
|
||||
<p>Szabolcs Borsanyi<br>
|
||||
Theoretische Physik<br>
|
||||
Gaussstraße 20<br>
|
||||
42097 Wuppertal<br>
|
||||
Germany<br>
|
||||
<a href="mailto:borsanyi@uni-wuppertal.de">borsanyi@uni-wuppertal.de</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make borsanyi
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./borsanyi < some_data_file
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./borsanyi < data.1
|
||||
./borsanyi < data.2
|
||||
./borsanyi < data.3
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This is a nice quick histogram plotter. A useful utility when you need to
|
||||
look at the distribution of some data.</p>
|
||||
|
||||
<p>Here are some challenges:</p>
|
||||
|
||||
<p>You can modify the number of histogram bins and the scaling of the histogram
|
||||
by editing the source. Try to find them!</p>
|
||||
|
||||
<p>If you look at the source you will notice that the usual array of
|
||||
histogram bins is missing. The source contains no arrays and it does not
|
||||
use malloc or alloca. How does it build the histogram?</p>
|
||||
|
||||
<p>While the input does not need to be sorted, the histogram output is sorted.
|
||||
How does it put the data into buckets? Why does it fork 22 times?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<p>This small piece of program is meant to be a useful tool, when
|
||||
there are some data around and you need a quick glance at the
|
||||
histogram. I am all too often logged in to a remote machine with
|
||||
slow X connection, and a terminal-based program would be of
|
||||
great help.</p>
|
||||
|
||||
<h1>Limitations:</h1>
|
||||
|
||||
<ul>
|
||||
<li>I optimized the output for the data I had around, you might want to adjust
|
||||
for your needs. For a great excess of data points the program will crash
|
||||
(depending on the available stack).</li>
|
||||
<li>Giving too few (distinct) points can also cause crash (or division by zero).</li>
|
||||
<li>The program expects plain numbers separated by white spaces.</li>
|
||||
<li>ASCII is assumed.</li>
|
||||
<li>Some POSIX-like system is assumed (fork and wait(NULL) are used)</li>
|
||||
<li>Do not give any arguments to the program.</li>
|
||||
<li>Could rounding errors cause the omission of the highest bin? There might be
|
||||
empty bins at the edges.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h1>Obfuscation:</h1>
|
||||
|
||||
<ul>
|
||||
<li>The program follows a rather unconventional approach to the task
|
||||
of histogram building. The usual array of integers (for the histogram
|
||||
bins) is missing entirely. The data are read once, the range is determined,
|
||||
but the data points are not put in any array. Yet they are remembered,
|
||||
and each of them is put into its own bin afterwards. But where are the bins?</li>
|
||||
<li>I tried to use as few keywords as possible, hence there are no loops.</li>
|
||||
<li>Multi-process approach for optimal use of resources.</li>
|
||||
<li>Some bin size obfuscation.</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-2012,
|
||||
<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,329 +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.3 DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most self deprecating</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most self deprecating</h1>
|
||||
|
||||
<p>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></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make dlowe
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./dlowe -<n_iterations> corpus1/ [...] corpus0/ < start.net > end.net
|
||||
|
||||
NOTE: The directory entries MUST end in a /
|
||||
|
||||
./dlowe file [file ...] < trained.net
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
Download the
|
||||
<a href="/2011/dlowe/dlowe-aux-data.tar.bz2">2011 dlowe entry dlowe-aux-data.tar.bz2</a>
|
||||
file and then:
|
||||
<pre><code>
|
||||
|
||||
tar -jxf dlowe-aux-data.tar.bz2
|
||||
|
||||
./dlowe dlowe.c < ioccc-winlose-trained.net
|
||||
./dlowe dlowe < ioccc-winlose-trained.net
|
||||
|
||||
./dlowe xor-0/00 < xor-trained.net
|
||||
./dlowe xor-0/11 < xor-trained.net
|
||||
./dlowe xor-1/01 < xor-trained.net
|
||||
./dlowe xor-1/10 < xor-trained.net
|
||||
|
||||
./dlowe hint.html < english-trained.net
|
||||
|
||||
./dlowe dlowe-aux-data.tar.bz2 < png-trained.net
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This entry is a ghoulish example of a brain (dead?) neural network classifier.
|
||||
It comes with a set of corpora for you to try.</p>
|
||||
|
||||
<h4>ioccc-winlose-trained.net</h4>
|
||||
|
||||
<p>You can create your own trained networks. For example, we trained a network
|
||||
on the C code of entries that were supplied to the 20Th IOCCC.</p>
|
||||
|
||||
<p>The ioccc-winlose-trained.net was trained using the earlystop.pl tool:</p>
|
||||
|
||||
<pre><code>rm -f ioccc-winlose-trained.net
|
||||
./earlystop.pl ioccc-winlose-trained.net ioccc_won_training/ ioccc_lost_training/ ioccc_won_test/ ioccc_lost_test/
|
||||
</code></pre>
|
||||
|
||||
<p>where:</p>
|
||||
|
||||
<pre><code>ioccc_won_training/
|
||||
1/2 of C code of the 20th IOCCC winners (except for dlowe.c from 2011)
|
||||
plus 1/2 of the C code winners from prior IOCCC contests
|
||||
|
||||
ioccc_won_test/
|
||||
1/2 of C code of the 20th IOCCC winners (except for dlowe.c from 2011)
|
||||
plus 1/2 of the C code winners from prior IOCCC contests
|
||||
|
||||
ioccc_lost_training/
|
||||
1/2 of C code from entries that that did not win
|
||||
|
||||
ioccc_lost_test/
|
||||
1/2 of C code from entries that that did not win
|
||||
|
||||
NOTE: The above directies were not shipped and the C code from
|
||||
entries that that did not win was flushed to /dev/null.
|
||||
</code></pre>
|
||||
|
||||
<p>The earlystop.pl tool wrote:</p>
|
||||
|
||||
<pre><code>training 1 to 1001...
|
||||
training 1001 to 2001...
|
||||
prior error = 56.746974766043; current error = 58.095691135305
|
||||
</code></pre>
|
||||
|
||||
<p>The resulting ioccc-winlose-trained.net file was included in the
|
||||
dlowe-aux-data.tar.bz2 file in the above mentioned URL.</p>
|
||||
|
||||
<p>The dlowe.c was explicitly excluded from this trailing set. So this test is interesting:</p>
|
||||
|
||||
<pre><code>./dlowe dlowe.c < ioccc-winlose-trained.net
|
||||
</code></pre>
|
||||
|
||||
<p>The match of dlowe.c to the lose/win trailed network was:</p>
|
||||
|
||||
<pre><code>dlowe.c 0.125108
|
||||
</code></pre>
|
||||
|
||||
<p>NOTE: The non-artificially intelligent decisions of the IOCCC judges include random
|
||||
quirks and their non-linear judgment calls not found in the ioccc trained network.
|
||||
Just because C code is or isn’t scored highly by this network does not
|
||||
mean it will win or lose a future IOCCC. On the other hand … it just might!</p>
|
||||
|
||||
<h4>other data sets to try</h4>
|
||||
|
||||
<p>While we cannot supply you with the losing IOCCC source code, the author did supply a number
|
||||
data sets on which to test:</p>
|
||||
|
||||
<p>We created the english-trained.net as follows:</p>
|
||||
|
||||
<pre><code>./dlowe -8000 english-1/ english-0/ < /dev/null > english-trained.net
|
||||
|
||||
english-0/
|
||||
Non-English (French) text
|
||||
english-1/
|
||||
English (non-French) text
|
||||
</code></pre>
|
||||
|
||||
<p>We created the png-trained.net as follows:</p>
|
||||
|
||||
<pre><code>./dlowe -8000 png-1/ png-0/ < /dev/null > png-trained.net
|
||||
|
||||
png-0/
|
||||
Non-png (gif) images
|
||||
png-1/
|
||||
png (non-gif) images
|
||||
</code></pre>
|
||||
|
||||
<p>We created the xor-trained.net as follows:</p>
|
||||
|
||||
<pre><code>./dlowe -8000 xor-1/ xor-0/ < /dev/null > xor-trained.net
|
||||
|
||||
xor-0/
|
||||
Data that XORs to 0
|
||||
xor-1/
|
||||
Data that XORs to 1
|
||||
</code></pre>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h1>Synopsis:</h1>
|
||||
|
||||
<p>This is an artificially intelligent judging tool to help the IOCCC judges.
|
||||
Here’s to shorter, more frequent contests!</p>
|
||||
|
||||
<h1>Description:</h1>
|
||||
|
||||
<p>This is a multilayer perceptron (a feedforward artificial neural network)
|
||||
which can be trained, using on-line backpropagation, to classify input files.</p>
|
||||
|
||||
<p>It has a fixed topology of 2<sup>16</sup> input neurons, 6 hidden neurons and 1 output
|
||||
neuron.</p>
|
||||
|
||||
<p>The neurons' activation function is the logistic function 1 / (1 + e ^ -x).</p>
|
||||
|
||||
<h2>Classifying</h2>
|
||||
|
||||
<pre><code>./dlowe file [file ...] < trained.net
|
||||
</code></pre>
|
||||
|
||||
<p>To classify files, one specifies a trained network (on stdin) and one or more
|
||||
files to classify. The program will output one line per successfully-classified
|
||||
file to stderr, with the filename and the classification: a number between 0
|
||||
and 1.</p>
|
||||
|
||||
<p>The interpretation of the classification number depends on how the network was
|
||||
trained, but it’s geared toward interpretation as a <em>probability</em> or a
|
||||
<em>confidence</em>.</p>
|
||||
|
||||
<h2>Training</h2>
|
||||
|
||||
<pre><code>./dlowe -<n_iterations> corpus1/ [...] corpus0/ < start.net > end.net
|
||||
|
||||
NOTE: The directory args must end in a / for them to work.
|
||||
</code></pre>
|
||||
|
||||
<p>To train a network, one specifies a starting network (on stdin), two or more
|
||||
corpora (directories containing training data), and the number of training
|
||||
iterations to run. The program will write some progress data to stderr and,
|
||||
when it’s done, will serialize the updated network to stdout.</p>
|
||||
|
||||
<p>If no input network is given, a random new network will be generated as a
|
||||
starting point (i.e. provide an empty stdin).</p>
|
||||
|
||||
<p>The first corpus will be assigned a target value of 1. The last will be
|
||||
assigned a target value of 0. Intervening directories (if any) will be assigned
|
||||
intermediate target values.</p>
|
||||
|
||||
<p>The learning rate is hard-coded as 0.3. No momentum factor is used.</p>
|
||||
|
||||
<h3>png corpora</h3>
|
||||
|
||||
<p>The png-1 corpus was obtained by manually scraping the first results from an
|
||||
https://images.google.com search for “obfuscate filetype:png”.</p>
|
||||
|
||||
<p>The png-0 corpus was obtained by manually scraping the first results from an
|
||||
https://images.google.com search for “obfuscate filetype:gif”.</p>
|
||||
|
||||
<p>Results:</p>
|
||||
|
||||
<ul>
|
||||
<li>using these corpora as a training set</li>
|
||||
<li>using several hundred random <em>.gif and </em>.png files from my home computer as
|
||||
a test set</li>
|
||||
<li>using the included “earlystop.pl” script, which stopped after 67000 iterations.</li>
|
||||
<li>interpreting output of “> 0.5” as “probably a .png” and “< 0.5” as “probably
|
||||
a .gif”</li>
|
||||
<li>produced a network with about 87% accuracy</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>english corpora</h3>
|
||||
|
||||
<p>The english-1 corpus was obtained by manually scraping the first results from
|
||||
a https://www.google.com/webhp?lr=lang_en search for “paris filetype:txt”.</p>
|
||||
|
||||
<p>The english-0 corpus was obtained by manually scraping the first results from
|
||||
a https://www.google.com/webhp?lr=lang_fr search for “paris filetype:txt”.</p>
|
||||
|
||||
<p>Results:</p>
|
||||
|
||||
<ul>
|
||||
<li>using these corpora as a training set</li>
|
||||
<li>using several dozen additional text files (obtained by the same methods)
|
||||
as a test set</li>
|
||||
<li>using the included “earlystop.pl” script, which stopped after 10000
|
||||
iterations.</li>
|
||||
<li>interpreting output of “> 0.5” as “probably english” and “< 0.5” as
|
||||
“probably french”</li>
|
||||
<li>produced a network with 100% accuracy</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>xor corpora</h3>
|
||||
|
||||
<p>The xor-1 corpus consists of two files containing ‘01’ and ‘10’ respectively.</p>
|
||||
|
||||
<p>The xor-0 corpus consists of two files containing ‘00’ and ‘11’ respectively.</p>
|
||||
|
||||
<p>Results:</p>
|
||||
|
||||
<ul>
|
||||
<li>using these corpora as a training set</li>
|
||||
<li>takes about 8000 iterations to learn xor to within a tolerance of <0.01</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h1>Limitations</h1>
|
||||
|
||||
<p>The program can’t tell you anything meaningful about files with less than two
|
||||
bytes in them (I’m looking at you, smr.c!)</p>
|
||||
|
||||
<p>You must include the trailing directory separator on training directories
|
||||
(this allows the program to be portable without wasting precious bytes on
|
||||
figuring out how to concatenate directory and file names…)</p>
|
||||
|
||||
<p>Serialized network files are only portable between systems with the same
|
||||
floating-point representation and endianness.</p>
|
||||
|
||||
<p>Making sure not to overfit the network to the training data is a bit of a
|
||||
black art. I have enclosed ‘earlystop.pl’, a wrapper script that implements
|
||||
a simple ‘early stopping’ algorithm; other techniques are possible.</p>
|
||||
|
||||
<p>Bad input (e.g. nonexistent files, non-numeric number of iterations, etc.)
|
||||
tends to result in empty output.</p>
|
||||
|
||||
<p>Given exactly one corpus, the program will crash or produce garbage.</p>
|
||||
|
||||
<p>Leaks memory and file descriptors while processing files.</p>
|
||||
|
||||
<p>Will crash and die horribly if it runs out of memory.</p>
|
||||
|
||||
<p>The Microsoft C compiler doesn’t provide a dirent API, so to get this working
|
||||
on a Windows system you’ll need cygwin+gcc (tested) or a dirent compatibility
|
||||
library (untested, but they do exist).</p>
|
||||
|
||||
<p>Backpropagation doesn’t always converge: if you play with this long enough,
|
||||
you’ll eventually have a training session that completely fails to converge.</p>
|
||||
|
||||
<h1>Obfuscation:</h1>
|
||||
|
||||
<p>Zombies! (Since neural networks are modeled after BRAINS, ya know? And
|
||||
corpus sounds a lot like corpse. And I have 4- and 7-year-old kids ;)</p>
|
||||
|
||||
<p>Neural networks are interesting, and while the math isn’t terribly difficult,
|
||||
their behavior is difficult to fully understand.</p>
|
||||
|
||||
<p>Had some extra space in one of the major data structures, and it seemed a
|
||||
shame to waste it.</p>
|
||||
|
||||
<p>Similarly, I think three file pointers ought to be enough for anyone.</p>
|
||||
|
||||
<p>Lots of magic numbers expressed in various ways.</p>
|
||||
|
||||
<p>Random abuse of random C trivia.</p>
|
||||
|
||||
<p>Some textual changes were made to maximize the classification of this program
|
||||
by a network trained to recognize ioccc winners ;)</p>
|
||||
|
||||
<p>… but mostly zombies!</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-2012,
|
||||
<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,110 +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.3 DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Best ball</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best ball</h1>
|
||||
|
||||
<p>Peter Eastman<br>
|
||||
<a href="mailto:peter.eastman@gmail.com">peter.eastman@gmail.com</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make eastman
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./eastman
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>Quit the program. Resize your terminal window. Run it again.
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This round program will generate a classic spherical result!</p>
|
||||
|
||||
<p>You will need a terminal capable of displaying coloured ANSI
|
||||
characters (for example an xterm or a Terminal.app window).</p>
|
||||
|
||||
<p>You might also want to turn off any scrollback history. The program will
|
||||
size itself to the initial geometry of your terminal.</p>
|
||||
|
||||
<p>If you are ambitious, make the font really small and the window really
|
||||
large for hi-rez graphics!</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<p>This program uses ANSI graphics to recreate the classic Boing Ball demo from
|
||||
the Commodore Amiga. See http://www.youtube.com/watch?v=-ga41edXw3A if you
|
||||
aren’t familiar with it. Back in its day, this demo inspired lust and awe in
|
||||
geeks around the world.</p>
|
||||
|
||||
<p>The graphics are raytraced, with procedural textures on the ball and the back
|
||||
wall. I did cheat a little to simplify the calculations: it uses a parallel
|
||||
projection, but textures the back wall to look as if there were a floor being
|
||||
viewed in perspective. The shadow is also just part of the texture, not an
|
||||
actual raytraced shadow.</p>
|
||||
|
||||
<p>This program automatically adapts to the size of the terminal it is running in,
|
||||
so try enlarging the window to get higher resolution. Don’t resize while the
|
||||
program is running, though. It only checks the size once, when it starts up.</p>
|
||||
|
||||
<p>To compile:</p>
|
||||
|
||||
<p>cc -lm ball.c</p>
|
||||
|
||||
<p>Portability:</p>
|
||||
|
||||
<p>It should be completely portable. I’ve tested with gcc on Mac OS X 10.7 and
|
||||
Fedora 10. I would expect it to work in any Unix-like environment.</p>
|
||||
|
||||
<p>Obfuscation:</p>
|
||||
|
||||
<p>I have merged expressions wherever possible, making extensive use of ternary
|
||||
operators, commas, return values of assignment operators, etc. The entire
|
||||
raytracing computation, include ray intersection tests and procedural texture
|
||||
evaluations, is a single expression involving 41 operators.</p>
|
||||
|
||||
<p>Variables are named alphabetically in the order they are declared.</p>
|
||||
|
||||
<p>The third argument to ioctl() should really be a “struct winsize”, and I should
|
||||
then look up the ws_row and ws_col fields, but that makes it way too obvious
|
||||
what I’m doing there. Since a winsize just contains four unsigned shorts, I
|
||||
replaced it with an array. And since all the values will be much less than
|
||||
32767, I further simplified the type to just short[].</p>
|
||||
|
||||
<p>A wonderful thing about ANSI graphics is that it produces nearly unintelligible
|
||||
code. Consider the printf spec to print a single space in a desired color:
|
||||
“\x1B[%dm ”. I could have done something to further obfuscate it, but it’s
|
||||
already indistinguishable from line noise, so why bother?</p>
|
||||
|
||||
<p>There are lots of other minor obfuscations to make the code less obvious. For
|
||||
example, I could have written the outer loop as while(1), but why write a 1
|
||||
when I can calculate it from the return value of usleep() instead? And I could
|
||||
have written usleep(80000), but usleep(79383) just looks so much better. And
|
||||
so on.</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-2012,
|
||||
<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,307 +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.3 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</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most useful</h1>
|
||||
|
||||
<p>Kimmo Fredriksson<br>
|
||||
<a href="mailto:kimmo.k.k.fredriksson@gmail.com">kimmo.k.k.fredriksson@gmail.com</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make fredriksson
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./fredriksson [-icvtnk#] regexp < file
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./fredriksson -k1 -i POOT < /etc/group
|
||||
ulimit -s unlimited
|
||||
./fredriksson -k2 -t -n bofuskate < /usr/share/dict/words
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>The author of this entry was making sure that it does not win the
|
||||
“Best Short Program” award. On the outside, the program behaves
|
||||
as an approximate grep. On the inside, it is a Burrows-Wheeler
|
||||
transform decompressor that produces the source code of the actual
|
||||
obfuscated approximate grep program and calls it. As an exercise,
|
||||
try writing the compressor.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h1>Approximate grep</h1>
|
||||
|
||||
<p>Implements a variant of grep.</p>
|
||||
|
||||
<h2>Usage</h2>
|
||||
|
||||
<p>To search regexp from file, do:</p>
|
||||
|
||||
<pre><code>./fredriksson [-icvtnk#] regexp < file
|
||||
</code></pre>
|
||||
|
||||
<p>Pipes may not work, see the section Limitations.
|
||||
The options <code>-i -c -v</code> and <code>-n</code> are the classic ones:</p>
|
||||
|
||||
<ul>
|
||||
<li><p><code>-i</code> Ignore case.</p></li>
|
||||
<li><p><code>-c</code> Count only, prints the number of matches, but not the matching lines.</p></li>
|
||||
<li><p><code>-v</code> Invert match.</p></li>
|
||||
<li><p><code>-n</code> Prefixes each printed line by its line number (only if
|
||||
<code>-c</code> was not given).</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>This version of grep recognizes two more options, not present in normal
|
||||
grep implementations:</p>
|
||||
|
||||
<ul>
|
||||
<li><p><code>-kN</code> Permit <code>N</code> insertions, deletions or mismatches of characters in the
|
||||
matches (aka edit-distance). E.g. “obfuscated” matches “obfuscation”
|
||||
with one deletion and two mismatches. Likewise, “obfuscate” and
|
||||
“oversimplify” match with 7 edit operations. The default is <code>-k0</code>
|
||||
(i.e. exact match).</p></li>
|
||||
<li><p><code>-t</code> Add local transpositions to the set of allowed edit-operations.
|
||||
That is, “ab” matches “ba” with one transposition (swap), and
|
||||
“obfuscated” matches “bofsuact” with three swaps and two insertions,
|
||||
i.e. use <code>-tk5</code> to find this.</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Of course, one could construct a standard regexp that matches the same
|
||||
patterns, but the problem is that such a regexp grows exponentially in
|
||||
size when the number of allowed edit operations is increased.</p>
|
||||
|
||||
<p>This version does not recognize all regular expressions, but the
|
||||
following are allowed:</p>
|
||||
|
||||
<ul>
|
||||
<li><p>Wild card: <code>.</code> (dot) matches any character.</p></li>
|
||||
<li><p>Bracket expression: list of charactres enclosed by <code>[</code> and <code>]</code>,
|
||||
matches any single character in the list.</p></li>
|
||||
<li><p>Range expression: two characters separated by hyphen and enclosed in
|
||||
brackets, matches any character that is lexicographically between the
|
||||
two characters (inclusive). E.g. <code>[a-d]</code> is the same as <code>[abcd]</code>.</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>The special characters must be escaped, if they are to be taken
|
||||
literally (i.e. use e.g. <code>\.</code> to match period). You might want to protect
|
||||
these with <code>'</code>, i.e. use <code>'foo\[bar'</code> instead of <code>foo\[bar</code>. If you want to
|
||||
use the literal <code>-</code> in bracket expression, protect that too (<code>\-</code>),
|
||||
otherwise this is not needed. Note that the syntax differs from standard
|
||||
(?) grep a bit, i.e. in plain grep you can use <code>]</code> and <code>-</code> in bracket
|
||||
expressions by putting <code>]</code> as the first character, and putting <code>-</code> last.</p>
|
||||
|
||||
<h3>Other uses</h3>
|
||||
|
||||
<ul>
|
||||
<li><p>You can use this in place of cat. Just say</p>
|
||||
|
||||
<pre><code> ./fredriksson -k3 cat < file
|
||||
</code></pre></li>
|
||||
<li><p>Like with cat, you can append line numbers too:</p>
|
||||
|
||||
<pre><code> ./fredriksson -nk3 cat < file
|
||||
</code></pre></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Other features</h3>
|
||||
|
||||
<ul>
|
||||
<li><p>It is assumed that the user knows how to feed correct input to the
|
||||
program. If undefined options are given, the result is also undefined.
|
||||
This is a feature.</p></li>
|
||||
<li><p>It may consume huge amounts of memory, and a stack overflow may occur.
|
||||
This results in Segmentation fault (or the equivalent of your favorite
|
||||
system, such as Bus error). This is a feature, that can be used to detect
|
||||
overly long lines in the input file, such as checking the lenght of one
|
||||
liners in IOCCC entries, just adjust your stack size to a suitable
|
||||
threshold, and search for “ioccc”, with option <code>-vk5</code>.</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Limitations and remarks</h2>
|
||||
|
||||
<ul>
|
||||
<li><p>Using warning options (such as -Wall) when building gives a lot of warning,
|
||||
such as <code>suggest parentheses around '&&' within '||'</code>, <code>value computed is
|
||||
not used</code>, <code>implicit declaration of function 'putchar'</code>, <code>implicit
|
||||
declaration of function 'getchar'</code>, <code>control reaches end of non-void
|
||||
function</code> and <code>format not a string literal and no format arguments</code>.
|
||||
Please ignore them all, since they just try to tell you that the source
|
||||
is obfuscated.</p></li>
|
||||
<li><p>Only standard input is handled. And <em>only</em> if stdin comes from a file,
|
||||
i.e. pipes may or may not work. If you want to count only (<code>-c</code> option),
|
||||
then this shouldn’t be an issue.</p></li>
|
||||
<li><p>The total lenght of the (preprocessed) pattern is at most
|
||||
<code>sizeof(long)*CHAR_BIT</code>. That does not count things like bracket expressions
|
||||
or escape chars, that is, the pattern <code>'a[bcd]e\.f'</code> is 5 chars long, not
|
||||
10 chars. That does not mean that the matched substring in the standard
|
||||
input has this limit, as using the edit operations can make the string
|
||||
longer. However, no assumptions are made for <code>sizeof(long)</code>. In fact,
|
||||
you can easily use <code>long long</code> instead,</p></li>
|
||||
<li><p>Depending on the file, may require a lot of stack space. If the
|
||||
program segfaults (because of this), say</p>
|
||||
|
||||
<pre><code> ulimit -s unlimited
|
||||
</code></pre>
|
||||
|
||||
<p>cross your fingers, hope it is enough, and try again.</p></li>
|
||||
<li><p>Assumes C99 standard, because of the one very long line. Most C compilers
|
||||
handle this just fine even in C89 mode, though.</p></li>
|
||||
<li><p>The code should be reasonably portable, it assumes standard ASCII codes
|
||||
for each char, and that a C compiler is on $PATH; the latter is hard coded
|
||||
to be ‘gcc’, but any compiler would work, provided that it supports
|
||||
C99, or long lines as an extension. This code has been tested on:</p>
|
||||
|
||||
<ul>
|
||||
<li>GNU/Linux FC4, i386, gcc</li>
|
||||
<li>GNU/Linux FC7, x86_64, gcc 4.1.2, tcc 0.9.24 and icc 10.0</li>
|
||||
<li>GNU/Linux FC9, x86_64, gcc 4.?.?</li>
|
||||
<li>GNU/Linux CentOS 5, gcc 4.1.2</li>
|
||||
<li>GNU/Linux Ubuntu 11.04, gcc 4.5.2</li>
|
||||
<li>SunOS 5.8, UltraSPARC IIIi, gcc 4.1.2</li>
|
||||
<li>SunOS 5.9, UltraSPARC IIIi, gcc 4.1.1 and Sun ONE Studio 8 CC</li>
|
||||
<li>AIX 5.3, IBM eServer p5-550, gcc 3.3.3 and AIX CC Version 6</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>(Btw, tcc has its roots in IOCCC…)</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Obfuscations (a.k.a. spoilers…)</h2>
|
||||
|
||||
<ul>
|
||||
<li><p>The initialized char array includes the source code of the real program,
|
||||
as well as its name and commands to build and run it, all Burrows-Wheeler
|
||||
-transformed, then run-length-encoded with unary coding. The main program
|
||||
extracts and builds that, and then calls it. More precicely, the command
|
||||
to build is</p>
|
||||
|
||||
<pre><code> gcc -O3 ag.c -o ag
|
||||
</code></pre>
|
||||
|
||||
<p>To change that you need to edit the char array <code>p[]</code> and (possibly) two
|
||||
specially encoded constants, <code>-~('('*'(')</code> and <code>'C'*' '-'-'</code>.
|
||||
The extracted source (<code>ag.c</code>) is obfuscated as well.</p>
|
||||
|
||||
<p>(The original version also deleted the generated source and the
|
||||
corresponding binary after running it, but this feature was removed
|
||||
from the submitted entry.)</p></li>
|
||||
<li><p>The code demonstrates several useful programming paradigms, such as</p>
|
||||
|
||||
<ul>
|
||||
<li>recursion to remove all loops</li>
|
||||
<li>sub routines (<code>main()</code> contains several logical sub routines,
|
||||
selected by the first argument)</li>
|
||||
<li>function pointers</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p>Algorithmically, it incorporates the following</p>
|
||||
|
||||
<ul>
|
||||
<li>(inverse) Burrows-Wheeler transform (used also e.g. in bzip2)</li>
|
||||
<li>data compression (really expansion :-), run-lenght-encoding,
|
||||
unary coding (this is why it is expansion rather than compression)</li>
|
||||
<li>approximate string matching</li>
|
||||
<li>dynamic programming to compute the edit distance</li>
|
||||
<li>parallel computation in sequential computers (by packing
|
||||
several objects into a single long, to speed up the dynamic
|
||||
programming)</li>
|
||||
<li>self extracting, compiling and running code</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p>As a C program, it demonstrates that</p>
|
||||
|
||||
<ul>
|
||||
<li>a C subset without reserved words is complete enough,
|
||||
(excluding data type specific things (<code>int</code>, <code>char</code>, <code>void</code> …))</li>
|
||||
<li>only letters are needed (i.e. the digits 0-9 are not)</li>
|
||||
<li>only one statement is enough to code any program (plus
|
||||
variable definitions)</li>
|
||||
<li>white space has other uses than just indenting the code</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><p>It also shows the power of boolean logic and bitwise arithmetic.</p></li>
|
||||
<li><p>This is the first (?) entry in the history of IOCCC, that cannot be
|
||||
totally un-obfuscated by the author. This is due to the clever choice of
|
||||
the actual algorithm, that is obfucated by nature, and it is an open
|
||||
research problem whether a simpler algorithm exists, with the same time
|
||||
complexity.</p></li>
|
||||
<li><p>The main obfuscation comes from using only arithmetic and boolean
|
||||
(short-circuit) logic combined with recursion to remove all loops and
|
||||
if-then-else constructs (also, no ternary <code>?:</code> constructs are present).
|
||||
Two’s complement representation of integers is also abused. E.g. instead
|
||||
of writing <code>x++</code> or <code>x-1</code>, it is much better to write <code>x=-~x</code> and <code>~-x</code>.</p></li>
|
||||
<li><p>No numerical values, other than in the initialized char array, try</p>
|
||||
|
||||
<pre><code> ./fredriksson -ck0 [0-9] < fredriksson.c
|
||||
</code></pre>
|
||||
|
||||
<p>This should print 1, as there is a numer ‘3’ in the char array (only).
|
||||
You can also try</p>
|
||||
|
||||
<pre><code> ./fredriksson -ck0 [0-9] < ag.c
|
||||
</code></pre>
|
||||
|
||||
<p>after running fredriksson at least once (since this generates that
|
||||
<code>ag.c</code> file), and this should print 0.</p></li>
|
||||
<li><p>The source code is best viewed with cat (or using the program itself),
|
||||
instead of some editor. (This is a somewhat system dependent thing.)</p>
|
||||
|
||||
<p>One reason for this is that the code builds (some of the) constant
|
||||
values from string literal <code>"\b"</code>, except that the backspace <code>\b</code> is not
|
||||
escaped like that, the source uses the raw ascii value (010 octal) instead.
|
||||
Thus when viewing with cat or something, that backspace erases the leading
|
||||
quotation mark. Makes it appear uncompilable, and it is: if you copy-paste
|
||||
the cat output from terminal to some editor, save it, the result would not
|
||||
compile.</p>
|
||||
|
||||
<p>Some other constants are built from ASCII values of chars.</p>
|
||||
|
||||
<p>Besides of making the code hard to read, all this makes it also quite large.</p></li>
|
||||
<li><p>Running it through GNU indent or bcpp (C beautifiers) does not beautify
|
||||
it a bit. In fact, indent makes it only worse (at least with the default
|
||||
options). Running it through the preprocessor does basically nothing,
|
||||
since no <code>#define</code>s are used.</p></li>
|
||||
<li><p>Some <em>abuse of the rules</em>. The number of non-whitespace and <code>;</code>, <code>{</code>
|
||||
and <code>}</code> chars is below the limit, but most of the whitespace chars are
|
||||
in an <em>initialized character array</em>. That is, the number of chars in the
|
||||
program exceeds the 2048 limit. However, whitespace is whitespace and
|
||||
the rules did not specify that these must be in between the statements.
|
||||
A character is a whitespace if <code>isspace()</code> returns non-zero value. Even
|
||||
if deleting even one of those chars breaks the program! (This does not
|
||||
apply to the generated source <code>ag.c</code>.)</p></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-2012,
|
||||
<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,112 +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.3 DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most artistic</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most artistic</h1>
|
||||
|
||||
<p>Uri Goren<br>
|
||||
<a href="mailto:goren.uri@gmail.com">goren.uri@gmail.com</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make goren
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>echo "some text" | ./goren
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>echo "Hello, world!" | ./goren
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>In the words of <a href="http://en.wikipedia.org/wiki/Rene_Magritte">René François Ghislain Magritte Magritte</a>:</p>
|
||||
|
||||
<p><img src="http://upload.wikimedia.org/wikipedia/en/b/b9/MagrittePipe.jpg" title="Ceci n'est pas une pipe" alt="This is not a pipe" /></p>
|
||||
|
||||
<p>One may ask the surrealist question:</p>
|
||||
|
||||
<pre><code>echo 'If | is just a representation of a pipe, then how can data stuff it?' | ./goren
|
||||
</code></pre>
|
||||
|
||||
<p>However if one takes a firm stand and declares:</p>
|
||||
|
||||
<pre><code>echo '| is just a representation of a pipe because I say so! So stuff it!' | ./goren
|
||||
</code></pre>
|
||||
|
||||
<p>something happens! Why?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<p>This program was written in homage to Rene Magritte’s picture “La
|
||||
trahison des images” (The Treachery of Images).</p>
|
||||
|
||||
<p>In order to show my unconditional admiration of this work, I avoided
|
||||
using conditions.</p>
|
||||
|
||||
<p>In this work, Magritte points out that a picture of a pipe is not
|
||||
a pipe. But what IS a pipe? This program tries to provide an answer.</p>
|
||||
|
||||
<p>Magritte’s [test for pipes](http://en.wikipedia.org/wiki/The_Treachery_of_Images} is:</p>
|
||||
|
||||
<pre><code>The famous pipe. How people reproached me for it! And yet, could
|
||||
you stuff my pipe? No, it's just a representation, is it not?
|
||||
</code></pre>
|
||||
|
||||
<p>Accordingly, this program only approves pipes which can be used for
|
||||
stuffing data.</p>
|
||||
|
||||
<p>One thing I tried to achieve is condition free programming. Many
|
||||
have noted that conditions make the code harder to read and understand.
|
||||
A good example would be:</p>
|
||||
|
||||
<p><a href="/years.html#2004_burley">Brent Burley’s 2004 IOCCC winner</a></p>
|
||||
|
||||
<p>That entry omits conditional statements such as “if” and “while”.
|
||||
His achievement in improving clarity by omitting conditions is
|
||||
impressive, but I think it can be taken further, in two ways.</p>
|
||||
|
||||
<p>First, conditional operators, such as ?:, && and ||, can be thrown
|
||||
away. Second, using setjmp and longjmp, which are unfortunately
|
||||
not in common use, might make it difficult for a novice programmer
|
||||
to understnad the code without referring to the man page.</p>
|
||||
|
||||
<p>By removing these, the code is 100% condition free, and every
|
||||
function runs its instructions in perfect order. Naturally, this
|
||||
makes the program flow trivial to understand. This can be verified
|
||||
by disassembling the compiled code and looking for conditional jumps
|
||||
(when compiled with gcc on x86, there are none).</p>
|
||||
|
||||
<h3>Compatibility:</h3>
|
||||
|
||||
<p>The program should compile with any C compiler, but was tested
|
||||
mostly with gcc on Linux.</p>
|
||||
|
||||
<p>It doesn’t support 64 bits (due to integer-pointer casts, and a >>31).
|
||||
It does work on 64-bit Linux, becasue all functions are below 4GB.</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-2012,
|
||||
<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,242 +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.3 DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Best solved puzzle</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best solved puzzle</h1>
|
||||
|
||||
<p>Shinichiro Hamaji<br>
|
||||
<a href="mailto:shinichiro.hamaji@gmail.com">shinichiro.hamaji@gmail.com</a></p>
|
||||
|
||||
<p>bsoup</p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make hamaji
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./hamaji < a_nonogram_file
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./hamaji < dragon.nono
|
||||
./hamaji < random.nono
|
||||
./hamaji < soccer.nono
|
||||
./hamaji < codegolf.nono
|
||||
./hamaji < face.nono
|
||||
./hamaji < penguin.nono
|
||||
./hamaji < samurai.nono
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This program solves “Nonogram”, which also known as “Paint by Numbers”:</p>
|
||||
|
||||
<p><a href="http://en.wikipedia.org/wiki/Nonogram">http://en.wikipedia.org/wiki/Nonogram</a></p>
|
||||
|
||||
<p>This entry roar as the Year of the Dragon: A year considered
|
||||
some to be good luck. Well it was certainly true that the
|
||||
IOCCC was lucky to get such a fine submission!</p>
|
||||
|
||||
<p>The source code is a solution to a Paint by Numbers puzzle when you
|
||||
paint by C. Try your hand at solving a few of the other .nono
|
||||
files and then compare your solution with this program!</p>
|
||||
|
||||
<p>NOTE: NONOGRAM ® is a registered Trademark and is used with permission.
|
||||
See http://nonogram.com/ for more information.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<p>The format of the input files are as same as this site:</p>
|
||||
|
||||
<p><a href="http://codegolf.com/paint-by-numbers">http://codegolf.com/paint-by-numbers</a></p>
|
||||
|
||||
<p>For example, for a simple problem which shows a glider of <a href="http://en.wikipedia.org/wiki/Conway's_Game_of_Life">conway’s
|
||||
lifegame</a>.</p>
|
||||
|
||||
<pre><code> 1
|
||||
.
|
||||
112
|
||||
|
||||
1 X
|
||||
1 X
|
||||
3 XXX
|
||||
</code></pre>
|
||||
|
||||
<p>the input should be</p>
|
||||
|
||||
<pre><code>1
|
||||
1
|
||||
3
|
||||
-
|
||||
1
|
||||
1.1
|
||||
2
|
||||
</code></pre>
|
||||
|
||||
<p>The width and the height of an input puzzle should be less than or
|
||||
equal to 60.</p>
|
||||
|
||||
<p>When this solver finds the problem has no solution, it prints “invalid”.
|
||||
This means the problem is indeed broken. For example, this happens for
|
||||
an input like</p>
|
||||
|
||||
<pre><code>2
|
||||
-
|
||||
2
|
||||
</code></pre>
|
||||
|
||||
<p>When this solver cannot find a solution, it prints “failed”. This
|
||||
failure can happen when the problem has more than one solution or the
|
||||
solver cannot solve the input problem. Here is an example input of the
|
||||
former:</p>
|
||||
|
||||
<pre><code>1
|
||||
1
|
||||
-
|
||||
1
|
||||
1
|
||||
</code></pre>
|
||||
|
||||
<p>There are two solutions:</p>
|
||||
|
||||
<pre><code> 11
|
||||
|
||||
1 X
|
||||
1 X
|
||||
</code></pre>
|
||||
|
||||
<p>and</p>
|
||||
|
||||
<pre><code> 11
|
||||
|
||||
1 X
|
||||
1 X
|
||||
</code></pre>
|
||||
|
||||
<h3>Detail</h3>
|
||||
|
||||
<p>Solving Nonogram is known NP-complete, so we cannot make a solver
|
||||
which solves all puzzles. However, we can write a solver which solves
|
||||
most problems solvable by humans. There are a bunch of ways to write
|
||||
such programs. The two most obvious approaches are:</p>
|
||||
|
||||
<ol>
|
||||
<li>Check all possible solutions with backtracking.</li>
|
||||
<li>Implement all techniques which humans use.</li>
|
||||
</ol>
|
||||
|
||||
|
||||
<p>The former, brute-force approach is easy to implement. However, it
|
||||
works only for smaller problems (width and height should be at most 30
|
||||
or so). Similarly, using generic probabilistic metaheuristics such as
|
||||
simulated annealing doesn’t work for big problems.</p>
|
||||
|
||||
<p><a href="http://ccl.northwestern.edu/netlogo/models/community/Nonogram">http://ccl.northwestern.edu/netlogo/models/community/Nonogram</a></p>
|
||||
|
||||
<p>By its definition, the latter works for all human-solvable
|
||||
problems. The issue of the latter approach is this kind of programs
|
||||
tends to be lengthy. This approach still requires some recursions. The
|
||||
most difficult problems which are considered human-solvable may
|
||||
require some “guesses”. For this kind of problems, we need to assume a
|
||||
cell is a space or a box, go ahead some steps with simple methods,
|
||||
mark the tried cell as a box (or a space if we assumed the tried cell
|
||||
is a box) if a contradiction is found.</p>
|
||||
|
||||
<p>My program uses an approach like “Set based solver” introduced in
|
||||
<a href="http://www.haskell.org/haskellwiki/Nonogram">http://www.haskell.org/haskellwiki/Nonogram</a> .
|
||||
This should be equivalent to the combinations of simple methods (no
|
||||
advanced reasoning with guess). My solver also runs non-recursive
|
||||
guess for each undetermined cells. So, my program should be able to
|
||||
solve most human-solvable problems (assuming humans cannot execute
|
||||
deeper recursions).</p>
|
||||
|
||||
<h3>Obfuscation</h3>
|
||||
|
||||
<p>First of all, as you see, my program looks like a nonogram puzzle
|
||||
which results a dragon. This puzzle is “dragon.nono” in this
|
||||
directory. Note that whitespaces in character literals, a string
|
||||
literal, and around the last comment are considered as a boxed cell.</p>
|
||||
|
||||
<p>My program is based on bit operations for speed. Many values are
|
||||
stored using negative logic (0 means on and 1 means off) to utilize
|
||||
the initial value of global variables. Thus, it might be difficult to
|
||||
figure out how it works.</p>
|
||||
|
||||
<p>My program is decently shortened, because the size of source code is
|
||||
limited by IOCCC’s rule (2048 non-whitespace characters) and a lot of
|
||||
characters are just wasted for numbers around the picture.</p>
|
||||
|
||||
<p>The three requirements (dragon, speed, and size) naturally ended up
|
||||
with the well obfuscated code.</p>
|
||||
|
||||
<h3>Portability</h3>
|
||||
|
||||
<p>This program uses two C99 features. One line comments and “long long”.
|
||||
GCC’s “-ansi -pedantic” check should pass:</p>
|
||||
|
||||
<pre><code>$ gcc -ansi -pedantic -std=c99 hamaji.c
|
||||
</code></pre>
|
||||
|
||||
<p>I checked my program with gcc-4.6.2 on linux, llvm-gcc-4.2 on mac, and
|
||||
clang-3.0 on mac.</p>
|
||||
|
||||
<p>Note that the behavior of scanf differs on linux and mac, but this
|
||||
program supports both semantics.</p>
|
||||
|
||||
<p>This program should not depend on sizeof(int), sizeof(void*), ASCII,
|
||||
memory layout, undefined evaluation order (e.g., a[i++]=i), etc.
|
||||
This program won’t work if the size of long long literal is less than 8.
|
||||
By grepping the source code of gcc</p>
|
||||
|
||||
<pre><code>grep LONG_LONG_TYPE_SIZE gcc/config/*/*
|
||||
</code></pre>
|
||||
|
||||
<p>I found long long may be 32bit integers only on AVR.</p>
|
||||
|
||||
<h3>A few more</h3>
|
||||
|
||||
<p>This code is considered as a new year’s postcard in Japan. We chose
|
||||
the dragon because 2012 is the year of dragon.</p>
|
||||
|
||||
<p><a href="http://en.wikipedia.org/wiki/Japanese_New_Year#Postcards">http://en.wikipedia.org/wiki/Japanese_New_Year#Postcards</a></p>
|
||||
|
||||
<p>The second author wrote the picture, and the first author did
|
||||
everything else.</p>
|
||||
|
||||
<p>The dragon.nono, samurai.nono, and penguin.nono was written by the
|
||||
second author. The soccer.nono was from a wikipedia entry. This file
|
||||
is important because it requires some guesses. The random.nono file
|
||||
was randomly generated. The codegolf.nono and face.nono have borrowed
|
||||
from this site:</p>
|
||||
|
||||
<p><a href="http://codegolf.com/paint-by-numbers">http://codegolf.com/paint-by-numbers</a></p>
|
||||
|
||||
<p>You can reproduce dragon.nono from hamaji.c using c2nono.pl:</p>
|
||||
|
||||
<pre><code>perl c2nono.pl hamaji.c | ./hamaji
|
||||
</code></pre>
|
||||
|
||||
<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-2012,
|
||||
<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,137 +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.3 DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Best self documenting program</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best self documenting program</h1>
|
||||
|
||||
<p>Hou Qiming<br>
|
||||
<a href="mailto:hqm03ster@gmail.com">hqm03ster@gmail.com</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make hou
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./hou 'a calculator expression -- see the C Code for details'
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./hou 11/26+222/31
|
||||
|
||||
./hou 'log((21701-19937)-(23209-21701))/log(2)'
|
||||
|
||||
./hou 'sin(1.5708)+0.04321+log(sqrt(exp(1*1*1)))+(1+2*3)-0.4-0.6+(4+6)*(2-1+2*3)-tan(0.785398)+2*10/3*6*sqrt(16/2/2)*10+10000-1000'
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This self-documenting scientific calculator compiles clean with no
|
||||
warnings under the most strict pedantic mode of gcc and clang.</p>
|
||||
|
||||
<p>The first example, along with the correct result appears in the
|
||||
source code. What does it mean?</p>
|
||||
|
||||
<p>The calculator obeys the precendence rules and allows parenthesis,</p>
|
||||
|
||||
<pre><code> ./hou '1+2*3'
|
||||
./hou '(1+2)*3'
|
||||
</code></pre>
|
||||
|
||||
<p>What exactly does the text formatting do?</p>
|
||||
|
||||
<p>What does this evaluate to in C?</p>
|
||||
|
||||
<pre><code> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
|
||||
</code></pre>
|
||||
|
||||
<h4>Self documenting source</h4>
|
||||
|
||||
<p>Comments would almost be redundant. :-}</p>
|
||||
|
||||
<h4>The ASCII art is valid C code</h4>
|
||||
|
||||
<p>Not just fancy formatted comment removed by the C Pre-processor</p>
|
||||
|
||||
<h4>The only multi-byte strings are format strings</h4>
|
||||
|
||||
<p>The code does not contain some simple string-encoded lookup table for calculator operations.</p>
|
||||
|
||||
<h4>Example input and output in the source</h4>
|
||||
|
||||
<p>The example input and output in the C code is significant. Can you find out why?</p>
|
||||
|
||||
<h4>The button layout</h4>
|
||||
|
||||
<p>The button layout in the C code is significant … not just a nice looking layout.</p>
|
||||
|
||||
<h4>input parsing</h4>
|
||||
|
||||
<p>The parser is functionally equivalent to a normal arithmetic parser for all valid inputs.
|
||||
For another fun challenge: try to determine how it parses the command line argument.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Obfuscations</h3>
|
||||
|
||||
<p>This program is designed to be self-documenting. It doesn’t just provide an
|
||||
example command line. It also provides the expected output and illustrates all
|
||||
supported functionality using embedded ASCII art.</p>
|
||||
|
||||
<ul>
|
||||
<li>A few line numbers are significant and careless beautification will break the program.</li>
|
||||
<li>The entire ASCII art is valid code. The preprocessor won’t remove any part of it.</li>
|
||||
<li>The only strings longer than 1 byte are printf/sscanf format strings, even
|
||||
after preprocessing. No string-encoded lookup table is used.</li>
|
||||
<li>The example input and its expected output are both algorithmically significant.</li>
|
||||
<li>The button layout is also significant.</li>
|
||||
<li>The actual syntax being parsed is not the obvious, despite being
|
||||
functionally equivalent for all correct inputs.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Portability</h3>
|
||||
|
||||
<ul>
|
||||
<li>This program requires “argv” to point to writable memory. It doesn’t require
|
||||
the actual argv strings to be writable, though.</li>
|
||||
<li>This program requires ASCII.</li>
|
||||
<li>This program doesn’t work with %e style numbers like “1e-4”.</li>
|
||||
<li>Some seemingly redundant code works to eliminate warnings and evade a gcc bug.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Spoilers</h3>
|
||||
|
||||
<p>The parser parses function names, substraction, and division as single-letter
|
||||
unary operators. A bitmask encoded hash table is used to check no-ops/digits
|
||||
and another hash function maps the ASCII to a function ordinal, which is then
|
||||
executed by the button panel.</p>
|
||||
|
||||
<p>Both hash functions are found using a separate search program. Another program
|
||||
is used to find a way to format one hash function as example input such that
|
||||
it produces something resembling the bitmask hash table as part of its output.</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-2012,
|
||||
<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,77 +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.3 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 just_a_single_argument_of_lower_case_letters
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./konno qwerty
|
||||
./konno ioccc
|
||||
./konno "the quick brown fox jumps over the lazy dog"
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This tiny program outputs what looks like a tiny keyboard.<br>
|
||||
OK, so the letters are missing. But that is no problem because
|
||||
this program identifes the lower case letters that were pressed!</p>
|
||||
|
||||
<p>It is one of those minimal keyboards without all of those
|
||||
confusing symbols keys. No shift for SHOULDING CAPS
|
||||
but at least it does not have that useless caps lock key!</p>
|
||||
|
||||
<p>We recommend that you completely deconstruct / figure out
|
||||
how this program works and does what it does. Can you
|
||||
extend this program to deal with a full QWERTY keyboard?
|
||||
Can you then minimize the size of that code?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Limitation</h3>
|
||||
|
||||
<p>This program ignores non-lower case letters.</p>
|
||||
|
||||
<h3>Obfuscation</h3>
|
||||
|
||||
<ul>
|
||||
<li>“for” is not used.</li>
|
||||
<li>A part of program is encrypted.</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-2012,
|
||||
<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,104 +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.3 DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most surprisingly portable</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most surprisingly portable</h1>
|
||||
|
||||
<p>Gregor Richards<br>
|
||||
<a href="mailto:Richards@codu.org">Richards@codu.org</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make richards
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./richards
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>echo '10 9 8 7 6 5 4 3 2 1*p*p*p*p*p*p*p*p*p' | ./richards
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>Oh no, yet another dc-style calculator? (see 2000/dlowe using an embedded Perl
|
||||
interpreter and deemed Worst Abuse of the Rules).
|
||||
Well, this one does it (expression calculation, that is, not the rule abuse) in a different way.
|
||||
The author claims that his calculator does just-in-time compilation.
|
||||
What would you do to prove or disprove his claim without attempting to unravel the source?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<p>This is an implementation of the classic UNIX dc command, the reverse-polish
|
||||
calculator. Actually it’s a pretty bad implementation, since it only implements
|
||||
32-bit integers (well, sizeof(int)-sized integers). It only implements the
|
||||
commands +, -, *, /, p (only for numbers), register stacks, macros and
|
||||
comparisons. Wow, you’d think I could’ve done better in 2K of code.</p>
|
||||
|
||||
<p>OH! I forgot to mention! It’s a JIT.</p>
|
||||
|
||||
<p>Wait, don’t stop reading! I know what you’re thinking, platform-specific code
|
||||
is discouraged in IOCCC. But do you see any platform-specific code? There’s no
|
||||
assembler here! This JIT works on a dozen platforms, and the only
|
||||
platform-specific assumptions it makes are that the stack grows down and
|
||||
integers are at least 32-bit.</p>
|
||||
|
||||
<p>You will probably get warnings while compiling the code. In particular:</p>
|
||||
|
||||
<ul>
|
||||
<li>If your system requires the inclusion of alloca.h to use alloca, use the
|
||||
compile flag -DAH</li>
|
||||
<li>If your system cannot use mmap, use the compile flag -DNM</li>
|
||||
<li>I don’t include any headers I don’t strictly need to, so you’ll get warnings
|
||||
about (at least) memcpy, isdigit, atoi, calloc, malloc and alloca if you
|
||||
didn’t use -DAH.</li>
|
||||
<li>GCC likes to complain about while (a = b) (assignments as a condition).</li>
|
||||
<li>I don’t return from main, even though it’s declared to return int.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Platforms on which all known/tested optimization levels work with no additional
|
||||
flags:</p>
|
||||
|
||||
<ul>
|
||||
<li>gcc 4.6.2 + x86[_64] + GNU/Linux, Mac OS X or Windows</li>
|
||||
<li>clang 2.9-16 + x86[_64] + GNU/Linux or Mac OS X</li>
|
||||
<li>tcc 0.9.25</li>
|
||||
<li>gcc 4.4.5 + alpha, arm, mips[el], powerpc[64], s390x (IBM zSeries)</li>
|
||||
<li>gcc 4.1.3 + vax + NetBSD</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Platforms which work but not at all optimization levels or needing special
|
||||
flags:</p>
|
||||
|
||||
<ul>
|
||||
<li>owcc 1.9 + x86 + Windows: Needs -DNM -DAH -fno-stack-check</li>
|
||||
<li>gcc 4.4.5 + sh4: -O0 works, higher optimization levels don’t work for unknown reasons.</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-2012,
|
||||
<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,283 +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.3 DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Best non-chess game</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best non-chess game</h1>
|
||||
|
||||
<p>Oscar Toledo G.<br>
|
||||
Av. Sta. Cruz del Monte 9-304<br>
|
||||
Cd. Satelite. Edo. de Mexico.<br>
|
||||
CP. 53110. Mexico.<br>
|
||||
<a href="mailto:biyubi@gmail.com">biyubi@gmail.com</a><br>
|
||||
<a href="http://nanochess.110mb.com/">http://nanochess.110mb.com/</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make toledo
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./toledo
|
||||
|
||||
# NOTE: This requires X11 to run or modifications to use layer.c on
|
||||
# Windows
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./toledo
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This two player game uses X11. The control keys can be configured by
|
||||
modifying the A,B,C and D macros at compilation.</p>
|
||||
|
||||
<p>After a quick splash screen the objective should be clear. There
|
||||
are Red, Green and Cyan tanks. A larger window can be made by altering
|
||||
the source early on, right before the code gets hard to follow.</p>
|
||||
|
||||
<p>Like Oscar’s previous winning X11 program for the 19th IOCCC, if
|
||||
you remove both the X11 include files and replace them with</p>
|
||||
|
||||
<pre><code>#include "layer.c"
|
||||
</code></pre>
|
||||
|
||||
<p>you ought to be able to compile and run this program on Windows.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<pre><code> /=========\
|
||||
\==\ /==/ ||
|
||||
|| || /====\ |\/=\ || //==\ ==\ |=\
|
||||
|| || || || || || // || =| | |
|
||||
|| || //===| || || ||=// \\=\\ ==/ |=/
|
||||
|| || || || || || || \\ || User's
|
||||
\===/ \\==// || || || \\ \==// Manual
|
||||
</code></pre>
|
||||
|
||||
<p>This is a color X11 3D tank-game for two players, just compile
|
||||
and run it without arguments.</p>
|
||||
|
||||
<p>You will see briefly a tank spinning before each level.</p>
|
||||
|
||||
<p>Left half of the window shows the red player view and right
|
||||
half shows the green player view, the background will change to
|
||||
blue when the view goes inactive.</p>
|
||||
|
||||
<p>The objective is to chase and destroy the other player’s tank,
|
||||
there is also an aqua tank for testing your aim and getting
|
||||
extra points.</p>
|
||||
|
||||
<blockquote><p>Caveat: You can shoot only 3 bullets at a time.
|
||||
Trick: You can fire faster if they explode on anything.
|
||||
Believe it or not, it has strategy!</p></blockquote>
|
||||
|
||||
<p>When only one tank remains on the field, the level will advance.
|
||||
Don’t forget to destroy the aqua tank.</p>
|
||||
|
||||
<p>The playground is surrounded by mountains and each level is
|
||||
filled with random obstacles (pyramids and cubes).</p>
|
||||
|
||||
<p>The bars show players energy and score, each bar shows energy
|
||||
and indicates current player view (wider on the left), right
|
||||
part grows with every point.</p>
|
||||
|
||||
<p>Keys for player 1 (lowercase):</p>
|
||||
|
||||
<ul>
|
||||
<li>Tab - Fire</li>
|
||||
<li>w - Go ahead</li>
|
||||
<li>s - Go backwards</li>
|
||||
<li>a - Turn left</li>
|
||||
<li>d - Turn right</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Keys for player 2:</p>
|
||||
|
||||
<ul>
|
||||
<li>Backspace - Fire</li>
|
||||
<li>Up arrow - Go ahead</li>
|
||||
<li>Down arrow - Go backwards</li>
|
||||
<li>Left arrow - Turn left</li>
|
||||
<li>Right arrow - Turn right</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<blockquote><p>Note: Numeric keys don’t work.</p></blockquote>
|
||||
|
||||
<p>If you don’t like the keys assignment, you can change it on the
|
||||
the makefile.</p>
|
||||
|
||||
<h2>PARENTAL ADVISORY WARNING:</h2>
|
||||
|
||||
<p>This game is highly violent, when the tank explodes you can
|
||||
see the little stick man blowing in parts.</p>
|
||||
|
||||
<p>Not really, just kidding :D</p>
|
||||
|
||||
<h2>PLATFORMS TESTED:</h2>
|
||||
|
||||
<ul>
|
||||
<li>openSuSE 10.2 x86-32, X11R6 1024x768 32-bits color.</li>
|
||||
<li>Fedora Core 8 x86-64, X11R6 1280x1024 32-bits color.</li>
|
||||
<li>Fedora Core 11 x86-64, X11R6 1024x768 32-bits color.</li>
|
||||
<li>Fedora Core 14 x86-64, X11R6 1024x768 32-bits color.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>COMPLETE FEATURE SET:</h2>
|
||||
|
||||
<ul>
|
||||
<li>Multiplayer out of the box.</li>
|
||||
<li>Totally self-contained, no external files.</li>
|
||||
<li>Fast-furious action at 29.97 frames per second.</li>
|
||||
<li>Just as the movies, 16:9 aspect-ratio.</li>
|
||||
<li>Beautiful mountains landscape plus horizon line :)</li>
|
||||
<li>Tanks and bullets exploding as wires with weird physics.</li>
|
||||
<li>Tanks backoff when firing.</li>
|
||||
<li>There is an infinite number of levels.</li>
|
||||
<li>Always different levels.</li>
|
||||
<li>Animated intro.</li>
|
||||
<li>It has color!.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>FEATURES THAT PROGRAMMERS WILL FIND APPEALING:</h2>
|
||||
|
||||
<ul>
|
||||
<li>Works both with x86-32 and x86-64 processors.</li>
|
||||
<li>Double buffered, portable to any X11 with 24/32-bit color.</li>
|
||||
<li>Memory-hungry as must be any 3-D program, uses a 256 MB
|
||||
array.</li>
|
||||
<li>Total and absolute irreverent coding style, so it generates
|
||||
a lot of warnings when compiled.</li>
|
||||
<li>It can take several minutes to compile (known culprits:
|
||||
Fedora Core 11-14 on x86-64 512 MB)</li>
|
||||
<li>It is written in the only true C: K&R, and no, it not means
|
||||
Katherine & Rose.</li>
|
||||
<li>Vectorial scalable graphics, do you want a bigger
|
||||
playfield? change variables M & N.</li>
|
||||
<li>Half of the program is formatted as 3-D cube, view with
|
||||
Tabs at 8 columns and a square font.</li>
|
||||
<li>The other half of the program is unprintable source code,
|
||||
so no typing from paper, you have to write a converter of
|
||||
tabs and formfeeds to its C escaped forms.</li>
|
||||
<li>No text, so this program can be used and understood easily
|
||||
on any country.</li>
|
||||
<li>This program is highly ecologic, it sleeps when it is not
|
||||
doing anything.</li>
|
||||
<li>Virtual world with its own physics laws.</li>
|
||||
<li>When closing the window it will show an X11 error :P</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>OBFUSCATION TRICKS:</h2>
|
||||
|
||||
<ul>
|
||||
<li>Loop code included inside loop test.</li>
|
||||
<li>Function arguments used as variables.</li>
|
||||
<li>Operators used freely.</li>
|
||||
<li>Precalculated values to save bytes.</li>
|
||||
<li><p>Uses the +++, +- and *+ undocumented C operators :P</p>
|
||||
|
||||
<pre><code> ....,,,,---++++++--,,..
|
||||
.,,,....... .$@@@@@@@@@@@@$$@@@@@@@@@@@@@@#+
|
||||
@@@@@###@@@@$$$@@@@$$$@@@-......-@+......,,,,,,##
|
||||
=++==++++++++=@@$==#$$$$$---,,,,@@@,,,,,,-------@@,..........,,.
|
||||
,===#$$$$$$###$####=======@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+=##$@@@@@@@@.
|
||||
+@,,++++++++=+=========++++===++++++++++-+++@@-,,,,,,,,---+++=++++--,,... @.
|
||||
.@. .......,,,,-----++=@=++==@$=+--,,... @.
|
||||
$# S P O I L E R .,,-#@--,,,@$..... @.
|
||||
.@ ..,--+==++-,,,,.,,,,=@+++++====+++++---,,,....@.
|
||||
@+ ..,,-+++++++-,,.. @. ....,,,,,---+@@
|
||||
,@ ..,--+++=+++,,.. $# .==+
|
||||
@#--++==++-,,.. ,@ S P O I L E R .==+
|
||||
,#@@$+,,. @. ==+
|
||||
.,,+++++,,. S P O I L E R $= +=+
|
||||
..,-==++-,. ,@ ---
|
||||
.,-+=+++,.. @. .++-
|
||||
.,,++=++-,. @+ ==+
|
||||
.,-++==+-,. +@ ==+
|
||||
..,+++=+-,.. .@. +=+
|
||||
.,-+++++,@@==
|
||||
</code></pre></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h1>THE HISTORY OF THIS PROGRAM:</h1>
|
||||
|
||||
<p>When I started working on this program, I figured that it would
|
||||
be easy to fit on the character limit, but I missed three
|
||||
things, the enormous X11 names, the unportable keycodes and my
|
||||
2 KB of artwork.</p>
|
||||
|
||||
<p>Very hard coding did the first thing, in fact I worked out
|
||||
twenty-nine different versions, at one step I had four
|
||||
parallel versions with different characteristics removed
|
||||
(mountains, horizon line, score/status bars and explosions),
|
||||
I’ve managed to fit it all together!.</p>
|
||||
|
||||
<p>The second thing was solved using the makefile, it is under
|
||||
160 bytes and you get adjustable keyboard. The greatest
|
||||
mistery on the earth is why X11 handles unportable keycodes to
|
||||
the user.</p>
|
||||
|
||||
<p>And finally, the third “Thing” was growing and growing, and
|
||||
growing, eating bytes for lunch… after endless rounds of
|
||||
crunching I obtained three-hundred seventy-eight bytes of
|
||||
artwork and guess what?, it doesn’t fitted.</p>
|
||||
|
||||
<p>So I had to integrate a decompressor, based on the space,
|
||||
tabulators and other non-counted characters.</p>
|
||||
|
||||
<p>The final program is composed of eight microfunctions, one is
|
||||
the core and does most of the hard work, other functions help
|
||||
doing the X11 things, explosion effects, 3-D calculations and
|
||||
viewing.</p>
|
||||
|
||||
<ul>
|
||||
<li>K() - 3-D transformation</li>
|
||||
<li>s() - Rendering</li>
|
||||
<li>b() - Line color selection</li>
|
||||
<li>G() - Explosion animation</li>
|
||||
<li>g() - Moves 3-D object backward and forward</li>
|
||||
<li>F() - Collision detection</li>
|
||||
<li>T() - Core (also known as main loop :D)</li>
|
||||
<li>main() - Initialization and uncruncher, what a common name!,
|
||||
C programs should start in the cool() function :).</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>The source code was formatted as an cube using a specially
|
||||
written program, the reality is that the program is smaller and
|
||||
obfuscated of what is needed so the reformatting doesn’t
|
||||
exceeded the character limits, the crunched vectors were
|
||||
generated by another special program and the tank that
|
||||
surrounds this text was generated by yet another program.</p>
|
||||
|
||||
<p><em>Have fun!</em></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-2012,
|
||||
<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,187 +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.3 DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most sound</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most sound</h1>
|
||||
|
||||
<p>Daniel Vik<br>
|
||||
802 Durshire Way<br>
|
||||
Sunnyvale, Ca 94087<br>
|
||||
<a href="mailto:daniel@vik.cc">daniel@vik.cc</a><br>
|
||||
<a href="http://www.danielvik.com">http://www.danielvik.com</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make vik
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./vik file.mod > audio_file.raw
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./vik randowan.mod | mplayer -demuxer rawaudio -
|
||||
./vik mad_world.mod | mplayer -demuxer rawaudio -
|
||||
</code></pre>
|
||||
|
||||
<p>Alternatively, you can use</p>
|
||||
|
||||
<pre><code>./vik file.mod > file.raw; ./raw2wav file.raw > file.wav
|
||||
</code></pre>
|
||||
|
||||
<p>It is possible to download a number of Mod files from <a href="http://modarchive.org">The Mod Archive</a>.</p>
|
||||
|
||||
<p>The randowan.mod and mad_world.mod files were created by
|
||||
<a href="http://www.translucentboy.com">Henrik Bertilsson</a> and
|
||||
are included with his permission.</p>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This entry converts .MOD audio files to a playable stream
|
||||
in a most pleasing manner if you don’t like tremolo or vibrato.</p>
|
||||
|
||||
<p>Also it abuses the C compiler and/or assembler with a partially
|
||||
initialized 32 MByte array. Can you tell what is that partial
|
||||
initilzation for?</p>
|
||||
|
||||
<p>Does it take your system a long time to compile? You may want to do try:</p>
|
||||
|
||||
<pre><code> cc -S vik.c
|
||||
</code></pre>
|
||||
|
||||
<p>and to examine the resulting assembly file vik.s. On some platforms
|
||||
the assembly file is about 128 MBytes in size!</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h1>Introduction</h1>
|
||||
|
||||
<p>In 1987, Karsten Obarski changed the way music was handled in games and
|
||||
demos with the introducton of the MOD file format on Commodore Amiga.</p>
|
||||
|
||||
<p>A MOD file contains a set of samples, a number of patterns indicating
|
||||
how and when the samples are to be played, a list of what patterns to
|
||||
play in what order, and a number of effects.</p>
|
||||
|
||||
<h1>Features</h1>
|
||||
|
||||
<p>This program converts MOD files created with the standard trackers for
|
||||
Amiga, e.g. Pro Tracker, Noise Tracker and Sound Tracker to raw 16 bit
|
||||
44.1kHz stereo audio. The program supports MOD music with 4, 6, and 8
|
||||
channels MOD files with up to 31 samples.</p>
|
||||
|
||||
<p>The MOD format includes many effects for each audio channel and this
|
||||
program supports most of them, including:</p>
|
||||
|
||||
<ul>
|
||||
<li>Arpeggio</li>
|
||||
<li>Slide and fine slide up/down/to note</li>
|
||||
<li>Set sample offset</li>
|
||||
<li>Volume slide</li>
|
||||
<li>Pattern break</li>
|
||||
<li>Filter on/off</li>
|
||||
<li>Set volume</li>
|
||||
<li>Cut sample</li>
|
||||
<li>Delay sample</li>
|
||||
<li>Delay pattern</li>
|
||||
<li>Set speed</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Due to size constraints tremolo and vibrato is not supported. Also, to
|
||||
avoid infinite long songs, the position jump feature is ignored.</p>
|
||||
|
||||
<h1>Songs</h1>
|
||||
|
||||
<p>With his permission, the package incldues two songs composed by Henrik
|
||||
Bertilsson, also known as Deelite:</p>
|
||||
|
||||
<ol>
|
||||
<li> Mad World</li>
|
||||
<li> Randowan</li>
|
||||
</ol>
|
||||
|
||||
|
||||
<h1>Build</h1>
|
||||
|
||||
<p>Compiling for *nix systems (including cygwin) is straight forward:</p>
|
||||
|
||||
<pre><code>$ gcc -o vik vik.c
|
||||
</code></pre>
|
||||
|
||||
<h1>Usage</h1>
|
||||
|
||||
<h3>Convert MOD file to raw 44.1kHz stereo audio file</h3>
|
||||
|
||||
<pre><code>$ ./vik mad_world.mod > audio_file.raw
|
||||
</code></pre>
|
||||
|
||||
<h3>Listen to the MOD file (streaming to mplayer)</h3>
|
||||
|
||||
<pre><code>$ ./vik randowan.mod | mplayer -demuxer rawaudio -
|
||||
</code></pre>
|
||||
|
||||
<p>(Don’t forget the last ‘-’ as it makes mplayer read from stdin.)</p>
|
||||
|
||||
<h1>Obfuscation</h1>
|
||||
|
||||
<p>The IOCCC rules did not put a limit on the entropy of the source code,
|
||||
and it appears that the general entropy rules doesn’t apply. An estimate
|
||||
is that the code density entropy of this entry is ~1.2 which means that
|
||||
there are around 2500 characters of code carrying information, yet there
|
||||
are only 2037 IOCCC characters of actual code. Most of the additional
|
||||
characters are encoded with non-counting characters in the frequency
|
||||
table. But there are also ~50 or so white space characters spread out
|
||||
through the source code that carry information.</p>
|
||||
|
||||
<p>The use of macros certainly adds to the obfuscation but the reason for
|
||||
using them is mainly to fit as many features as possible within the size
|
||||
limits. So please excuse the use of them.</p>
|
||||
|
||||
<p>Once the preprocessor is run, the code gets more interesting. The MOD
|
||||
player is basically a register based state machine and all the magic is
|
||||
hidden in a fog of short statements. Many of the register updates are
|
||||
conditional and the program uses the ? operator (sigh) mainly to save
|
||||
space, but also to leverage the comma operator and precedence more
|
||||
efficiently.</p>
|
||||
|
||||
<h1>Portability</h1>
|
||||
|
||||
<p>The progam is portable to most platforms. The only system dependency is
|
||||
that the program relies on writing binary data to stdout.</p>
|
||||
|
||||
<p>Microsoft compilers adds a carriges return to newlines, and to compile
|
||||
the program with this platform, the following line can be added after
|
||||
the main declaration in order for the program to run correctly:</p>
|
||||
|
||||
<pre><code>_setmode(_fileno(stdout), 0x8000);
|
||||
</code></pre>
|
||||
|
||||
<h1>Limitations</h1>
|
||||
|
||||
<p>The program only runs when a valid MOD file is passed as argument. If
|
||||
no argument is passed, the program crashes.</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-2012,
|
||||
<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,186 +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.3 DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most shiny</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most shiny</h1>
|
||||
|
||||
<p>Matt Zucker<br>
|
||||
<a href="mailto:mzucker1@swarthmore.edu">mzucker1@swarthmore.edu</a><br>
|
||||
<a href="http://www.swarthmore.edu/NatSci/mzucker1/">http://www.swarthmore.edu/NatSci/mzucker1/</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make zucker
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./zucker > image.ppm
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./zucker "Hello!!!" > hello.ppm
|
||||
./zucker faster\! -preview > image2.ppm
|
||||
|
||||
# Display the PPM image with your favorite image viewer
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>The rendered image is centered and is output as a 600 by 220 pixel PPM.
|
||||
The vector font is proportional.</p>
|
||||
|
||||
<p>This entry uses no local variables. None! At! All!</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h1>An image generator</h1>
|
||||
|
||||
<h2>What it does:</h2>
|
||||
|
||||
<p>This program makes pretty pictures. To see the default output, try
|
||||
running</p>
|
||||
|
||||
<pre><code> ./zucker > image.ppm
|
||||
</code></pre>
|
||||
|
||||
<p>On the author’s 2.5 GHz MacBook Pro, this command takes approximately
|
||||
1 minute and 18 seconds to run – your runtime may vary. You will
|
||||
need an image viewer capable of displaying Netpbm images in order to
|
||||
display the output. On the Mac, <a href="http://wakaba.c3.cx/s/apps/xee">Xee</a>
|
||||
works well; otherwise <a href="http://www.imagemagick.org/">ImageMagick</a>
|
||||
and/or <a href="http://www.graphicsmagick.org/">GraphicsMagick</a> are both
|
||||
capable of displaying Netpbm files, and are available on multiple
|
||||
platforms. (Using Xee is particularly nice because it periodically
|
||||
reloads the image as it is rendered.)</p>
|
||||
|
||||
<p>Aside from the default image, you may create your own by running the
|
||||
program as follows:</p>
|
||||
|
||||
<pre><code> ./zucker "your text" > image.ppm
|
||||
</code></pre>
|
||||
|
||||
<p>To mitigate long runtimes, the program can be invoked in a “preview”
|
||||
mode by appending <code>-preview</code> to the command line arguments, like so:</p>
|
||||
|
||||
<pre><code> ./zucker faster\! -preview > image.ppm
|
||||
</code></pre>
|
||||
|
||||
<p>If your platform distinguishes between binary and text streams, you
|
||||
may need to insert some code to reopen standard output in binary mode
|
||||
at the start of <code>main</code>. An ASCII platform is assumed.</p>
|
||||
|
||||
<h2>Pedagogical value:</h2>
|
||||
|
||||
<p>This program is quite suitable for the inexperienced programmer, due
|
||||
to a number of considerations:</p>
|
||||
|
||||
<ul>
|
||||
<li><p>It is fairly short: just 4 preprocessor directives followed by 29
|
||||
lines of source.</p></li>
|
||||
<li><p>It compiles cleanly as ANSI C under gcc 4.2.1 with very strict
|
||||
compilation flags.</p></li>
|
||||
<li><p>It uses a very small subset of the keywords available in C, namely
|
||||
<code>char</code>, <code>float</code>, <code>int</code>, <code>typedef</code>, <code>struct</code>, <code>for</code>, and <code>return</code>.
|
||||
More difficult concepts such as <code>void</code>, <code>if</code>, <code>switch</code>, and
|
||||
<code>while</code> are eschewed for simplicity’s sake.</p></li>
|
||||
<li><p>It also uses a very small number of library functions: just <code>putchar</code>,
|
||||
<code>cos</code>, <code>sin</code>, <code>atan2</code>, <code>sqrt</code>, and <code>pow</code>.</p></li>
|
||||
<li><p>New programmers often prefer to use global variables when
|
||||
possible. Hence, <em>all</em> variables in this program (aside from
|
||||
function parameters) have global scope.</p></li>
|
||||
<li><p>An important aspect of the computation is graphically illustrated
|
||||
by the source code itself: the geometric construction of a
|
||||
reflection ray at an object’s surface, given the incoming
|
||||
direction and surface normal.</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Further details (contains spoilers):</h2>
|
||||
|
||||
<p>The program is not quite a traditional ray tracer, but a “sphere
|
||||
tracer” which uses distance fields to encode proximity to objects in
|
||||
the scene. Using sphere tracing to compute visibility instead of
|
||||
analytic ray tracing provides two advantages: first, it greatly eases
|
||||
the computation of ray-torus intersection (which would otherwise
|
||||
require solving a quartic polynomial), and second, it makes it
|
||||
possible to compute ambient occlusion (which is used to generate soft
|
||||
shadows). Unlike many traditional ray tracers and sphere tracers, this
|
||||
one uses iteration instead of recursion to compute the effect of
|
||||
reflections. This, unfortunately, resulted in the programmer going
|
||||
insane; however, program size was reduced and readability
|
||||
hindered. Neither the plaintext for the program’s default output nor
|
||||
for the Netpbm header appears in the program source, which hinders
|
||||
readability as well. Also, unlike some previous IOCCC entries which
|
||||
render ASCII text, this one uses a vector (as opposed to raster)
|
||||
font. Although the program does not generate uppercase letters, it
|
||||
handles them in a reasonable manner when they appear in the input.</p>
|
||||
|
||||
<p>Even when the program is pretty-printed and preprocessor macros are
|
||||
expanded, it should be fairly resistant to analysis due to reckless
|
||||
reuse of global variables, to the inherently opaque nature of the
|
||||
math, and to its overall density. Global variables are used to store
|
||||
the results of intermediate computation. As a result, seemingly simple
|
||||
functions have important side effects. Although some of the global
|
||||
variables are simply constants, their use is overloaded. For instance,
|
||||
the variable <code>X</code> is used both as the number 40 and as the ASCII
|
||||
character <code>'('</code>. Maintainability is hindered due to hardcoding
|
||||
several aspects of the program in multiple locations. As an example,
|
||||
it is impossible to modify either the image width or height without
|
||||
changing the source in at least three different places, including
|
||||
inside the large string literal.</p>
|
||||
|
||||
<p>Some of the functions are simple vector algebra operations such as
|
||||
vector construction, dot product, and normalization. However, it was
|
||||
found to be much more compact to define a single operation for
|
||||
multiply-and-add rather than to have separate functions for addition,
|
||||
subtraction, and scaling. Again, compactness led to obfuscation.</p>
|
||||
|
||||
<p>This program heavily abuses <code>for</code> loops. The comma operator is used to
|
||||
get as much milage as possible out of statements inside of loop
|
||||
declarations. Between <code>for</code> loops, the comma operator, and the ternary
|
||||
operator, it was possible to avoid <code>if</code> and <code>while</code> altogether.</p>
|
||||
|
||||
<p>Bitwise and arithmetic operators are used instead of logical operators
|
||||
whenever gcc doesn’t warn about it. Conversely, integer
|
||||
multiplication, division, and modulus are sometimes used in place of
|
||||
traditional bitwise operators just to keep the reader on his or her
|
||||
toes. Automatic casting between characters, integers, and floats is
|
||||
performed just about everywhere. Fascinatingly, this doesn’t seem to
|
||||
affect performance too badly. Sometimes when an explicit cast
|
||||
(i.e. from float to int) is needed, the program instead simply assigns
|
||||
to a free variable of the desired type instead. Both the <code>array[index]</code>
|
||||
and <code>index[array]</code> notations are used interchangably throughout the
|
||||
program.</p>
|
||||
|
||||
<p>Two other programs were written to support development of this
|
||||
program. The first used a randomized search algorithm to deduce the
|
||||
most compact encoding of the vector font instructions into ASCII; the
|
||||
second used a modified form of the Knuth-Plass algorithm to layout the
|
||||
final text on top of a hand-generated ASCII “stencil”. The programs
|
||||
were not submitted as entries for this year’s IOCCC, not because they
|
||||
lack obfuscation, but because neither is written in C (they are in C++
|
||||
and Python, respectively).</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-2012,
|
||||
<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