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,286 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2018 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
|
||||
GZIP_PROG= gzip
|
||||
BZIP2= bzip2
|
||||
CURL= curl
|
||||
DD= dd
|
||||
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-string-plus-int -Wno-empty-body -Wno-unused-result
|
||||
#CSILENCE= -Wno-implicit-int
|
||||
|
||||
# compiler standard
|
||||
#
|
||||
#CSTD=
|
||||
#CSTD= -ansi
|
||||
CSTD= -std=c11
|
||||
|
||||
# compiler bit architecture
|
||||
#
|
||||
# Some entries require 32-bitness:
|
||||
# ARCH= -m32
|
||||
#
|
||||
# Some entries require 64-bitness:
|
||||
# ARCH= -m64
|
||||
#
|
||||
# By default we assume nothing:
|
||||
#
|
||||
ARCH=
|
||||
|
||||
# defines that are needed to compile
|
||||
#
|
||||
CDEFINE=
|
||||
#CDEFINE= -DIOCCC=25
|
||||
|
||||
# include files that are needed to compile
|
||||
#
|
||||
CINCLUDE=
|
||||
#CINCLUDE= -include stdlib.h
|
||||
#CINCLUDE= -include stdio.h
|
||||
#CINCLUDE= -include stdlib.h -include stdio.h
|
||||
#CINCLUDE= -I ${X11_INCDIR}
|
||||
|
||||
# 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= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT}
|
||||
|
||||
# Libraries needed to build
|
||||
#
|
||||
LIBS=
|
||||
#LIBS= -L ${X11_LIBDIR}
|
||||
|
||||
# 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
|
||||
##############################
|
||||
#
|
||||
OBJ= prog.o
|
||||
DATA=
|
||||
TARGET= prog
|
||||
#
|
||||
ALT_OBJ= prog.orig.o
|
||||
ALT_TARGET= prog.orig
|
||||
|
||||
|
||||
#################
|
||||
# build the entry
|
||||
#################
|
||||
#
|
||||
all: ${TARGET} ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
prog: prog.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
||||
|
||||
# alternative executable
|
||||
#
|
||||
alt: ${ALT_TARGET}
|
||||
@${TRUE}
|
||||
|
||||
prog.orig: prog.orig.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
||||
|
||||
# data files
|
||||
#
|
||||
data: ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
${RM} -f ${OBJ} ${ALT_OBJ}
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${TARGET} ${ALT_TARGET}
|
||||
@-if [ -e sandwich ]; then \
|
||||
${RM} -f sandwich; \
|
||||
echo 'ate sandwich'; \
|
||||
fi
|
||||
|
||||
nuke: clobber
|
||||
@${TRUE}
|
||||
|
||||
dist_clean: nuke
|
||||
@${TRUE}
|
||||
|
||||
install:
|
||||
@echo "Surely you are performing, 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 often mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Eggy
|
||||
|
||||
fabricate fashion form frame manufacture produce: make
|
||||
@${TRUE}
|
||||
|
||||
sandwich:
|
||||
@if [ `id -u` -eq 0 ]; then \
|
||||
echo 'Okay.'; \
|
||||
echo $${RANDOM}`date +%s`$${RANDOM} > $@; \
|
||||
else \
|
||||
echo 'What? Make it yourself.'; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
# 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_v6; \
|
||||
else \
|
||||
echo "planet deniers, like some members of the IAU, are so cute when they try to defend their logic"; \
|
||||
fi
|
||||
@echo A $@ helps ${MAKE} the elements that help form planets
|
||||
@${TRUE}
|
||||
|
||||
deep_magic:
|
||||
@-if [ -r .code_anal ]; then \
|
||||
ccode_analysis --deep_magic 3a3fabb90892eeb2f610ae0f74a35a970060665a063ab702bd686c17c4ae07f6 --FNV1a_hash_256_bit "prog"; \
|
||||
else \
|
||||
echo "Wrong! Do it again!"; \
|
||||
sleep 2; \
|
||||
echo "Wrong! Do it again!"; \
|
||||
sleep 2; \
|
||||
echo "Wrong! Do it again!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
|
||||
magic: deep_magic
|
||||
@-if [ -r .code_anal ]; then \
|
||||
ccode_analysis --mode 216091 --level 216193 --FNV1a_hash_256_bit "prog"; \
|
||||
else \
|
||||
echo "If you don't eat yer meat, you can't have any pudding!"; \
|
||||
echo "How can you have any pudding if you don't eat yer meat?!"; \
|
||||
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,162 @@
|
||||
<!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 cacophonic</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most cacophonic</h1>
|
||||
|
||||
<p>Anton Älgmyr<br>
|
||||
Twitter: @aalgmyr</p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make
|
||||
|
||||
cat prog.c | ./prog # Printing garbage might break your font
|
||||
./prog <file1> <file2> > out.raw
|
||||
./prog -d 2 0 out.raw # Decode the first (0th) channel out of two
|
||||
</code></pre>
|
||||
|
||||
<h3>To try:</h3>
|
||||
|
||||
<pre><code>./prog -h | ./prog -d 1 0
|
||||
|
||||
# Who needs cat?
|
||||
./prog prog.c | ./prog -d 1 0
|
||||
|
||||
# Assuming ALSA
|
||||
echo '<<<<<< /\_/\_/\ _-_-_-_ !!!!! :.:.:.: >>>>>> ****** ~~~~~~~' |
|
||||
./prog | aplay -c1 -fFLOAT_LE -r44100
|
||||
|
||||
# Assuming sox
|
||||
echo -n ' MENE MENE TEKEL UPHARSIN ' | ./prog |
|
||||
sox -t raw -c 1 -r 44100 -L -e floating-point -b 32 - -n spectrogram -d 10 -X 300
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>Be warned, this is not your garden variety text-to-speech program! Earplugs are advised,
|
||||
or at least a handy and well-tested volume knob.</p>
|
||||
|
||||
<p>Pixels are numbered, amplitudes are weighed, frequencies are divided,
|
||||
and the message can be displayed in fiery letters, but don’t be alarmed.</p>
|
||||
|
||||
<p>How does decoding of the waveform work? Can you encode an arbitrary text in a sound sample?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h1>What is this?</h1>
|
||||
|
||||
<p>To put it brief, this entry is akin to a sound based cat. It takes characters as input and outputs them into frequency space as audio. The entry also supports decoding the produced waveforms using the <code>-d</code> flag. Usage instructions is output if run with the <code>-h</code> flag, albeit not in an immediately legible format.</p>
|
||||
|
||||
<h2>Details</h2>
|
||||
|
||||
<p>In normal operation, the entry reads characters from one or more sources. If the <code>-h</code> flag is given, usage instructions is used as a source. Else if file paths are present as arguments those will be used. Else stdin is used.</p>
|
||||
|
||||
<p>If a character is part of the supported subset of ASCII <code>{10, 32-126}</code> then that character is output into frequency space of an audio signal (44.1 kHz single precision float, endianness should depend on system endianness) through stdout. Any other character will be interpreted and outputted as a space.</p>
|
||||
|
||||
<p>Characters are printed using a (slightly modified) pixel font based on <a href="https://github.com/hchargois/gohufont">gohufont</a>. Pixels are drawn using crosses in frequency space, achieved by simultaneous up and down chirps.</p>
|
||||
|
||||
<p>Each input source is designated its own channel in the output (one float per channel per time step in the output) so if you have a surround sound system you could listen to a cacophony of chirpy characters.</p>
|
||||
|
||||
<p>Interestingly, with training you might actually be able to tell characters just from hearing. But even without training you can easily read along with the printed characters and have the sound make sense with the look of the characters.</p>
|
||||
|
||||
<p>See image spoiler.png for an example spectrogram.</p>
|
||||
|
||||
<h2>Limitations</h2>
|
||||
|
||||
<p>There is no error checking done when opening files, so expect segfaults if you provide the wrong path to a file.</p>
|
||||
|
||||
<p>This program is bound to misbehave if int is less than 32 bits.</p>
|
||||
|
||||
<p>Flags will only be interpreted correctly if they are the first argument. Reading a file named <code>-d</code> or <code>-h</code> is fully possible if it is not the first file provided, even though I am not sure why you would want to do that.</p>
|
||||
|
||||
<p>Providing invalid/unexpected arguments to the decode flag will result in odd behavior. Some erroneous arguments cause segfaults (negative number of channels, channel id outside valid range). One argument in particular causes an infinite loop printing whitespace.</p>
|
||||
|
||||
<h1>Techniques</h1>
|
||||
|
||||
<h2>Obfuscation</h2>
|
||||
|
||||
<p>A lot of the obfuscations done came naturally from trying to appease the size tool. To name some:</p>
|
||||
|
||||
<ul>
|
||||
<li>One character names</li>
|
||||
<li>Merging of related (and not so related) arithmetic operations</li>
|
||||
<li>Short circuiting for flow control to replace some <code>if</code>s</li>
|
||||
<li>Some <code>#defines</code>, sadly</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>On the intersection of size and obfuscation is the data encoding, which was quite fun to design.</p>
|
||||
|
||||
<p>Some additional obfuscation was done to mathematical formulas. Somewhat known expressions was transformed into equivalent but less recognizable counterparts.</p>
|
||||
|
||||
<p>I have tried to avoid intentional red herrings in the code, although fishy statements are plentiful.</p>
|
||||
|
||||
<h2>Data encoding</h2>
|
||||
|
||||
<p>The large string in the beginning of the source file contains font data, encoded in base64 using characters in the range <code>' '</code> to <code>'_'</code>. The space was chosen as the zero because the data contains a lot of zeroes, and quite helpfully the size tool ignores whitespace even in strings. Without this fact the program would have been too large and the decoding feature would have had to go. Fortunately this hole in the size spec was readily available. :)</p>
|
||||
|
||||
<p>Characters in the font (5x8 pixels, 40 bits) is packed into 7 base64 digits (which was a pain to decode in minimal code).</p>
|
||||
|
||||
<h2>Math</h2>
|
||||
|
||||
<p>Note that even though floats are used for the waveforms, the standard math library is not used at all! Most arithmetic is done purely on integers. The only major exception is generating a table of sine values which are interpolated to give high resolution waveforms. Can you see when the generation is triggered, and how it is done?</p>
|
||||
|
||||
<p>A critical issue encountered was that having abrupt starts and ends of signals cause a lot of problems with spectral leakage which makes spectrograms hard to read and audio painful to listen to. To reduce spectral leakage a windowing function was used. Although the one used is quite well known, it is not in a form that should be familiar to anyone. What looks like a polynomial and quacks like a polynomial might not actually be a polynomial, at least not deep inside.</p>
|
||||
|
||||
<h2>Printing a string</h2>
|
||||
|
||||
<p>The program was written to deal exclusively with file descriptors, so how would one go about printing a char array not from a file descriptor without adding additional logic? Answer: <code>ungetc</code> into stdin, one char at a time (to be standards compliant). This is used to print the usage instructions.</p>
|
||||
|
||||
<h1>Compilation warnings</h1>
|
||||
|
||||
<p>Compiling using</p>
|
||||
|
||||
<pre><code>gcc -Wall -Wextra -pedantic
|
||||
</code></pre>
|
||||
|
||||
<p>gives only <code>-Wmisleading-indentation</code> which is sensible considering the source code. While</p>
|
||||
|
||||
<pre><code>clang -Wall -Wextra -pedantic
|
||||
</code></pre>
|
||||
|
||||
<p>is a bit more pessimistic and gives <code>-Wempty-body</code> (I like loops without bodies), <code>-Wstring-plus-int</code> (since apparently some people think string+int is a concatenation) and one of the weirder warnings I have seen from me splitting a negative constant with whitespace. Compiling using</p>
|
||||
|
||||
<pre><code>clang -Wall -Wextra -pedantic -Weverything
|
||||
</code></pre>
|
||||
|
||||
<p>produces a few pagefuls of warnings and makes me feel generally bad about myself. :(</p>
|
||||
|
||||
<h1>Misc</h1>
|
||||
|
||||
<p>The reported size of the source code using the size tool is very intentionally 2018.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<!--
|
||||
(c) Copyright 1984-2018, [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-2018,
|
||||
<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,135 @@
|
||||
# Most cacophonic
|
||||
|
||||
Anton Älgmyr
|
||||
Twitter: @aalgmyr
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
### To use:
|
||||
|
||||
make
|
||||
|
||||
cat prog.c | ./prog # Printing garbage might break your font
|
||||
./prog <file1> <file2> > out.raw
|
||||
./prog -d 2 0 out.raw # Decode the first (0th) channel out of two
|
||||
|
||||
### To try:
|
||||
|
||||
./prog -h | ./prog -d 1 0
|
||||
|
||||
# Who needs cat?
|
||||
./prog prog.c | ./prog -d 1 0
|
||||
|
||||
# Assuming ALSA
|
||||
echo '<<<<<< /\_/\_/\ _-_-_-_ !!!!! :.:.:.: >>>>>> ****** ~~~~~~~' |
|
||||
./prog | aplay -c1 -fFLOAT_LE -r44100
|
||||
|
||||
# Assuming sox
|
||||
echo -n ' MENE MENE TEKEL UPHARSIN ' | ./prog |
|
||||
sox -t raw -c 1 -r 44100 -L -e floating-point -b 32 - -n spectrogram -d 10 -X 300
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
Be warned, this is not your garden variety text-to-speech program! Earplugs are advised,
|
||||
or at least a handy and well-tested volume knob.
|
||||
|
||||
Pixels are numbered, amplitudes are weighed, frequencies are divided,
|
||||
and the message can be displayed in fiery letters, but don't be alarmed.
|
||||
|
||||
How does decoding of the waveform work? Can you encode an arbitrary text in a sound sample?
|
||||
|
||||
|
||||
## Author's comments:
|
||||
|
||||
What is this?
|
||||
=============
|
||||
To put it brief, this entry is akin to a sound based cat. It takes characters as input and outputs them into frequency space as audio. The entry also supports decoding the produced waveforms using the `-d` flag. Usage instructions is output if run with the `-h` flag, albeit not in an immediately legible format.
|
||||
|
||||
Details
|
||||
-------
|
||||
In normal operation, the entry reads characters from one or more sources. If the `-h` flag is given, usage instructions is used as a source. Else if file paths are present as arguments those will be used. Else stdin is used.
|
||||
|
||||
If a character is part of the supported subset of ASCII `{10, 32-126}` then that character is output into frequency space of an audio signal (44.1 kHz single precision float, endianness should depend on system endianness) through stdout. Any other character will be interpreted and outputted as a space.
|
||||
|
||||
Characters are printed using a (slightly modified) pixel font based on [gohufont](https://github.com/hchargois/gohufont). Pixels are drawn using crosses in frequency space, achieved by simultaneous up and down chirps.
|
||||
|
||||
Each input source is designated its own channel in the output (one float per channel per time step in the output) so if you have a surround sound system you could listen to a cacophony of chirpy characters.
|
||||
|
||||
Interestingly, with training you might actually be able to tell characters just from hearing. But even without training you can easily read along with the printed characters and have the sound make sense with the look of the characters.
|
||||
|
||||
See image spoiler.png for an example spectrogram.
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
There is no error checking done when opening files, so expect segfaults if you provide the wrong path to a file.
|
||||
|
||||
This program is bound to misbehave if int is less than 32 bits.
|
||||
|
||||
Flags will only be interpreted correctly if they are the first argument. Reading a file named `-d` or `-h` is fully possible if it is not the first file provided, even though I am not sure why you would want to do that.
|
||||
|
||||
Providing invalid/unexpected arguments to the decode flag will result in odd behavior. Some erroneous arguments cause segfaults (negative number of channels, channel id outside valid range). One argument in particular causes an infinite loop printing whitespace.
|
||||
|
||||
Techniques
|
||||
==========
|
||||
|
||||
Obfuscation
|
||||
-----------
|
||||
A lot of the obfuscations done came naturally from trying to appease the size tool. To name some:
|
||||
|
||||
* One character names
|
||||
* Merging of related (and not so related) arithmetic operations
|
||||
* Short circuiting for flow control to replace some `if`s
|
||||
* Some `#defines`, sadly
|
||||
|
||||
On the intersection of size and obfuscation is the data encoding, which was quite fun to design.
|
||||
|
||||
Some additional obfuscation was done to mathematical formulas. Somewhat known expressions was transformed into equivalent but less recognizable counterparts.
|
||||
|
||||
I have tried to avoid intentional red herrings in the code, although fishy statements are plentiful.
|
||||
|
||||
|
||||
Data encoding
|
||||
-------------
|
||||
The large string in the beginning of the source file contains font data, encoded in base64 using characters in the range `' '` to `'_'`. The space was chosen as the zero because the data contains a lot of zeroes, and quite helpfully the size tool ignores whitespace even in strings. Without this fact the program would have been too large and the decoding feature would have had to go. Fortunately this hole in the size spec was readily available. :)
|
||||
|
||||
Characters in the font (5x8 pixels, 40 bits) is packed into 7 base64 digits (which was a pain to decode in minimal code).
|
||||
|
||||
Math
|
||||
----
|
||||
Note that even though floats are used for the waveforms, the standard math library is not used at all! Most arithmetic is done purely on integers. The only major exception is generating a table of sine values which are interpolated to give high resolution waveforms. Can you see when the generation is triggered, and how it is done?
|
||||
|
||||
A critical issue encountered was that having abrupt starts and ends of signals cause a lot of problems with spectral leakage which makes spectrograms hard to read and audio painful to listen to. To reduce spectral leakage a windowing function was used. Although the one used is quite well known, it is not in a form that should be familiar to anyone. What looks like a polynomial and quacks like a polynomial might not actually be a polynomial, at least not deep inside.
|
||||
|
||||
Printing a string
|
||||
-----------------
|
||||
The program was written to deal exclusively with file descriptors, so how would one go about printing a char array not from a file descriptor without adding additional logic? Answer: `ungetc` into stdin, one char at a time (to be standards compliant). This is used to print the usage instructions.
|
||||
|
||||
Compilation warnings
|
||||
====================
|
||||
Compiling using
|
||||
|
||||
gcc -Wall -Wextra -pedantic
|
||||
|
||||
gives only `-Wmisleading-indentation` which is sensible considering the source code. While
|
||||
|
||||
clang -Wall -Wextra -pedantic
|
||||
|
||||
is a bit more pessimistic and gives `-Wempty-body` (I like loops without bodies), `-Wstring-plus-int` (since apparently some people think string+int is a concatenation) and one of the weirder warnings I have seen from me splitting a negative constant with whitespace. Compiling using
|
||||
|
||||
clang -Wall -Wextra -pedantic -Weverything
|
||||
|
||||
produces a few pagefuls of warnings and makes me feel generally bad about myself. :(
|
||||
|
||||
Misc
|
||||
====
|
||||
The reported size of the source code using the size tool is very intentionally 2018.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(c) Copyright 1984-2018, [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,66 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#define M malloc(sizeof(
|
||||
#define R fread(x,sizeof(float),Z*w,f)
|
||||
#define E free(
|
||||
|
||||
char*G=
|
||||
" "
|
||||
" '"
|
||||
"@(*AP( "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" _"
|
||||
"0 #@ . \"C^*/XH\"Q2_U(D&(5*E0C 4B54DV X \"!9A@ 89H$ !"
|
||||
"0(/@@4 @(/@@( #@T @(\" @( P, , P# , #Y1244^ ?R 0#%)14,A#9)24$B 1"
|
||||
"_)!0,$Y145%R Y145$^&!81T! #9)24DV#Y)24DP ;&P -C4 $$B% @ !04%!04 @4(D$ #!(1"
|
||||
"4 @#U574$^'^0D)!_&Z1D9'_$*!@8%^'Z!@8'_(&1D9'_(\"0D)#_%Z1D8%^/\\0$!#_ \"!_X$ /X! 0"
|
||||
"$&(-$*!#_ $! 0'_/] ,$#_/\\&&&#_'Z!@8%^&\"0D)#_'V\"A8%^&>8D)#_$Z1D9%B(\" _X\" /X"
|
||||
"! 0'^/ , PSP/P#' /\\,<H$\"C', @'R# ,&AD8F'(&!_P ,,,, _X&!! @0\" 0 "
|
||||
"$! 0$! @0( \\5%14\" X1$0G_!$1$1$./\\2$1$. T5%14. \"0D'\\ 'Y)"
|
||||
"144X \\0$ C_ !7Q 7A$! $2# 3_ $!_H \\0'Q ? \\0"
|
||||
"$! ? X1$1$.#A$1\"1_'](1$0X @0$ @? (5%14)"
|
||||
" 1$?X0!\\\" 0$>!@& 088!X!#@$>"
|
||||
"!$*! H1#X)!04X!$9%1,1"
|
||||
"(&!;A 0 _P "
|
||||
" ! 0;H&!"
|
||||
" @$\""
|
||||
"! ("
|
||||
"\0"; int s,p,e,c,t,r,a,l; /* l e a k a g e */
|
||||
|
||||
int
|
||||
F(int o
|
||||
,int n, int t
|
||||
){char*p=(o*(136-o)
|
||||
>=1260)*7*(o-9)+G; for(
|
||||
n=!(o=-1); n=*p+++64*n-*G
|
||||
,(o+=3)>>2<5-t; ); return 255
|
||||
&n>>2*o%8; } float L[0x400];int
|
||||
T(float a,float b,float l,float*e)
|
||||
{return L[0x3ff]||!(e[1]=b*a+l**e)||
|
||||
!T(l*a-b**e,b,l,e+1); } float f(int x)
|
||||
{int w=s<<!!T(1,6.135885e-3,-1.882472e-5
|
||||
+1,L); x=(x%w+w)%w<<9; return(L[x/s]*(s-x%
|
||||
s)+L[x/s+1]*(x%s))/s; } int C(float*h,float*
|
||||
i,int r,int P){ int x,y,c; for(y=0; h<i; ++y,h
|
||||
+=r){ c=P<1; for(*h=x=0; x<8; c+=(1&P>>x&&P+(*
|
||||
h+=f(e*(l+a*(2*x+1))*y)*f(s/2-e*a*y+e*a*y*y*(t/p
|
||||
)/(s/p)))),++x); float z=f(y*t)*f(y*t); *h=z*(1+3*
|
||||
z+2*z*z)/6**h/c; } return h-i-r+1; } void d(int w,
|
||||
int n,FILE*f){int Z=s/t; int S[5]; float**P=M float*
|
||||
)*c);for(r=0;r<c;++r){ P[r]=M float)*Z); C(P[r],P[r]
|
||||
+Z,1,r); } float*x=M float)*Z*w); for (; ; ){ for(r=0;
|
||||
r<5 ; ++r){ int o=1; for(R,a=256; o&&--a; )for(o=t=0; t<Z; o+=
|
||||
P[a][ t]!=x[w*t+n],++t); S[r]=a; } if(R-Z*w)break; for(r=a= - 12;r<
|
||||
5&&(a+= a<11?22:1)<127; )for(r=-1; ++r<5&&F(a,1,r)==S[r]; );if(a <127&&r
|
||||
==5 )putchar( a); } for(; --c; E P[c])); E P); fclose(f);}int main(int q,char**v) {s=
|
||||
44100 ;p=25; e= 55;c=256; t=75; r=q>1?v[1][0]*c+v[1][1]:0; a=7;l=16;if(r ==11620){d (atoi
|
||||
(v[2]), atoi(v[3]), q<5?stdin:fopen(v[4],"r")); return 0; } char*H=malloc(c),* h=H; sprintf (H,"\0"
|
||||
"Usage\n" " %s [-" "h] [-d #c cid] file1 file2 ... (or stdin)"+(q-1&&r==11624 ),v[0]);if(* H)q=1;int
|
||||
w=2>q?1:q -1; FILE**f=M FILE*)*w); f[0]=stdin; if(q>1)for(r=0; r<w; f[r]=fopen(v[r +1],"r"),++r); int l=s/t
|
||||
*w; float *b=M float)*l ),*t=b+l; int*i=M int)*w); for(; ; ){ int x=*h&&1>ungetc(* H++,*f); for(r =w; r--;)
|
||||
{ i[r]=getc (f[r]); if(i[r]<0)i[r]=!++x; } if(x==w)break; while(++r<6){ while(C(b++,t,w,F(*i++,r< 5,r))); i-=
|
||||
w; fwrite(b-=w,sizeof(float),l,stdout); } fflush(stdout); } while(fclose(f[--w]),w); E f); E b); E i); E h);}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#define M malloc(sizeof(
|
||||
#define R fread(x,sizeof(float),Z*w,f)
|
||||
#define E free(
|
||||
|
||||
char*G=
|
||||
" "
|
||||
" '"
|
||||
"@(*AP( "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" _"
|
||||
"0 #@ . \"C^*/XH\"Q2_U(D&(5*E0C 4B54DV X \"!9A@ 89H$ !"
|
||||
"0(/@@4 @(/@@( #@T @(\" @( P, , P# , #Y1244^ ?R 0#%)14,A#9)24$B 1"
|
||||
"_)!0,$Y145%R Y145$^&!81T! #9)24DV#Y)24DP ;&P -C4 $$B% @ !04%!04 @4(D$ #!(1"
|
||||
"4 @#U574$^'^0D)!_&Z1D9'_$*!@8%^'Z!@8'_(&1D9'_(\"0D)#_%Z1D8%^/\\0$!#_ \"!_X$ /X! 0"
|
||||
"$&(-$*!#_ $! 0'_/] ,$#_/\\&&&#_'Z!@8%^&\"0D)#_'V\"A8%^&>8D)#_$Z1D9%B(\" _X\" /X"
|
||||
"! 0'^/ , PSP/P#' /\\,<H$\"C', @'R# ,&AD8F'(&!_P ,,,, _X&!! @0\" 0 "
|
||||
"$! 0$! @0( \\5%14\" X1$0G_!$1$1$./\\2$1$. T5%14. \"0D'\\ 'Y)"
|
||||
"144X \\0$ C_ !7Q 7A$! $2# 3_ $!_H \\0'Q ? \\0"
|
||||
"$! ? X1$1$.#A$1\"1_'](1$0X @0$ @? (5%14)"
|
||||
" 1$?X0!\\\" 0$>!@& 088!X!#@$>"
|
||||
"!$*! H1#X)!04X!$9%1,1"
|
||||
"(&!;A 0 _P "
|
||||
" ! 0;H&!"
|
||||
" @$\""
|
||||
"! ("
|
||||
"\0"; int s,p,e,c,t,r,a,l; /* l e a k a g e */
|
||||
|
||||
int
|
||||
F(int o
|
||||
,int n, int t
|
||||
){char*p=(o*(136-o)
|
||||
>=1260)*7*(o-9)+G; for(
|
||||
n=!(o=-1); n=*p+++64*n-*G
|
||||
,(o+=3)>>2<5-t; ); return 255
|
||||
&n>>2*o%8; } float L[0x400];int
|
||||
T(float a,float b,float l,float*e)
|
||||
{return L[0x3ff]||!(e[1]=b*a+l**e)||
|
||||
!T(l*a-b**e,b,l,e+1); } float f(int x)
|
||||
{int w=s<<!!T(1,6.135885e-3,-1.882472e-5
|
||||
+1,L); x=(x%w+w)%w<<9; return(L[x/s]*(s-x%
|
||||
s)+L[x/s+1]*(x%s))/s; } int C(float*h,float*
|
||||
i,int r,int P){ int x,y,c; for(y=0; h<i; ++y,h
|
||||
+=r){ c=P<1; for(*h=x=0; x<8; c+=(1&P>>x&&P+(*
|
||||
h+=f(e*(l+a*(2*x+1))*y)*f(s/2-e*a*y+e*a*y*y*(t/p
|
||||
)/(s/p)))),++x); float z=f(y*t)*f(y*t); *h=z*(1+3*
|
||||
z+2*z*z)/6**h/c; } return h-i-r+1; } void d(int w,
|
||||
int n,FILE*f){int Z=s/t; int S[5]; float**P=M float*
|
||||
)*c);for(r=0;r<c;++r){ P[r]=M float)*Z); C(P[r],P[r]
|
||||
+Z,1,r); } float*x=M float)*Z*w); for (; ; ){ for(r=0;
|
||||
r<5 ; ++r){ int o=1; for(R,a=256; o&&--a; )for(o=t=0; t<Z; o+=
|
||||
P[a][ t]!=x[w*t+n],++t); S[r]=a; } if(R-Z*w)break; for(r=a=- 12;r<
|
||||
5&&(a+= a<11?22:1)<127; )for(r=-1; ++r<5&&F(a,1,r)==S[r]; );if(a <127&&r
|
||||
==5 )putchar( a); } for(; --c; E P[c])); E P); fclose(f);}int main(int q,char**v) {s=
|
||||
44100 ;p=25; e= 55;c=256; t=75; r=q>1?v[1][0]*c+v[1][1]:0; a=7;l=16;if(r ==11620){d (atoi
|
||||
(v[2]), atoi(v[3]), q<5?stdin:fopen(v[4],"r")); return 0; } char*H=malloc(c),* h=H; sprintf (H,"\0"
|
||||
"Usage\n" " %s [-" "h] [-d #c cid] file1 file2 ... (or stdin)"+(q-1&&r==11624 ),v[0]);if(* H)q=1;int
|
||||
w=2>q?1:q -1; FILE**f=M FILE*)*w); f[0]=stdin; if(q>1)for(r=0; r<w; f[r]=fopen(v[r +1],"r"),++r); int l=s/t
|
||||
*w; float *b=M float)*l ),*t=b+l; int*i=M int)*w); for(; ; ){ int x=*h&&1>ungetc(* H++,*f); for(r =w; r--;)
|
||||
{ i[r]=getc (f[r]); if(i[r]<0)i[r]=!++x; } if(x==w)break; while(++r<6){ while(C(b++,t,w,F(*i++,r< 5,r))); i-=
|
||||
w; fwrite(b-=w,sizeof(float),l,stdout); } fflush(stdout); } while(fclose(f[--w]),w); E f); E b); E i); E h);}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
Reference in new issue
Block a user