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,287 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Best painting tool</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best painting tool</h1>
|
||||
|
||||
<p>Michael Birken<br>
|
||||
<a href="mailto:o__1@hotmail.com">o__1@hotmail.com</a><br>
|
||||
<a href="http://www.meatfighter.com/">http://www.meatfighter.com/</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make birken
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./birken < 17_columns_wide_paint_by_numbers_file
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./birken < examples/ioccc.txt
|
||||
|
||||
perl -e 'map{map{print int(rand()*8);}(0..16);print chr(10);}(0..30);' | tr '[0-4]' ' '| ./birken
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This program also wins the “Most amusing abuse of the iocccsize tool” award; although not the
|
||||
absolute best: it is possible to achieve 0 by writing</p>
|
||||
|
||||
<pre><code>/* *\
|
||||
/....
|
||||
</code></pre>
|
||||
|
||||
<p>The game of Tetris had been used in many endeavors, from studying <a href="http://arxiv.org/abs/cs/0210020">algorithmic complexity</a> to <a href="http://www.livescience.com/19894-tetris-treat-ptsd-flashbacks.html">treating PTSD</a>.
|
||||
Using it for painting by numbers looks like a novel idea.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>About This Document</h3>
|
||||
|
||||
<p>This document is best viewed as an HTML file in a browser that supports animated gifs. Extract <code>examples.tbz2</code> for the sample input files.</p>
|
||||
|
||||
<pre><code>tar -xjvf examples.tbz2
|
||||
</code></pre>
|
||||
|
||||
<h3>Abstract</h3>
|
||||
|
||||
<p>By rotating, positioning and dropping a predetermined sequence of pieces, this program exploits the mechanics of Tetris to generate arbitrary images.</p>
|
||||
|
||||
<h3>Algorithm Overview</h3>
|
||||
|
||||
<p>The algorithm converts pixels from a source image into squares in the Tetris playfield, one row at a time from the bottom up. To generate an individual square, the algorithm assembles a structure consisting of a rectangular region fully supported by a single square protruding from the bottom. When the rectangular region is completed, its rows are cleared, leaving behind the protruding square. Three examples of the process appear below.</p>
|
||||
|
||||
<p><img src="pen0.gif" alt="" /></p>
|
||||
|
||||
<p><img src="pen1.gif" alt="" /></p>
|
||||
|
||||
<p><img src="pen2.gif" alt="" /></p>
|
||||
|
||||
<p>During construction of a row, all of the squares produced by this method must be supported. In the images above, the generated squares are supported by the floor of the playfield. However, if an arbitrary row contains holes, it may not provide the support necessary for the construction of the row above it. The algorithm solves this problem by constructing a flat platform on top of the row with holes. In the animation below, a platform is built above a row comprising of a single red square. The platform is a temporary structure and inserting the final piece removes it.</p>
|
||||
|
||||
<p><img src="platform0.gif" alt="" /></p>
|
||||
|
||||
<p>Below, a row containing 5 red squares is deposited above a row containing 3 red squares. This is accomplished by building a flat platform on top of the lower row. The platform provides the support necessary to generate the 5 red squares. Finally, the platform is removed by inserting its final piece and the new row drops into place. Note, if the algorithm needed to generate the rows in the opposite order (a row of 3 red squares above a row of 5 red squares), a platform would not be necessary.</p>
|
||||
|
||||
<p><img src="platform1.gif" alt="" /></p>
|
||||
|
||||
<h3>Single Square Emitters</h3>
|
||||
|
||||
<p>For reference, the names of the 7 Tetriminos (the game pieces) appear in the table below.</p>
|
||||
|
||||
<p><img src="names.png" alt="" /></p>
|
||||
|
||||
<p>This algorithm was tailored specifically to render sprites from early video games. Those games packed graphics into 8×8 tiles where 2 bits were dedicated to each pixel. Consequentially, sprites usually contained only 3 colors plus transparent regions and they were typically sized either 16×16 or 16×32 pixels.</p>
|
||||
|
||||
<p>The animation below depicts all the patterns used to emit single squares. J, T and L Tetriminos are used interchangeably within each pattern to produce the protruding square at the bottom. The algorithm assigns those Tetriminos to the 3 colors present in the sprite. The remaining Tetriminos are assigned arbitrary colors. And, all the colors remain constant during gameplay.</p>
|
||||
|
||||
<p><img src="pen4.gif" alt="" /></p>
|
||||
|
||||
<p>It is not possible to emit a square of all 3 colors in the first 2 and the last 2 columns due to the shapes of the 3 Tetriminos. As a result, the minimal width of a playfield to accommodate a 16 pixel wide sprite is 2 + 16 + 2 = 20 squares. However, it turns out that 20 is too small.</p>
|
||||
|
||||
<p>As illustrated below, the region above the protruding square cannot exclusively consist of a single row because the only pieces that could fit, the I Tetriminos, are unsupported.</p>
|
||||
|
||||
<p><img src="pen5.gif" alt="" /></p>
|
||||
|
||||
<p>With 2 rows, the only means of spanning the full playfield width in a way that remains supported is to use S and Z Tetriminos. But, that will always leave holes in the upper row.</p>
|
||||
|
||||
<p><img src="pen6.gif" alt="" /></p>
|
||||
|
||||
<p>The minimal number of rows required above the protruding square is 3 and as shown repeatedly above, such patterns do exist. 20 squares is the minimal width required to fit a 16 pixel wide sprite. But, 20 × 3 + 1 = 61, which is not divisible by 4 and hence not constructible out of Tetriminos. However, a width of 21 yields 21 × 3 + 1 = 64, which can be built with 16 Tetriminos. That width actually enables the algorithm to render sprites up to 17 pixels wide.</p>
|
||||
|
||||
<p>The original Tetris playfield is 10×20 squares, a 1:2 ratio. The program maintains that ratio by using a playfield of 21×42 squares.</p>
|
||||
|
||||
<p>Since J, T and L Tetriminos are used interchangeably to produce the emitted square and 3 squares of those Tetriminos contribute to the row above it, there are 21 − 3 + 1 = 19 single square emitting patterns. However, due to mirror symmetry, there are really only 10 patterns. Clearing 3 rows works for the majority of them. But, an exhaustive computer search revealed that 2 of the patterns require more. The next possible option is 7 rows since 21 × 7 + 1 = 148, requiring 37 Tetriminos. As the images below show, those patterns do exist.</p>
|
||||
|
||||
<p><img src="pen7.gif" alt="" /></p>
|
||||
|
||||
<p><img src="pen8.gif" alt="" /></p>
|
||||
|
||||
<h3>Platforms</h3>
|
||||
|
||||
<p>Before a row is constructed, the algorithm inspects the row below it. If the row below fails to provide support for all of the squares to be deposited above it, then a temporary platform is required. When that platform is removed, the new row will drop, leaving some of the squares apparently floating above empty space due to the way that gravity works in the original Tetris.</p>
|
||||
|
||||
<p>The illustration below depicts the 10 platform patterns (really only 5 considering mirror symmetry). The construction of a platform begins by dropping a T Tetrimino on top one of the squares of the last generated row. The remaining Tetriminos support each other down to that first T. Meaning, as long as the previously generated row contains at least 1 square, like the red square below, then it is possible to construct a flat platform above it for the generation of the next row.</p>
|
||||
|
||||
<p><img src="platform2.gif" alt="" /></p>
|
||||
|
||||
<p>In the middle of platform construction, the bottom row gets completed and cleared, leaving 3 rows above it. The final J or L Tetrimino that will remove those rows is not inserted until the square emitters are done generating the next row of the sprite on top of the platform. That final piece precludes square emission in the first and last 2 columns. But, as discussed above, the square emitters are limited to the 17 inner columns due to the geometry of the J, T and L Tetriminos used in the process.</p>
|
||||
|
||||
<p>Also, of the 19 possible ways to start constructing a platform on top of a T Tetrimino, only the 10 patterns shown above exist.</p>
|
||||
|
||||
<h3>Program Input</h3>
|
||||
|
||||
<p>The input sprite is represented textually. Digit characters <code>0</code> to <code>7</code> correspond to pixels with colors from the palette below.</p>
|
||||
|
||||
<p><img src="palette.png" alt="ANSI color palette" /></p>
|
||||
|
||||
<p>As discussed above, sprites are limited to a maximum of 3 colors from this palette.</p>
|
||||
|
||||
<p>All other characters are interpreted as transparent pixels.</p>
|
||||
|
||||
<p>The maximum permissible size of the input text is 32 rows by 17 columns. Row length can vary as long as no single row exceeds 17 characters.</p>
|
||||
|
||||
<p>Every row must contain at least one palette digit character.</p>
|
||||
|
||||
<p>The <code>examples</code> directory contains several sprites in this textual format that can be fed into standard input. Several examples take advantage of the Tetris playfield background color. Instead of using character <code>0</code>, internal regions marked as transparent are effectively rendered as black.</p>
|
||||
|
||||
<h3>Program Output</h3>
|
||||
|
||||
<p>The program conceptually uses Tetris as an output device similar to a line printer. It restricts itself to those operations that can be performed on the Tetris playfield: spawning, rotating, positioning and dropping Tetriminos. This process is visually represented using ANSI escape sequences.</p>
|
||||
|
||||
<h3>ANSImation</h3>
|
||||
|
||||
<p>The rate at which the program plays Tetris is completely determined by the rate in which the terminal application receives and displays the ANSI escape sequences.</p>
|
||||
|
||||
<p>To slowdown the output programmatically, introduce a delay immediately after the call to <code>fflush</code>.</p>
|
||||
|
||||
<h3>IOCCC Size Tool Bug</h3>
|
||||
|
||||
<p>This program demonstrates how to exploit a bug in IOCCC size tool version 2013-07-30-v17. The first line of the program is reproduced below.</p>
|
||||
|
||||
<pre><code>char*_ = "'""/*";
|
||||
</code></pre>
|
||||
|
||||
<p>If that line is added to the top of any program, the tool will report a size of 8.</p>
|
||||
|
||||
<pre><code>./iocccsize -i < prog.c
|
||||
8
|
||||
</code></pre>
|
||||
|
||||
<p>When that line is deleted from this program, the tool properly reports the secondary size limit of the program as 2048.</p>
|
||||
|
||||
<pre><code>./iocccsize -i < prog.c
|
||||
2048
|
||||
</code></pre>
|
||||
|
||||
<p>Although this bug provides an easy means of circumventing contest rule 2, as demonstrated from the size value, this entry is not necessarily striving for a ‘worst abuse of the rules’ award.</p>
|
||||
|
||||
<h3>Obfuscations</h3>
|
||||
|
||||
<p>This program is almost, but not quite, entirely unlike a demonstration of good programming practices. Contrary to other programs, an inspection of this one will certainly reveal that it possesses tea, not to mention an affinity for the constant 42.</p>
|
||||
|
||||
<p>Variables are named and ordered to spell out, “Tetris”, “ELORG”, “DVK” and the aforementioned “Tea”. ELORG is the abbreviation for Elektronorgtechnica, the former Soviet state owned computer organization that handled the worldwide Tetris intellectual property rights. DVK is the line of Soviet PDP-11-compatible personal computers capable of running Alexey Pajitnov’s original 1984 Tetris prototype.</p>
|
||||
|
||||
<p>Carefully selected variable names also yielded wonderful expressions like <code>l=0</code>, <code>O=0</code>, <code>O=1</code> and <code>while(O)</code>. “Tetris” also makes a second appearance of sorts:</p>
|
||||
|
||||
<pre><code>[T][e][t]--; while(R+i) { s
|
||||
</code></pre>
|
||||
|
||||
<p>The source is formatted to resemble the Tetris playfield midgame. It is also an homage to all the past IOCCC entries formatted as a compact block of text; the T, orientated appropriately to reflect its name and the first letter in the title of the game, is just a moment away from producing such a text block.</p>
|
||||
|
||||
<p>Three tables are encoded as separate strings within the program:</p>
|
||||
|
||||
<p>The first string stores the coordinates of the squares of the 19 distinct rotations of Tetriminos (see below). Since a Tetrimino is a chain of 4 squares, all Tetriminos fit within a 4×4 matrix. To determine the coordinates of the squares, the Tetrimino is pushed to the upper-left of the matrix. Each coordinate value requires 2 bits of storage. Consequentially, the four x-coordinates and the four y-coordinates were packed into separate octets. To convert the octets into valid ASCII characters, the squares were sorted such that the least significant bits stored the largest coordinate values. The results were offset by 35, the <code>#</code> character, which is 1 beyond the ASCII value of <code>"</code>, making it easier to pack into a string. None of the resultant values are beyond ASCII 127. The coordinates for all 19 rotations fit in a string of length 38.</p>
|
||||
|
||||
<p><img src="rotations.png" alt="" /></p>
|
||||
|
||||
<p>The second string stores the single square emitter patterns and the platform patterns. Each pattern is a sequence of pairs, { Tetrimino index, drop x-coordinate }. As mentioned, there are 19 distinct rotations, requiring 5 bits of storage for the Tetrimino index. Another 5 bits is required for the drop x-coordinate since there are 21 columns in the playfield. Necessarily, the pair is stored as 2 separate characters. By offsetting them by 40, the <code>(</code> character, the resultant string almost resembles a long and complex mathematical expression. The program takes advantage of mirror symmetry by only storing 10 single square emitter patterns and 5 platform patterns. The pattern lengths are not encoded within the string. Rather, they are embedded within the string decoding logic.</p>
|
||||
|
||||
<p>The third string conceptually stores the default colors of the 19 rotations. A 3-bit value is assigned to each, covering the 7 possible colors. In addition, when a mirrored pattern is executed, J exchanges with L and S exchanges with Z, necessitating a second list of 3-bit color values. Pairs of color values (6 bits) fit comfortably into a character that is offset by <code>#</code>. The result is a string of length 19.</p>
|
||||
|
||||
<p>The program is full of subtle obfuscations:</p>
|
||||
|
||||
<ul>
|
||||
<li><p>The unary decrement operator is used in conjunction with global variable automatic zero initialization to set variables to <code>-1</code>.</p></li>
|
||||
<li><p>The boolean expression of the form, <code>x + 1</code>, is used multiple times to determine if a value is not <code>-1</code>. Similarly, expressions of the form <code>x - y</code> are used to determine if <code>x != y</code>.</p></li>
|
||||
<li><p>Several arrays store unrelated data in segments throughout the array to reduce named variables.</p></li>
|
||||
<li><p>The <code>x["..."]</code> trick appears once.</p></li>
|
||||
<li><p>Variable <code>i</code> is less than necessary.</p></li>
|
||||
<li><p>A cursorily glance at the expressions <code>4&&L</code> and <code>m&&e==m</code> suggests that they always evaluate to true.</p></li>
|
||||
<li><p>The varying single square emitter pattern lengths are resolved during string decoding using the clever expression, <code>(i & 3) - 3</code>, which identifies pattern 3 and 7 as longer.</p></li>
|
||||
<li><p>The file size of <code>prog.c</code> is a prime number. Deleting the first line also produces a prime-sized program. These properties do not qualify the program as a prime number generator.</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Beyond Obfuscation</h3>
|
||||
|
||||
<p>Due to the contest code size constraint, some optimizations reluctantly had to be omitted. For example, multi-square emitters are possible:</p>
|
||||
|
||||
<p><img src="multi2.gif" alt="" /></p>
|
||||
|
||||
<p><img src="multi3.gif" alt="" /></p>
|
||||
|
||||
<p><img src="multi4.gif" alt="" /></p>
|
||||
|
||||
<p><img src="multi5.gif" alt="" /></p>
|
||||
|
||||
<p>In fact, using dynamic programming and creative heuristics, real-time search is possible, enabling patterns like this:</p>
|
||||
|
||||
<p><img src="triple0.gif" alt="" /></p>
|
||||
|
||||
<p>And, even this:</p>
|
||||
|
||||
<p><img src="triple1.gif" alt="" /></p>
|
||||
|
||||
<p>In addition, it is possible to extend the algorithm to 6 colors instead of just 3. This is achieved using I, S and Z to produce the protruding square. A series of rectangular regions are constructed above those Tetriminos to erode them down to a single emitted square.</p>
|
||||
|
||||
<p>The details of these enhancements are left as an exercise to the reader.</p>
|
||||
|
||||
<h3>Example Files</h3>
|
||||
|
||||
<p>The following example files were created by the program author. They can be freely used and distributed.</p>
|
||||
|
||||
<ul>
|
||||
<li><code>format.txt</code> - The layout of the program</li>
|
||||
<li><code>helloworld.txt</code> - Hello World, Tetris-style</li>
|
||||
<li><code>hilbert.txt</code> - A graphic based on the Hilbert curve</li>
|
||||
<li><code>ioccc.txt</code> - IOCCC</li>
|
||||
<li><code>landon.txt</code> - Portrait of a man with glasses</li>
|
||||
<li><code>leo.txt</code> - Portrait of a man without glasses</li>
|
||||
<li><code>rhino.txt</code> - A purple rhinoceros</li>
|
||||
<li><code>simon.txt</code> - Portrait of a man without hair</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>The following files are based on graphics from non-free, copyrighted video games. The use of a limited number of textual representations of the graphics for the demonstration of this program qualifies as fair use as such files do not significantly impede the right of the copyright holder to sell the copyrighted material and it is not being used to generate profit in this context. The origin of each file is detailed below (character, game, company, year).</p>
|
||||
|
||||
<ul>
|
||||
<li><code>belmont.txt</code> - Simon Belmont, Castlevania, Konami, 1986</li>
|
||||
<li><code>bloober.txt</code> - Bloober, Super Mario Brothers, Nintendo, 1985</li>
|
||||
<li><code>bomberman.txt</code> - Bomberman, Bomberman, Hudson, 1983</li>
|
||||
<li><code>boo.txt</code> - Boo, Super Mario Brothers 3, Nintendo, 1988</li>
|
||||
<li><code>bub.txt</code> - Bub, Bubble Bobble, Taito, 1986</li>
|
||||
<li><code>cheepcheep.txt</code> - Cheep Cheep, Super Mario Brothers, Nintendo, 1985</li>
|
||||
<li><code>gurin.txt</code> - Gurin, Binary Land, Hudson, 1983</li>
|
||||
<li><code>koopaparatroopa.txt</code> - Koopa Paratroopa, Super Mario Brothers, Nintendo, 1985</li>
|
||||
<li><code>lakitu.txt</code> - Lakitu, Super Mario Brothers, Nintendo, 1985</li>
|
||||
<li><code>mario.txt</code> - Fire Mario, Super Mario Brothers, Nintendo, 1985</li>
|
||||
<li><code>mspacman.txt</code> - Ms. Pac-Man and Ghost, Ms. Pac-Man, Midway, 1982</li>
|
||||
<li><code>paranaplant.txt</code> - Piranha Plant, Super Mario Brothers, Nintendo, 1985</li>
|
||||
<li><code>samus.txt</code> - Samus Aran, Metroid, Nintendo/Intelligent Systems, 1986</li>
|
||||
<li><code>toad.txt</code> - Toad, Super Mario Brothers 2, Nintendo, 1987</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>The origin of the remaining files are described below:</p>
|
||||
|
||||
<ul>
|
||||
<li><code>happyface.txt</code> - Based on a smiley; rights unknown</li>
|
||||
<li><code>snoo.txt</code> - 8-bit version of Snoo, Reddit’s alien mascot</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,121 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most partisan 1-liner</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most partisan 1-liner</h1>
|
||||
|
||||
<p>Adrian Cable<br>
|
||||
<a href="mailto:adrian.cable@gmail.com">adrian.cable@gmail.com</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make cable1
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./cable1 name group1 group2
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./cable1 obama republican democrat
|
||||
./cable1 nixon republican democrat
|
||||
./cable1 bush republican democrat
|
||||
./cable1 kennedy republican democrat
|
||||
./cable1 lincoln republican democrat
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>Partisan may be defined as a strong supporter of a cause, party or person.
|
||||
We need not limit ourselves to the two major political parties in the US today.</p>
|
||||
|
||||
<p>Let us consider:</p>
|
||||
|
||||
<pre><code>./cable1 Cooper Mac PC
|
||||
</code></pre>
|
||||
|
||||
<p>Simon works for Apple, so would would expect Mac. :-)
|
||||
Landon is a long time Mac user:</p>
|
||||
|
||||
<pre><code>./cable1 Noll Mac PC
|
||||
</code></pre>
|
||||
|
||||
<p>That works too!. Now Leo brings PCs to the IOCCC judging for cross-platform
|
||||
testing:</p>
|
||||
|
||||
<pre><code>./cable1 Broukhis Mac PC
|
||||
</code></pre>
|
||||
|
||||
<p>We can test other people. The late Steve Jobs:</p>
|
||||
|
||||
<pre><code>./cable1 Jobs Mac PC
|
||||
</code></pre>
|
||||
|
||||
<p>That works! How about Bill?</p>
|
||||
|
||||
<pre><code>./cable1 Gates Mac PC
|
||||
</code></pre>
|
||||
|
||||
<p>A PC guy as expected. What about that other Steve?</p>
|
||||
|
||||
<pre><code>./cable1 Ballmer Mac PC
|
||||
</code></pre>
|
||||
|
||||
<p>Humm .. maybe there is a hidden reason he is leaving the late Micro$oft? :-)
|
||||
Why late? See <a href="https://twitter.com/landonnoll/status/401582967123742720">this tweet</a>.</p>
|
||||
|
||||
<p>So how does a one line C source know so much? Hint: it doesn’t.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h1>Presidents of the United States of America!</h1>
|
||||
|
||||
<p>Politics is full of memorable one-liners. Without wishing to misunderestimate the taste of the judges, nor prejudge the past, the author hopes you enjoy this contribution to the genre.</p>
|
||||
|
||||
<p>This one-line C program accepts as a first command-line argument the last name of any of the last 31 US Presidents (from Franklin Pierce onwards), in lower case, and prints out their political affiliation.</p>
|
||||
|
||||
<p>Use “republican” as the 2nd command-line argument, and “democrat” as the 3rd (or equivalent strings of your choice).</p>
|
||||
|
||||
<h2>Why is this entry obfuscated/interesting?</h2>
|
||||
|
||||
<ul>
|
||||
<li>The program looks up the name supplied on the command line against a list of Presidents' names, and matches names to political affiliations using a look-up table. But where in the source is the list of names, and where is the look-up table?</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Notes</h2>
|
||||
|
||||
<ul>
|
||||
<li>For Theodore Roosevelt, use: ./cable1 roosevelt republican democrat</li>
|
||||
<li>But, for Franklin D Roosevelt, use: ./cable1 fdr republican democrat</li>
|
||||
<li>This program needs a little endian CPU to work properly.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Compiler warnings</h2>
|
||||
|
||||
<p>clang warns about a missing type specifier for main, and that implicit function declarations are invalid in C99 (but still accepts them).</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,145 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Best of show</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best of show</h1>
|
||||
|
||||
<p>Adrian Cable<br>
|
||||
<a href="mailto:adrian.cable@gmail.com">adrian.cable@gmail.com</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make cable2
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./cable2 file.bmp [color]
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<p>Extract example-images.tbz2:</p>
|
||||
|
||||
<pre><code>make data
|
||||
</code></pre>
|
||||
|
||||
<p>Here is an OCR example that shows all 94 supported ASCII characters:</p>
|
||||
|
||||
<pre><code>./cable2 ascii.bmp
|
||||
</code></pre>
|
||||
|
||||
<p>Here is an example of colored ASCII:</p>
|
||||
|
||||
<pre><code>./cable2 multi_color.bmp color
|
||||
</code></pre>
|
||||
|
||||
<p>Here is an example using different character sizes and different
|
||||
positions in the same file:</p>
|
||||
|
||||
<pre><code>./cable2 mixed_sizes.bmp
|
||||
</code></pre>
|
||||
|
||||
<p>How about about hand-written C code:</p>
|
||||
|
||||
<pre><code>./cable2 hello_world.bmp | gcc -xc -o hello -
|
||||
./hello
|
||||
</code></pre>
|
||||
|
||||
<p>Sometimes typeset text will work, if the typeset has characters that
|
||||
are enough to the supported handwritten shapes. For example,
|
||||
Menlo, 160 pt:</p>
|
||||
|
||||
<pre><code>./cable2 typeset.bmp
|
||||
</code></pre>
|
||||
|
||||
<p>And as an added IOCCC bonus: :-)</p>
|
||||
|
||||
<pre><code>./cable2 bonus.bmp
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>We can confirm that this is the first time the IOCCC has been used
|
||||
to peer-review a new research. We had quite a bit of fun with a sharpie and a
|
||||
scanner.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h1>OCR - Obfuscated Character Recognition of Handwritten Text</h1>
|
||||
|
||||
<p>This entry takes a BMP image file of hand-drawn (mouse-drawn?) text, specified as the first command-line parameter, and converts it to an ASCII text document. Magic!</p>
|
||||
|
||||
<p>BMP files created by most paint programs should work. The author recommends Paint.NET.</p>
|
||||
|
||||
<h2>Features</h2>
|
||||
|
||||
<ul>
|
||||
<li>Every printable ASCII character is recognized (94 characters plus space), plus a special bonus character.</li>
|
||||
<li>Input images can be any size (limited only by memory), containing any number of lines of text.</li>
|
||||
<li>BMP is really a mess of different formats, but the program supports most of them from Windows 3.1 and later.</li>
|
||||
<li>Hand-drawn characters in the input image can be variably spaced and positioned and be of any width or height, but the bigger the better for accurate recognition (300 pixels tall or more is recommended). Characters must be drawn with a stroke width of around 9 pixels, and separated from adjacent characters. (In Paint.NET a brush of width 9 works well, with anti-aliasing turned off.)</li>
|
||||
<li>You can use any colors you like for the text and background, even different colors for different text characters.</li>
|
||||
<li>If “color” is specified as the second command line parameter, the program’s output will also be in color, on ANSI/VTxxx terminals.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Why is this entry obfuscated/interesting?</h2>
|
||||
|
||||
<ul>
|
||||
<li>The source is presented as a beautiful moonlit scene, in which a quick brown fox jumps over a lazy dog. Far too often in software development is aesthetic nuance lost in the name of serious-sounding conventions like “GNU style”, but not here.</li>
|
||||
<li>Newcomers to C find it hard to learn all those different ways to control flow: for, while, if, do, goto, continue, break and heaven knows what else! So, in this program we only use for, so absolute beginners can get into the code straight away.</li>
|
||||
<li>To teach newcomers all the important features of C, we demonstrate the importance of the liberal use of short circuits, sequence points, the ternary operator, using x<sup>y</sup> or x-y instead of x!=y, using ~x in place of x!=-1 for conciseness, mixing x[y] and y[x] for variety, educational #define’s, and so on.</li>
|
||||
<li>main is the most useful function in all of C - so it is a mystery to the author why most programs use it only once. Here we use it over and over for maximum benefit.</li>
|
||||
<li>The number 42 is featured in the source to provide an answer to the judges' deeper questions.</li>
|
||||
<li>How are character colors converted from RGB in the input image to ANSI escape sequences? Clue: the weird macro P does the interesting part of it, but how?</li>
|
||||
<li>The program prints a string when the bonus character is detected. How does it do this? Clue: the string to print is defined in the macro $, but how can a string defined in that way ever get printed?</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Other notes</h2>
|
||||
|
||||
<ul>
|
||||
<li>The novel character recognition algorithm used has not been previously published and was developed by the author specifically for the contest. Should this entry win the IOCCC, it will be the first time (to the author’s knowledge) that the IOCCC has been used for peer review/publication of original research.</li>
|
||||
<li>OCR in general is a hard problem. Here, we only recognise one possible form for each character. You can see what the supported character shapes look like by looking at the examples in ascii.bmp. If you copy the shape of the character forms you find in there, recognition accuracy should be very good (95%+). A more “useful” version would extend the character stroke table to support multiple different commonly-used forms for each character.</li>
|
||||
<li>Despite being the largest possible IOCCC entry at 4096 bytes, it is also probably the smallest general-purpose OCR program ever written (including the character stroke data), maybe by several orders of magnitude.</li>
|
||||
<li>The author used an interesting compression algorithm (suggested by Gareth McCaughan - thank you!) to squeeze the character stroke table (containing around 2000 strokes for the whole ASCII character set) into a string constant of just 472 characters.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Bugs/features</h2>
|
||||
|
||||
<ul>
|
||||
<li>The width of input images must be a multiple of 4.</li>
|
||||
<li>Input images can be 8-bit grayscale, 24-bit color or 32-bit color only. 8-bit color and 16-bit color are not supported. If you use the “color” command-line feature, do not use a grayscale input file!</li>
|
||||
<li>Normal Windows BMP files are stored “upside-down”, i.e. the bottom line in the image is written first. Some (old) graphics programs actually write BMP files “top-to-bottom” and the program does not support such files.</li>
|
||||
<li>Using antialiased brush strokes to draw your letters is fine, however, antialiasing interferes with color detection in “color” mode.</li>
|
||||
<li>Only runs on little endian machines (since the BMP format is little endian, and endianness conversion would make the source too large for IOCCC rule 2).</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Compiler warnings</h2>
|
||||
|
||||
<p>clang warns about unused expression results, missing type specifiers, and incompatible pointer conversions - all just a fun consequence of the obfuscations.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,264 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Largest small system emulator</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Largest small system emulator</h1>
|
||||
|
||||
<p>Adrian Cable<br>
|
||||
<a href="mailto:adrian.cable@gmail.com">adrian.cable@gmail.com</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make cable3
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./cable3 bios-image-file floppy-image-file [harddisk-image-file]
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./runme
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This entry weighs in at a magical 4043 bytes (8086 nibbles, 28,301
|
||||
bits). It manages to implement most of the hardware in a 1980’s era
|
||||
IBM-PC using a few hundred fewer bits than the total number of
|
||||
transistors used to implement the original 8086 CPU.</p>
|
||||
|
||||
<p>If you are using OS X, the included sc-ioccc.terminal configuration file will
|
||||
correctly display console applications that use ANSI graphics.</p>
|
||||
|
||||
<p>Update: This entry now has its own web page <a href="http://www.megalith.co.uk/8086tiny">http://www.megalith.co.uk/8086tiny</a></p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h1>A tiny but highly functional PC emulator/virtual machine</h1>
|
||||
|
||||
<p>The author hereby presents, for the delectation (?) of the judges, a portable PC emulator/VM written specifically for the IOCCC which runs DOS, Windows 3.0, Excel, MS Flight Simulator, AutoCAD, Lotus 1-2-3 …</p>
|
||||
|
||||
<p>In just 4043 bytes of C source, you get a complete mid-late 1980s-era IBM-compatible PC, consisting of:</p>
|
||||
|
||||
<ul>
|
||||
<li>Intel 8086/186 CPU</li>
|
||||
<li>1MB RAM</li>
|
||||
<li>8072A 3.5" floppy disk controller (1.44MB/720KB)</li>
|
||||
<li>Fixed disk controller (supports a single hard drive up to 528MB)</li>
|
||||
<li>Hercules graphics card with 720x348 2-color graphics (64KB video RAM), and CGA 80x25 16-color text mode support</li>
|
||||
<li>8253 programmable interval timer (PIT)</li>
|
||||
<li>8259 programmable interrupt controller (PIC)</li>
|
||||
<li>8042 keyboard controller with 83-key XT-style keyboard</li>
|
||||
<li>MC146818 real-time clock</li>
|
||||
<li>PC speaker</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>The emulator uses the SDL graphics library for portability, and compiles for Windows, Mac OS X, Linux and probably most other 32-bit/64-bit systems too.</p>
|
||||
|
||||
<p>If you like living on the edge you can try building the emulator on a big endian machine, and you will get an emulation of a big endian 8086, a rather bizarre and somewhat useless beast. For everyone else, please run the emulator on a little endian machine.</p>
|
||||
|
||||
<p><em>RULE 2 ABUSE DISCLAIMER</em></p>
|
||||
|
||||
<ul>
|
||||
<li>cable3.c is 4043 bytes in length (half an 8086)</li>
|
||||
<li>iocccsize -i < cable3.c returns 1977 (the year the 4.77 MHz 8086 CPU was announced)</li>
|
||||
<li>Therefore, any suspicions the judges may have regarding rule 2 non-compliance may be well-intentioned but are groundless.</li>
|
||||
<li>Nonetheless, the author would like to apologise to the judges for the one-big-block-of-code nature of this entry, which turned out to be unavoidable. Hopefully the joys of this entry will make up for its shortcomings.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p><em>/RULE 2 ABUSE DISCLAIMER</em></p>
|
||||
|
||||
<h2>Why is this entry obfuscated/interesting?</h2>
|
||||
|
||||
<ul>
|
||||
<li>First of all the 8086 is a nightmare processor to emulate. Instruction codings are complex and irregular in size and structure, with multiple addressing modes and no consistent memory placement for operands, very often multiple possible encodings for the same instruction, and the bizarre segment:offset memory model. In addition, the 8086 has a number of bugs (e.g. PUSH SP), undocumented behaviours and instructions (e.g. AAM/AAD + imm8, SALC, flag behaviour for MUL/DIV, etc. etc.), and archaic features (e.g. parity/auxiliary flags) which all need to be emulated properly. Here we emulate every feature of the CPU pretty exactly (in fact better than most commercial clones of the processor e.g. the NEC V30), with the exception of the trap flag which no real software uses except for debuggers (although support for the TF can be added if deemed important, without exceeding the IOCCC size limit).</li>
|
||||
<li>In addition to the CPU we also emulate all the standard PC peripheral hardware. Parts of it are somewhat complete, much is rather dysfunctional (like the 8253/8259) but enough to support most real software.</li>
|
||||
<li>Nonetheless the source, while large for the IOCCC, is rather tiny for a functional PC emulator - around 2% of the size of the source of other open-source 8086 PC emulators with comparable functionality.</li>
|
||||
<li>In fact, this entry is just like happy hour - at 4043 bytes long, you pay for half the 8086, but you get served the whole one.</li>
|
||||
<li>Getting the code down to <= 4096 characters to meet the IOCCC rule 2 overall size limit required a good deal of effort (and appreciable risk of divorce), with obfuscation being a pretty unavoidable consequence in most places … for the rest, I use short circuit operators whenever possible, mix x[y] and y[x], don’t use any flow control keywords except for for, use K&R-style declarations to honor the C language’s rich cultural heritage (plus it saves a byte), and occasionally go overboard with nasty nested indexes to give things like this: –64[T=1[O=32[L=(X=*Y&7)&1,o=X/2&1,l]=0,t=(c=y)&7,a=c/8&7,Y]>>6,g=~-T?y:(n)y,d=BX=y,l]</li>
|
||||
<li>This entry highlights the importance of comments in C.</li>
|
||||
<li>This entry might result in an adjustment to the IOCCC size tool for the 2014 competition (see above).</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Compiling on different platforms</h2>
|
||||
|
||||
<p>This entry has been tested on Windows (compiled with MS Visual Studio 2010 and 2013), Mac OS X (clang and gcc), and Linux (clang and gcc). The Makefile supplied is good for Mac OS X, Linux and probably other UNIXes. I have received reports that the emulator works on Raspberry Pi/Android/ARM (you will need to compile with -fsigned-char) and iOS. You will need to adjust the Makefile if your system lacks sdl-config to correctly point to the SDL libraries and header files.</p>
|
||||
|
||||
<p>On UNIX-based systems we can get raw keystrokes using stty. However Windows has no stty. Therefore the Makefile includes a -D entry to define a “keyboard driver” KB which as it stands is suitable for UNIXes, but maybe not non-UNIX platforms. For example, for Windows/MS Visual Studio, instead of the Makefile definition of KB, use something slightly different - add the following entry to the Preprocessor Definitions list in the Project Properties page:</p>
|
||||
|
||||
<pre><code>KB=(kb=H(8),kbhit())&&(r[1190]=getch(),H(7))
|
||||
</code></pre>
|
||||
|
||||
<h2>POSIX portability note</h2>
|
||||
|
||||
<p>The code as supplied uses implicit function declarations for POSIX file I/O and in doing so assumes that file offsets are the same bit width as your architecture. For some systems (e.g. 32-bit Mac OS X, which uses 64-bit file offsets) this is not the case, and to run successfully on these systems, you will need to explicitly declare these functions by adding the appropriate include to the top of the source:</p>
|
||||
|
||||
<pre><code>#include <unistd.h>
|
||||
</code></pre>
|
||||
|
||||
<h2>Usage</h2>
|
||||
|
||||
<pre><code>./cable3 bios-image-file floppy-image-file [harddisk-image-file]
|
||||
</code></pre>
|
||||
|
||||
<p>PLEASE NOTE that under UNIXes the keyboard must be in raw mode for the emulator to work properly. Therefore the emulator is best run from a shell script that looks something like:</p>
|
||||
|
||||
<pre><code>stty cbreak raw -echo min 0
|
||||
./cable3 bios floppy.img harddisk.img
|
||||
stty cooked echo
|
||||
</code></pre>
|
||||
|
||||
<h2>To run the emulator - floppy mode only</h2>
|
||||
|
||||
<p>The simplest use of the emulator is with a single floppy boot disk image, like the fd.img provided, which is a FreeDOS boot disk.</p>
|
||||
|
||||
<p>Before running the emulator on a Unix-type system, stty needs to be used to put the keyboard into raw mode (and afterwards it needs to be put back to cooked). So, run the emulator using something like this script (provided as “runme”):</p>
|
||||
|
||||
<pre><code>stty cbreak raw -echo min 0
|
||||
./cable3 bios fd.img
|
||||
stty cooked echo
|
||||
</code></pre>
|
||||
|
||||
<h2>To run the emulator - floppy + HD mode</h2>
|
||||
|
||||
<p>Easiest to start with is to try a ready-made 40MB hard disk image containing a whole bunch of software:</p>
|
||||
|
||||
<p><a href="http://bitly.com/1bU8URK">http://bitly.com/1bU8URK</a></p>
|
||||
|
||||
<p>For the more adventurous, you can start off with (for example) a blank 40MB image file called hd.img made using e.g. mkfile. Then use:</p>
|
||||
|
||||
<pre><code>stty cbreak raw -echo min 0
|
||||
./cable3 bios fd.img hd.img
|
||||
stty cooked echo
|
||||
</code></pre>
|
||||
|
||||
<p>Preparing the hard disk for use in the emulator is done just like a real PC. Boot the emulator, and use FDISK to partition the hard disk. When it’s done FDISK will reboot the emulator. Then you can use FORMAT C: and you are done. The resulting disk image is in the right format to be mounted on a real Windows PC using e.g. OSFMount, on a Mac using hdiutil, or on Linux using mount, providing an easy way to copy files and programs to and from the disk image. Or, you can install programs from regular floppy disk images (see “Floppy disk support” below).</p>
|
||||
|
||||
<h2>Keyboard emulation</h2>
|
||||
|
||||
<p>The emulator simulates an XT-style keyboard controlled by an Intel 8042 chip on I/O port 0x60, generating IRQ1 and then interrupt 9 on each keypress. This is harder than it sounds because a real 8042 returns scan codes rather than the ASCII characters which the C standard I/O functions return. Rather than make the emulator less portable and use ioctl or platform-dependent equivalents to obtain real scan codes from the keyboard, the emulator BIOS does the reverse of a real PC BIOS and converts ASCII characters to scancodes, simulating press/release of the modifier keys (e.g. shift) as necessary to work like a “real” keyboard. The OS (DOS/Windows) then converts them back to ASCII characters and normally this process works seamlessly (although don’t be surprised if there are issues, for example, with non-QWERTY e.g. international keyboards).</p>
|
||||
|
||||
<p>Most of the time you can just type normally, but there are special sequences to get Alt+xxx and Fxxx.</p>
|
||||
|
||||
<p>To send an Alt+XXX key combination, press Ctrl+A then the key, so for example to type Alt+F, press Ctrl+A then F.</p>
|
||||
|
||||
<p>To send an Fxx key, press Ctrl+F then a number key. For example, to get the F4 key, press Ctrl+F then 4. To get F10, press Ctrl+F then 0.</p>
|
||||
|
||||
<p>To send a Page Down key, press Ctrl+F then O. To send a Page Up key, press Ctrl+F then E. Other key combinations are left for the discovery of the user.</p>
|
||||
|
||||
<h2>Text mode support</h2>
|
||||
|
||||
<p>The emulator supports both text output via the standard BIOS interrupt 0x10 interface, and also direct video memory access (one page, 4KB video RAM at segment B800) in 80x25 CGA 16-color text mode.</p>
|
||||
|
||||
<p>BIOS text output calls are converted to simple writes to stdout. Direct video memory accesses for the 80x25 CGA color text mode are converted to ANSI terminal escape sequences. If you are using a terminal which does not support ANSI (e.g. you are compiling the emulator with MS VC++ and running in a Windows console window) then PC applications that directly write to video memory in text mode may be unusable.</p>
|
||||
|
||||
<p>Most CGA I/O ports are not supported except for the CGA refresh register at 0x3DA, which some applications use for timing or synchronisation.</p>
|
||||
|
||||
<p>The regular PC character code page (437) includes various extended ASCII characters for things like line drawing. You might want to set the font in your terminal program to something that includes these (e.g. on Mac OS X there is a freeware font called Perfect DOS VGA 437 which does the trick).</p>
|
||||
|
||||
<p>Occasionally a DOS application on exit will leave the video hardware in an odd state which confuses the emulator, resulting in subsequent text output being invisible. If this happens, just use the DOS CLS command to clear the screen and all will be well again.</p>
|
||||
|
||||
<h2>Graphics mode support</h2>
|
||||
|
||||
<p>Hercules 720x348 monochrome graphics mode emulation is implemented using SDL. Most Hercules features are supported via the normal I/O interface on ports 0x3B8 and 0x3BA including video memory bank switching (segments B000/B800), which some games use for double-buffered graphics. CGA graphics modes are not supported.</p>
|
||||
|
||||
<p>When an application enters graphics mode, the emulator will open an SDL window (which will be closed when the application goes back to text mode). Including code to redirect keystrokes from the SDL window to the main terminal window would have busted the IOCCC size limits, so you need to keep the main emulator terminal window in focus at all times even when you are doing graphics (sounds a little odd but you will get used to it).</p>
|
||||
|
||||
<p>On UNIXes, SDL will automatically output graphics via X11 if the DISPLAY environment variable is set up.</p>
|
||||
|
||||
<h2>Dual graphics card support</h2>
|
||||
|
||||
<p>Some applications (e.g. AutoCAD) support a PC configuration with a CGA card and a Hercules card, for simultaneous text and graphics output on different displays. The emulator simulates this configuration, too, using separate windows for the (terminal) text and (SDL) graphics displays.</p>
|
||||
|
||||
<h2>BIOS</h2>
|
||||
|
||||
<p>Like a real PC, the emulator needs a BIOS to do anything useful. Here we use a custom BIOS, written from scratch specifically for the emulator. Source code for the BIOS (written in 8086 assembly language) which compiles with the freely-available NASM x86 assembler is available from the author on request.</p>
|
||||
|
||||
<p>The BIOS implements the standard interrupt interfaces for video, disk, timer, clock and so on, much as a “real” PC BIOS does, and also a small timer-controlled video driver to convert video memory formatting into ANSI escape sequences when the emulator is in text mode.</p>
|
||||
|
||||
<h2>CPU and memory emulation</h2>
|
||||
|
||||
<p>Memory map is largely as per a real PC, with interrupt vector table at 0:0, BIOS data area including keyboard buffer at 40:0, CGA text video memory at B800:0, Hercules dual-bank graphics memory at B000/B800:0, and BIOS at F000:100. Unlike a real PC, in the emulator the CPU registers are memory-mapped (at F000:0), which enables considerable optimisation of the emulator’s instruction execution unit by permitting the unification of memory and register operations, while remaining invisible to the running software.</p>
|
||||
|
||||
<p>CPU supports the full 8086/186 instruction set. Due to the complexities of the 8086’s arbitrary-length instruction decoding and flags, 8086 instructions are first converted to a simpler intermediate format before being executed. This conversion, along with instruction lengths and how each instruction modifies the flags, is assisted by some lookup tables which form part of the BIOS binary.</p>
|
||||
|
||||
<p>The CPU also implements some “special” two-byte opcodes to help the emulator talk with the outside world. These are:</p>
|
||||
|
||||
<pre><code>0F 00 - output character in register AL to terminal
|
||||
0F 01 - write real-time clock data (as returned by localtime) to memory location ES:BX
|
||||
0F 02 - read AX bytes from disk at offset 512*(16*SI+BP) into memory location ES:BX. Disk is specified in DL (0 = hard disk, 1 = floppy disk)
|
||||
0F 03 - write AX bytes at memory location ES:BX to disk at offset 512*(16*SI+BP). Disk is specified in DL as per 0F 02
|
||||
</code></pre>
|
||||
|
||||
<p>Emulator exit is triggered if CS:IP == 0:0 (which would be nonsensical in real software since this is where the interrupt vector table lives). The supplied Dos6.22.img disk includes a small program QUITEMU.COM which contains a single JMP 0:0 instruction, to allow the user to easily quit the emulator without shutting down the terminal.</p>
|
||||
|
||||
<h2>Floppy disk support</h2>
|
||||
|
||||
<p>Emulates a 3.5" high-density floppy drive. Can read, write and format 1.44MB disks (18 sectors per track, 2 heads) and 720KB disks (9 sectors per track, 2 heads).</p>
|
||||
|
||||
<p>If you want to install your own software from floppy images (downloaded from e.g. Vetusware), the easiest way to “change disks” is to copy each disk image in turn over the floppy image file you specify on the command line. Don’t forget to put your original boot disk back at the end!</p>
|
||||
|
||||
<h2>Hard disk support</h2>
|
||||
|
||||
<p>Supports up to 1023 cylinders, 63 sectors per track, 63 heads for disks up to 528MB.</p>
|
||||
|
||||
<p>Disk image format used is a subset of the standard “raw” format used by most disk image mount tools. In general, disk images prepared by the emulator will work with disk image tools and other emulators, but not the other way around.</p>
|
||||
|
||||
<p>The emulator uses a particularly dumb algorithm to derive a simulated cylinder/sector/head geometry from the disk image file’s size. This algorithm often results in not all the space in the image file being available for disk partitions. For example, creating a 40,000,000 byte image file results in DOS FDISK seeing only 31.9MB as the volume size.</p>
|
||||
|
||||
<p>Note that unlike a real PC, the emulator cannot boot from a hard disk (image). Therefore, you will always need to use a bootable floppy image, even if after boot everything runs from the HD.</p>
|
||||
|
||||
<h2>Mouse</h2>
|
||||
|
||||
<p>No mouse is emulated.</p>
|
||||
|
||||
<h2>Real-time clock</h2>
|
||||
|
||||
<p>Reading the RTC (both time and date) is emulated via the standard BIOS clock interface, pulling the time/date from the host computer. Setting the time or date is not supported.</p>
|
||||
|
||||
<h2>Timers</h2>
|
||||
|
||||
<p>A countdown timer on I/O port 0x40 is simulated in a broken way which is good enough for most software. On a real PC this has a default period of 55ms and is programmable. No programmability is supported in the emulator and the period may be about right or completely wrong depending on the actual speed of your computer.</p>
|
||||
|
||||
<p>On a real PC, IRQ0 and interrupt 8 are fired every 55ms. The emulator tries to do the same but again, the delay period is uncalibrated so you get what you get.</p>
|
||||
|
||||
<h2>PC speaker</h2>
|
||||
|
||||
<p>Beeps only, through the console.</p>
|
||||
|
||||
<h2>Software supported</h2>
|
||||
|
||||
<p>The emulator will run practically any software a real PC (of the spec listed at the top of this file) can. The author has tested a number of OSes/GUIs (MS-DOS 6.22, FreeDOS 0.82pl3, Windows 3.0, DESQview 2.8), professional software (Lotus 1-2-3 2.4 and AsEasyAs 5.7 for DOS, Excel 2.1 for Windows, AutoCAD 2.5, WordStar 4), programming languages (QBASIC, GWBASIC, Turbo C++), games (Carrier Command, Police Quest, and a bunch of freeware Windows games), and diagnostic/benchmark software (Manifest, Microsoft MSD, InfoSpot, CheckIt) and all of them run well.</p>
|
||||
|
||||
<p>Screenshots of some of these applications running (on Mac OS X) are provided for the impatient.</p>
|
||||
|
||||
<h2>Compiler warnings</h2>
|
||||
|
||||
<p>A lot of compiler warnings are produced by clang. Missing type specifiers, control reaching the end of functions without returning values, incompatible pointer type assignments, and some precedence warnings, all necessary to keep the source size down. Other compilers are likely to produce similar warnings.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,140 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Best sparkling utility</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best sparkling utility</h1>
|
||||
|
||||
<ol type="a">
|
||||
<li>David Lowe<br>
|
||||
434 Tenney Drive<br>
|
||||
Rogue River, OR<br>
|
||||
97537<br>
|
||||
<a href="mailto:j.david.lowe@gmail.com">j.david.lowe@gmail.com</a><br>
|
||||
<a href="http://www.pootpoot.net/">http://www.pootpoot.net/</a></li>
|
||||
</ol>
|
||||
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make dlowe
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./dlowe [numbers...]
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./dlowe 0 1 2 3 4 5 6 7
|
||||
./dlowe 16 32 64 128
|
||||
|
||||
echo sparkline of file sizes: `wc -c * | awk '{print $1}' | xargs ./dlowe`
|
||||
|
||||
./dlowe 0
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>We liked how this entry used Unicode, specifically UTF-8, in a somewhat obfuscated way.</p>
|
||||
|
||||
<p>Also, why doesn’t it crash, and produces a correct output when called with one argument
|
||||
or when all arguments are equal?</p>
|
||||
|
||||
<p>For extra fun, compile and run</p>
|
||||
|
||||
<pre><code>#include <stdio.h>
|
||||
int main() {
|
||||
printf("%d %d %d\n", (int)(-1.0/0.0), (int)(0.0/0.0), (int)(1.0/0.0));
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
<p>with gcc and clang.</p>
|
||||
|
||||
<p>With GCC (4.7.2), we get</p>
|
||||
|
||||
<pre><code>-2147483648 -2147483648 -2147483648
|
||||
</code></pre>
|
||||
|
||||
<p>and with clang (3.3), we get</p>
|
||||
|
||||
<pre><code>-2147483648 0 2147483647
|
||||
</code></pre>
|
||||
|
||||
<p>Which one is correct? :)</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h1>sparkl</h1>
|
||||
|
||||
<p>A tiny implementation of command-line ‘sparkline’ data visualization.</p>
|
||||
|
||||
<h2>Synopsis</h2>
|
||||
|
||||
<pre><code>$ sparkl 0 1 2 3 4 5 6 7
|
||||
▁▂▃▄▅▆▇▉
|
||||
|
||||
$ echo sparkline of file lengths: `wc -c * | awk '{print $1}' | xargs sparkl`
|
||||
sparkline of file sizes: ▁▁▁▃▃▂▁▂▁▁▉
|
||||
</code></pre>
|
||||
|
||||
<h2>Description</h2>
|
||||
|
||||
<p>This is a handy little tool for visualizing numeric series from the
|
||||
command-line, using ‘sparklines’. Pass it a numeric series as arguments, and
|
||||
sparkl will display a sparkline graph, which you can use to very quickly get a
|
||||
sense of the shape of your data.</p>
|
||||
|
||||
<h2>Limitations</h2>
|
||||
|
||||
<ul>
|
||||
<li>Crashes with 0 arguments. It’d be trivial to fix, but adds a few bytes to the
|
||||
code.</li>
|
||||
<li>Produces bogus graphs when given > about 5000 arguments.</li>
|
||||
<li>Only works if your terminal is utf-8 and your font supports the 8 glyphs
|
||||
used.</li>
|
||||
<li>Produces a few harmless compiler warnings.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Obfuscation</h2>
|
||||
|
||||
<p>The code is very terse. I was torn between submitting this version, and a
|
||||
one-line version compressed using a couple more -D flags.</p>
|
||||
|
||||
<p>Hand-rolled utf-8 sequence, magic numbers (what’s that 7 for?), meaningless
|
||||
variable names, reused variables, and so on.</p>
|
||||
|
||||
<h2>Acknowledgements</h2>
|
||||
|
||||
<p>Edward Tufte invented sparklines (among other things.) Brilliant.</p>
|
||||
|
||||
<p>Zach Holman’s <a href="https://github.com/holman/spark">‘spark’ utility</a> was absolutely
|
||||
an inspiration.</p>
|
||||
|
||||
<p>As I was writing up this description, I discovered I’m not the first person to
|
||||
write an obfuscated C sparkline utility! Vicent Martí created
|
||||
<a href="https://gist.github.com/vmg/1368661">this one</a> years (!) ago. (My
|
||||
implementation is completely independent.)</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,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.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most lazy SKIer</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most lazy SKIer</h1>
|
||||
|
||||
<p>Yusuke Endoh<br>
|
||||
<a href="mailto:mame@ruby-lang.org">mame@ruby-lang.org</a><br>
|
||||
<a href="https://github.com/mame/">https://github.com/mame/</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make
|
||||
</code></pre>
|
||||
|
||||
<p>This builds endoh1, echo, hello, and tac.</p>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./endoh1 [file.lazy]
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./endoh1 hello.lazy
|
||||
./hello
|
||||
echo Hello | ./echo
|
||||
./tac < endoh1.c
|
||||
</code></pre>
|
||||
|
||||
<p>Be patient with the last one.</p>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>We liked this entry because it can serve as a standalone program as well as an include file; and, as usual,
|
||||
because its input data is at least as obfuscated as the program itself.</p>
|
||||
|
||||
<p>This entry can be considered an abuse of the GCC’s optimizer; it takes GCC about 4x longer to compile it
|
||||
with -O3 than without, compared to clang’s 2x.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Remarks</h3>
|
||||
|
||||
<pre><code>$ less prog.c
|
||||
$ gcc -o prog prog.c
|
||||
$ ./prog
|
||||
</code></pre>
|
||||
|
||||
<p>… Isn’t there any more to it?</p>
|
||||
|
||||
<p>Yes, of course.</p>
|
||||
|
||||
<p>This is a tool <em>for C programmers</em> to play the <a href="http://en.wikipedia.org/wiki/SKI_combinator_calculus">SKI combinator calculus</a>,
|
||||
especially, <a href="redacted">Lazy K</a>.</p>
|
||||
|
||||
<p>This program will shine when it is used as a library.
|
||||
For example, <code>hello.lazy</code> is a “Hello world” program written in Lazy K.</p>
|
||||
|
||||
<pre><code>$ lazy hello.lazy
|
||||
Hello, world!
|
||||
</code></pre>
|
||||
|
||||
<p>where <code>lazy</code> is <a href="redacted">a reference implementation of Lazy K</a>.
|
||||
At the same time, <code>hello.lazy</code> is <em>a valid C program</em> that uses <code>prog.c</code> as a library.</p>
|
||||
|
||||
<pre><code>$ gcc -o hello -xc hello.lazy
|
||||
$ ./hello
|
||||
Hello, world!
|
||||
</code></pre>
|
||||
|
||||
<p>In other words, this program is a kind of <a href="http://en.wikipedia.org/wiki/Polyglot_%28computing%29">polyglot</a>.</p>
|
||||
|
||||
<p>The usage is simple:
|
||||
you just have to wrap Lazy K program with <code>#include "prog.c"</code>.
|
||||
Note that <code>#</code> is a comment in Lazy K.</p>
|
||||
|
||||
<h3>Obfuscation</h3>
|
||||
|
||||
<p>… is inherent in SKI combinator calculus :-)</p>
|
||||
|
||||
<p>In addition, it uses various hacks to parse SKI code as C,
|
||||
and to satisfy IOCCC’s size rule.</p>
|
||||
|
||||
<ul>
|
||||
<li>Abuse of function pointers</li>
|
||||
<li>Code duplication by macros</li>
|
||||
<li>Short coding</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>These led to the good obfuscation.
|
||||
See Spoiler section in detail, if you need.</p>
|
||||
|
||||
<h3>Limitation</h3>
|
||||
|
||||
<p>This program supports only “Combinator-calculus style notation” of Lazy K.
|
||||
“Unlambda style” and “Iota and Jot” style are not supported.
|
||||
Also, it requires a space between identifiers.
|
||||
In short, use <code>(S K)</code> instead of <code>(SK)</code>, “`sk”, <code>**i*i*i*ii*i*i*ii</code>,
|
||||
or <code>11111100011100</code>.</p>
|
||||
|
||||
<p>Huge memory may be required to compile the program
|
||||
(about 300 MB on my machine).</p>
|
||||
|
||||
<p>In addition, there are some limitations (and workarounds)
|
||||
mentioned in Spoiler section.
|
||||
But I think it wouldn’t matter only when you run the attached programs.</p>
|
||||
|
||||
<h3>Portability</h3>
|
||||
|
||||
<p>I confirmed that the program successfully worked
|
||||
with the following compilers.</p>
|
||||
|
||||
<ul>
|
||||
<li>gcc 4.6.3 [Linux, Mac OS X]</li>
|
||||
<li>clang 3.0 [Linux, Mac OS X]</li>
|
||||
<li>tcc 0.9.26 [Linux]
|
||||
|
||||
<ul>
|
||||
<li>N.B. tcc 0.9.25 seems to have a bug and fails to run it.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Recent compilers with <code>-Wall -W -Wextra -pedantic</code> say nothing.</p>
|
||||
|
||||
<pre><code>gcc -Wall -W -Wextra -pedantic prog.c
|
||||
clang -Wall -W -Wextra -pedantic prog.c
|
||||
tcc -Wall -W -Wextra -pedantic prog.c
|
||||
</code></pre>
|
||||
|
||||
<p>I think it will work on almost all platforms. I confirmed:</p>
|
||||
|
||||
<ul>
|
||||
<li>Ubuntu Linux</li>
|
||||
<li>Mac OS X</li>
|
||||
<li>Raspberry PI</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>To check whether the program is specified on the command line
|
||||
or included from another source file,
|
||||
the program uses a predefined macro <code>__INCLUDE_LEVEL__</code>.
|
||||
It is a gcc extention, and also supported by clang.
|
||||
If your compiler does not support it,
|
||||
you cannot use the program as a library.
|
||||
But you can compile and run it as a standalone program, at least.
|
||||
In fact, tcc does not support the macro, but does work.</p>
|
||||
|
||||
<h3>Spoiler (rot13)</h3>
|
||||
|
||||
<p>Gur jubyr cebtenz vf vagrecergrq ol znpeb rkcnafvba.
|
||||
Sbe rknzcyr, <code>F (X V)</code> vf genafyngrq gb n abezny P pbqr, <code>(f)((x)(v))</code>,
|
||||
be fvzcyl <code>f(x(v))</code>.
|
||||
Guvf rkcerffvba ergheaf na nofgenpg flagnk gerr,
|
||||
naq <code>cebt.p</code> rinyhngrf vg.
|
||||
Guvf cebtenz hfrf irel fvzcyr “grez erjevgvat” nccebnpu
|
||||
sbe rinyhngvat FXV pbzovangbe pnyphyhf.
|
||||
Gur erjevgvat ehyrf ner fubja va gur funcr bs gur pbqr.</p>
|
||||
|
||||
<h4>Nohfr bs shapgvba cbvagref</h4>
|
||||
|
||||
<p>Pbafvqre n frdhrapr bs shapgvba nccyvpngvbaf va P:</p>
|
||||
|
||||
<pre><code>f(k)(k)(k)(k)...
|
||||
</code></pre>
|
||||
|
||||
<p>Jung glcr fubhyq <code>f</code> unir?
|
||||
Hasbeghangryl, P qbrf <em>abg</em> cebivqr n “erphefvir glcr”,
|
||||
fhpu nf <code>glcrqrs s (*s)();</code>.
|
||||
Fb, V hfrq n urniyl arfgrq shapgvba cbvagre glcr:</p>
|
||||
|
||||
<pre><code>glcrqrs ibvq *(*(*(*...(*(s))()...)())())
|
||||
</code></pre>
|
||||
|
||||
<p>Guvf yvzvgf ubj znal nethzragf bar shapgvba pna or pbafrphgviryl nccyvrq gb.
|
||||
Ohg lbh pna vapernfr gur ahzore ol gjrnxvat gur qrsvavgvba bs znpeb <code>c</code>.</p>
|
||||
|
||||
<h4>Pbqr qhcyvpngvba ol znpebf</h4>
|
||||
|
||||
<p>Arkg, jr arrq gb rapbqr “pybfherf”.
|
||||
N pybfher vf n shapgvba gbtrgure jvgu na raivebazrag
|
||||
juvpu vf n ersrerapr gb aba-ybpny inevnoyr.</p>
|
||||
|
||||
<p>Va guvf pnfr, jr arrq fbzrguvat gung:</p>
|
||||
|
||||
<ul>
|
||||
<li>vf pnyynoyr vgfrys,</li>
|
||||
<li>vagreanyyl cbffrffrf n ersrerapr gb nabgure pybfher nf n aba-ybpny inevnoyr, naq</li>
|
||||
<li>nccyvrf gur vagreany pybfher gb na nethzrag jura vg vf pnyyrq.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Ubjrire, ab glcr va P vf pnyynoyr naq unf n ersrerapr ng gur fnzr gvzr.
|
||||
(Vg vf srnfvoyr ol qlanzvp pbqr trarengvba, ohg vg vf sne sebz cbegnoyr.)</p>
|
||||
|
||||
<p>Fb, V nqqerffrq guvf vffhr ol trarengvat znal shapgvba qrsvavgvbaf
|
||||
fgngvpnyyl ol (no)hfvat znpebf:</p>
|
||||
|
||||
<pre><code>ibvq *k1; ibvq s1(ibvq *l) { erghea nccyl(k1, l); }
|
||||
ibvq *k2; ibvq s2(ibvq *l) { erghea nccyl(k2, l); }
|
||||
ibvq *k3; ibvq s3(ibvq *l) { erghea nccyl(k3, l); }
|
||||
...
|
||||
ibvq *(u[]) = { s1, s2, s3, ... }
|
||||
</code></pre>
|
||||
|
||||
<p>naq ol nyybgvat rnpu bs gurz jura n pybfher vf arrqrq.</p>
|
||||
|
||||
<p>Guvf yrnqf gb nabgure yvzvgngvba:
|
||||
gur ahzore bs cer-qrsvarq pybfherf yvzvgf
|
||||
ubj znal vaqragvsvref (<code>F</code> <code>X</code> <code>V</code>) bar cebtenz pna hfr.
|
||||
Ohg lbh pna vapernfr guvf ahzore
|
||||
ol gjrnxvat gur qrsvavgvba bs znpeb <code>N</code> <code>O</code> <code>P</code> naq <code>Q</code>.
|
||||
(Abgr gung pybfherf ner nyybggrq bayl jura cnefvat;
|
||||
nsgre gur rinyhngvba fgnegf, “bhg bs pybfher” pnaabg bpphe.)</p>
|
||||
|
||||
<h4>Fubeg pbeqvat</h4>
|
||||
|
||||
<p>Guvf znetva vf gbb aneebj gb pbagnva n qrgnvyrq rkcynangvba.
|
||||
Vafgrnq, V whfg nfx lbh bar dhrfgvba.
|
||||
Pna lbh gryy jung <code>i f[]={0,0,f+6,f+2,f+4,f,f+3,f+5,f+1};</code> vf?
|
||||
V sbhaq guvf ol hfvat FZG fbyire.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,117 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most recyclable</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most recyclable</h1>
|
||||
|
||||
<p>Yusuke Endoh<br>
|
||||
<a href="mailto:mame@ruby-lang.org">mame@ruby-lang.org</a><br>
|
||||
<a href="https://github.com/mame/">https://github.com/mame/</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make endoh2
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code> make all
|
||||
</code></pre>
|
||||
|
||||
<p>You’ll need to have Ruby installed to run all the automated check</p>
|
||||
|
||||
<pre><code>make check
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>cat jpeg.c
|
||||
</code></pre>
|
||||
|
||||
<p>Look at jpeg.jpg in an image viewer program.</p>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This is a program which, when fed its own source, generates a program that almost is its whitespace inverse,
|
||||
which, in its order, generates a JPEG file (speaking of file size abuse, that is about 16.4 times
|
||||
larger than a PBM file with the same image, but the source was also abusing the size counting program…)</p>
|
||||
|
||||
<p>Don’t pay attention to the OCR <del>behind the ruby curtain</del> — it’s a straightforward bitmap comparison.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Highlights</h3>
|
||||
|
||||
<ul>
|
||||
<li>LZ77-like compression for font and template data</li>
|
||||
<li>tiny JPEG encoder
|
||||
|
||||
<ul>
|
||||
<li>Zig-zag space-filling curve</li>
|
||||
<li>Discrete cosine transform</li>
|
||||
<li>JPEG Huffman encoding (cheeting)</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Notes</h3>
|
||||
|
||||
<p>I picked JPEG instead of PNG, GIF, or BMP
|
||||
because it is the most difficult to generate.
|
||||
I believe that the JPEG encoder is the world’s smallest ever.
|
||||
Nevertheless, the program was too big to meet the IOCCC’s size rule.
|
||||
So I created a smaller bootstrap program that generates the main program.
|
||||
<code>prog.c</code> contains fragments of the main program <em>as a comment</em>
|
||||
which <code>iocccsize -i</code> does <em>not</em> count.
|
||||
I gratefully think the judges for spoiling the size rule this year.</p>
|
||||
|
||||
<p>I think the program will work on any major platforms and compilers.</p>
|
||||
|
||||
<h3>Legal</h3>
|
||||
|
||||
<p>This program uses (a part of) Proggy Tiny Fonts
|
||||
which is distributed in MIT License:</p>
|
||||
|
||||
<pre><code>Copyright (c) 2004, 2005 Tristan Grimmer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
</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-2015,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,234 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most tweetable 1-liner</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most tweetable 1-liner</h1>
|
||||
|
||||
<p>Yusuke Endoh<br>
|
||||
<a href="mailto:mame@ruby-lang.org">mame@ruby-lang.org</a><br>
|
||||
<a href="https://github.com/mame/">https://github.com/mame/</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make endoh3
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./endoh3
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<p>Trying this out will depend on how your system can play sounds. The author’s
|
||||
remarks include some options for different operating systems.</p>
|
||||
|
||||
<p>The simplest way is to create a .wav file and have your system play that.</p>
|
||||
|
||||
<pre><code>echo 'CDEFGABc' | ./endoh3 | ruby wavify.rb > cde.wav
|
||||
</code></pre>
|
||||
|
||||
<p>There are also some other musical samples, twinkle.abc and menuet.abc.</p>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This program can tweet out a tune and is small enough to tweet.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Remarks</h3>
|
||||
|
||||
<p>This is a sound synthesizer for a subset of <a href="http://en.wikipedia.org/wiki/ABC_notation">ABC music notation</a>.</p>
|
||||
|
||||
<p>Try:</p>
|
||||
|
||||
<pre><code>gcc -o prog prog.c
|
||||
echo "CDEFGABc" | ./prog > /dev/dsp
|
||||
</code></pre>
|
||||
|
||||
<p>If <code>/dev/dsp</code> is not available on your system, use an OSS sound wrapper such
|
||||
as <code>padsp</code> or <code>aoss</code>:</p>
|
||||
|
||||
<pre><code>echo "CDEFGABc" | ./prog | padsp tee /dev/dsp > /dev/null
|
||||
</code></pre>
|
||||
|
||||
<p>If you are using Mac OS X, try <a href="http://sox.sourceforge.net/">sox</a>:</p>
|
||||
|
||||
<pre><code>echo "CDEFGABc" | ./prog | sox -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio
|
||||
</code></pre>
|
||||
|
||||
<p>If they do not work, use the attached script to convert the output
|
||||
into a wave file format:</p>
|
||||
|
||||
<pre><code>echo "CDEFGABc" | ./prog | ruby wavify.rb > cde.wav
|
||||
</code></pre>
|
||||
|
||||
<p>and play <code>cde.wav</code>.</p>
|
||||
|
||||
<p>You can enjoy some music scores that I attached:</p>
|
||||
|
||||
<pre><code>cat twinkle.abc | ./prog > /dev/dsp
|
||||
cat menuet.abc | ./prog > /dev/dsp
|
||||
</code></pre>
|
||||
|
||||
<h3>Obfuscation</h3>
|
||||
|
||||
<p>The following sequence of questions may be helpful to understand the program.</p>
|
||||
|
||||
<ul>
|
||||
<li>How does it convert ABC notes into the frequency?</li>
|
||||
<li>What is <code>89/84.</code>? I found it by using Stern-Brocot tree.</li>
|
||||
<li>How does it generate a wave? Hint: it generates a saw wave.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Limitation</h3>
|
||||
|
||||
<p>The following features are supported:</p>
|
||||
|
||||
<ul>
|
||||
<li>Notes:
|
||||
|
||||
<ul>
|
||||
<li><code>C</code> <code>D</code> <code>E</code> <code>F</code> <code>G</code> <code>A</code> <code>B</code> (in low octave)</li>
|
||||
<li><code>c</code> <code>d</code> <code>e</code> <code>f</code> <code>g</code> <code>a</code> <code>b</code> (in high octave)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Rests: <code>z</code></li>
|
||||
<li>Note lengths:
|
||||
|
||||
<ul>
|
||||
<li><code>A</code> (an eighth note)</li>
|
||||
<li><code>A2</code> (a quarter note)</li>
|
||||
<li><code>A3</code> (a dotted quarter note)</li>
|
||||
<li><code>A4</code> (a half note)</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>The following features are <em>not</em> supported:</p>
|
||||
|
||||
<ul>
|
||||
<li>Sharp and flat: <code>^C</code> <code>_C</code>
|
||||
|
||||
<ul>
|
||||
<li>But it is possible to emit the half tones. Do you see how?</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Shorter note lengths than 1: <code>C1/2</code>
|
||||
|
||||
<ul>
|
||||
<li>But you can use <code>C0.5</code> instead.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Higher and lower notes: <code>c'</code> <code>C,</code></li>
|
||||
<li>Any meta fields: <code>T:title</code> <code>L:1/4</code></li>
|
||||
<li>Bar line, repeat, ties and slurs, and everything else.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Known Bugs</h3>
|
||||
|
||||
<p>You can <em>not</em> write a note length immediately followed by a note <code>E</code>,
|
||||
such as <code>C2E2</code>.
|
||||
Can you know why?
|
||||
You can work it around by inserting a whitespace: <code>C2 E2</code>.</p>
|
||||
|
||||
<h3>Portability</h3>
|
||||
|
||||
<p>I tested it on:</p>
|
||||
|
||||
<ul>
|
||||
<li>Ubuntu 13.10 with gcc 4.7.3, clang 3.2, and tcc 0.9.25.</li>
|
||||
<li>Mac OS X 10.6 with gcc 4.2.1 and clang 1.7.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Legal</h3>
|
||||
|
||||
<p>I believe that all the scores that I attached are out-of-copyright.</p>
|
||||
|
||||
<p>I did write a score of the Happy Birthday song too.
|
||||
(It does not matter because the song is out-of-copyright in my country.)
|
||||
But I do not attach it to protect you from W****r.</p>
|
||||
|
||||
<p>For the same reason, do not play a score that contains only <code>z1092</code>.
|
||||
You know, it is <a href="http://en.wikipedia.org/wiki/4%E2%80%B233%E2%80%B3">“the famous song”</a>.</p>
|
||||
|
||||
<h3>Spoiler (rot13)</h3>
|
||||
|
||||
<p>Urer vf n zntvpny rkcerffvba juvpu V sbhaq ol oehgr-sbepr:</p>
|
||||
|
||||
<pre><code>(p % 32 + 5) * 9 / 5 % 13 + a / 32 * 12 - 22
|
||||
</code></pre>
|
||||
|
||||
<p>Vagrerfgvatyl, vg pbairegf na NFPVV ahzore bs NOP abgrf
|
||||
gb gur pbeerfcbaqvat gbar ahzore.</p>
|
||||
|
||||
<pre><code>'P' (NFPVV 67) => 3
|
||||
'Q' (NFPVV 68) => 5
|
||||
'R' (NFPVV 69) => 7
|
||||
'S' (NFPVV 70) => 9
|
||||
'T' (NFPVV 71) => 10
|
||||
'N' (NFPVV 65) => 12
|
||||
'O' (NFPVV 66) => 14
|
||||
'p' (NFPVV 99) => 15
|
||||
'q' (NFPVV 100) => 17
|
||||
'r' (NFPVV 101) => 19
|
||||
's' (NFPVV 102) => 20
|
||||
't' (NFPVV 103) => 22
|
||||
'n' (NFPVV 97) => 24
|
||||
'o' (NFPVV 98) => 26
|
||||
</code></pre>
|
||||
|
||||
<p>Ol gur jnl, lbh pna jevgr n unys-gbar ol gur sbyybjvat punenpgref.</p>
|
||||
|
||||
<pre><code>'X' => 4 (= P#)
|
||||
'Y' => 6 (= Q#)
|
||||
'H' => 8 (= S#)
|
||||
'I' => 11 (= T#)
|
||||
'C' => 13 (= N#)
|
||||
</code></pre>
|
||||
|
||||
<p>Abgr gung gur gbar ahzoref fvzcyl rahzrengr gur frzv-gbar fgrcf.
|
||||
Fb jr pna pnyphyngr gur serdhrapl rnfvyl: <code>cbj(2, a / 12.0)</code>.
|
||||
Gura, ubj pna jr pnyphyngr <code>cbj</code> jvgubhg <code>zngu.u</code>?
|
||||
<code>cbj(2, 1.0 / 12.0)</code> vf nccebkvzngrq ol <code>89/84.</code>.
|
||||
(V sbhaq guvf nccebkvzngvba ol hfvat <a href="uggc://ra.jvxvcrqvn.bet/jvxv/Fgrea%R2%80%93Oebpbg_gerr">Fgrea-Oebpbg gerr</a>.)
|
||||
Jr pna tnva gur serdhrapl ol zhygvcylvat gur inyhr <code>a</code> gvzrf.</p>
|
||||
|
||||
<p>Svanyyl, gur sbyybjvat pbqr trarengrf n fnj jnir:</p>
|
||||
|
||||
<pre><code>sbe(p = 0; p < yra; p++) chgpune(n = a * Q);
|
||||
</code></pre>
|
||||
|
||||
<p>jurer <code>Q</code> vf n serdhrapl naq <code>n</code> vf n inevnoyr jubfr glcr vf pune.
|
||||
Ol nffvtavat sybng gb pune inevnoyr, gur vzcyvpvg glcr pbairegvba vf cresbezrq sebz sybng gb pune (zbqhyb 256).
|
||||
(Fgevpgyl fcrnxvat, guvf orunivbe vf haqrsvarq nppbeqvat gb 6.3.1.4 va P99;
|
||||
lbh pna ercynpr vg jvgu <code>(ybat)(a*Q)</code> vs lbh ner crqnagvp.)</p>
|
||||
|
||||
<p>Nyy gung jnf yrsg jnf gb pbzovar naq pbaqrafr gur pbzcbaragf.
|
||||
Gur xrl vf fdhnfuvat gurz vagb whfg bar sbe-ybbc.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,142 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most solid</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most solid</h1>
|
||||
|
||||
<p>Yusuke Endoh<br>
|
||||
<a href="mailto:mame@ruby-lang.org">mame@ruby-lang.org</a><br>
|
||||
<a href="https://github.com/mame/">https://github.com/mame/</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make endoh4
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./endoh4
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<p>NOTE: The author recommends the use of xterm.</p>
|
||||
|
||||
<pre><code>./endoh4 < cube.txt
|
||||
</code></pre>
|
||||
|
||||
<p>For example, if you are a soccer fan, try:</p>
|
||||
|
||||
<pre><code>make all
|
||||
./endoh4 < solids/archimedian-solid/a11-truncated-icosahedron.txt
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This program is formatted as the net for a tetrahedron. (hint, try feeding the
|
||||
program it’s own source code). When it runs there is an animation for the
|
||||
computation to work out the convex hull.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Spec</h3>
|
||||
|
||||
<p>This is a convex polyhedron viewer, which:</p>
|
||||
|
||||
<ol>
|
||||
<li>reads three-dimentional vertices (3N float values) from stdin,</li>
|
||||
<li>calculates a convex hull of them, and</li>
|
||||
<li>renders it.</li>
|
||||
</ol>
|
||||
|
||||
|
||||
<p>This simple spec involves many details.</p>
|
||||
|
||||
<ul>
|
||||
<li>3D convex hull calculation
|
||||
|
||||
<ul>
|
||||
<li>recursive gift wrapping algorithm</li>
|
||||
<li>automatical merging of (almost) co-planar faces
|
||||
(i.e., faces are not triangulated)</li>
|
||||
<li>random perturbation for robustness</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>3D rendering
|
||||
|
||||
<ul>
|
||||
<li>perspective projection</li>
|
||||
<li>ASCII line drawing: <code>"',;;;,;'"</code></li>
|
||||
<li>camera in a spherical spiral orbit</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>(Note that this program does not use <code>math.h</code>.)</p>
|
||||
|
||||
<h3>Portability</h3>
|
||||
|
||||
<p>I think it conforms with both C89 and C99.
|
||||
I confirmed that it worked on gcc, clang, and tcc.
|
||||
It should not be warned with -pedantic and -Wextra.</p>
|
||||
|
||||
<h3>Tips</h3>
|
||||
|
||||
<p>You may want to use <code>tput</code> to hide a terminal cursor.</p>
|
||||
|
||||
<pre><code>tput civis
|
||||
./endoh4 < cube.txt
|
||||
tput cnorm
|
||||
</code></pre>
|
||||
|
||||
<h3>Bonuses</h3>
|
||||
|
||||
<p>You can change the screen size. Let the aspect ratio be about 3:1.</p>
|
||||
|
||||
<pre><code>gcc -DS=120,40 -o endoh4 endoh4.c
|
||||
</code></pre>
|
||||
|
||||
<p>The shape of this code is the geometric net of a regular tetrahedron.
|
||||
So, try:</p>
|
||||
|
||||
<pre><code>./endoh4 < endoh4.c
|
||||
</code></pre>
|
||||
|
||||
<p>The solids.tbz2 file includes various solid data:
|
||||
<a href="http://en.wikipedia.org/wiki/Platonic_solid">Platonic solids</a>,
|
||||
<a href="http://en.wikipedia.org/wiki/Archimedean_solid">Archimedean solids</a>,
|
||||
<a href="http://en.wikipedia.org/wiki/Prism_%28geometry%29">Prisms</a>,
|
||||
<a href="http://en.wikipedia.org/wiki/Antiprism">Antiprisms</a>,
|
||||
<a href="http://en.wikipedia.org/wiki/Bipyramid">Bipyramids</a>,
|
||||
<a href="http://en.wikipedia.org/wiki/Trapezohedron">Trapezohedrons</a>, and
|
||||
<a href="http://en.wikipedia.org/wiki/Johnson_solid">Johnson solids</a>.</p>
|
||||
|
||||
<p>I created the files by using the POV-Ray scripts
|
||||
(<a href="http://en.wikipedia.org/wiki/File:Poly.pov">1</a> and
|
||||
<a href="http://en.wikipedia.org/wiki/User:AndrewKepert/poly.pov">2</a>)
|
||||
in Wikipedia.
|
||||
They are copyrighted in CC BY-SA 3.0
|
||||
by “User:Cyp” and “User:AndrewKepert”.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,142 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Best use of 1 Infinite Loop</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best use of 1 Infinite Loop</h1>
|
||||
|
||||
<p>Qiming Hou<br>
|
||||
<a href="mailto:hqm03ster@gmail.com">hqm03ster@gmail.com</a><br>
|
||||
<a href="http://www.houqiming.net">http://www.houqiming.net</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make hou
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./hou [scene-file-name] [options]
|
||||
|
||||
Follow the instructions in stdout, preferably with an auto-refreshing PPM image viewer ready.
|
||||
Refresh the image every time the output refreshes, all effects should be more or less recognizable when you see 16.
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./hou BIG
|
||||
./hou old_default.scene BIG
|
||||
./hou otherroom.scene
|
||||
./hou otherroom.scene NAIVE
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>You could consider that this program violates the source code size
|
||||
limit. This is because the first compliation of this program is
|
||||
really just a decompressor to generate the real source code of the
|
||||
program.</p>
|
||||
|
||||
<p>This program will loop infinitely while progressivly refining a
|
||||
raytraced image.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Using hou</h3>
|
||||
|
||||
<p>This program is a programmable rendering engine with a built-in default scene. The standard command line is:</p>
|
||||
|
||||
<pre><code>./hou [scene-file-name] [options]
|
||||
</code></pre>
|
||||
|
||||
<p>As hou runs, it writes a progressively refining image to a ppm file specified in the scene. The initialization may take a while, but once it’s done, a rough preview should be available in seconds. Leave hou running for the night, and you get a high quality result like the attached *.jpg files. Kill hou manually after you’re satisfied with the image quality.</p>
|
||||
|
||||
<p>To save time and energy for the judges, rendered images for all provided scenes are provided as attached files.</p>
|
||||
|
||||
<h3>Features</h3>
|
||||
|
||||
<ul>
|
||||
<li><p>Fully programmable: Almost every stage of the renderer is programmable with a shader, i.e., a short script that does something rendering-related. In particular, each scene consists of one or more geometry shaders, a camera shader, and one or more material shaders. Shaders are written in an interpreted language that supports basic arithmetic, a few math functions, variables and procedural call in the CPS (Continuation Passing Style).</p></li>
|
||||
<li><p>Fast preview: This renderer isn’t just a naive path tracer, it actually uses a modern global illumination algorithm which is robust against challenging scene configurations. You can mostly place light sources and specify surface properties as you please without worrying too much about the convergence speed – you always get a nice fast preview within one or two minutes. As proof, there is a comparison: “./hou otherroom.scene” gives a rough idea about the overall illumination at 16 samples per pixel (i.e., when the program prints 16), whereas the naive approach “./hou otherroom.scene NAIVE” only produces a mess of white dots.</p></li>
|
||||
<li><p>Rich visual effects: The algorithm samples all light path types so most physically based effects can be produced. The default scene demonstrates quite a few of them: reflection, area light, soft shadows, color bleeding, caustics, and depth-of-field blur. Of course, one can also get programmable-shading effects like procedural texturing and approximated Fresnel terms.</p></li>
|
||||
<li><p>Accelerated ray tracing: The ray tracing part uses an algorithm better than the brute-force intersection of everything. The renderer even builds an acceleration data structure! Despite the double precision and the single-threaded-ness, it still runs at about 0.5 million rays per second on the author’s machine.</p></li>
|
||||
<li><p>Pause and resume: Can’t run ./hou overnight? No problem! You can kill and resume a rendering session whenever you want. The renderer automatically saves the progress every 16 samples and resumes where it’s left off when restarted. Also, each scene/parameter combination gets a different saved session so you don’t have to worry about conflicts.</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Abuse of the rules</h3>
|
||||
|
||||
<ul>
|
||||
<li><p>hou.c uses compression to get around the size limit. The compression fully complies with the rules and the guidelines (at least the portion that shows up in grep “size limit”). Please see the “Self-imposed restrictions” section below for more details.</p></li>
|
||||
<li><p>hou does not terminate (as suggested by the second line of rule 6).</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Self-imposed restrictions</h3>
|
||||
|
||||
<ul>
|
||||
<li><p>The building process does not involve any OS tool beyond cc and make. No gzip compression! a.c.gz doesn’t fit in 2053 bytes, anyway.</p></li>
|
||||
<li><p>Neither hou.c nor a.c (the <em>real</em> decompressed source) uses #define (or cc -D) at all.</p></li>
|
||||
<li><p>The source code is not required at runtime.</p></li>
|
||||
<li><p>a.c does not drop optional features to reduce size. There are pure optimization code that can be dropped without affecting the converged output (only affecting the ray tracing speed / convergence rate). All files are properly fopened with “rb” / “wb” for Windows compatibility. The PPM header has a comment line for non-standard-compliant viewers (specifically, my old HDRShop 1.0). And there is a nice text message saying “please wait…”.</p></li>
|
||||
<li><p>Despite the messy look, a.c and hou.c compiles warning-free (hou.c even wastes 18 bytes on #include<stdio.h> just for putchar). a.c compiles mostly clean in the C99/ANSI modes of clang and gcc (with -Wall –pedantic). The only warning generated is a pedantic one: “string constant too long”.</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Comments and why obfuscated</h3>
|
||||
|
||||
<ul>
|
||||
<li><p>Both the compression and the rendering use mathematically involved algorithms. Understanding the C doesn’t help much if one isn’t familiar with the math.</p></li>
|
||||
<li><p>Modern renderers provide shader access to just about any internal state. This one follows suit and reuses the same shader-accessible array for all important internal states.</p></li>
|
||||
<li><p>Infinity and not-a-number are used during normal course of execution.</p></li>
|
||||
<li><p>Previous image-generating entries may take care to hide the “IOCCC” string in the code, but they leave the text clear in the <em>result</em>. This entry takes it further and obfuscates the output image as well. Can you find the text in the image? Hint: look up.</p></li>
|
||||
<li><p>a.c leaves all shaders in plain text, but the plain text shader code can’t be taken for its face value – the arithmetic rules subtly diverge from our common sense.</p></li>
|
||||
<li><p>a.c is less portable than hou.c itself. hou.c only depends on ASCII and should run just fine on 16-bit, small memory, or float-incapable machines. a.c, while still reasonably portable, is quite memory consuming, requires IEEE754-compliant double, and assumes int to be 32-bit.</p></li>
|
||||
<li><p>Though technically endian-dependent, a.c remains portable providing that one doesn’t copy saved sessions across endians.</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Spoiler</h3>
|
||||
|
||||
<pre><code> 3225 3225 3225 9 9 3225 3225
|
||||
1 1 1 1 1 1 1 1 1 1
|
||||
4225 1226 1 1 1 1 1222 1226
|
||||
1 1 1 1 1 1 1 1 1
|
||||
4226 1 4226 8 4222 4226 1 1
|
||||
</code></pre>
|
||||
|
||||
<p> The program consists of a recursive-descend interpreter, a 3DDDA (3D Discrete Differential Analysis) ray tracer, a PSSMLT (Primary Sample Space Metropolis Light Transport) light path sampler, all squeezed into the size limit using a PPM compressor (Prediction by Partial Matching, and yes, the output format is chosen for the pun).</p>
|
||||
|
||||
<p> PSSMLT uses the Metropolis-Hasting algorithm to sample a 32D unit hypercube. Each point in the hypercube is interpreted as a sequence of random numbers, and is sent to a path tracer to generate a light path. The point’s Metropolis-Hasting energy is then defined as the corresponding path’s contribution value to the final image. Since each path is sampled with a probability proportional to its energy, the sample distribution directly corresponds to the final image, which can then be produced as a simple per-pixel histogram of all generated paths. The robustness comes from a state mutation strategy that actively tries to explore the neighborhood of high energy peaks (e.g. paths that happen to hit the light source in otherroom.scene). In addition, a rudimentary form of lens path stratification is added to balance the attention each pixel receives. The Metropolis-Hasting process completely avoids the tell-tale pixel sampling loop required in most other image generation methods.</p>
|
||||
|
||||
<p> The 3DDDA tracer is chosen for scalability: its performance doesn’t get much worse as scene complexity increases. Another benefit is that with the DDA code in place one can naturally use hierarchical grids as an acceleration structure. The downside, of course, is that the setup involves quite a few divisions, which naturally turns into division-by-zeros. Fortunately, the IEEE754 standard has a nice set of rules just for this purpose and the arithmetics are organized in a specific way to take advantage of this. The shader interpreter component is relatively straightforward, just an expression evaluator stripped to the bare minimum – it doesn’t even support numerical constants natively. A final little bit is a just-good-enough PRNG (Pseudo Random Number Generator) to replace the low precision Windows rand() and the non-C99 Unix drand48(). An overnight session would run through its short period many times, but that doesn’t necessarily map to the same set of paths in PSSMLT. After all, Metropolis et al. used an even worse PRNG in their 1953 paper.</p>
|
||||
|
||||
<p> The PPM compressor uses statically weighted fixed order contexts with an arithmetic encoder tweaked for iocccsize. The encoder emits octet-space pairs where each octet encodes ~6.5 bits of information and each space encodes 2 bits (thanks to the generous definition of “space” in iocccsize.c). The compressor actively shuffles the variable names around until the compressed string happens to contain enough “{}; ” to pass the final iocccsize test. There are a few other tweaks:</p>
|
||||
|
||||
<ul>
|
||||
<li><p>The PPM model uses mostly whitespace characters for weights.</p></li>
|
||||
<li><p>The encoder never emits ‘“’ and ‘\’.</p></li>
|
||||
<li><p>The decoder uses an O(n<sup>2</sup>) algorithm to avoid the gigabytes-sized hash table frequently found in other PPM implementations.</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-2015,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,152 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most timely rendered</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most timely rendered</h1>
|
||||
|
||||
<p>Christopher Mills<br>
|
||||
<a href="mailto:mrxo@sonic.net">mrxo@sonic.net</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make mills
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./mills
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./mills &
|
||||
</code></pre>
|
||||
|
||||
<p>While that is running, point your favorite browser at: <a href="http://localhost:8224">http://localhost:8224</a></p>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>Who will be the first to post an image rendered during a leap-second?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h1>The Program</h1>
|
||||
|
||||
<p>This program is a handy graphical clock. Simply run the program, click <em>OK</em> to
|
||||
any annoying security dialogs that pop up (aren’t those annoying?), then fire
|
||||
up your web browser and type in the following URL:</p>
|
||||
|
||||
<blockquote><p> <a href="http://localhost:8224">http://localhost:8224</a></p></blockquote>
|
||||
|
||||
<p>You will soon be presented with a lovely dynamically rendered 3D scene that
|
||||
also convienently tells you the current time!</p>
|
||||
|
||||
<h2>Usage Notes</h2>
|
||||
|
||||
<p>The program will continue to give you the time of day as it changes by
|
||||
reloading the page as often as it can render. If you grow tired of watching
|
||||
your life slip by, hit <code>Control-C</code> in the original window. Note that if you
|
||||
want to restart the program again, you should wait a minute or two before
|
||||
doing so. For details as to why this is necessary, feel free to Google
|
||||
<code>TIME_WAIT</code>. And while you are there, click on an ad. They could use the
|
||||
money.</p>
|
||||
|
||||
<p>It would be possible to fix this by adding</p>
|
||||
|
||||
<pre><code>n=1,setsockopt(s,SOL_SOCKET,SO_REUSEADDR,&n,sizeof n),
|
||||
</code></pre>
|
||||
|
||||
<p>at an appropriate spot in the code (an exercise left to the reader). However,
|
||||
as this limitation is documented, it is not techinally a bug.</p>
|
||||
|
||||
<h2>Details of Operation</h2>
|
||||
|
||||
<p>The program wears many hats (not literally). It is</p>
|
||||
|
||||
<ul>
|
||||
<li>a web server</li>
|
||||
<li>a PNG encoder</li>
|
||||
<li>a ray tracer</li>
|
||||
<li>a clock</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>It replies to web requests with a PNG image that uses the
|
||||
<a href="http://en.wikipedia.org/wiki/Adam7_algorithm">Adam7</a>
|
||||
encoding to return data progressively. Since the data is returned in Adam7
|
||||
format, the scene is displayed initally at a lower resolution and allowed to
|
||||
be progressively refined as time goes on. The ray tracer is integrally tied
|
||||
to the PNG encoder, casting rays in the Adam7 order. The web server uses
|
||||
PNG primarily because of PNG’s ability to return data progressively, and not
|
||||
as you might think because the PNG standard is so obfuscated as to require
|
||||
both little- and big-endian encodings at different spec layers.</p>
|
||||
|
||||
<p>Since ray-tracing was an obvious choice to return to a web server, I needed
|
||||
something to ray-trace. A static scene would be uninteresting. I took
|
||||
inspiration (as I often do) from the IOCCC remarks file which says</p>
|
||||
|
||||
<blockquote><p> At least one judge prefers to maintain the use of the leap-second
|
||||
as part of the world’s time standard.</p></blockquote>
|
||||
|
||||
<p>Then it was obvious; The code should display the time. It is believed (but
|
||||
not confirmed) that the code will, in fact, display leap seconds correctly.</p>
|
||||
|
||||
<p>To display the time, of course we would need a font. This font is encoded
|
||||
as a string, using only the C whitespace characters. Clearly, the judges
|
||||
intended this use of whitespace for data compression, since their tool
|
||||
doesn’t count whitepsace in strings differently than whitespace outside of
|
||||
them.</p>
|
||||
|
||||
<h2>User-modifyable Features</h2>
|
||||
|
||||
<p>The code can be user-modified simply by changing the build command line.
|
||||
The following symbols are defined in the build file:</p>
|
||||
|
||||
<ul>
|
||||
<li><p><code>-DLT=x1,y1,z1,x2,y2,z2,...</code></p>
|
||||
|
||||
<p>Defines the coordinates of the lights in the scene. It should be a
|
||||
comma-separated list of coordinates (x, y, z), three per light.</p></li>
|
||||
<li><p><code>-DNL=n</code></p>
|
||||
|
||||
<p>Defines the number of lights. Should be equal to the length of the list
|
||||
above (three times the number of lights).</p></li>
|
||||
<li><p><code>-DEY=x,y,z</code></p>
|
||||
|
||||
<p>Defines the position of the viewer (the eyepoint) for the scene. The eye
|
||||
is looking at the origin (0, 0, 0).</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Other Build Flags</h2>
|
||||
|
||||
<p>The original program bound the server to <code>INADDR_ANY</code> to allow everyone to
|
||||
experience the server’s output. The Judges suggested that I instead restrict
|
||||
the bind to <code>INADDR_LOOPBACK</code> to reduce security alarms. As a compliant veteran
|
||||
of innumerable post-ship late feature additions, I have modified the <code>Makefile</code>
|
||||
to inject the new code without destroying the beautiful spherical symmetry of
|
||||
the source code. In addition, I have altered the word <code>sin_port</code> to the more
|
||||
family-friendly version <code>win_port</code> to protect against curious impressionable
|
||||
youth trying to learn about sockets on Internet.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,295 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most catty</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most catty</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 misaka
|
||||
</code></pre>
|
||||
|
||||
<p>This will build a bunch of versions of the code. See the author’s details for information on all of these builds.</p>
|
||||
|
||||
<p>To understand the various intermediate source files that are built, try:</p>
|
||||
|
||||
<pre><code>make understanding
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./horizontal_cat [files...] > [output]
|
||||
./vertical_cat [files...] > [output]
|
||||
</code></pre>
|
||||
|
||||
<p>NOTE: Use - for standard input. For example:</p>
|
||||
|
||||
<pre><code>./vertical_cat - -
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>seq 1 12 | ./horizontal_cat - - -
|
||||
|
||||
./long_cat
|
||||
./long_faat_cat
|
||||
./long_fat_cat
|
||||
./loong_cat
|
||||
./loooong_cat
|
||||
./loooooooong_cat
|
||||
|
||||
seq -f '%.0f ' 45 | ./horizontal_cat - misaka.c
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>There is more to cat than <a href="http://cheezburger.com/1680494336">mere cats</a>.<br>
|
||||
Be they tall, fat, long or squat, this source code is sure to amuse.</p>
|
||||
|
||||
<h4>Slight diversion</h4>
|
||||
|
||||
<p>While one of the judges was reviewing this entry on the stern of the
|
||||
<a href="http://www.noble-caledonia.co.uk/information/detail.asp?id=2&spid=76">Island Sky</a>
|
||||
in the middle of the Atlantic Ocean waiting the
|
||||
<a href="http://en.wikipedia.org/wiki/Solar_eclipse_of_November_3,_2013">total solar eclipse of 2013</a>
|
||||
the judge was stuck by a
|
||||
<a href="http://en.wikipedia.org/wiki/Flying_fish">flying fish</a>.
|
||||
While result the impact was that the
|
||||
<a href="http://en.wikipedia.org/wiki/Port_wine">Port</a> from Portugal was lost, the
|
||||
<a href="http://www.travelforpassion.com/grog-factory-cape-verde-santo-antao-cape-verde-1602-photo">Grog</a> from Cape Verde
|
||||
and the laptop containing this entry was saved.</p>
|
||||
|
||||
<p>While I’m sure most cats would have preferred otherwise,
|
||||
the flying fish was returned to <em>em</em>swim with the fishes<em>em</em>. :-)
|
||||
No cats were harmed in the process of judging this entry.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h1>Overview</h1>
|
||||
|
||||
<p>Misaka is a file concatenation utility, with at least two modes of
|
||||
operation:</p>
|
||||
|
||||
<pre><code>gcc misaka.c -o horizontal_cat
|
||||
./horizontal_cat [files...] > [output]
|
||||
|
||||
./horizontal_cat misaka.c misaka.c > misaka2.c
|
||||
gcc misaka2.c -o vertical_cat
|
||||
./vertical_cat [files...] > [output]
|
||||
</code></pre>
|
||||
|
||||
<p>Where [files…] are a list of text file names. Use “-” to read from stdin.</p>
|
||||
|
||||
<h1>Details</h1>
|
||||
|
||||
<h2>Horizontal cat</h2>
|
||||
|
||||
<p>One of my favorite unix utilities is <em>cat</em>. The best thing about it was
|
||||
that it was named “cat”. That, and it’s useful for quickly showing contents
|
||||
of a file. Though it was primary meant for concatenating files, that
|
||||
function only seem to work if I wanted to concatenate files vertically.</p>
|
||||
|
||||
<p>I thought the lack of horizontal concatenation must have been an oversight,
|
||||
so I implemented this utility:</p>
|
||||
|
||||
<pre><code>gcc misaka.c -o horizontal_cat
|
||||
./horizontal_cat files...
|
||||
</code></pre>
|
||||
|
||||
<p><em>horizontal_cat</em> concatenates files horizontally and write the output to
|
||||
stdout. Each input file is padded with spaces on the right so that the
|
||||
original text alignments are preserved.</p>
|
||||
|
||||
<p>If “-” is specified as a file name, <em>horizontal_cat</em> will read from stdin.
|
||||
Unlike <em>cat</em>, <em>horizontal_cat</em> loads all input to memory first. Thus you
|
||||
can specify “-” multiple times to get stdin multiplied horizontally. For
|
||||
example, if you have seq(1) in your shell, you can add line numbers to both
|
||||
sides of misaka.c like this:</p>
|
||||
|
||||
<pre><code>seq -f ' %.0f ' 45 | ./horizontal_cat - misaka.c -
|
||||
</code></pre>
|
||||
|
||||
<h2>Vertical cat</h2>
|
||||
|
||||
<p>Because <em>horizontal_cat</em> must know the maximum width of all files before
|
||||
writing any output, all files must be processed at least twice. To support
|
||||
stdin, file must be buffered to memory. This lead to the feature that
|
||||
<em>horizontal_cat</em> can be used to duplicate stdin.</p>
|
||||
|
||||
<p>Seems like the stdin doubling feature might be useful even for concatenating
|
||||
files vertically, so I included a vertical mode. But supporting vertical
|
||||
mode with command line options would be no fun. Instead, vertical mode is
|
||||
enabled by concatenating the source code horizontally:</p>
|
||||
|
||||
<pre><code>./horizontal_cat misaka.c misaka.c > misaka2.c
|
||||
gcc misaka2.c -o vertical_cat
|
||||
./vertical_cat files...
|
||||
</code></pre>
|
||||
|
||||
<p><em>vertical_cat</em> works more or less like <em>cat</em>, except you can use
|
||||
<em>vertical_cat</em> to duplicate stdin:</p>
|
||||
|
||||
<pre><code>./vertical_cat - -
|
||||
</code></pre>
|
||||
|
||||
<h2>Long cat</h2>
|
||||
|
||||
<p>After <em>horizontal_cat</em> and <em>vertical_cat</em>, I thought, maybe all I really
|
||||
wanted was just more cats. So I implemented one more mode, this one is
|
||||
enabled by concatenating misaka.c vertically:</p>
|
||||
|
||||
<pre><code>./vertical_cat misaka.c misaka.c > misaka3.c
|
||||
gcc misaka3.c -o long_cat
|
||||
./long_cat
|
||||
</code></pre>
|
||||
|
||||
<p><em>long_cat</em> outputs ASCII art of a cat to stdout. You can make this cat
|
||||
exponentially longer by concatenating more files vertically (up to 31 levels
|
||||
high, depending on sizeof(int) for your compiler):</p>
|
||||
|
||||
<pre><code>./vertical_cat misaka.c misaka.c misaka.c > misaka4.c
|
||||
gcc misaka4.c -o loong_cat
|
||||
|
||||
./vertical_cat misaka.c misaka.c misaka.c misaka.c > misaka5.c
|
||||
gcc misaka5.c -o loooong_cat
|
||||
|
||||
./vertical_cat misaka.c misaka.c misaka.c misaka.c misaka.c > misaka6.c
|
||||
gcc misaka6.c -o loooooooong_cat
|
||||
</code></pre>
|
||||
|
||||
<p>If your terminal has really thin fonts, you can also make this output fatter
|
||||
by concatenating files horizontally:</p>
|
||||
|
||||
<pre><code>./vertical_cat misaka.c misaka.c | ./horizontal_cat - - > misaka7.c
|
||||
gcc misaka7.c -o long_fat_cat
|
||||
|
||||
./vertical_cat misaka.c misaka.c | ./horizontal_cat - - - > misaka8.c
|
||||
gcc misaka8.c -o long_faat_cat
|
||||
</code></pre>
|
||||
|
||||
<p>Output width is determined by the first level of stacked programs, so a
|
||||
triangle like the following will not have horizontally expanded output:</p>
|
||||
|
||||
<pre><code>./horizontal_cat misaka.c misaka.c | ./vertical_cat misaka.c - > misaka9.c
|
||||
gcc misaka9.c -o same_as_long_cat
|
||||
</code></pre>
|
||||
|
||||
<p>Finally, if you lost track of how many misaka.c you have stacked together,
|
||||
you can feed the source to a brainfuck interpreter to get a overview of how
|
||||
the programs are stacked. Example:</p>
|
||||
|
||||
<pre><code>perl bf.pl misaka9.c
|
||||
</code></pre>
|
||||
|
||||
<p>This outputs:</p>
|
||||
|
||||
<pre><code>MISAKA
|
||||
MISAKA MISAKA
|
||||
</code></pre>
|
||||
|
||||
<h1>Return value</h1>
|
||||
|
||||
<p><em>horizontal_cat</em> and <em>vertical_cat</em> will exit with zero status on success.</p>
|
||||
|
||||
<p>If any input file fails to open, <em>horizontal_cat</em> and <em>vertical_cat</em> will
|
||||
report the offending file name to stdout, and exit with nonzero status.</p>
|
||||
|
||||
<p>If <em>horizontal_cat</em> and <em>vertical_cat</em> ran out of memory, they will exit
|
||||
with nonzero status without outputting anything.</p>
|
||||
|
||||
<h1>Compatibility</h1>
|
||||
|
||||
<p><em>horizontal_cat</em> makes the following assumptions about input files:</p>
|
||||
|
||||
<ul>
|
||||
<li> ASCII with LF end of line sequences. If CR-LF sequences are used, CR
|
||||
characters will appear in the middle of output lines.</li>
|
||||
<li> All characters are of equal width, even tab characters.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Misaka has been verified to work on these following compiler+OS
|
||||
combinations:</p>
|
||||
|
||||
<ul>
|
||||
<li> gcc 4.6.3 on Linux 3.5.0-41</li>
|
||||
<li> gcc 4.4.5 on Linux 2.6.32-5</li>
|
||||
<li> gcc 4.3.5 on JS/Linux 2.6.20</li>
|
||||
<li> gcc 4.8.1 on Windows (Cygwin and MingW)</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Misaka requires a C99 compiler due to the use of single line comments.
|
||||
Misaka does not depend on any other C99 features.</p>
|
||||
|
||||
<h1>Obfuscation</h1>
|
||||
|
||||
<p>Main obfuscation is in having a C program that compiles when tiled
|
||||
horizontally and vertically, while using single line comments in less than
|
||||
half of the lines. <em>And</em> maintaining a meaningful layout while doing that.</p>
|
||||
|
||||
<p>There are other challenges too, of course, like getting a Brainfuck program
|
||||
to tile horizontally and vertically. Really, tiling code of any sort
|
||||
horizontally is an interesting exercise, I encourage everyone to try this
|
||||
once.</p>
|
||||
|
||||
<p>Other features to look for:</p>
|
||||
|
||||
<ul>
|
||||
<li> Peculiar bits that switches horizontal cat to vertical cat.</li>
|
||||
<li> Run-length encoded long cat.</li>
|
||||
<li> Symmetric and recycled variable names.</li>
|
||||
<li> CRC of the source code in the source code.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>“gcc -Wall” should provide a hint to where the mode switch happens, it
|
||||
does not output any irrelevant other warnings (verified on 4.6.3).</p>
|
||||
|
||||
<h1>Extra files</h1>
|
||||
|
||||
<p>Extra files included in my submission are informational only, they are not
|
||||
needed for the program to work.</p>
|
||||
|
||||
<ul>
|
||||
<li> bf.pl = a brainfuck interpreter, in case if you don’t have one handy.</li>
|
||||
<li> spoiler.html = making of this program.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h1>About Misaka</h1>
|
||||
|
||||
<p>The name, layout, and functionality of Misaka is inspired by a particular
|
||||
stackable figure:</p>
|
||||
|
||||
<ul>
|
||||
<li> <a href="http://google.co.jp/search?q=%E3%83%9F%E3%82%B5%E3%82%AB%E7%9B%9B%E3%82%8A&tbm=isch">Google images</a></li>
|
||||
<li> <a href="http://main.kotobukiya.co.jp/figure/tsubucole_tmi_misakamori/">Kotobukiya</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,129 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Smallest large system simulator</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Smallest large system simulator</h1>
|
||||
|
||||
<p>Yves-Marie Morgan<br>
|
||||
<a href="mailto:yves-marie.morgan@parrot.com">yves-marie.morgan@parrot.com</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make morgan1
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>echo "2013/10/03" | ./morgan1
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>echo "1985/10/28" | ./morgan1
|
||||
|
||||
echo "1996/12/31" | ./morgan1
|
||||
</code></pre>
|
||||
|
||||
<p>Try pressing the arrow keys when your focus is in the window.</p>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>To verify the output, try echoing the date of an evening with a clear sky.
|
||||
Use binoculars and/or telescope as needed. In some cases you may need
|
||||
to wait for a better time of the evening. In a few cases, such as
|
||||
the South Pole in the summer, you may need to move to a different
|
||||
observing site.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h1>Instructions</h1>
|
||||
|
||||
<p>It displays the position of the 8 planets of the solar system around the sun.
|
||||
The date given in the command line is in the format YYYY/MM/DD (year, month and
|
||||
day). The direction keys can be used to move in time :
|
||||
Left : go back 1 day.
|
||||
Right : go forward 1 day.
|
||||
Down : go back 20 days.
|
||||
Up : go forward 20 days.</p>
|
||||
|
||||
<p>It handles correctly all leap years and the switch between julian calendar and
|
||||
gregorian calendar (10 days missing between 1582/10/04 and 1582/10/15).</p>
|
||||
|
||||
<p>The scale is logarithmic to be able to display the 8 planets without having
|
||||
Mercury, Venus, Earth and Mars squizzed around the sun.</p>
|
||||
|
||||
<p>The size is not proportinal either.</p>
|
||||
|
||||
<h1>Bonus</h1>
|
||||
|
||||
<p>It also displays the position of 2 famous comets during their last approach :
|
||||
- The first one arround the third IOCCC.
|
||||
- The second one between the thirteenth and fourteenth IOCCC.</p>
|
||||
|
||||
<h1>Limitations</h1>
|
||||
|
||||
<ul>
|
||||
<li>ASCII character set is assumed.</li>
|
||||
<li>a c99 compiler is required (for some math.h functions).</li>
|
||||
<li>The position should be correct for years between (-1000; +3000)</li>
|
||||
<li>The approximations done in the formula are OK for displaying the
|
||||
position around the sun but not for other applications like ephemeride or
|
||||
sky view from Earth (angles may be off by 1 or 2 degrees sometimes).</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h1>Obfuscation</h1>
|
||||
|
||||
<ul>
|
||||
<li>Reuse of 1 letter variables.</li>
|
||||
<li>Only the main function with some for loops.</li>
|
||||
<li>Constants for orbital elements encoded in a string.</li>
|
||||
<li>Hexadecimal and decimal values used inconsitentely.</li>
|
||||
<li>Comparisons order are not consitent.</li>
|
||||
<li>A lot of stuff is done in the different parts of the for loop.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h1>Compilation warnings</h1>
|
||||
|
||||
<p>with gcc 4.7.2 on Linux Ubuntu 12.10 :
|
||||
* prog.c:38:3: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
|
||||
* prog.c:40:34: warning: value computed is not used [-Wunused-value]
|
||||
* prog.c:56:6: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
|
||||
* prog.c:58:50: warning: value computed is not used [-Wunused-value]
|
||||
* prog.c:61:5: warning: suggest parentheses around ‘-’ inside ‘>>’ [-Wparentheses]</p>
|
||||
|
||||
<p>with clang 3.1 on Linux Ubuntu 12.10 :
|
||||
* prog.c:38:49: warning: ‘&&’ within ‘||’ [-Wlogical-op-parentheses]
|
||||
* prog.c:38:27: warning: ‘&&’ within ‘||’ [-Wlogical-op-parentheses]
|
||||
* prog.c:55:13: warning: ‘&&’ within ‘||’ [-Wlogical-op-parentheses]
|
||||
* prog.c:56:14: warning: ‘&&’ within ‘||’ [-Wlogical-op-parentheses]</p>
|
||||
|
||||
<p>Due to most parentheses and braces removed when unecessary.</p>
|
||||
|
||||
<p>To verify the display, you can look at one of this programs :
|
||||
* xephem : http://www.clearskyinstitute.com/xephem/
|
||||
* homeplanet : http://www.fourmilab.ch/homeplanet/
|
||||
* http://www.theplanetstoday.com/</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,162 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most playfully versatile</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most playfully versatile</h1>
|
||||
|
||||
<p>Yves-Marie Morgan<br>
|
||||
<a href="mailto:yves-marie.morgan@parrot.com">yves-marie.morgan@parrot.com</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code> make morgan2
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./morgan2
|
||||
</code></pre>
|
||||
|
||||
<p>For the console version (ncurses)</p>
|
||||
|
||||
<p>or</p>
|
||||
|
||||
<pre><code>./morgan2 X
|
||||
</code></pre>
|
||||
|
||||
<p>For the graphical version (X11)</p>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>The judges enjoyed playing the game almost to completion; if we remember correctly,
|
||||
we managed to place 59 or 60 dominos. We wonder, what would be faster: to play the game to completion
|
||||
or to write an unobfuscated version of it?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<p>This program is a domino game. The goal is to place dominos on the 8x8 grid.
|
||||
Each domino is made of 6 squares of the color red or green. To place a domino,
|
||||
at least one of it side shall match the other side of another domino.</p>
|
||||
|
||||
<h1>How to play</h1>
|
||||
|
||||
<h2>Start of the game</h2>
|
||||
|
||||
<p>At the start of the game, the first domino is placed randomly on the grid. You
|
||||
get another domino to place by selecting one empty position in the stack on the
|
||||
right. You can have to 8 dominos pending at any time.</p>
|
||||
|
||||
<h2>Moving in the stack</h2>
|
||||
|
||||
<p>Use <code>Up</code> and <code>Down</code> key to move the cursor in the stack. Press <code>Enter</code> to either</p>
|
||||
|
||||
<ul>
|
||||
<li>reveal a new domino if the position was empty.</li>
|
||||
<li>select the domino to try to place it if the position was not empty.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>The currently selected domino is indicated on the top right.</p>
|
||||
|
||||
<h2>Placing a domino</h2>
|
||||
|
||||
<p>Once a domino has been selected, the cursor moves to the grid. Use <code>Up</code>, <code>Down</code>,
|
||||
<code>Left</code> and <code>Right</code> keys to move in the grid. Press <code>Enter</code> on an empty position
|
||||
to place the domino.</p>
|
||||
|
||||
<p>To go back to selection mode, press <code>Enter</code> on an occupied position.</p>
|
||||
|
||||
<p>The domino can be place in an empty position if all its neighbour have matching
|
||||
sides and the domino has at least one neighbour.</p>
|
||||
|
||||
<h2>Scoring</h2>
|
||||
|
||||
<p>First, depending on the number of dominos pending in the stack, a bonus is
|
||||
accorded :
|
||||
* 1 domino in the stack : 8 points.
|
||||
* 2 dominos in the stack : 4 points.
|
||||
* 3 or 4 dominos in the stack : 2 points.
|
||||
* 5 or more dominos in the stack : 0 point.</p>
|
||||
|
||||
<p>Then the bonus is multiplied by the number of matching neighbor the placed domino
|
||||
has (1, 2, 3 or 4). This is added to the score.</p>
|
||||
|
||||
<p>Finally, the total score is divided by the number of dominos placed (1 - 64).</p>
|
||||
|
||||
<p>The 3 numbers on display represent : the total score, the fill count and the
|
||||
final score (total score divided by fill count).</p>
|
||||
|
||||
<h2>End of the game</h2>
|
||||
|
||||
<p>The game is finished when no more domino can be placed and you either :
|
||||
* filled the complete grid.
|
||||
* have 8 pending dominos in the stack.
|
||||
* no more domino can be revealed in the stack (more than 56 dominos placed on
|
||||
the grid).</p>
|
||||
|
||||
<p><strong>Note</strong> There is no real end of game detection implemented in the program,
|
||||
simply press <code>q</code> when you have finished…</p>
|
||||
|
||||
<h2>Strategy</h2>
|
||||
|
||||
<ul>
|
||||
<li>Try to minimize the number of dominos revealed in the stack. The lower the number,
|
||||
the higher the bonus.</li>
|
||||
<li>Each domino is unique and all combination of colors exists, so keep track
|
||||
of what is already place and what is left.</li>
|
||||
<li>Make sure you don’t render dead some positions by preventing a future placement
|
||||
If the corner of domino does not match another corner in diagonal, the move
|
||||
is valid but will prevent some future moves.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h1>Limitations</h1>
|
||||
|
||||
<ul>
|
||||
<li>ASCII character set is assumed.</li>
|
||||
<li>Requires both ncurses and X11 at compilation and runtime, but selection could
|
||||
be done at compilation with some extra code (mainly empty stubs).</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h1>Obfuscation</h1>
|
||||
|
||||
<ul>
|
||||
<li>1 letter identifier, reused when possible.</li>
|
||||
<li>1 algorithm, 2 different kind of display (ncurses and X11) mixed.</li>
|
||||
<li>No parameters to functions, all variables are global and shared.</li>
|
||||
<li>Some variables are not initialized if they have a known value at the time of use.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h1>Compilation warnings</h1>
|
||||
|
||||
<p>with gcc 4.7.2 on Linux Ubuntu 12.10 :
|
||||
* prog.c:46:65: warning: value computed is not used [-Wunused-value]</p>
|
||||
|
||||
<p>with clang 3.1 on Linux Ubuntu 12.10 :
|
||||
* prog.c:23:24: warning: adding ‘int’ to a string does not append to the string [-Wstring-plus-int]</p>
|
||||
|
||||
<p><strong>!!!!! HAVE FUN !!!!!</strong></p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,130 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.1.5a DL=DISCOUNT">
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Most poetic use of strings</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most poetic use of strings</h1>
|
||||
|
||||
<p>Arch D. Robison<br>
|
||||
<a href="mailto:arch.d.robison@gmail.com">arch.d.robison@gmail.com</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make robison
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./robison
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>echo '1*2*3*4*5*6*7*8*9%1000' | ./robison
|
||||
echo '100000000000000000000*(20*(1+(99477941840441*50)))/31664812345028528' | ./robison
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>Of integers this prog does a lot,
|
||||
plus minus, div times (and what not).</p>
|
||||
|
||||
<p>And modulus if remainders the needing,
|
||||
on standard input percent be feeding.</p>
|
||||
|
||||
<p>More than one line can thru give input,
|
||||
when interactive one values more than thruput.</p>
|
||||
|
||||
<p>With cut and paste and some time,
|
||||
one can compute M(23209).</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h2>Oh, The Strings You Can C!</h2>
|
||||
|
||||
<p>I love the C language; its tersness is tops.<br>
|
||||
But the thing I abhor is numerical ops!</p>
|
||||
|
||||
<p>No shifting, division, remainder, or times.<br>
|
||||
No increment, decrement, or subscripting blech,<br>
|
||||
No addition, subtraction, or bitwise bool glop.<br>
|
||||
As for pointer arithmetic – totally yech!</p>
|
||||
|
||||
<p>But I do have a pref'rence, for pointer deref'rence.<br>
|
||||
I find NOTS are a bang, and relations a ball.<br>
|
||||
I like calling routines, and recursions in essence. <br>
|
||||
But the thing I like MOST is a string dot h CALL!</p>
|
||||
|
||||
<p>With mem copy I copy, and mem set I clear. <br>
|
||||
Take string len of this, and string copy that.<br>
|
||||
From my keyboard I pause, to hear subroutines dear: <br>
|
||||
The bark of string chrr, and the purr of string CAT!</p>
|
||||
|
||||
<p>One tiny detail that could lead to defeat.<br>
|
||||
From where an arg points: string calls only go forth,<br>
|
||||
So how to go back, to be Turing complete?<br>
|
||||
From standard dot H, to the rescue, q SORT!</p>
|
||||
|
||||
<p>My fixation might hint at a textual bent. <br>
|
||||
Does my program compose a tatoo for your shin? <br>
|
||||
Play crosswords or translate from Urdu to Tzouby?<br>
|
||||
To give it a whirl, just punch 2 + 2 in.</p>
|
||||
|
||||
<p>You can add, do division, and multiply too.<br>
|
||||
Take unary minus and also subtract.<br>
|
||||
Summing hairs of a walrus? No longer a fuss.<br>
|
||||
Parenthetical grouping – no pushing a stack!</p>
|
||||
|
||||
<p>Try dividing a googol by one forty three, <br>
|
||||
Subtract an octillion - it’s simply divine.<br>
|
||||
To compute a remainder, inscribe a percent.<br>
|
||||
For the sign of the answer, see C ninety nine!</p>
|
||||
|
||||
<p>A hundred and twenty five digits or so,<br>
|
||||
Are the lengthiest figures the program can gnash.<br>
|
||||
Go over that limit, by even a digit: <br>
|
||||
Risk incorrect answers, or witness a crash!</p>
|
||||
|
||||
<p>Say, say, does it have octal or binary zen?<br>
|
||||
What about duodecimal, ternary, hex? <br>
|
||||
Try the base as an option (of course in base ten)<br>
|
||||
Any base two to twenty – for that is the specs.</p>
|
||||
|
||||
<p>Use lowercase in trans-decimal radix, <br>
|
||||
Divide <em>babbage</em> (in base seventeen) by <em>cafe</em> – <br>
|
||||
a nice <em>fad</em>, but avoid a division by nix: <br>
|
||||
No errant result, but you could wait all day!</p>
|
||||
|
||||
<p>To grok the internals, ask Queen Cleopatra,<br>
|
||||
or King Tutankhamun; for him it’s a romp. <br>
|
||||
Addition by cats, and if given two figures,<br>
|
||||
to tell which is bigger, sort down and string CMP!</p>
|
||||
|
||||
<p>Unlawful subtraction, a grade school infraction, <br>
|
||||
starts at the left and works to the right. <br>
|
||||
Yet more innovation: like Henry Ford’s cars,<br>
|
||||
With a pound and define, mass production of vars!</p>
|
||||
|
||||
<p>The moral is clear, for programmers out there: <br>
|
||||
With the C lib for strings, you can hack with a flair.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2015,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user