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,259 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2015 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
|
||||
BUNZIP2= bunzip2
|
||||
LD= ld
|
||||
MAKE= make
|
||||
RM= rm
|
||||
SED= sed
|
||||
TAR= tar
|
||||
TRUE= true
|
||||
MKDIR= mkdir
|
||||
MV= mv
|
||||
TR= tr
|
||||
GREP= grep
|
||||
SORT= sort
|
||||
UNIQ= uniq
|
||||
|
||||
# Set X11_LIBDIR to the directory where the X11 library resides
|
||||
#
|
||||
#X11_LIBDIR= /usr/X11R6/lib
|
||||
#X11_LIBDIR= /usr/X11/lib
|
||||
X11_LIBDIR= /opt/X11/lib
|
||||
|
||||
# Set X11_INCLUDEDIR to the directory where the X11 include files reside
|
||||
#
|
||||
#X11_INCDIR= /usr/X11R6/include
|
||||
#X11_INCDIR= /usr/X11/include
|
||||
X11_INCDIR= /opt/X11/include
|
||||
|
||||
# Compiler warnings
|
||||
#
|
||||
#CWARN=
|
||||
#CWARN= -Wall
|
||||
#CWARN= -Wall -Wextra
|
||||
CWARN= -Wall -Wextra -pedantic ${CSILENCE}
|
||||
#CWARN= -Wall -Wextra -Weverything
|
||||
#CWARN= -Wall -Wextra -Weverything -pedantic
|
||||
#CWARN= -Wall -Wextra -Weverything -pedantic ${CSILENCE}
|
||||
|
||||
# Silence warnings that ${CWARN} would normally complain about
|
||||
#
|
||||
CSILENCE= -Wno-parentheses -Wno-unused-value -Wno-return-type \
|
||||
-Wno-overlength-strings -Wno-unused-result \
|
||||
-Wno-implicit-int
|
||||
|
||||
clang_CSILENCE=-Wno-string-plus-int -Wno-int-conversion
|
||||
|
||||
# compiler standard
|
||||
#
|
||||
CSTD= -std=c11 \
|
||||
-D_BSD_SOURCE \
|
||||
-D_XOPEN_SOURCE
|
||||
# _BSD_SOURCE needed for function usleep()
|
||||
# _XOPEN_SOURCE needed for function lrand48()
|
||||
|
||||
# compiler bit architecture
|
||||
#
|
||||
# Some entries require 32-bitness:
|
||||
# ARCH= -m32
|
||||
#
|
||||
# Some entries require 64-bitess:
|
||||
# ARCH= -m64
|
||||
#
|
||||
# By default we assume nothing:
|
||||
#
|
||||
ARCH=
|
||||
|
||||
# defines that are needed to compile
|
||||
#
|
||||
CDEFINE=
|
||||
|
||||
# include files that are needed to compile
|
||||
#
|
||||
CINCLUDE=
|
||||
|
||||
# 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.
|
||||
# Reasonable compilers will allow for -O3.
|
||||
#
|
||||
#OPT=
|
||||
#OPT= -O
|
||||
#OPT= -O1
|
||||
#OPT= -O2
|
||||
OPT= -O3
|
||||
|
||||
# default flags for ANSI C compilation
|
||||
#
|
||||
CFLAGS= ${CWARN} ${CSTD} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT}
|
||||
|
||||
# Libraries needed to build
|
||||
#
|
||||
LIBS=
|
||||
|
||||
# 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
|
||||
|
||||
CSILENCE+= ${${CC}_CSILENCE}
|
||||
|
||||
##############################
|
||||
# Special flags for this entry
|
||||
##############################
|
||||
#
|
||||
ENTRY= prog
|
||||
CSRC= ${ENTRY}.c
|
||||
OBJ= ${ENTRY}.o
|
||||
DATA=
|
||||
ALT_OBJ=
|
||||
ALT_ENTRY=
|
||||
TARGET= ${ENTRY}
|
||||
|
||||
|
||||
#################
|
||||
# build the entry
|
||||
#################
|
||||
#
|
||||
all: ${TARGET} ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
${ENTRY}: ${CSRC}
|
||||
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
||||
|
||||
# alternative executable
|
||||
#
|
||||
alt: ${ALT_ENTRY}
|
||||
@${TRUE}
|
||||
|
||||
# data files
|
||||
#
|
||||
data: ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
${RM} -f ${OBJ} ${ALT_OBJ}
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${TARGET} ${ALT_ENTRY}
|
||||
|
||||
nuke: clobber
|
||||
@${TRUE}
|
||||
|
||||
dist_clean: nuke
|
||||
@${TRUE}
|
||||
|
||||
install:
|
||||
@echo "Surely we are joking Dr. May!"
|
||||
@${TRUE}
|
||||
|
||||
# backwards compatibility
|
||||
#
|
||||
build: all
|
||||
@${TRUE}
|
||||
|
||||
|
||||
##################
|
||||
# 133t hacker rulz
|
||||
##################
|
||||
#
|
||||
love:
|
||||
@echo 'not war?'
|
||||
@${TRUE}
|
||||
|
||||
haste:
|
||||
$(MAKE) waste
|
||||
@${TRUE}
|
||||
|
||||
waste:
|
||||
@echo 'haste'
|
||||
@${TRUE}
|
||||
|
||||
make:
|
||||
@echo 'Attend a maker faire'
|
||||
@${TRUE}
|
||||
|
||||
easter_egg:
|
||||
@echo you expected to sometimes mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Readers shall not be disallowed from not failing to be 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_v5; \
|
||||
else \
|
||||
echo "planet deniers, like the IAU, are amusing"; \
|
||||
fi
|
||||
@echo A $@ helps ${MAKE} the elements that help form planets
|
||||
@${TRUE}
|
||||
|
||||
deep_magic:
|
||||
@-if [ -r .code_anal ]; then \
|
||||
ccode_analysis --deep_magic 2ed3582ec5c094a093fea2a6bcb9f19439892873c9cc45ed1ceaafe08b7d52e1b2c7cd524be3b0b2 --FNV1a_hash_512_bit "${ENTRY}"; \
|
||||
else \
|
||||
echo "You are holding it wrong!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
|
||||
magic: deep_magic
|
||||
@-if [ -r .code_anal ]; then \
|
||||
ccode_analysis --mode 216091 --level 216193 --FNV1a_hash_512_bit "${ENTRY}"; \
|
||||
else \
|
||||
echo "These aren't the primes you're looking for Pauline!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
|
||||
# The IOCCC resident astronomer states
|
||||
#
|
||||
charon: supernova
|
||||
@echo $@ is a dwarf planet
|
||||
@echo dwarf is a type of planet
|
||||
@echo $@ is a planet
|
||||
|
||||
pluto: supernova
|
||||
${MAKE} charon
|
||||
@echo $@ is a dwarf planet
|
||||
@echo dwarf is a type of planet
|
||||
@echo $@ is a planet
|
||||
@echo get used to having lots of planets because a $< can ${MAKE} a lot of them
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
k: CALL l_no_end 1_FORWARD GO_BACK 1_TURN_RIGHT 2_FORWARD TGGL_PEN GO_BACK 1_TURN_LEFT 1_FORWARD TGGL_PEN 1_FORWARD
|
||||
h: CALL l_no_end 1_FORWARD GO_BACK 2_FORWARD 1_TURN_RIGHT BOUNCE 1_TURN_RIGHT 1_FORWARD
|
||||
f: CALL l_no_end 2_FORWARD 2_FORWARD 1_TURN_RIGHT
|
||||
l: CALL l_no_end 1_TURN_LEFT
|
||||
l_no_end: 2_FORWARD TGGL_PEN 1_TURN_RIGHT 1_FORWARD 1_TURN_LEFT 1_FORWARD 1_TURN_LEFT BOUNCE 1_TURN_LEFT 2_FORWARD 2_FORWARD
|
||||
j: MIDDLE 5_FORWARD 1_FORWARD 1_TURN_RIGHT GO_BACK TGGL_PEN 1_FORWARD 1_TURN_LEFT 5_FORWARD 2_FORWARD TGGL_PEN
|
||||
i: MIDDLE 2_FORWARD 1_TURN_LEFT GO_BACK TGGL_PEN 1_FORWARD 1_TURN_RIGHT 2_FORWARD 1_FORWARD TGGL_PEN
|
||||
t: ABOVE 5_FORWARD 1_FORWARD 1_TURN_LEFT TGGL_PEN 2_TURN_LEFT 2_TURN_LEFT 2_FORWARD GO_BACK TGGL_PEN 1_TURN_LEFT 1_FORWARD
|
||||
s: 1_FORWARD TGGL_PEN 1_TURN_RIGHT 1_FORWARD BOUNCE 2_TURN_RIGHT 1_TURN_RIGHT
|
||||
v: MIDDLE 1_FORWARD 1_TURN_LEFT 1_FORWARD BOUNCE 1_FORWARD 1_TURN_LEFT
|
||||
x: MIDDLE 1_TURN_LEFT 2_FORWARD TGGL_PEN 5_TURN_LEFT TGGL_PEN 1_TURN_LEFT 2_FORWARD
|
||||
p: MIDDLE 5_FORWARD 2_FORWARD GO_BACK 5_FORWARD 1_FORWARD 5_TURN_RIGHT 1_TURN_RIGHT
|
||||
e: 1_FORWARD 1_TURN_RIGHT TGGL_PEN 1_TURN_RIGHT TGGL_PEN 1_TURN_RIGHT GO_BACK 1_TURN_RIGHT TGGL_PEN 5_TURN_LEFT 1_TURN_LEFT
|
||||
z: TGGL_PEN 2_FORWARD 1_TURN_RIGHT BOUNCE 1_TURN_RIGHT 1_FORWARD 1_TURN_LEFT 1_FORWARD 2_TURN_RIGHT BOUNCE 2_TURN_RIGHT 1_FORWARD
|
||||
w: CALL half_w CALL half_w
|
||||
half_w: MIDDLE 2_FORWARD 1_TURN_LEFT BOUNCE 1_TURN_LEFT 1_FORWARD
|
||||
y: CALL u 2_FORWARD 1_FORWARD 1_TURN_RIGHT
|
||||
u: MIDDLE CALL u_bridge 2_FORWARD 1_FORWARD
|
||||
u_bridge: 2_FORWARD 2_TURN_LEFT 2_TURN_LEFT 1_FORWARD GO_BACK
|
||||
m: CALL n GO_BACK 2_FORWARD 2_TURN_RIGHT 2_TURN_RIGHT 1_FORWARD
|
||||
n: CALL r 2_TURN_RIGHT 1_FORWARD
|
||||
b: ABOVE 2_FORWARD 2_FORWARD CALL r_trace 2_TURN_RIGHT 2_TURN_RIGHT
|
||||
r: MIDDLE CALL r_trace
|
||||
r_trace: 2_FORWARD 1_FORWARD GO_BACK 2_FORWARD 2_TURN_RIGHT
|
||||
q: CALL o GO_BACK 5_FORWARD 2_FORWARD
|
||||
g: CALL o GO_BACK 5_FORWARD 1_FORWARD 5_TURN_RIGHT
|
||||
o: CALL c 2_TURN_LEFT 1_FORWARD
|
||||
d: CALL c 1_FORWARD ABOVE 5_FORWARD 1_FORWARD 1_TURN_LEFT
|
||||
a: CALL c 1_FORWARD TGGL_PEN 2_TURN_LEFT 1_TURN_LEFT GO_BACK TGGL_PEN 1_TURN_RIGHT 1_FORWARD 1_TURN_LEFT
|
||||
c: 2_FORWARD 2_TURN_RIGHT GO_BACK TGGL_PEN 1_FORWARD 2_TURN_LEFT 2_TURN_LEFT
|
||||
.: TGGL_PEN
|
||||
,: TGGL_PEN GO_BACK 1_TURN_RIGHT
|
||||
;: CALL : 1_TURN_RIGHT
|
||||
:: MIDDLE TGGL_PEN 2_FORWARD 1_FORWARD TGGL_PEN
|
||||
!: ABOVE 5_FORWARD TGGL_PEN 2_FORWARD TGGL_PEN
|
||||
?: 5_FORWARD 1_FORWARD TGGL_PEN 2_TURN_RIGHT 2_TURN_RIGHT 1_FORWARD 1_TURN_RIGHT 1_TURN_LEFT TGGL_PEN 2_FORWARD TGGL_PEN
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
<!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 Handwriting</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best Handwriting</h1>
|
||||
|
||||
<p>Etienne Duble <a href="mailto:etienne.duble@imag.fr">etienne.duble@imag.fr</a><br>
|
||||
<a href="http://lig-membres.imag.fr/duble">http://lig-membres.imag.fr/duble</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make
|
||||
|
||||
echo Some text | ./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>echo Hello, world | ./prog
|
||||
|
||||
DRAFT=1 ./prog < prog.c
|
||||
|
||||
./prog
|
||||
> [type]
|
||||
(...observe...)
|
||||
|
||||
./prog < prog.c
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>Beautiful penmanship! However, your fonts may vary.</p>
|
||||
|
||||
<p>How does this entry compress the font it uses? What’s the purpose of lrand48()?
|
||||
Why does the program dump core, when it does :) ?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Introduction</h3>
|
||||
|
||||
<p>This program <strong>prints text in your terminal with an interesting
|
||||
hand-writing effect</strong>.</p>
|
||||
|
||||
<p>It uses the <em>braille patterns</em> range of the unicode standard: this
|
||||
allows to consider each terminal character as a tiny 2x4 bitmap.</p>
|
||||
|
||||
<p>Turning the Braille code into something visual might be considered
|
||||
blasphemous. When I was fighting to make this program work, I started
|
||||
wondering if it was not the reason for its very erratic behaviour.</p>
|
||||
|
||||
<h3>prog.c vs prog.orig.c</h3>
|
||||
|
||||
<p>The file <code>prog.orig.c</code> is the one I submitted.</p>
|
||||
|
||||
<p>Gil Dogon noted a few unsafe statements (statements whose behaviour is
|
||||
undefined in the C standard and, as such, could cause issues with other
|
||||
compilers or optimization levels). These have been fixed in <code>prog.c</code>.
|
||||
After this fix, in order to remain rule-2-compliant, a variable name has
|
||||
also been shortened in this file.</p>
|
||||
|
||||
<h3>How to build</h3>
|
||||
|
||||
<p>If you have <code>clang</code>:</p>
|
||||
|
||||
<pre><code>$ CC=clang make -e
|
||||
</code></pre>
|
||||
|
||||
<p>Otherwise (gcc):</p>
|
||||
|
||||
<pre><code>$ make
|
||||
</code></pre>
|
||||
|
||||
<p>(You will get a few warnings in this case.)</p>
|
||||
|
||||
<h3>How to use it</h3>
|
||||
|
||||
<p>You need a terminal configured to handle an <em>UTF-8</em> encoding and a
|
||||
font including <em>braille patterns</em>.
|
||||
This is the default on most modern GNU/Linux operating systems.
|
||||
The default terminal application (gnome-terminal) or even a simple
|
||||
xterm should render things properly.
|
||||
I tested this on several Debian and Ubuntu systems, 32 and 64bits (no configuration was needed).
|
||||
I also tested it on FreeBSD 9.3 32bits (font and encoding configuration
|
||||
was needed in this case).</p>
|
||||
|
||||
<p>Basic mode:</p>
|
||||
|
||||
<pre><code>$ echo 'I am testing this thing.' | ./prog
|
||||
[... rendering ...]
|
||||
|
||||
$ ./prog < lorem-ipsum.txt
|
||||
[... rendering ...]
|
||||
</code></pre>
|
||||
|
||||
<p>Interactive mode:</p>
|
||||
|
||||
<pre><code>$ ./prog
|
||||
> hello world!!!
|
||||
[... rendering ...]
|
||||
>
|
||||
</code></pre>
|
||||
|
||||
<h3>Obfuscation</h3>
|
||||
|
||||
<p>This entry is obfuscated in various ways:</p>
|
||||
|
||||
<ul>
|
||||
<li>The structure is hidden by avoiding loops, ‘if’ statements, ternary
|
||||
conditionals, and jump-related instructions. Instead, recursivity is
|
||||
heavily used.</li>
|
||||
<li>Merging all functions into one added even more recursivity. ;)</li>
|
||||
<li>The provided code does not contain the same number of opening and closing
|
||||
parenthesis.</li>
|
||||
<li>Preprocessing the code inflates it and adds lots of indents. Removing some
|
||||
of the tricks involved without breaking the program will be challenging.</li>
|
||||
<li>The program ‘plays’ with standard input & output streams, which causes
|
||||
unusual side effects.</li>
|
||||
<li>Some variables are re-used for unrelated processings.</li>
|
||||
<li>Crucial data may be hidden in unexpected places (e.g. as the size of
|
||||
a temporary buffer).</li>
|
||||
<li>Some parts of the code may have no effect (but may have an effect in a
|
||||
specific context, who knows?), and classical libc functions may not act
|
||||
as usual.</li>
|
||||
<li>And of course variable names are hard to read (or distracting).</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>On the other hand, the following may help:</p>
|
||||
|
||||
<ul>
|
||||
<li>The code layout should help to identify which part of the code is
|
||||
obfuscated. ;)</li>
|
||||
<li>File ‘codes.txt’ shows how each character is drawn. This data is
|
||||
encoded in macro O_o at the top of the source file.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Limitations</h3>
|
||||
|
||||
<h4>Charset</h4>
|
||||
|
||||
<p>In order to comply with the size rule, I encoded only a part of the visible ASCII
|
||||
chars:</p>
|
||||
|
||||
<pre><code>a-z, A-Z, '.' ':' ',' ';' '!' and '?'.
|
||||
</code></pre>
|
||||
|
||||
<p>Uppercase and lowercase chars are rendered the same.
|
||||
The program also understand the space and the linefeed (\n).
|
||||
Other chars are simply ignored (most of the time ;)</p>
|
||||
|
||||
<h4>Stack size</h4>
|
||||
|
||||
<p>This limitation is due to the heavy use of recursivity. After having processed
|
||||
a large number of characters, the process may exceed the stack size and crash.
|
||||
(However I did not experience this myself. The top-level recursion might be
|
||||
removed by the compiler as part of its optimizations.)</p>
|
||||
|
||||
<h4>Line rendering</h4>
|
||||
|
||||
<p>The program does its best to avoid cutting words at the end of lines, but
|
||||
it could still happen in case of long words.</p>
|
||||
|
||||
<h3>Subtleties and extra features</h3>
|
||||
|
||||
<h4>Handling more than text docs?</h4>
|
||||
|
||||
<p>Given the limited set of characters handled, the program is mostly limited
|
||||
to simple text documents.
|
||||
Thus, if you try for example:</p>
|
||||
|
||||
<pre><code>$ ./prog < prog.c
|
||||
</code></pre>
|
||||
|
||||
<p>You will not get something that looks like C code. (but you can still try,
|
||||
if you are curious. :)</p>
|
||||
|
||||
<h4>A ‘draft’ mode</h4>
|
||||
|
||||
<p>Defining an environment variable called DRAFT will enable the ‘draft-mode’.
|
||||
Try for example:</p>
|
||||
|
||||
<pre><code>$ echo 'testing the draft mode' | DRAFT=1 ./prog
|
||||
</code></pre>
|
||||
|
||||
<p>The program will run much faster but the rendering will be less precise.</p>
|
||||
|
||||
<h4>The subtle interactive mode</h4>
|
||||
|
||||
<p>I saved the best for last: usually, programs that handle an “interactive
|
||||
mode” have to check whether their standard input is a terminal or not (by
|
||||
using isatty()). Did you notice that this program does not perform any such
|
||||
detection, but still behaves (or seems to behave) appropriately?</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<!--
|
||||
(c) Copyright 1984-2016, [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-2016,
|
||||
<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,187 @@
|
||||
# Best Handwriting
|
||||
|
||||
Etienne Duble <etienne.duble@imag.fr>
|
||||
<http://lig-membres.imag.fr/duble>
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
### To use:
|
||||
|
||||
make
|
||||
|
||||
echo Some text | ./prog
|
||||
|
||||
### Try:
|
||||
|
||||
echo Hello, world | ./prog
|
||||
|
||||
DRAFT=1 ./prog < prog.c
|
||||
|
||||
./prog
|
||||
> [type]
|
||||
(...observe...)
|
||||
|
||||
./prog < prog.c
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
Beautiful penmanship! However, your fonts may vary.
|
||||
|
||||
How does this entry compress the font it uses? What's the purpose of lrand48()?
|
||||
Why does the program dump core, when it does :) ?
|
||||
|
||||
## Author's comments:
|
||||
|
||||
### Introduction
|
||||
|
||||
This program **prints text in your terminal with an interesting
|
||||
hand-writing effect**.
|
||||
|
||||
It uses the *braille patterns* range of the unicode standard: this
|
||||
allows to consider each terminal character as a tiny 2x4 bitmap.
|
||||
|
||||
Turning the Braille code into something visual might be considered
|
||||
blasphemous. When I was fighting to make this program work, I started
|
||||
wondering if it was not the reason for its very erratic behaviour.
|
||||
|
||||
### prog.c vs prog.orig.c
|
||||
|
||||
The file `prog.orig.c` is the one I submitted.
|
||||
|
||||
Gil Dogon noted a few unsafe statements (statements whose behaviour is
|
||||
undefined in the C standard and, as such, could cause issues with other
|
||||
compilers or optimization levels). These have been fixed in `prog.c`.
|
||||
After this fix, in order to remain rule-2-compliant, a variable name has
|
||||
also been shortened in this file.
|
||||
|
||||
### How to build
|
||||
|
||||
If you have `clang`:
|
||||
|
||||
$ CC=clang make -e
|
||||
|
||||
Otherwise (gcc):
|
||||
|
||||
$ make
|
||||
|
||||
(You will get a few warnings in this case.)
|
||||
|
||||
### How to use it
|
||||
|
||||
You need a terminal configured to handle an *UTF-8* encoding and a
|
||||
font including *braille patterns*.
|
||||
This is the default on most modern GNU/Linux operating systems.
|
||||
The default terminal application (gnome-terminal) or even a simple
|
||||
xterm should render things properly.
|
||||
I tested this on several Debian and Ubuntu systems, 32 and 64bits (no configuration was needed).
|
||||
I also tested it on FreeBSD 9.3 32bits (font and encoding configuration
|
||||
was needed in this case).
|
||||
|
||||
Basic mode:
|
||||
|
||||
$ echo 'I am testing this thing.' | ./prog
|
||||
[... rendering ...]
|
||||
|
||||
$ ./prog < lorem-ipsum.txt
|
||||
[... rendering ...]
|
||||
|
||||
Interactive mode:
|
||||
|
||||
$ ./prog
|
||||
> hello world!!!
|
||||
[... rendering ...]
|
||||
>
|
||||
|
||||
### Obfuscation
|
||||
|
||||
This entry is obfuscated in various ways:
|
||||
|
||||
* The structure is hidden by avoiding loops, 'if' statements, ternary
|
||||
conditionals, and jump-related instructions. Instead, recursivity is
|
||||
heavily used.
|
||||
* Merging all functions into one added even more recursivity. ;)
|
||||
* The provided code does not contain the same number of opening and closing
|
||||
parenthesis.
|
||||
* Preprocessing the code inflates it and adds lots of indents. Removing some
|
||||
of the tricks involved without breaking the program will be challenging.
|
||||
* The program 'plays' with standard input & output streams, which causes
|
||||
unusual side effects.
|
||||
* Some variables are re-used for unrelated processings.
|
||||
* Crucial data may be hidden in unexpected places (e.g. as the size of
|
||||
a temporary buffer).
|
||||
* Some parts of the code may have no effect (but may have an effect in a
|
||||
specific context, who knows?), and classical libc functions may not act
|
||||
as usual.
|
||||
* And of course variable names are hard to read (or distracting).
|
||||
|
||||
On the other hand, the following may help:
|
||||
|
||||
* The code layout should help to identify which part of the code is
|
||||
obfuscated. ;)
|
||||
* File 'codes.txt' shows how each character is drawn. This data is
|
||||
encoded in macro O_o at the top of the source file.
|
||||
|
||||
|
||||
### Limitations
|
||||
|
||||
#### Charset
|
||||
|
||||
In order to comply with the size rule, I encoded only a part of the visible ASCII
|
||||
chars:
|
||||
|
||||
a-z, A-Z, '.' ':' ',' ';' '!' and '?'.
|
||||
|
||||
Uppercase and lowercase chars are rendered the same.
|
||||
The program also understand the space and the linefeed (\n).
|
||||
Other chars are simply ignored (most of the time ;)
|
||||
|
||||
#### Stack size
|
||||
|
||||
This limitation is due to the heavy use of recursivity. After having processed
|
||||
a large number of characters, the process may exceed the stack size and crash.
|
||||
(However I did not experience this myself. The top-level recursion might be
|
||||
removed by the compiler as part of its optimizations.)
|
||||
|
||||
#### Line rendering
|
||||
|
||||
The program does its best to avoid cutting words at the end of lines, but
|
||||
it could still happen in case of long words.
|
||||
|
||||
### Subtleties and extra features
|
||||
|
||||
#### Handling more than text docs?
|
||||
|
||||
Given the limited set of characters handled, the program is mostly limited
|
||||
to simple text documents.
|
||||
Thus, if you try for example:
|
||||
|
||||
$ ./prog < prog.c
|
||||
|
||||
You will not get something that looks like C code. (but you can still try,
|
||||
if you are curious. :)
|
||||
|
||||
#### A 'draft' mode
|
||||
|
||||
Defining an environment variable called DRAFT will enable the 'draft-mode'.
|
||||
Try for example:
|
||||
|
||||
$ echo 'testing the draft mode' | DRAFT=1 ./prog
|
||||
|
||||
The program will run much faster but the rendering will be less precise.
|
||||
|
||||
#### The subtle interactive mode
|
||||
|
||||
I saved the best for last: usually, programs that handle an "interactive
|
||||
mode" have to check whether their standard input is a terminal or not (by
|
||||
using isatty()). Did you notice that this program does not perform any such
|
||||
detection, but still behaves (or seems to behave) appropriately?
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(c) Copyright 1984-2016, [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/
|
||||
-->
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat in, pretium a, enim. Pellentesque congue. Ut in risus volutpat libero pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo in pede. Praesent blandit odio eu enim. Pellentesque sed dui ut augue blandit sodales. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam nibh. Mauris ac mauris sed pede pellentesque fermentum. Maecenas adipiscing ante non diam sodales hendrerit.
|
||||
|
||||
Ut velit mauris, egestas sed, gravida nec, ornare ut, mi. Aenean ut orci vel massa suscipit pulvinar. Nulla sollicitudin. Fusce varius, ligula non tempus aliquam, nunc turpis ullamcorper nibh, in tempus sapien eros vitae ligula. Pellentesque rhoncus nunc et augue. Integer id felis. Curabitur aliquet pellentesque diam. Integer quis metus vitae elit lobortis egestas. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi vel erat non mauris convallis vehicula. Nulla et sapien. Integer tortor tellus, aliquam faucibus, convallis id, congue eu, quam. Mauris ullamcorper felis vitae erat. Proin feugiat, augue non elementum posuere, metus purus iaculis lectus, et tristique ligula justo vitae magna.
|
||||
|
||||
Aliquam convallis sollicitudin purus. Praesent aliquam, enim at fermentum mollis, ligula massa adipiscing nisl, ac euismod nibh nisl eu lectus. Fusce vulputate sem at sapien. Vivamus leo. Aliquam euismod libero eu enim. Nulla nec felis sed leo placerat imperdiet. Aenean suscipit nulla in justo. Suspendisse cursus rutrum augue. Nulla tincidunt tincidunt mi. Curabitur iaculis, lorem vel rhoncus faucibus, felis magna fermentum augue, et ultricies lacus lorem varius purus. Curabitur eu amet.
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#define O_o "sfX4.Fv8H!`uf"\
|
||||
"|~0y'vWtA@:LcO9d}y.!uL!Gd+ml(<+Ds!J"\
|
||||
"e.6!r!%l6G!n~^<i=%pEwL%P!'<!FQt%u 5toG57j/3"\
|
||||
"!:E%;!ea!!!WqE0z!f/y}!%!!Qi6!uzt!n}?]!bl!ak!SetR<"\
|
||||
"Zj$x!~V!n&g8!cK! KrgR'8@c]!%-q9V.3fa[E8X%dY'w!#H <P~6"\
|
||||
"?guhljL!^P% ?" "8!@dP,!!o+fb"\
|
||||
"!pv!;!Hm%Ro4" "n:}nkD!Q!kN"\
|
||||
"e:| 'b5sc!e" /* nothing */
|
||||
#define mu(a) a a a a a //-
|
||||
#define O_(Q_ ) "\033[" #Q_
|
||||
#define Q_(O) mu(mu(mu(O)))
|
||||
#define Q/*-- ++--*/O9--||(
|
||||
#define main( )main(){/**/\
|
||||
signal(13,1), _();}f()//--+
|
||||
#define k( k) getenv( "D"#k
|
||||
char*O0=O_o,OO,*Q1,O5[97];int*Q5,_Q=0,Q0=0,_O=0,_0=0,O=5,QQ,O6,Q6,O3
|
||||
,Q4,O4=41088,O1=sizeof(O5),O7=234;long long __;_()Q_({)int*Q3,Q2,O2,C,
|
||||
QO,O9=O,O8=!!!!!!!!!!k(RAFT));long long Q8;char*Q9=O_(1A)O_(%dB)O_(%dC
|
||||
)O_(34m)"\xe2%c%c\r\n"O_(0m)O_(%dA),*Q7;__+=(__*92+*O0-35-__)*(QO=Q_(!
|
||||
!)(*O0-33)*!O9--),O0+=O1*QO,QO&&_(),Q Q4&&(O--,_(),O0+=194,O++,Q4--,_(
|
||||
))),Q O=0,__=0,_(),O=3,_()),Q __&&(C=__&15,_O+=(C<2)*12+!(QO=C&14^2)*(
|
||||
4-_O)+(C==6)*( 12-2*_O)+(C>6)*(9-(C-7)%3),_Q+=!QO*(_Q%QQ+(C&1)*O3-_Q),
|
||||
_0+=!_0*!QO+(1-2*_0)*!(C^4),(C==5)&&(__>>=4,Q8=__,Q7=O0,Q4=__&15,O=1,_
|
||||
()|O ++&_(),__=Q8 ,O0=Q7 ),Q3=( _Q+= O8*(9 *O4*
|
||||
O1 > lrand48()) +(_O%=8,( (_O% 6>2) -(_O%
|
||||
7<2) )*QQ+((_O +7)%8<3 )-(_O>4) )*( C>5 ),
|
||||
Q2 = _Q/ O3)* O6+Q5 +(O2=_Q%QQ )/ 2,*Q3=*
|
||||
Q3 % O4+O4|(1 << Q_("" "@CADBEHI") [_Q%2+_Q
|
||||
%O3/ QQ*2 ]- 64)* _0, sprintf(O5, Q9, Q2+1,
|
||||
O2/2 ,*Q3>>8 ,85* 3&* Q3,Q2+1 )&& _0&&(O=8,
|
||||
Q1 = O5,_()), Q0 +=(O2 >Q0)*_0*(O2 -Q0 ),__
|
||||
+=!( C>9)*(3- __+ ( __>>4))-3, __ +=(C>12
|
||||
) *( (__<<4 )+ C-3-__) ,usleep( O4* _0/(3*
|
||||
O8+1 )),O =3,_() )) ,!O9 --&& read(
|
||||
1 ,& OO,1)> 0&&(O= (QO=OO ==35 )*3+6 ,_()
|
||||
,QO&&(OO=10,O=6,_(),1)||(O=4,_()),0)||close(dup2(3-dup2(1,dup(0)-3),1)
|
||||
*0+2)*0||Q write(1,"> ",2),ioctl(Q0=0,TIOCGWINSZ,O5)^--O&(O3=(QQ=(O6=*
|
||||
((short*)O5+1))*2)*4),Q6=-O1,Q5=calloc(3*O6,8),_()),Q (O=8,QO=!(O2=OO-
|
||||
10)|!(Q2=OO-32)*(Q0+58>QQ)|(Q0+12>QQ))&&(Q1=O_(3B),_(),write(1,"> ",2)
|
||||
),Q0+=!QO*!Q2*4-QO*Q0,O2*Q2&&(!Q0&&(memset(Q5,0,3*O3),Q0=4,Q1="\n\n\n"
|
||||
O_(3A),_()),O=7,_Q=7*QQ+Q0+2,_O=_0=0,OO+=(OO>64 &OO<91)*32,O0=Q_(O_o)+
|
||||
O7,_(),(*O0-OO)||(O=2,O0+='a',_( )))),Q *O0-OO)&&(*(O0+=O1)-33)&&(O=0,
|
||||
_(),O=7,O0+=O1,_()),Q write(0,Q1,strlen(Q1))),Q OO=Q_(O_o)[Q6+=O1],(Q6
|
||||
%strlen(O_o)-O7)&&(O=6,_(),O=9,_()));Q_(})/*+++++ IOCCC 2015 +++++*/
|
||||
|
||||
main()
|
||||
{
|
||||
puts("hello world!");
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#define O_o "sfX4.Fv8H!`uf"\
|
||||
"|~0y'vWtA@:LcO9d}y.!uL!Gd+ml(<+Ds!J"\
|
||||
"e.6!r!%l6G!n~^<i=%pEwL%P!'<!FQt%u 5toG57j/3"\
|
||||
"!:E%;!ea!!!WqE0z!f/y}!%!!Qi6!uzt!n}?]!bl!ak!SetR<"\
|
||||
"Zj$x!~V!n&g8!cK! KrgR'8@c]!%-q9V.3fa[E8X%dY'w!#H <P~6"\
|
||||
"?guhljL!^P% ?" "8!@dP,!!o+fb"\
|
||||
"!pv!;!Hm%Ro4" "n:}nkD!Q!kN"\
|
||||
"e:| 'b5sc!e" /* nothing */
|
||||
#define mu(a) a a a a a //-
|
||||
#define O_(Q_ ) "\033[" #Q_
|
||||
#define Q_(O) mu(mu(mu(O)))
|
||||
#define Q/*-- ++--*/O9--||(
|
||||
#define main( )main(){/**/\
|
||||
signal(13,1), _();}f()//--+
|
||||
#define k( k) getenv( "D"#k
|
||||
char*O0=O_o,OO,*Q1,O5[97];int*Q5,_Q=0,Q0=0,_O=0,_0=0,O=5,QQ,O6,Q6,O3
|
||||
,Q4,O4=41088,O1=sizeof(O5),O7=234;long long __;_()Q_({)int*Q3,Q2,O2,OQ
|
||||
,QO, O9=O,O8=!!/*OQ*/k(RAFT));long long Q8;char*Q9=O_(1A)O_(%dB)O_(%dC
|
||||
)O_(34m)"\xe2%c%c\r\n"O_(0m)O_(%dA),*Q7;__+=(__*92+*O0-35-__)*(QO=Q_(!
|
||||
!)(*O0-33)*!O9--),O0+=O1*QO,QO&&_(),Q Q4&&(O--,_(),O0+=194,O++,Q4--,_(
|
||||
))),Q O=0,__=0,_(),O=3,_()),Q __&&(_O+=((OQ=__&15)<2)*12+!(QO=OQ&14^2)
|
||||
*(4-_O)+(OQ==6)*(12-2*_O)+(OQ>6)*(9-(OQ-7)%3),_Q+=!QO*(_Q%QQ+(OQ&1)*O3
|
||||
-_Q),_0+=!_0*!QO+(1-2*_0)*!(OQ^4),(OQ==5)&&(__>>=4,Q8=__,Q7 =O0,Q4=__&
|
||||
15,O =1,_()|++O&_ (),O0 =Q7,__= Q8), Q3 =( Q2=(
|
||||
_Q+= (lrand48() <O4*O1*9) *O8+ (OQ> 5)*((
|
||||
(2<( _O%=8)%6) -(_O%7< 2))*QQ+( (_O +7)%8<
|
||||
3)-( _O>4)))/ O3 )* O6+Q5+(O2= _Q %QQ)/2,
|
||||
*Q3= *Q3 %O4+ O4 |(1<< Q_("@CADBE" "HI")[_Q
|
||||
%O3/ QQ*2+_Q %2]- 64) *_0,sprintf (O5,Q9,Q2
|
||||
+=1, O2 /2,* Q3>> 8,* Q3&85*3,Q2) &&_0&&(Q1
|
||||
=O5, O =8,_() ), Q0+=( O2>Q0)*_0*( O2-Q0 ),
|
||||
__+= (OQ>12)* (((__ +=!(OQ>9)* (3 -__+(__
|
||||
>>4) )-3)<<4)+ OQ-3-__ ),usleep (O4 *_0/(3
|
||||
*O8+ 1)), O=3,_())) ,!O9 --&& read(
|
||||
1 ,& OO,1)> 0&&(O= (QO=OO ==35 )*3+6 ,_()
|
||||
,QO&&(OO=10,O=6,_(),1)||(O=4,_()),0)||close(dup2(3-dup2(1,dup(0)-3),1)
|
||||
*0+2)*0||Q write(1,"> ",2),ioctl(Q0=0,TIOCGWINSZ,O5)^--O&(O3=(QQ=(O6=*
|
||||
((short*)O5+1))*2)*4),Q6=-O1,Q5=calloc(3*O6,8),_()),Q (O=8,QO=!(O2=OO-
|
||||
10)|!(Q2=OO-32)*(Q0+58>QQ)|(Q0+12>QQ))&&(Q1=O_(3B),_(),write(1,"> ",2)
|
||||
),Q0+=!QO*!Q2*4-QO*Q0,O2*Q2&&(!Q0&&(memset(Q5,0,3*O3),Q0=4,Q1="\n\n\n"
|
||||
O_(3A),_()),O=7,_Q=7*QQ+Q0+2,_O=_0=0,OO+=(OO>64 &OO<91)*32,O0=Q_(O_o)+
|
||||
O7,_(),(*O0-OO)||(O=2,O0+='a',_( )))),Q *O0-OO)&&(*(O0+=O1)-33)&&(O=0,
|
||||
_(),O=7,O0+=O1,_()),Q write(0,Q1,strlen(Q1))),Q OO=Q_(O_o)[Q6+=O1],(Q6
|
||||
%strlen(O_o)-O7)&&(O=6,_(),O=9,_()));Q_(})/*+++++ IOCCC 2015 +++++*/
|
||||
|
||||
main()
|
||||
{
|
||||
puts("hello world!");
|
||||
}
|
||||
Reference in new issue
Block a user