Add preview of 1984-2019
The 2020 winners are hinted it, but the source code is not there,
nor are the hints. Someone could look into the HTML and
see what was commented out, but that is not a problem because
WHO won is known and the name of their AWARD is known already.
Moreover a number of the winners have talked about what their
entirs do, so the commented out spoiler text is not a bit problem.
One will find HTML commented out with:
<!-- XXX remove when 2020 is ready
2020 links here
XXX remove when 2020 is ready -->
The "XXX remove when 2020 is ready" string is found at the
start and end comment blocks. Again, soneone could read
what was commented out, but that is OK since most of that
information is known or can be known. The following files
have such HTML comment blocks in them.
./winners.html
./years-spoiler.html
./years.html
In addition, ./all/summary.txt was modified to not
include the 2020 entries for the momemt.
The 2020 winner code AND write-ups are NOT part of this set.
p.s. The all/all.tar.bz2 does not contain the 2020 source code (yet?).
This commit is contained in:
1 parent
28efc67f5d
commit
c0663537cb
1683 files changed
+220064
No files matched your search
@@ -0,0 +1,208 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2013 makefile
|
||||
#
|
||||
# This work by Landon Curt Noll, Simon Cooper, and Leonid A. Broukhis
|
||||
# is licensed under:
|
||||
#
|
||||
# Creative Commons Attribution-ShareAlike 3.0 Unported License.
|
||||
#
|
||||
# See: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
|
||||
################
|
||||
# tool locations
|
||||
################
|
||||
#
|
||||
SHELL= /bin/bash
|
||||
CP= cp
|
||||
CPP= cpp
|
||||
GUNZIP= gunzip
|
||||
LD= ld
|
||||
MAKE= make
|
||||
RM= rm
|
||||
SED= sed
|
||||
TAR= tar
|
||||
TRUE= true
|
||||
|
||||
# Set X11_LIBDIR to the directory where the X11 library resides
|
||||
#
|
||||
X11_LIBDIR= /usr/X11R6/lib
|
||||
|
||||
# Set X11_INCLUDEDIR to the directory where the X11 include files reside
|
||||
#
|
||||
X11_INCDIR= /usr/X11R6/include
|
||||
|
||||
# Compiler warnings
|
||||
#
|
||||
#CWARN=
|
||||
CWARN= -Wall -Wno-bitwise-op-parentheses -Wno-unsequenced \
|
||||
-Wno-incompatible-pointer-types -Wno-shift-op-parentheses \
|
||||
-Wno-empty-body -Wno-parentheses -Wno-int-conversion \
|
||||
-Wno-implicit-int
|
||||
#CWARN= -Wall -pedantic
|
||||
|
||||
# compiler standard
|
||||
#
|
||||
#CSTD=
|
||||
#CSTD= -ansi
|
||||
CSTD= -std=c99
|
||||
|
||||
# compiler bit architecture
|
||||
#
|
||||
# Some entries require 32-bitness:
|
||||
# ARCH= -m32
|
||||
#
|
||||
# Some entries require 64-bitess:
|
||||
# ARCH= -m64
|
||||
#
|
||||
# By default we assume nothing:
|
||||
#
|
||||
ARCH=
|
||||
|
||||
# optimization
|
||||
#
|
||||
# Most compiles will safely use -O2. Some can use only -O1 or -O.
|
||||
# A few compilers have broken optimizers or this entry make break
|
||||
# under those buggy optimizers and thus you may not want anything.
|
||||
#
|
||||
#OPT=
|
||||
#OPT= -O
|
||||
#OPT= -O1
|
||||
OPT= -O2
|
||||
#OPT= -O3
|
||||
|
||||
# Libraries needed to build
|
||||
#
|
||||
LIBS=
|
||||
|
||||
# default flags for ANSI C compilation
|
||||
#
|
||||
CFLAGS= ${CWARN} ${CSTD} ${ARCH} ${OPT}
|
||||
|
||||
# ANSI compiler
|
||||
#
|
||||
# Set CC to the name of your ANSI compiler.
|
||||
#
|
||||
# Some entries seem to need gcc. If you have gcc, set
|
||||
# both CC and MAY_NEED_GCC to gcc.
|
||||
#
|
||||
# If you do not have gcc, set CC to the name of your ANSI compiler, and
|
||||
# set MAY_NEED_GCC to either ${CC} (and hope for the best) or to just :
|
||||
# to disable such programs.
|
||||
#
|
||||
CC= cc
|
||||
#CC=clang
|
||||
MAY_NEED_GCC= gcc
|
||||
|
||||
|
||||
##############################
|
||||
# Special flags for this entry
|
||||
##############################
|
||||
#
|
||||
ENTRY= cable2
|
||||
DATA= example-images.tbz2
|
||||
BUILT_DATA= ascii.bmp bonus.bmp hello_world.bmp mixed_sizes.bmp multi_color.bmp typeset.bmp
|
||||
ALT_OBJ=
|
||||
ALT_ENTRY=
|
||||
|
||||
|
||||
#################
|
||||
# build the entry
|
||||
#################
|
||||
#
|
||||
all: ${ENTRY} data
|
||||
@${TRUE}
|
||||
|
||||
${ENTRY}: ${ENTRY}.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
||||
|
||||
# alternative executable
|
||||
#
|
||||
alt: ${ALT_ENTRY}
|
||||
@${TRUE}
|
||||
|
||||
# data files
|
||||
#
|
||||
data: ${DATA}
|
||||
@echo extracting sample bmp files
|
||||
${TAR} -jxvf ${DATA}
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
${RM} -f ${ENTRY}.o ${ALT_OBJ}
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${ENTRY} ${ALT_ENTRY}
|
||||
${RM} -f ${BUILT_DATA}
|
||||
|
||||
nuke: clobber
|
||||
@${TRUE}
|
||||
|
||||
dist_clean: nuke
|
||||
@${TRUE}
|
||||
|
||||
install:
|
||||
@echo "Surely we are joking Dr. Lehmer!"
|
||||
@${TRUE}
|
||||
|
||||
# backwards compatibility
|
||||
#
|
||||
build: all
|
||||
@${TRUE}
|
||||
|
||||
|
||||
##################
|
||||
# 133t hacker rulz
|
||||
##################
|
||||
#
|
||||
love:
|
||||
@echo 'not war?'
|
||||
@${TRUE}
|
||||
|
||||
haste:
|
||||
$(MAKE) waste
|
||||
@${TRUE}
|
||||
|
||||
waste:
|
||||
@echo 'haste'
|
||||
@${TRUE}
|
||||
|
||||
easter_egg:
|
||||
@echo you expected to mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Readers shall not be disallowed from being unable to not partly misunderstand this partocular final echo.
|
||||
|
||||
# Understand the history of the Homebrew Computer Club
|
||||
# as well as the West Coast Computer Faire and
|
||||
# you might be confused different. :-)
|
||||
#
|
||||
supernova: nuke
|
||||
@-if [ -r .code_anal ]; then \
|
||||
${RM} -f .code_anal_v4; \
|
||||
else \
|
||||
echo "We are not expected to understand that"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
|
||||
deep_magic:
|
||||
@-if [ -r .code_anal ]; then \
|
||||
ccode_analysis --deep_magic 2ed3582ec5c094a093fea2a6bcb9f19439892873c9cc45ed1ceaafe08b7d52e1b2c7cd524be3b0b2 --FNV1a_hash 512-bit "${ENTRY}"; \
|
||||
else \
|
||||
echo "Park different"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
|
||||
magic: deep_magic
|
||||
@-if [ -r .code_anal ]; then \
|
||||
ccode_analysis --mode 391581 --level 216193 --FNV1a_hash 512-bit "${ENTRY}"; \
|
||||
else \
|
||||
echo "These aren't the primes you're looking for Paul Erdos!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
@@ -0,0 +1,77 @@
|
||||
#include\
|
||||
<stdio.h>//
|
||||
#define Y(\
|
||||
_)_##char
|
||||
#define \
|
||||
_ [9<<9],
|
||||
#define j\
|
||||
L;fread(&\
|
||||
L,4,1,f);u
|
||||
#define P\
|
||||
&4**(int*\
|
||||
)" ")% \
|
||||
3901%31///
|
||||
#define q\
|
||||
Z[F++]=*E
|
||||
#define $\
|
||||
for("IOCCC"
|
||||
#include\
|
||||
<stdlib.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int *Q,u,i,c,k,B,r=0,w,n,F=0,x,J,u,m,p,s=0,v,e,r,L,a,z,y,D,o,g; Y( )*
|
||||
Z= "Vn"
|
||||
"-S" "xR9Q" "[$s"
|
||||
"Zd&o+" "pf^cM" "cbac\
|
||||
J_VHMF_" "BkaEg^" "x`i_i\
|
||||
us%d]oWG:" "r`IZ.6_]H3ec]_\
|
||||
bWW_^Ej2i[r" "ZZnJjW[bK`hZakb\
|
||||
_l]gL3X]d_#$eK" "[G3 d[Xe][:V`4Z]Z" "VfX^]V:X%b]N,ma-j"
|
||||
"^m57c!`O.qP8lTc^" "gm,Um;m`m^^`5n_nci<Wf[h<t+e$%" "]Lha&=l Umc>m#_mdp"
|
||||
"h/codZ#i`,''mbb(fh" ")h)(^uV9b7dcZq`^d`/*3`#ko`lj;^idad/]0ffxP*]??bff$h`@(Zgtcn"
|
||||
"k10t<A6mYZNh!g&a2^j" "!^hOZb!&]bd(]TuqI]#iepZc/XdX(Z X4a!dgpc>0q;]^7p`q*AtqC1j,'#_on tp"
|
||||
"on e !1+tA6`db`qciq`'=?ui]'`_`dk`!kx_%]bu]cZX8u_)Z=8@ghg$mlp`a>D_o2_eb)sb)sa0g@f-h"
|
||||
"1bl_DeblFsa&Dt^t4*X *mCC^5Y",M _ A _ G _ I _ C _ K[]="',b}q}a9\"],)'(cDDJr4"
|
||||
"Ab,:sdtd/E*#2eXkZ7cPthkq`(stnhct!a:>A;A+jA9>A;A+js",*E=I;FILE*f;main
|
||||
(int d,Y()**t){$;!t;s=c=-D){$,t=v=D?k:J;v++-d;){$,o=L=z=0,s=D?J:k;s+++d
|
||||
-B-F;)(o&&(e=m),y=*Q!=(m=Q[u*i+(D?v-u*s:s-u*v)]))^o&&(G[z++]=s-L>20,L=s,o=y);$,
|
||||
s=z,o=0;s--;o+=G[s]^s[A]);$;z^w||o;z=w){$,o=1;o&&!--o*D-~-~-w|1[A]|v-a>28&&w^4|1[A]|
|
||||
3[A]|!2[A ]|v-a>5;)$;I[g[I]=2,++g]=-1,-s<w;I[~-g]=A[-s--]);$,a=v,w=z;z--;A[z]=z[G]);
|
||||
}}$,v=a =o;(Z=C+!D*734)[z=a] ^3;d=0){$;!~I[v];a=z,v=o=0)$,M[L
|
||||
++]+= Z[z]^4?-42:o; Z[z++]^4;); $;~z&&2>(s=I
|
||||
[v ])&4<Z[z] |Z[z]==s ;)++z,s^2?
|
||||
d++,++ v:v&&(o +=d,a=z,
|
||||
z=-1 );$;v++[ I]^2;) ;}}$;d
|
||||
;d =c){$,p=*Z;F++ [I]= *++
|
||||
Z%p,*Z;);$,Z=C;x=F ,F=
|
||||
r,s=2,p---7;Q=E,E=Z
|
||||
,Z=Q)$;s%x;p^(c=s++[E
|
||||
])?q*0+c:(q++, q--));$;K[F];K[F++]-=p
|
||||
);c=fseek((f=fopen(*++t,"rb"))?f:(exit(1)
|
||||
,f),10,r);j;n=j=j=j;i=j;F=a=fseek(f,n,c);
|
||||
Q=calloc(z=i--*u,4);$;a^z;fread(a+++Q,L>>
|
||||
19,1,f));$;F++<i;r=n){$,n=0,B=u;B;n|=*Q^Q
|
||||
[u*(i-F)+--B]);$,n&&Y(!r&&(D=F-J,J=F);
|
||||
!n&&r;r=x=!put)(10))$;B^u;B++,c=p){$,p=
|
||||
0,s=J;s^F;p|=*Q^Q[B+u*(i-s++)]);$;p&&!c;
|
||||
)$;++Y (c*F-J<<1<5*((k=B)-x);put)(32
|
||||
),++c); $;!p&&c;x=B){$,F-J<<1<Y(D&&
|
||||
put)( 10),D=95;D--;D[M]=0);$;main(
|
||||
++D?B: F,w=a=g=0),!D;);$;x=K[o++]-
|
||||
27;M [x]*M[K[o++] -27]>0&&(M
|
||||
[x]=s));$; ++c^L;M[c]
|
||||
>s&&(s=M[ x=c]));$;
|
||||
3^d||printf (K+--o,(
|
||||
*Q P,(e P), D*!(c+~x);
|
||||
w++)$,o= '~';-~o;)$
|
||||
[w]Y(^-- o||put)(D=
|
||||
o);0;);c =Y(~o&&!
|
||||
put)(*K+ x);}}}}}
|
||||
Binary file not shown.
@@ -0,0 +1,153 @@
|
||||
<!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 />
|
||||
|
||||
<!--
|
||||
(c) Copyright 1984-2015, [Leo Broukhis, Simon Cooper, Landon Curt Noll][judges] - All rights reserved
|
||||
This work is licensed under a [Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].
|
||||
|
||||
[judges]: http://www.ioccc.org/judges.html
|
||||
[cc]: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
-->
|
||||
|
||||
<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>
|
||||
@@ -0,0 +1,114 @@
|
||||
# Best of show
|
||||
|
||||
Adrian Cable
|
||||
<adrian.cable@gmail.com>
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
### To build:
|
||||
|
||||
make cable2
|
||||
|
||||
### To run:
|
||||
|
||||
./cable2 file.bmp [color]
|
||||
|
||||
### Try:
|
||||
|
||||
Extract example-images.tbz2:
|
||||
|
||||
make data
|
||||
|
||||
Here is an OCR example that shows all 94 supported ASCII characters:
|
||||
|
||||
./cable2 ascii.bmp
|
||||
|
||||
Here is an example of colored ASCII:
|
||||
|
||||
./cable2 multi_color.bmp color
|
||||
|
||||
Here is an example using different character sizes and different
|
||||
positions in the same file:
|
||||
|
||||
./cable2 mixed_sizes.bmp
|
||||
|
||||
How about about hand-written C code:
|
||||
|
||||
./cable2 hello_world.bmp | gcc -xc -o hello -
|
||||
./hello
|
||||
|
||||
Sometimes typeset text will work, if the typeset has characters that
|
||||
are enough to the supported handwritten shapes. For example,
|
||||
Menlo, 160 pt:
|
||||
|
||||
./cable2 typeset.bmp
|
||||
|
||||
And as an added IOCCC bonus: :-)
|
||||
|
||||
./cable2 bonus.bmp
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
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.
|
||||
|
||||
## Author's comments:
|
||||
OCR - Obfuscated Character Recognition of Handwritten Text
|
||||
==========================================================
|
||||
|
||||
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!
|
||||
|
||||
BMP files created by most paint programs should work. The author recommends Paint.NET.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
- Every printable ASCII character is recognized (94 characters plus space), plus a special bonus character.
|
||||
- Input images can be any size (limited only by memory), containing any number of lines of text.
|
||||
- BMP is really a mess of different formats, but the program supports most of them from Windows 3.1 and later.
|
||||
- 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.)
|
||||
- You can use any colors you like for the text and background, even different colors for different text characters.
|
||||
- If "color" is specified as the second command line parameter, the program's output will also be in color, on ANSI/VTxxx terminals.
|
||||
|
||||
Why is this entry obfuscated/interesting?
|
||||
-----------------------------------------
|
||||
|
||||
- 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.
|
||||
- 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.
|
||||
- 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^y 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.
|
||||
- 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.
|
||||
- The number 42 is featured in the source to provide an answer to the judges' deeper questions.
|
||||
- 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?
|
||||
- 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?
|
||||
|
||||
Other notes
|
||||
-----------
|
||||
|
||||
- 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.
|
||||
- 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.
|
||||
- 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.
|
||||
- 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.
|
||||
|
||||
Bugs/features
|
||||
-------------
|
||||
|
||||
- The width of input images must be a multiple of 4.
|
||||
- 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!
|
||||
- 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.
|
||||
- Using antialiased brush strokes to draw your letters is fine, however, antialiasing interferes with color detection in "color" mode.
|
||||
- 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).
|
||||
|
||||
Compiler warnings
|
||||
-----------------
|
||||
|
||||
clang warns about unused expression results, missing type specifiers, and incompatible pointer conversions - all just a fun consequence of the obfuscations.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(c) Copyright 1984-2015, [Leo Broukhis, Simon Cooper, Landon Curt Noll][judges] - All rights reserved
|
||||
This work is licensed under a [Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].
|
||||
|
||||
[judges]: http://www.ioccc.org/judges.html
|
||||
[cc]: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
-->
|
||||
Reference in new issue
Block a user