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
Binary file not shown.
@@ -0,0 +1,68 @@
|
||||
2014/2014.tar.bz2
|
||||
2014/MANIFEST
|
||||
2014/Makefile
|
||||
2014/birken/Makefile
|
||||
2014/birken/hint.html
|
||||
2014/birken/hint.text
|
||||
2014/birken/prog.c
|
||||
2014/deak/Makefile
|
||||
2014/deak/hint.html
|
||||
2014/deak/hint.text
|
||||
2014/deak/prog.c
|
||||
2014/endoh1/Makefile
|
||||
2014/endoh1/hint.html
|
||||
2014/endoh1/hint.text
|
||||
2014/endoh1/prog.c
|
||||
2014/endoh1/src.zip
|
||||
2014/endoh2/Makefile
|
||||
2014/endoh2/hint.html
|
||||
2014/endoh2/hint.text
|
||||
2014/endoh2/prog.c
|
||||
2014/guidelines.txt
|
||||
2014/hint.css
|
||||
2014/iocccsize.c
|
||||
2014/iocccsize.mk
|
||||
2014/maffiodo1/Makefile
|
||||
2014/maffiodo1/giana.level
|
||||
2014/maffiodo1/giana.rgba
|
||||
2014/maffiodo1/giana8.wav
|
||||
2014/maffiodo1/hint.html
|
||||
2014/maffiodo1/hint.text
|
||||
2014/maffiodo1/mario.level
|
||||
2014/maffiodo1/mario.rgba
|
||||
2014/maffiodo1/mario8.wav
|
||||
2014/maffiodo1/prog.c
|
||||
2014/maffiodo1/prog.orig.c
|
||||
2014/maffiodo1/screenshot-giana.png
|
||||
2014/maffiodo1/screenshot-mario.png
|
||||
2014/maffiodo2/Makefile
|
||||
2014/maffiodo2/hint.html
|
||||
2014/maffiodo2/hint.text
|
||||
2014/maffiodo2/image.rgb
|
||||
2014/maffiodo2/prog.c
|
||||
2014/morgan/Makefile
|
||||
2014/morgan/hint.html
|
||||
2014/morgan/hint.text
|
||||
2014/morgan/prog.c
|
||||
2014/rules.txt
|
||||
2014/sinon/Makefile
|
||||
2014/sinon/glock.sh
|
||||
2014/sinon/hecate.sh
|
||||
2014/sinon/hint.html
|
||||
2014/sinon/hint.text
|
||||
2014/sinon/prog.c
|
||||
2014/sinon/spoiler.html
|
||||
2014/skeggs/Makefile
|
||||
2014/skeggs/hint.html
|
||||
2014/skeggs/hint.text
|
||||
2014/skeggs/prog.c
|
||||
2014/skeggs/prog.orig.c
|
||||
2014/vik/Makefile
|
||||
2014/vik/hint.html
|
||||
2014/vik/hint.text
|
||||
2014/vik/prog.c
|
||||
2014/whowon.html
|
||||
2014/wiedijk/Makefile
|
||||
2014/wiedijk/hint.html
|
||||
2014/wiedijk/hint.text
|
||||
2014/wiedijk/prog.c
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2014 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
|
||||
|
||||
# ANSI compiler
|
||||
#
|
||||
# Set CC to the name of your ANSI compiler.
|
||||
#
|
||||
CC= cc
|
||||
|
||||
|
||||
###############
|
||||
# IOCCC winners
|
||||
###############
|
||||
#
|
||||
WINNERS= birken deak endoh1 endoh2 maffiodo1 maffiodo2 morgan sinon skeggs vik wiedijk
|
||||
|
||||
###################
|
||||
# build all entries
|
||||
###################
|
||||
#
|
||||
all:
|
||||
@for i in ${WINNERS} ; do \
|
||||
echo "(cd $$i && $(MAKE) X11_LIBDIR=${X11_LIBDIR} X11_INCDIR=${X11_INCDIR} $@)"; \
|
||||
(cd $$i && $(MAKE) "X11_LIBDIR=${X11_LIBDIR}" "X11_INCDIR=${X11_INCDIR}" $@); \
|
||||
done
|
||||
|
||||
# alternative executable
|
||||
#
|
||||
alt:
|
||||
@for i in ${WINNERS} ; do \
|
||||
echo "(cd $$i && $(MAKE) X11_LIBDIR=${X11_LIBDIR} X11_INCDIR=${X11_INCDIR} $@)"; \
|
||||
(cd $$i && $(MAKE) "X11_LIBDIR=${X11_LIBDIR}" "X11_INCDIR=${X11_INCDIR}" $@); \
|
||||
done
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
@for i in ${WINNERS} ; do \
|
||||
echo "(cd $$i && $(MAKE) $@)"; \
|
||||
(cd $$i && $(MAKE) $@); \
|
||||
done
|
||||
|
||||
clobber:
|
||||
@for i in ${WINNERS} ; do \
|
||||
echo "(cd $$i && $(MAKE) $@)"; \
|
||||
(cd $$i && $(MAKE) $@); \
|
||||
done
|
||||
|
||||
nuke: clobber
|
||||
@for i in ${WINNERS} ; do \
|
||||
echo "(cd $$i && $(MAKE) $@)"; \
|
||||
(cd $$i && $(MAKE) $@); \
|
||||
done
|
||||
|
||||
install:
|
||||
@for i in ${WINNERS} ; do \
|
||||
echo "(cd $$i && $(MAKE) $@)"; \
|
||||
(cd $$i && $(MAKE) $@); \
|
||||
done
|
||||
|
||||
|
||||
##################
|
||||
# 133t hacker rulz
|
||||
##################
|
||||
#
|
||||
love:
|
||||
@for i in ${WINNERS} ; do \
|
||||
echo "(cd $$i && $(MAKE) $@)"; \
|
||||
(cd $$i && $(MAKE) $@); \
|
||||
done
|
||||
|
||||
haste:
|
||||
@for i in ${WINNERS} ; do \
|
||||
echo "(cd $$i && $(MAKE) $@)"; \
|
||||
(cd $$i && $(MAKE) $@); \
|
||||
done
|
||||
|
||||
waste:
|
||||
@for i in ${WINNERS} ; do \
|
||||
echo "(cd $$i && $(MAKE) $@)"; \
|
||||
(cd $$i && $(MAKE) $@); \
|
||||
done
|
||||
|
||||
easter_egg:
|
||||
@for i in ${WINNERS} ; do \
|
||||
echo "(cd $$i && $(MAKE) $@)"; \
|
||||
(cd $$i && $(MAKE) $@); \
|
||||
done
|
||||
|
||||
# Understand the history of the Homebrew Computer Club
|
||||
# as well as the West Coast Computer Faire and
|
||||
# you might be confused different. :-)
|
||||
#
|
||||
supernova: nuke
|
||||
@for i in ${WINNERS} ; do \
|
||||
echo "(cd $$i && $(MAKE) $@)"; \
|
||||
(cd $$i && $(MAKE) $@); \
|
||||
done
|
||||
|
||||
deep_magic:
|
||||
@for i in ${WINNERS} ; do \
|
||||
echo "(cd $$i && $(MAKE) $@)"; \
|
||||
(cd $$i && $(MAKE) $@); \
|
||||
done
|
||||
|
||||
magic:
|
||||
@for i in ${WINNERS} ; do \
|
||||
echo "(cd $$i && $(MAKE) $@)"; \
|
||||
(cd $$i && $(MAKE) $@); \
|
||||
done
|
||||
@@ -0,0 +1,206 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2014 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
|
||||
#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} \
|
||||
-Wno-comment -Wno-dangling-else -Wno-implicit-function-declaration \
|
||||
-Wno-incompatible-pointer-types -Wno-parentheses \
|
||||
-Wno-trigraphs --include string.h
|
||||
|
||||
|
||||
# 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= prog
|
||||
DATA=
|
||||
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}
|
||||
@${TRUE}
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
${RM} -f ${ENTRY}.o ${ALT_OBJ}
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${ENTRY} ${ALT_ENTRY}
|
||||
|
||||
nuke: clobber
|
||||
@${TRUE}
|
||||
|
||||
dist_clean: nuke
|
||||
@${TRUE}
|
||||
|
||||
install:
|
||||
@echo "Surely we are joking Dr. Science!"
|
||||
@${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 sometimes mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Readers shall not be disallowed from failong 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_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 "You are holding it wrong!"; \
|
||||
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 Pauline!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
@@ -0,0 +1,167 @@
|
||||
<!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 port 1701</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best use of port 1701</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>
|
||||
|
||||
<p>Alexander Prishchepov<br>
|
||||
<a href="https://github.com/sans17/">https://github.com/sans17/</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./prog < some_secret_or_something
|
||||
|
||||
./prog http://host[:port]
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./prog.c
|
||||
|
||||
./prog http://127.0.0.1:1701
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>Port 1701? Well this is not the l2f registered TCP/1701 protocol.
|
||||
Sniff the traffic to/from that port. You will see HTTP client
|
||||
and server traffic. The HTML content you may see is static and
|
||||
immutable. Nothing funny with the HTTP status codes. Even the
|
||||
timestamp cookie, once set, remains static throughout the
|
||||
session. The data appears to not be transmitted within the
|
||||
binary content communicated between client and server.</p>
|
||||
|
||||
<p>So how does this program do it? A trek though the cloak of
|
||||
obfuscation awaits the reader of the source!</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Abstract</h3>
|
||||
|
||||
<p>When launched in web server mode, this application appears to deliver nothing more than a static HTML page. But, in actuality, it provides covert file transfer over the Internet. This is demonstrated by starting the application as a client-side downloader. The hidden transmitted data cannot be reconstructed or even detected from the binary content of the traffic between the client and the server.</p>
|
||||
|
||||
<h3>To run web server</h3>
|
||||
|
||||
<pre><code>./prog < secret_file_to_be_downloaded
|
||||
</code></pre>
|
||||
|
||||
<p>Try using the program’s source code as the secret file:</p>
|
||||
|
||||
<pre><code>./prog < prog.c
|
||||
</code></pre>
|
||||
|
||||
<h3>To run client-side downloader</h3>
|
||||
|
||||
<pre><code>./prog http://host[:port]
|
||||
</code></pre>
|
||||
|
||||
<p>The optional port defaults to 1701. If the web server instance is started on the same box, try:</p>
|
||||
|
||||
<pre><code>./prog http://127.0.0.1:1701
|
||||
</code></pre>
|
||||
|
||||
<p>It will incrementally display the contents of the hidden file at a rate of approximately 1 baud.</p>
|
||||
|
||||
<p>The client-side downloader will automatically terminate if the web server is bounced.</p>
|
||||
|
||||
<h3>HTML content</h3>
|
||||
|
||||
<p>Plug the URL into a browser to view a static HTML page containing ASCII artwork.</p>
|
||||
|
||||
<h3>Exploration</h3>
|
||||
|
||||
<p>Studying the network traffic will reveal that the HTML content is static and immutable, the HTTP request and response fields do not contain anything remarkable, HTTP status and error codes are not exploited, no unusual or deprecated features of HTTP are used, and while the cookie is based on a timestamp, its value also remains unchanged throughout the session. As mentioned in the abstract, the data is not transmitted within the binary content communicated between the client and the server. A full explanation of the protocol appears below, but feel free to explore before reading further.</p>
|
||||
|
||||
<h3>Inspiration</h3>
|
||||
|
||||
<p>The inspiration for this program comes from <em>Star Trek VI: The Undiscovered Country</em>, specifically the final confrontation between the <em>Enterprise</em> and the enhanced prototype Klingon Bird of Prey. The definitive feature of the prototype was its ability to fire while cloaked. But, perhaps even more impressive was its able to keep an open communication channel with the <em>Enterprise</em> throughout the battle, enabling the antagonist Chang to taunt Captain Kirk with Shakespearian quotes while he slowly pelted his ship with torpedoes. Normally, cloaked vessels must maintain silent running to avoid detection.</p>
|
||||
|
||||
<p>The battle is commemorated in the form of ASCII artwork depicting the ships faced head-to-head in the page delivered by the web server. Plus, the program source code is formatted in the shape of a Klingon Bird of Prey. The code itself includes a number of Star Trek references: the registry number of the <em>Enterprise</em> (NCC-1701) is defined as a constant; variable names spell out Cpt. James T. Kirk and Odo (the Deep Space 9 character was played by René Auberjonois who also appeared as Colonel West in <em>Star Trek VI</em>); the STARDATE constant makes timing configurable; and, the constant k stands for Khan (in the final engagement in <em>Star Trek II: The Wrath of Khan</em>, the damaged <em>Enterprise</em> managed to disable the USS <em>Reliant</em>’s shield generator by accessing its prefix code: 16309).</p>
|
||||
|
||||
<h3>Secondary size limit</h3>
|
||||
|
||||
<p>As obligated by a program that employs 23rd century cloaking technology, when the source is fed as input to IOCCC size tool version 2014-09-23-v19, and the -i command line option is used, the value printed is 0.</p>
|
||||
|
||||
<h3>Transmission protocol revealed</h3>
|
||||
|
||||
<p>The client-side downloader relies on the response time of the web server rather than the binary content of the response. The server transmits 1 nibble at a time by counting to the nibble value via a sequence of rapid responses terminated by a long response. For instance, the value 5 would be transmitted by making a series of requests that result in 5 near instantaneous responses followed by a half-second delayed response. The long delay is skipped in the case of 15, the maximal nibble value. With the aid of an ASCII table, it is actually possible to read the nibbles by repeatedly pressing the refresh button within a browser and observing the page refresh delay.</p>
|
||||
|
||||
<p>Nibble Count Coding (file transfer protocol NCC-1701) is faster than transmitting each individual bit as a short or long delay because it sends each byte with 2 long delays whereas communicating individual bits requires 8 long delays in the worst case scenario. In fact, Nibble Count Coding is faster than applying Huffman Coding since that is designed to produce compact codes under the assumption that the bit value does not affect transmission time.</p>
|
||||
|
||||
<p>The server relies on the cookie to identify each client uniquely, enabling it to transfer the sequence independently to each client.</p>
|
||||
|
||||
<h3>Configuration</h3>
|
||||
|
||||
<p>As with all network communication, accurate transmission of data relies on the nature of hardware revealed through statistics and timeouts set accordingly. The long delay is arbitrarily set to 0.5 seconds. This is microsecond tunable via the STARDATE constant defined at the top of the source code. Increase the value in the event of transmission errors. Decrease the value to download faster and less reliably.</p>
|
||||
|
||||
<p>The NCC constant is the web server port number.</p>
|
||||
|
||||
<h3>Obfuscations</h3>
|
||||
|
||||
<ul>
|
||||
<li>The ASCII artwork is compressed using run-length encoding.</li>
|
||||
<li>One long string stores a series of strings concatenated together and referenced via pointers.</li>
|
||||
<li>The long string is shift encrypted.</li>
|
||||
<li>Short and meaningless identifiers are used throughout.</li>
|
||||
<li>Reversed array indexing was applied immoderately.</li>
|
||||
<li>Minus is used in place of not-equals.</li>
|
||||
<li>O and l were selected for their resemblance to 0 and 1 respectively.</li>
|
||||
<li>Standard constants and ASCII characters were replaced with their respective numerical values.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Compiler warnings</h3>
|
||||
|
||||
<p>For space considerations, the following include statements were dropped resulting in compiler warnings:</p>
|
||||
|
||||
<pre><code>#include <asm/byteorder.h>
|
||||
#include <ctype.h>
|
||||
#include <netinet/in.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/unistd.h>
|
||||
</code></pre>
|
||||
|
||||
<p>It may be necessary to restore some of these under certain environments.</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,132 @@
|
||||
# Best use of port 1701
|
||||
|
||||
Michael Birken
|
||||
<o__1@hotmail.com>
|
||||
<http://www.meatfighter.com/>
|
||||
|
||||
Alexander Prishchepov
|
||||
<https://github.com/sans17/>
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
### To build:
|
||||
|
||||
make
|
||||
|
||||
### To run:
|
||||
|
||||
./prog < some_secret_or_something
|
||||
|
||||
./prog http://host[:port]
|
||||
|
||||
### Try:
|
||||
|
||||
./prog.c
|
||||
|
||||
./prog http://127.0.0.1:1701
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
Port 1701? Well this is not the l2f registered TCP/1701 protocol.
|
||||
Sniff the traffic to/from that port. You will see HTTP client
|
||||
and server traffic. The HTML content you may see is static and
|
||||
immutable. Nothing funny with the HTTP status codes. Even the
|
||||
timestamp cookie, once set, remains static throughout the
|
||||
session. The data appears to not be transmitted within the
|
||||
binary content communicated between client and server.
|
||||
|
||||
So how does this program do it? A trek though the cloak of
|
||||
obfuscation awaits the reader of the source!
|
||||
|
||||
## Author's comments:
|
||||
### Abstract
|
||||
|
||||
When launched in web server mode, this application appears to deliver nothing more than a static HTML page. But, in actuality, it provides covert file transfer over the Internet. This is demonstrated by starting the application as a client-side downloader. The hidden transmitted data cannot be reconstructed or even detected from the binary content of the traffic between the client and the server.
|
||||
|
||||
### To run web server
|
||||
|
||||
./prog < secret_file_to_be_downloaded
|
||||
|
||||
Try using the program's source code as the secret file:
|
||||
|
||||
./prog < prog.c
|
||||
|
||||
### To run client-side downloader
|
||||
|
||||
./prog http://host[:port]
|
||||
|
||||
The optional port defaults to 1701. If the web server instance is started on the same box, try:
|
||||
|
||||
./prog http://127.0.0.1:1701
|
||||
|
||||
It will incrementally display the contents of the hidden file at a rate of approximately 1 baud.
|
||||
|
||||
The client-side downloader will automatically terminate if the web server is bounced.
|
||||
|
||||
### HTML content
|
||||
|
||||
Plug the URL into a browser to view a static HTML page containing ASCII artwork.
|
||||
|
||||
### Exploration
|
||||
|
||||
Studying the network traffic will reveal that the HTML content is static and immutable, the HTTP request and response fields do not contain anything remarkable, HTTP status and error codes are not exploited, no unusual or deprecated features of HTTP are used, and while the cookie is based on a timestamp, its value also remains unchanged throughout the session. As mentioned in the abstract, the data is not transmitted within the binary content communicated between the client and the server. A full explanation of the protocol appears below, but feel free to explore before reading further.
|
||||
|
||||
### Inspiration
|
||||
|
||||
The inspiration for this program comes from _Star Trek VI: The Undiscovered Country_, specifically the final confrontation between the _Enterprise_ and the enhanced prototype Klingon Bird of Prey. The definitive feature of the prototype was its ability to fire while cloaked. But, perhaps even more impressive was its able to keep an open communication channel with the _Enterprise_ throughout the battle, enabling the antagonist Chang to taunt Captain Kirk with Shakespearian quotes while he slowly pelted his ship with torpedoes. Normally, cloaked vessels must maintain silent running to avoid detection.
|
||||
|
||||
The battle is commemorated in the form of ASCII artwork depicting the ships faced head-to-head in the page delivered by the web server. Plus, the program source code is formatted in the shape of a Klingon Bird of Prey. The code itself includes a number of Star Trek references: the registry number of the _Enterprise_ (NCC-1701) is defined as a constant; variable names spell out Cpt. James T. Kirk and Odo (the Deep Space 9 character was played by René Auberjonois who also appeared as Colonel West in _Star Trek VI_); the STARDATE constant makes timing configurable; and, the constant k stands for Khan (in the final engagement in _Star Trek II: The Wrath of Khan_, the damaged _Enterprise_ managed to disable the USS _Reliant_’s shield generator by accessing its prefix code: 16309).
|
||||
|
||||
### Secondary size limit
|
||||
|
||||
As obligated by a program that employs 23rd century cloaking technology, when the source is fed as input to IOCCC size tool version 2014-09-23-v19, and the -i command line option is used, the value printed is 0.
|
||||
|
||||
### Transmission protocol revealed
|
||||
|
||||
The client-side downloader relies on the response time of the web server rather than the binary content of the response. The server transmits 1 nibble at a time by counting to the nibble value via a sequence of rapid responses terminated by a long response. For instance, the value 5 would be transmitted by making a series of requests that result in 5 near instantaneous responses followed by a half-second delayed response. The long delay is skipped in the case of 15, the maximal nibble value. With the aid of an ASCII table, it is actually possible to read the nibbles by repeatedly pressing the refresh button within a browser and observing the page refresh delay.
|
||||
|
||||
Nibble Count Coding (file transfer protocol NCC-1701) is faster than transmitting each individual bit as a short or long delay because it sends each byte with 2 long delays whereas communicating individual bits requires 8 long delays in the worst case scenario. In fact, Nibble Count Coding is faster than applying Huffman Coding since that is designed to produce compact codes under the assumption that the bit value does not affect transmission time.
|
||||
|
||||
The server relies on the cookie to identify each client uniquely, enabling it to transfer the sequence independently to each client.
|
||||
|
||||
### Configuration
|
||||
|
||||
As with all network communication, accurate transmission of data relies on the nature of hardware revealed through statistics and timeouts set accordingly. The long delay is arbitrarily set to 0.5 seconds. This is microsecond tunable via the STARDATE constant defined at the top of the source code. Increase the value in the event of transmission errors. Decrease the value to download faster and less reliably.
|
||||
|
||||
The NCC constant is the web server port number.
|
||||
|
||||
### Obfuscations
|
||||
|
||||
* The ASCII artwork is compressed using run-length encoding.
|
||||
* One long string stores a series of strings concatenated together and referenced via pointers.
|
||||
* The long string is shift encrypted.
|
||||
* Short and meaningless identifiers are used throughout.
|
||||
* Reversed array indexing was applied immoderately.
|
||||
* Minus is used in place of not-equals.
|
||||
* O and l were selected for their resemblance to 0 and 1 respectively.
|
||||
* Standard constants and ASCII characters were replaced with their respective numerical values.
|
||||
|
||||
### Compiler warnings
|
||||
|
||||
For space considerations, the following include statements were dropped resulting in compiler warnings:
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
#include <ctype.h>
|
||||
#include <netinet/in.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/unistd.h>
|
||||
|
||||
It may be necessary to restore some of these under certain environments.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(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/
|
||||
-->
|
||||
@@ -0,0 +1,60 @@
|
||||
/**??/
|
||||
/
|
||||
#include<netdb.h>
|
||||
#include<stdio.h>
|
||||
#include<sys/time.h>
|
||||
#define NCC 1701
|
||||
#define STARDATE 500000
|
||||
#define k 16309
|
||||
|
||||
int C,p,t,J,a,m,e,s,T,K,i,r[k],_[k][2],c[k][2],f=NCC;
|
||||
fd_set O,d,o;char g[8][k],*h,j[]="0\1&me\1&t&e\1TFTTJPO>"
|
||||
"\1&t\\_<\16\v^\1&+\\_;^&o;&e\1TFU.DPPLJF;\1iuuq;00&92:2\\_0^&"
|
||||
"o\1&tDppljf;!tfttjpo>&t\16\v\16\v\1HFU!&t!IUUQ02/1\16\vIptu;!"""
|
||||
"&t\16\v\1IUUQ02/1!311!PL\16\vDpoufou.uzqf;!ufyu0iunm\16\vFyqjsft;!1"""
|
||||
"\16\vTfu.Dppljf;!tfttjpo>&t\16\vDpoufou.Mfohui;!&me\16\v\16\v&t\1=iunm?=c" "pez!chdpmps>#cmbdl"
|
||||
"#?=ejw!tuzmf>(qptjujpo;bctpmvuf<upq;61&&<mfgu;61&&<usbotgpsn;usbotmbufY).61&&*u" "sbotmbufZ).61&&*<(?=gpou!dpm"
|
||||
"ps>#xijuf#?=qsf?&t=0qsf?=0gpou?=0ejw?=0cpez?=0iunm?\1T`K!`.`[!G!G`\v]C`)K>0`>`0!E`/" "D.(D.aD./E`D!C`p`K!F`0F`}\vM!]`!]E!"
|
||||
"]E./J`/E.0C!G>I`0L.0\vO!]!]D!0C!0E!a.`.(K!)E`0I!]G`E!}\vK!C`-C.a/a.(//(.`[!N!]C!+!]\vJ!0E`K!}}[!K!C`0E`0C`\vO!aC./E`-.([!K!|K`|";struct sockad\
|
||||
dr_in l;struct timeval n,q;struct hostent*u;long w;void x(int y){close(y);FD_CLR(y,&O);if(y>=m)while(--m)if(FD_ISSET(m,&O))break;}vo\
|
||||
id z(char*A,char*B){char*D,*E=A,*F=A;for(0[0[g]]=0;*E;E++)if(*E==10){if(E-F==(*(E-1)-13?1:2))break;*E=0;if(!strncmp(F,B,strlen(B))&&(D=strstr(F,j+\
|
||||
11))){sscanf(D+8,j+20,0[g]);break;}F=E+1;}else*E=toupper(*E);}int main(int G,char**H){h=j;while(*h)(*h)--,h++;h=j+414;do{t=*h++;e=1;if(t>=65&&t<=90)e
|
||||
=t-64,t=*h++;while(e--)6[g][i++]=t;}while(t);sprintf(7[g],j+229,6[g]);l.sin_family=2;if(G>1){sscanf(1[H],j+53,4[g],&K);sprintf(2[g],j+97,*(1[H]+K)?1[
|
||||
H]+K:j,4[g]);sscanf(4[g],j+29,&i,&f);i[4[g]]=0;u=gethostbyname(4[g]);memcpy(&l.sin_addr.s_addr,0[u->h_addr_list],u->h_length);l.sin_port=htons(f);\
|
||||
for(;;close(G))if(!connect(G=socket(2,1,0),&l,sizeof l))for(;;){strcpy(1[g],0[g]);s=sprintf(5[g],j+72,2[g],0[g]);if(write(G,5[g],s)<0)break;gett\
|
||||
imeofday(&n,0);0[3[g]]=0;e=read(G,3[g],k);if(e<0)break;else if(e&&*3[g]==72){gettimeofday(&q,0);3[g][k-1]=0;z(3[g],j+41);if(0[1[g]])if(!strnc\
|
||||
mp(1[g],0[g],strlen(1[g]))){t=0;if((q.tv_sec-n.tv_sec)*1000000+q.tv_usec-n.
|
||||
tv_usec<STARDATE-1000){t=p<15?1:16;p+=t;C+=t;}else p=p<15?15:255;if(p==2\
|
||||
55){putchar(C);fflush(stdout);C=p=0;}}else{T=1;goto l;}}}}else{for(f=0;
|
||||
f<k;f++){if((i=fgetc(stdin))<0)break;f[r]=i;}for(i=0;i<k;i++){0[i[_]]
|
||||
=1[i[_]]=-1;0[i[c]]=1[i[c]]=0;}gettimeofday(&n,0);p=sprintf(5[g],j+2
|
||||
,n.tv_sec);n.tv_sec=0;n.tv_usec=STARDATE;FD_ZERO(&d);FD_ZERO(&O);F\
|
||||
D_ZERO(&o);l.sin_addr.s_addr=0;l.sin_port=htons(NCC);bind(G=sock\
|
||||
et(2,1,0),&l,sizeof l);listen(G,10);FD_SET(m=G,&O);for(i=1,t=0;;
|
||||
){d=O;C=select(m+1,&d,0,0,0);if(C<=0){if(!i&&t)x(t);goto l;}fo\
|
||||
r(J=t;C&&J<=m;J++)if(FD_ISSET(J,&d)){C--;if(J==G){t=accept(G,
|
||||
0,0);FD_SET(t,&O);FD_CLR(t,&d);FD_SET(t,&o);if(t>m)m=t;t=0;
|
||||
}else if(!i||FD_ISSET(J,&o)){e=read(J,2[g],k);K=0;if(e>0){
|
||||
2[g][k-1]=0;if(*2[g]==71){a=0;strcpy(1[g],0[g]);z(2[g],j+
|
||||
45);if(!strncmp(0[g],5[g],strlen(5[g]))&&!strncmp(1[g],
|
||||
0[g],strlen(1[g]))){K=atoi(0[g]+p);}if(K){if(0[K[_]]<f
|
||||
){if(a=(1[K[_]]<15?1[K[_]]:1[K[_]]>>4)>=(1[K[_]]<15?
|
||||
0[K[_]][r]&15:0[K[_]][r]>>4))1[K[_]]=1[K[_]]<15?1\
|
||||
5:255;else 1[K[_]]+=1[K[_]]<16?1:16;if(_[K][1]==\
|
||||
255){0[K[_]]++;1[K[_]]=0;}}else{write(1[K[c]],_[
|
||||
K],sizeof(_[K]));close(1[K[c]]);K=0;}}else fo\
|
||||
r(s=1;s<k;s++)if(0[s[_]]==-1){0[s[_]]=1[s[_]]
|
||||
=0;K=s;break;}if(K)sprintf(0[g],j+6,5[g],K)
|
||||
;else 0[0[g]]=0;w=sprintf(3[g],j+125,0[g],
|
||||
strlen(7[g]),7[g]);if(i){pipe(c[K]);if(!
|
||||
(i=fork())){close(0[K[c]]);FD_ZERO(&O);
|
||||
FD_SET(t=m=J,&O);}}if(i<0){T=1;goto l;
|
||||
}if(i){close(1[K[c]]);FD_SET(0[K[c]]
|
||||
,&O);if(0[K[c]]>m)m=0[K[c]];x(J);\
|
||||
break;}else{if(a){n.tv_sec=0;n.t\
|
||||
v_usec=STARDATE;select(0,0,0,0,&
|
||||
n);}write(J,3[g],w);if(!K){close(J);return 0;}}}}else if(i){
|
||||
close(J);FD_CLR(J,&o);x(J);}else{write(1[K[c]],K[_],sizeof(K[_
|
||||
]));close(1[K[c]]);close(J);return 0;}}else{for(K=0;K<=m;K++)if(
|
||||
0[K[c]]==J){read(J,K[_],sizeof(K[_]));x(J);if(_[K][0]>=f){0[K[_]
|
||||
]=1[K[_]]=-1;0[K[c]]=1[K[c]]=0;}break;}}}}}l:close(G);return T;}
|
||||
@@ -0,0 +1,203 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2014 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
|
||||
#CWARN= -Wall -pedantic
|
||||
|
||||
# compiler standard
|
||||
#
|
||||
#CSTD=
|
||||
#CSTD= -ansi
|
||||
CSTD= -std=c11
|
||||
|
||||
# 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} \
|
||||
-Wno-int-conversion -Wno-implicit-int -Wno-main
|
||||
|
||||
# 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= prog
|
||||
DATA=
|
||||
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}
|
||||
@${TRUE}
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
${RM} -f ${ENTRY}.o ${ALT_OBJ}
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${ENTRY} ${ALT_ENTRY}
|
||||
|
||||
nuke: clobber
|
||||
@${TRUE}
|
||||
|
||||
dist_clean: nuke
|
||||
@${TRUE}
|
||||
|
||||
install:
|
||||
@echo "Surely we are joking Dr. Science!"
|
||||
@${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 sometimes mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Readers shall not be disallowed from failong 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_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 "You are holding it wrong!"; \
|
||||
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 Pauline!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
@@ -0,0 +1,115 @@
|
||||
<!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 underscored argument</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most underscored argument</h1>
|
||||
|
||||
<p>Ferenc Deak<br>
|
||||
<a href="mailto:fritzone@gmail.com">fritzone@gmail.com</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make deak
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>Changing bounding box coordinates in the source to explore
|
||||
various regions of the fractal.
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>We consider this entry a tribute to all “Abuse of the C preprocessor”
|
||||
and Mandelbrot fractal drawing entries we’ve seen over the years.</p>
|
||||
|
||||
<p>We liked the use of unary notation facilitated by variadic macros.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Portability</h3>
|
||||
|
||||
<p>The application was written on a standard Ubuntu 14.04 and tested with
|
||||
gcc 4.9.1 and clang 3.5 on 64 bit system (though this should not matter).
|
||||
The application makes no assumption regarding any system specific settings,
|
||||
and it only needs a console to run. The provided Makefile is just to have
|
||||
an easy compilation. I don’t see any problems porting it to different
|
||||
compiler/system as long as it supports the C99 standard.</p>
|
||||
|
||||
<h3>The application</h3>
|
||||
|
||||
<p>The purpose of the application is mainly to illustrate the weird possibilities
|
||||
of the C preprocessor, than to be a full featured console mode Mandelbrot
|
||||
drawer. There are tools much better suited for drawing fractals.</p>
|
||||
|
||||
<p>The usage of recognizable elements from the C programming language in the
|
||||
application source code is intentionally kept to a bare minimum. If this phrase
|
||||
would not be true, the application would be the following:</p>
|
||||
|
||||
<pre><code> double _[]={-2
|
||||
,1,-1.3 ,1.3, 0, 0,0,0
|
||||
,0 ,0,50, 80, 0,0,0 ,255
|
||||
, 8,0}; int main (
|
||||
int j) {if (j== 1 ){ if(
|
||||
_[12] >_[10] )_[17]=1 ;} if
|
||||
(_[13] >_[11 ] ||_[17]==1) return
|
||||
;_[6] = _ [13] / _[11]*(_[1]-_[ 0])
|
||||
+_[ 0]; _ [7]=_[12]/_[10]*(_[3]-_[2] )+_
|
||||
[2];_[8]=_[9]=_[14]=0;l2:_[4]=_[8] * _ [8]
|
||||
;_[ 5]= _ [9]*_[9];_[9]=2*_[8]*_[9]+ _[7
|
||||
];_[8 ] = _ [ 4 ]-_[5]+_[6];_[14 ]++
|
||||
;if((_ [14]< _ [15])&&(_[4]+ _[ 5]
|
||||
<_[16 ])) goto l2; putchar(
|
||||
" #@*+ "[( int) _[14]%
|
||||
5 ]);_ [13 ] ++ ; main (
|
||||
0) ;_[12]++; _[13] =0
|
||||
;if(_ [17] !=1) putchar
|
||||
(0xa); main(1);}
|
||||
</code></pre>
|
||||
|
||||
<p>The application expects no parameters, the only way you can change the behaviour
|
||||
is to modify the source code at the indicated location: the line
|
||||
<code>/* <-- Configure here: X1, X2, Y1, Y2 */</code> is intentionally not obfuscated so
|
||||
that the adventurous programmer can manually modify the coordinates of the
|
||||
fractal to be drawn on the screen.</p>
|
||||
|
||||
<h3>Compiler warnings</h3>
|
||||
|
||||
<p>Yes, unfortunately there are compiler warnings of the kind “initialization makes
|
||||
integer from pointer without a cast” the provided Makefile automatically
|
||||
disables them.</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,87 @@
|
||||
# Most underscored argument
|
||||
|
||||
Ferenc Deak
|
||||
<fritzone@gmail.com>
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
### To build:
|
||||
|
||||
make deak
|
||||
|
||||
### To run:
|
||||
|
||||
./prog
|
||||
|
||||
### Try:
|
||||
|
||||
Changing bounding box coordinates in the source to explore
|
||||
various regions of the fractal.
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
We consider this entry a tribute to all "Abuse of the C preprocessor"
|
||||
and Mandelbrot fractal drawing entries we've seen over the years.
|
||||
|
||||
We liked the use of unary notation facilitated by variadic macros.
|
||||
|
||||
## Author's comments:
|
||||
### Portability
|
||||
|
||||
The application was written on a standard Ubuntu 14.04 and tested with
|
||||
gcc 4.9.1 and clang 3.5 on 64 bit system (though this should not matter).
|
||||
The application makes no assumption regarding any system specific settings,
|
||||
and it only needs a console to run. The provided Makefile is just to have
|
||||
an easy compilation. I don't see any problems porting it to different
|
||||
compiler/system as long as it supports the C99 standard.
|
||||
|
||||
### The application
|
||||
|
||||
The purpose of the application is mainly to illustrate the weird possibilities
|
||||
of the C preprocessor, than to be a full featured console mode Mandelbrot
|
||||
drawer. There are tools much better suited for drawing fractals.
|
||||
|
||||
The usage of recognizable elements from the C programming language in the
|
||||
application source code is intentionally kept to a bare minimum. If this phrase
|
||||
would not be true, the application would be the following:
|
||||
|
||||
double _[]={-2
|
||||
,1,-1.3 ,1.3, 0, 0,0,0
|
||||
,0 ,0,50, 80, 0,0,0 ,255
|
||||
, 8,0}; int main (
|
||||
int j) {if (j== 1 ){ if(
|
||||
_[12] >_[10] )_[17]=1 ;} if
|
||||
(_[13] >_[11 ] ||_[17]==1) return
|
||||
;_[6] = _ [13] / _[11]*(_[1]-_[ 0])
|
||||
+_[ 0]; _ [7]=_[12]/_[10]*(_[3]-_[2] )+_
|
||||
[2];_[8]=_[9]=_[14]=0;l2:_[4]=_[8] * _ [8]
|
||||
;_[ 5]= _ [9]*_[9];_[9]=2*_[8]*_[9]+ _[7
|
||||
];_[8 ] = _ [ 4 ]-_[5]+_[6];_[14 ]++
|
||||
;if((_ [14]< _ [15])&&(_[4]+ _[ 5]
|
||||
<_[16 ])) goto l2; putchar(
|
||||
" #@*+ "[( int) _[14]%
|
||||
5 ]);_ [13 ] ++ ; main (
|
||||
0) ;_[12]++; _[13] =0
|
||||
;if(_ [17] !=1) putchar
|
||||
(0xa); main(1);}
|
||||
|
||||
The application expects no parameters, the only way you can change the behaviour
|
||||
is to modify the source code at the indicated location: the line
|
||||
`/* <-- Configure here: X1, X2, Y1, Y2 */` is intentionally not obfuscated so
|
||||
that the adventurous programmer can manually modify the coordinates of the
|
||||
fractal to be drawn on the screen.
|
||||
|
||||
### Compiler warnings
|
||||
|
||||
Yes, unfortunately there are compiler warnings of the kind "initialization makes
|
||||
integer from pointer without a cast" the provided Makefile automatically
|
||||
disables them.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(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/
|
||||
-->
|
||||
@@ -0,0 +1,41 @@
|
||||
#include <stdio.h>
|
||||
#define _$() 0
|
||||
#define __$() 1
|
||||
#define _$_() 10
|
||||
#define $_$(a) a;
|
||||
#define $_(b,a) a##b
|
||||
#define r(a,b) r##a##b##urn 0;
|
||||
#define m(b,a,x) }; m##a##b##n
|
||||
#define $(b,a,x) a##b##x
|
||||
#define ____ + __
|
||||
#define $_$_ =
|
||||
#define __(...) ( $(n,i,t))(\
|
||||
$(ze,si,of)(($(n,i,t)[]) { _$(), ##__VA_ARGS__})/$(ze,si,of) ($(n,i,t))-__$())
|
||||
$(n,i,t) (*___) ($(n,i,t)) = $(tch, pu, ar); $(ub,do,le) _<::> $_$_ <%
|
||||
|
||||
-2, 1, -1.3, 1.3 /* <-- Configure here: X1, X2, Y1, Y2 */
|
||||
|
||||
,_$(), _$(),_$(),_$(),_$() ,_$(), __( ',',',',',' ,',' ,',') * _$_() ,( _$_()
|
||||
- __('_','_')) * _$_(), _$(),_$(),_$(),__('_','_')*__('_','_', '_','_', '_') *
|
||||
__('_','_', '_','_', '_')*__('_','_', '_','_', '_')+__('_','_', '_','_' , '_')
|
||||
,__('_','_','_','_','_','_','_','_',), _$() m(i,a,u)($(n,i,t) $_)<% $_ (f,i) (
|
||||
$_ $_(=,=) __(_) ) $_$($_(f,i)(_[ _$_()____(_,_) ]>_[ _$_()] )_[_$_()____ (_,_
|
||||
,_,_,_,_,_)] $_$_ __(_) )$_(f,i)(_[_$_()____(_ ,_ ,_)] >_[ _$_()+ __$() ] ||
|
||||
_[_$_()____(_,_,_,_,_,_,_)] $_ (=,=) __$()) r(e,t) _[__(_,_,_ ,_,_ ,_)] $_$_ _
|
||||
[__ (_,_,_,_,_,_,_)____(_,_,_,_,_,_) ]/_[__(_,_,_,_,_) ____(_,_,_,_,_,_)]*( _[
|
||||
__$()]-_[_$()])+_[ _$() ];_[__(_,_,_,_,_,_,_)] $_$_ _[__(_,_,_,_,_,_,_) ____
|
||||
(_,_,_,_,_)]/_[_$_()]*(_[__(_,_,_,)]-_[__(_,_,)] )+_[__(_,_,)];_[__(_,_,_,_, _
|
||||
,_,_,_)] $_$_ _[_$_() - __$()] $_$_ _[__(_,_,_,_,_)+ _$_()-__$()] $_$_ _$();
|
||||
_f:_[__(_,_,_,_)] $_$_ _[__( _,_,_,_, _,_,_, _)] * _ [__(_,_,_, _,_,_,_,_)];
|
||||
_[__(_,_,_,_,_)] $_$_ _[_$_() - __$()]*_[_$_() - __$()];_[__(_,_,_,_,_,_,_,_,_
|
||||
)] $_$_ __(_,_)*_[__(_,_,_,_,_,_,_,_)]*_[_$_() -__$()]+ _[__ (_,_,_,_,_,_,_)];
|
||||
_[__(_,_,_,_,_,_,_,_)] $_$_ _ [ __(_,_,_,_) ]-_[__(_,_,_,_,_)]+_[__(_,_,_,_,_,
|
||||
_)];$_$(_[_$_()____(_,_,_,_,)]++)$_(f,i)((_ [_$_() ____ (_,_,_,_,)]< _ [_$_ ()
|
||||
____ (_,_,_,_,_)])&&(_[__(_,_,_,_)]+ _[__(_,_,_,_,_)]<_[_$_()____(_,_,_,_,_,_)
|
||||
])) $_(to,go) _f; $_(ar,ch) $(m,i,au)[] $_$_ <% __(_,_,_) * _$_()____(_,_), __
|
||||
(_,_,_,_) * _$_()____(_,_,_),__(_,_,_,_,_,_) * _$_()____(_,_,_,_), __(_,_,_,_)
|
||||
*_$_() ____(_,_,_,_,_),__(_,_,_,_) * _$_() ____(_,_,_,_,_,_),__(_,_,_,_) * _$_
|
||||
()____(_,_) %>;___($(m,i,au)[($(n,i,t)) _[_$_()____(_,_,_,_)]%__(_,_,_,_,_)]);
|
||||
$_$(_[__(_,_ ,_,_ ,_,_,_) + __(_,_,_,_,_,_)]++){m(i,a,u) ( _$()) ;$_$ (_[_$_()
|
||||
____(_,_)]++)$_$(_[_$_()____(_,_,_)] $_$_ _$()) $_(f,i)(_ [__(_,_,_,_,_,_,_) +
|
||||
_$_()] != __(_)) ___(_$_()) ;{ m(i,a,u)(__$()); r(e,t) /* IOCCC 2014*/ %>
|
||||
@@ -0,0 +1,208 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2014 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
|
||||
#CWARN= -Wall -pedantic
|
||||
|
||||
# compiler standard
|
||||
#
|
||||
#CSTD=
|
||||
#CSTD= -ansi
|
||||
CSTD= -std=c11
|
||||
|
||||
# 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} -Wno-empty-body -funsigned-char
|
||||
|
||||
# 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= prog main
|
||||
DATA=
|
||||
ALT_OBJ=
|
||||
ALT_ENTRY=
|
||||
|
||||
|
||||
#################
|
||||
# build the entry
|
||||
#################
|
||||
#
|
||||
all: ${ENTRY} ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
main: main.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
||||
|
||||
main.c: prog
|
||||
./prog > $@
|
||||
|
||||
prog: prog.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
||||
|
||||
# alternative executable
|
||||
#
|
||||
alt: ${ALT_ENTRY}
|
||||
@${TRUE}
|
||||
|
||||
# data files
|
||||
#
|
||||
data: ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
${RM} -f ${ENTRY}.o ${ALT_OBJ} main.o
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${ENTRY} ${ALT_ENTRY} main.c main
|
||||
|
||||
nuke: clobber
|
||||
@${TRUE}
|
||||
|
||||
dist_clean: nuke
|
||||
@${TRUE}
|
||||
|
||||
install:
|
||||
@echo "Surely we are joking Dr. Science!"
|
||||
@${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 sometimes mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Readers shall not be disallowed from failong 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_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 "You are holding it wrong!"; \
|
||||
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 Pauline!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
@@ -0,0 +1,82 @@
|
||||
<!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 square (YODA award)</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most square (YODA award)</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>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./prog > foo.c
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./prog > main.c
|
||||
|
||||
make main
|
||||
./main Hello
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>Big terminals with tiny fonts have their uses in certain cases.
|
||||
One of them is:</p>
|
||||
|
||||
<pre><code>./prog < prog.c > treacle.c
|
||||
make treacle
|
||||
# or instead of make: cc -Wno-empty-body -funsigned-char treacle.c -o treacle
|
||||
./treacle
|
||||
</code></pre>
|
||||
|
||||
<p>When using a smart phone to read the output, you may need to
|
||||
step back to see the bigger picture because that picture is worth
|
||||
more than 1000 words.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Remarks</h3>
|
||||
|
||||
<p>You may want to use a large display with a very small-font terminal.</p>
|
||||
|
||||
<h3>Spoiler</h3>
|
||||
|
||||
<p>Decompress <code>src.zip</code> if you need explanation.</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,54 @@
|
||||
# Most square (YODA award)
|
||||
|
||||
Yusuke Endoh
|
||||
<mame@ruby-lang.org>
|
||||
<https://github.com/mame/>
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
### To build:
|
||||
|
||||
make
|
||||
|
||||
### To run:
|
||||
|
||||
./prog > foo.c
|
||||
|
||||
### Try:
|
||||
|
||||
./prog > main.c
|
||||
|
||||
make main
|
||||
./main Hello
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
Big terminals with tiny fonts have their uses in certain cases.
|
||||
One of them is:
|
||||
|
||||
./prog < prog.c > treacle.c
|
||||
make treacle
|
||||
# or instead of make: cc -Wno-empty-body -funsigned-char treacle.c -o treacle
|
||||
./treacle
|
||||
|
||||
When using a smart phone to read the output, you may need to
|
||||
step back to see the bigger picture because that picture is worth
|
||||
more than 1000 words.
|
||||
|
||||
## Author's comments:
|
||||
### Remarks
|
||||
|
||||
You may want to use a large display with a very small-font terminal.
|
||||
|
||||
### Spoiler
|
||||
|
||||
Decompress `src.zip` if you need explanation.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(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/
|
||||
-->
|
||||
@@ -0,0 +1,58 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include<stdio.h>/*IOCCC2014 2014 2014 IOCCC2014IOCCC2014IOCCC201*/
|
||||
char*s="\"nsu{AntynCnuq}Bnu{ sEot ln>b )+c^g+@`+]_osk{;j@bkg&c<'^o\
|
||||
r'Q] bh'l vQ^k g&c: %n|\
|
||||
N]_o ptj9 lwg+ )d:b kg$\
|
||||
c8#^ #g+)d8`a%g+) d8`_ g&;bh'oq Q^)g +&kcNlyMc+)d 8`a\
|
||||
`g+@ u)|d8ak=bl}( Q^og (O{MK6lM L(rR pOpM866OsRlm N(q\
|
||||
Q]## OsR#M_(lQoOa N9$m vOwwRor~ }(cN mkM: q(Q]%_(uU]}_ {8b\
|
||||
%mRh #S^`#mOaaD%/ RI4$ 4SNH$%N4 RlMG /2MJ 24O3NF(tQ?1l N*N\
|
||||
+Q]l mq9l8b$^#h$# .d,d xv#mSOPm R8`/ lM;b h&^/lM:k8b%& Q^-\
|
||||
h%c9 .#,/&N$McPc% -d8, $c8``7:b %^h% :79b $^%$7ON8r%Qr h$Q\
|
||||
On%q N%O~ M$qN$OMp RmPQ O%rQ $rQ\
|
||||
MkQN 77O# dj#Nkd$7 O%d8 ``(r RmM\
|
||||
:(luN](%mRMmO%lNRmO_loa8%%O< b(lQ h'lQ O^ln ;b'%N&O^6sN#M9slltwzh&TmS$'\
|
||||
%R#ON$oNS&pRM7O$'%S#ON$oNS&p SMd9 ``(t pkO9 $:nk8b#^%}kx#O%lMtpk#OQOP:#\
|
||||
mR8`}(qQ O<b\
|
||||
'7M{N^kh 'Q]\
|
||||
7sN' M8q;k'N_7vN'nSM8 'nR; $%M' TamS&7O#d#7O &d8`z9b$ ^h$\
|
||||
rQ]6 yN$_$$pQaM8m{px$ TmSt 6O#N sM$nRmUd#7Os d77sNOsd 8`j\
|
||||
=nk; |8k9 b1g( Q^)$c:%] k*Q]g$9%_h*]+wnS _+sTaa:&%{R\
|
||||
M<%{ S{O_ &<#w kP8#a;'( 0d:`184>b)^15)OM :23h)QN<'/M\
|
||||
=b(^'h(Q]0h# c_kah%0d9`b'/O(Q^(/SlM90%M(/ RM;& $c&kckQ, -$c\
|
||||
.&kccMcOP$&d 9g(=``6:69j=b5g(Q^3(2lNUO<b4 'Q^s ;b&^%%pQ M8k\
|
||||
$7O#cQ]0(2(Q]'2O 3'Q]'_3a N_1' 5OMaMch&T$mR#nRMPmSk U$7\
|
||||
O#d8_a%%mS]l_%mR mS]$]h$9 j_la _$6N]g$9j_laaaN:`g'< ``7\
|
||||
oM:6%N9b%g$Q ^6%N8b%g #Q^l peoqemtemw#jQ7#QO$jQ O7$Q Ok#\
|
||||
$7OMQ]k_#$7O ckQaOrON epne luelue`lpeoqempepneu e`kf _a`\
|
||||
lf)) *+,**,*)-)/),0).0(6/2+667,(& $##\
|
||||
#;=@ D*0;#include<stdio.h>@intYH[ 9`%\
|
||||
.],*s,*c,d,t;`;'main(`-9n,ch ar*v []){ for(s=c= H+3`XI;\
|
||||
(*++s=Q[d++]););for(;n>1&&(* ++s= v[1] [tgANs=H ;d=*c++\
|
||||
%93, d-9; ){in tYv=*s,g []={ n+v, v-n,n*_\
|
||||
,#^_ ,,<v ,n?v /n:0`,#% `,,v >>n, v==n}ay\
|
||||
>t=0 ;d<4&&d>=2*! !n&& (c-=d/3*2_KK3+*c++,t||v!=98+d);) t+=v++/6-16\
|
||||
?0:v /2%3-1cq*d-1 4;t> 0_t$<3_z(105<*c_X'=t*21aq@-106;n =d>76?s--,g\
|
||||
[d-7 7]:d>55?H_1) 21]= n,*_@_8( 9?*++s_4&12>d_C`f3]+=21-d*2\
|
||||
:d<3 4?t:_Zadat57 <d?p utchar(n ),v:6<a](g+99]=a{d2#:`xa6,n\
|
||||
;}re turnY_.",*p, b,d[ 9338 ],*q,x,*r=d; int main(){;for(
|
||||
p=q= 5000+0+d;*s; s++) if(* s>32)*p++=*s -89?*s:32;for(p=
|
||||
1152 +q;( b=*p++);){for(d[17]= 10;x =*p++,b<
|
||||
92&& 34<b --;*r++=x)if(x==9*9) for( ;*q;x=34
|
||||
)*r++=*q++;for(p-=b<92;b-->4 *23;r++) *r=r[36- x];}puts (d);
|
||||
return(0);}/*IOCCC2014IOCCC2 014IOCCC 2014IOCC C2014IOC CC*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,205 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2014 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
|
||||
#CWARN= -Wall -pedantic
|
||||
|
||||
# compiler standard
|
||||
#
|
||||
#CSTD=
|
||||
#CSTD= -ansi
|
||||
CSTD= -std=c11
|
||||
|
||||
# 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= prog
|
||||
DATA=
|
||||
ALT_OBJ=
|
||||
ALT_ENTRY=
|
||||
|
||||
|
||||
#################
|
||||
# build the entry
|
||||
#################
|
||||
#
|
||||
all: ${ENTRY} ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
${ENTRY}: ${ENTRY}.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
||||
|
||||
hello: hello.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
||||
|
||||
# alternative executable
|
||||
#
|
||||
alt: ${ALT_ENTRY}
|
||||
@${TRUE}
|
||||
|
||||
# data files
|
||||
#
|
||||
data: ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
${RM} -f ${ENTRY}.o ${ALT_OBJ} hello.o
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${ENTRY} ${ALT_ENTRY} hello hello.c
|
||||
|
||||
nuke: clobber
|
||||
@${TRUE}
|
||||
|
||||
dist_clean: nuke
|
||||
@${TRUE}
|
||||
|
||||
install:
|
||||
@echo "Surely we are joking Dr. Science!"
|
||||
@${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 sometimes mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Readers shall not be disallowed from failong 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_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 "You are holding it wrong!"; \
|
||||
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 Pauline!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
@@ -0,0 +1,86 @@
|
||||
<!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 bioinformatics</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best use of bioinformatics</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>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./prog < input > output
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>echo Hello | ./prog
|
||||
|
||||
echo Hello | ./prog > hello.c
|
||||
make hello
|
||||
./hello
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>If you look closely at the source, you will see code that appears
|
||||
to puts C code that includes itself. How and why? Perhaps it is
|
||||
in the DNA code of the code? Perhaps there are 23 reasons? :-)</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Remarks</h3>
|
||||
|
||||
<p>This chromosome program synthesizes a double helix.
|
||||
The helix can also be compiled as a C program.</p>
|
||||
|
||||
<p>Enjoy DNA programming!</p>
|
||||
|
||||
<h3>For more information / backgroud reading:</h3>
|
||||
|
||||
<ul>
|
||||
<li><p>This program was inspired by Acme::DoubleHelix:
|
||||
http://search.cpan.org/~xern/Acme-DoubleHelix-0.01/</p></li>
|
||||
<li><p>The synthesized helix just includes the original program at the head.
|
||||
Do you see how <code>prog.c</code> determines whether it was invoked as a standalone program or included as a header file?
|
||||
Note that it does not use any gcc extension such as <code>__INCLUDE_LEVEL__</code>.</p></li>
|
||||
<li><p>The synthesized helix of course follows the base-pairing rules for DNA:
|
||||
A is bonding only to T, and C is bonding only to G.</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<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,58 @@
|
||||
# Best use of bioinformatics
|
||||
|
||||
Yusuke Endoh
|
||||
<mame@ruby-lang.org>
|
||||
<https://github.com/mame/>
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
### To build:
|
||||
|
||||
make
|
||||
|
||||
### To run:
|
||||
|
||||
./prog < input > output
|
||||
|
||||
### Try:
|
||||
|
||||
echo Hello | ./prog
|
||||
|
||||
echo Hello | ./prog > hello.c
|
||||
make hello
|
||||
./hello
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
If you look closely at the source, you will see code that appears
|
||||
to puts C code that includes itself. How and why? Perhaps it is
|
||||
in the DNA code of the code? Perhaps there are 23 reasons? :-)
|
||||
|
||||
## Author's comments:
|
||||
### Remarks
|
||||
|
||||
This chromosome program synthesizes a double helix.
|
||||
The helix can also be compiled as a C program.
|
||||
|
||||
Enjoy DNA programming!
|
||||
|
||||
### For more information / backgroud reading:
|
||||
|
||||
* This program was inspired by Acme::DoubleHelix:
|
||||
http://search.cpan.org/~xern/Acme-DoubleHelix-0.01/
|
||||
|
||||
* The synthesized helix just includes the original program at the head.
|
||||
Do you see how `prog.c` determines whether it was invoked as a standalone program or included as a header file?
|
||||
Note that it does not use any gcc extension such as `__INCLUDE_LEVEL__`.
|
||||
|
||||
* The synthesized helix of course follows the base-pairing rules for DNA:
|
||||
A is bonding only to T, and C is bonding only to G.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(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/
|
||||
-->
|
||||
@@ -0,0 +1,32 @@
|
||||
#include <stdio.h>
|
||||
#define TA q=/*XYXY*/
|
||||
#define/*X YXY*/CG r=
|
||||
void p(int n,int c){;
|
||||
for(;n--;) putchar(c)
|
||||
#define Y( z)d;d=c++\
|
||||
%2<1?x=x*4 +z,c%8>5?\
|
||||
x=x?p(1,x), 0:x:0:0;d=
|
||||
#define/*X YX*/C Y(1)
|
||||
#define/*X YX*/G Y(2)
|
||||
;}int(*f)( void),d,c,
|
||||
#define/*X YX*/A Y(0)
|
||||
#define/*XY*/AT int\
|
||||
m(void/**/){d=
|
||||
#define/*XYX*/T Y(3)
|
||||
#define GC d; return\
|
||||
0;}int(*f) (void )=m;
|
||||
x,q,r; int main(){if(
|
||||
f)f();else {for(puts(
|
||||
"#include" "\40\"pro\
|
||||
g.c\"\n\n \101T"+0);
|
||||
d=!d?x=(x= getchar())
|
||||
<0?0:x,8*8 :d,TA++c%8
|
||||
,TA(1+7*q- q*q)/3,r=c
|
||||
*15-c*c-36 ,p(r<0?!q+
|
||||
4:r/6+!q+4 ,32),q||x;
|
||||
c%=16)q?p( 1,"ACGT"[x
|
||||
/d&3]),p(q ,126),p(1,
|
||||
"TGCA"[x/d &3]),d/=4,
|
||||
p(001,10): puts(c%8?\
|
||||
"CG":"TA") ;puts("GC"
|
||||
);}return 0;}/**/
|
||||
@@ -0,0 +1,801 @@
|
||||
| 23rd International Obfuscated C Code Contest Official Guidelines
|
||||
|
||||
| Copyright (C) 2006-2014 Leonid A. Broukhis, Simon Cooper, Landon Curt Noll.
|
||||
|
||||
All Rights Reserved. Permission for personal, education or non-profit use is
|
||||
granted provided this this copyright and notice are included in its entirety
|
||||
and remains unaltered. All other uses must receive prior permission in
|
||||
writing from the contest judges.
|
||||
|
||||
| This guidelines file is version 2014-08-29-v18.
|
||||
|
||||
| Most of the changes from the previous IOCCC guidelines
|
||||
| been marked with a "|" on the left hand side of the line.
|
||||
|
||||
|
||||
ABOUT THIS FILE:
|
||||
|
||||
This file contains guidelines intended to help people who wish to
|
||||
| submit entries to the International Obfuscated C Code Contest (IOCCC).
|
||||
|
||||
This is not the IOCCC rules, though it does contain comments about
|
||||
them. The guidelines should be viewed as hints and suggestions.
|
||||
Entries that violate the guidelines but remain within the rules are
|
||||
allowed. Even so, you are safer if you remain within the guidelines.
|
||||
|
||||
You should read the current IOCCC rules, prior to submitting entries.
|
||||
The rules are typically sent out with these guidelines.
|
||||
|
||||
We recommend that you follow the twitter handle:
|
||||
|
||||
@IOCCC
|
||||
|
||||
to learn about IOCCC news, important IOCCC related alerts, IOCCC
|
||||
reminders, and changes to the rules and these guidelines.
|
||||
|
||||
You do not have to be a twitter user to follow @IOCCC. Non-twitter
|
||||
users should access:
|
||||
|
||||
https://twitter.com/ioccc
|
||||
|
||||
Non-twitter users should force their browsers to reload the above URL
|
||||
to be sure they are seeing the most recent tweets.
|
||||
|
||||
While we try to post use news at:
|
||||
|
||||
http://www.ioccc.org/index.html#news
|
||||
|
||||
such postings may be delayed or obscured by slow to respond mirrors.
|
||||
|
||||
|
||||
| WHAT'S NEW IN 2014:
|
||||
|
||||
| The contest runs from 2014-Sep-01 02:03:04 UTC to 2014-Oct-19 18:17:16 UTC.
|
||||
|
||||
The submission URL:
|
||||
|
||||
https://submit.ioccc.org/
|
||||
|
||||
| along with the final rules and updated iocccsize.c tool will be avalaible
|
||||
| and active on or slightly before 2014-Sep-15 15:15:15 UTC.
|
||||
|
||||
|
||||
HINTS AND SUGGESTIONS:
|
||||
|
||||
You are encouraged to examine the winners of previous contests. See
|
||||
FOR MORE INFORMATION for details on how to get previous winners.
|
||||
|
||||
Keep in mind that rules change from year to year, so some winning entries
|
||||
may not be valid entries this year. What was unique and novel one year
|
||||
might be 'old' the next year.
|
||||
|
||||
An entry is usually examined in a number of ways. We typically apply
|
||||
a number of tests to an entry:
|
||||
|
||||
* look at the original source
|
||||
* convert ANSI tri-graphs to ASCII
|
||||
* C pre-process the source ignoring '#include' lines
|
||||
* C pre-process the source ignoring '#define' and '#include' lines
|
||||
* run it through a C beautifier
|
||||
* examine the algorithm
|
||||
* compile it (with flags to enable all warnings)
|
||||
* execute it
|
||||
|
||||
You should consider how your entry looks in each of the above tests.
|
||||
You should ask yourself if your entry remains obscure after it has been
|
||||
'cleaned up' by the C pre-processor and a C beautifier.
|
||||
|
||||
Your entry need not pass all of the above tests. In certain
|
||||
cases, a test is not important. Entries that compete for the
|
||||
'strangest/most creative source layout' need not do as well as
|
||||
others in terms of their algorithm. On the other hand, given
|
||||
two such entries, we are more inclined to pick the entry that
|
||||
does something interesting when you run it.
|
||||
|
||||
We try to avoid limiting creativity in our rules. As such, we leave
|
||||
the contest open for creative rule interpretation. As in real life
|
||||
programming, interpreting a requirements document or a customer request
|
||||
is important. For this reason, we often award 'worst abuse of the
|
||||
rules' to an entry that illustrates this point in an ironic way.
|
||||
|
||||
We do realize that there are holes in the rules, and invite entries
|
||||
to attempt to exploit them. We will award 'worst abuse of the rules'
|
||||
and then plug the hole next year. Even so, we will attempt to use
|
||||
the smallest plug needed, if not smaller. :-)
|
||||
|
||||
| There are 23 reasons why these guidelines seem obfuscated.
|
||||
|
||||
Check out your program and be sure that it works. We sometimes make
|
||||
the effort to debug an entry that has a slight problem, particularly
|
||||
in or near the final round. On the other hand, we have seen some
|
||||
of the best entries fall down because they didn't work.
|
||||
|
||||
We tend to look down on a prime number printer that claims that
|
||||
16 is a prime number. If you do have a bug, you are better off
|
||||
documenting it. Noting "this entry sometimes prints the 4th power
|
||||
of a prime by mistake" would save the above entry. And sometimes,
|
||||
a strange bug/feature can even help the entry! Of course, a correctly
|
||||
working entry is best. Clever people will note that 16 might be prime
|
||||
under certain conditions. Wise people, when submitting something clever
|
||||
will fully explain such cleverness in their entry's remarks file.
|
||||
|
||||
People who are considering to just use some complex mathematical
|
||||
function or state machine to spell out something such as "hello,
|
||||
world!" really really, and we do mean really, do need to be more creative.
|
||||
|
||||
Ultra-obfuscated programs are, in some cases, easier to
|
||||
deobfuscate than subtly-obfuscated programs. Consider using
|
||||
misleading or subtle tricks layered on top of or under an
|
||||
appropriate level of obfuscation. A clean looking program with
|
||||
misleading comments and variable names might be a good start.
|
||||
|
||||
When programs use VTxxx/ANSI sequences, they should NOT limited to a
|
||||
specific terminal brand. Those programs that work in a standard xterm
|
||||
are considered more portable.
|
||||
|
||||
Rule 2 (the size rule) has been changed. In particular rule 2 refers to
|
||||
the use of an IOCCC size tool. The source for this tool is found at:
|
||||
|
||||
| http://www.ioccc.org/2014/iocccsize.c
|
||||
|
||||
The IOCCC size tool should be compiled as:
|
||||
|
||||
cc -pedantic -Wall -std=c99 iocccsize.c -o iocccsize
|
||||
|
||||
This tool imposes a 2nd limit on C code size. To check your program
|
||||
source against the 2nd limit of rule 2, use the -i command line option.
|
||||
For example:
|
||||
|
||||
./iocccsize -i < prog.c
|
||||
|
||||
The IOCCC size tool, when using the -i option, may be summarized as:
|
||||
|
||||
The size tool counts most C reserved words (keyword, secondary,
|
||||
and selected preprocessor keywords) as 1. The size tool counts all
|
||||
other octets as 1 excluding ASCII whitespace, and excluding any
|
||||
';', '{' or '}' followed by ASCII whitespace, and excluding any
|
||||
';', '{' or '}' octet immediately before the end of file.
|
||||
|
||||
ASCII whitespace includes ASCII tab, ASCII space, ASCII newline,
|
||||
ASCII formfeed, and ASCII carriage return.
|
||||
|
||||
In cases where the above summary and the algorithm implemented by
|
||||
the IOCCC size tool source code conflict, the algorithm implemented
|
||||
by the IOCCC size tool source code is preferred by the judges.
|
||||
|
||||
There are at least 2 other reasons for selecting 2053 as the 2nd limit
|
||||
besides the fact that 2053 is the next prime > 2048. These reasons
|
||||
may be searched for and discovered if you are "Curios!" about 2053. :-)
|
||||
Moreover, 2053 was the number of the kernel disk pack of one of the
|
||||
judge's BESM-6.
|
||||
|
||||
Take note that this secondary limit imposed by the IOCCC size tool
|
||||
obviates some of the need to #define C reserved words in an effort
|
||||
to get around the size limits of rule 2.
|
||||
|
||||
Yes Virginia, that is a hint!
|
||||
|
||||
|
||||
OUR LIKES AND DISLIKES:
|
||||
|
||||
Doing masses of #defines to obscure the source has become 'old'. We
|
||||
tend to 'see thru' masses of #defines due to our pre-processor tests
|
||||
that we apply. Simply abusing #defines or -Dfoo=bar won't go as far
|
||||
as a program that is more well rounded in confusion.
|
||||
|
||||
Many C compilers dislike the following code, and so do we:
|
||||
|
||||
#define d define
|
||||
#d foo /* <-- don't expect this to turn into #define foo */
|
||||
|
||||
When declaring local or global variables, you should declare the type:
|
||||
|
||||
int this_is_fine;
|
||||
this_is_not; /* <-- Try to avoid implicit type declarations */
|
||||
|
||||
We suggest that you compile your entry with an ISO/IEC 9899-1999
|
||||
("ISO C99") C compiler or at least an ANSI C compiler.
|
||||
|
||||
DO NOT assume that we will use gcc to compile your program.
|
||||
We will first try to compile your program using Clang.
|
||||
|
||||
| It is much better to not use any obscure compiler flags if
|
||||
you can help it. We want to discourage the use of obscure compiler
|
||||
flags that would make the program less portable.
|
||||
|
||||
One side effect of the above is that you cannot assume the use
|
||||
of nested functions such as:
|
||||
|
||||
main() {
|
||||
| void do_not_do_this() { printf("Albatross!\n"); }
|
||||
do_not_do_this();
|
||||
}
|
||||
|
||||
This is because such nested functions often requires one to compile with
|
||||
a flag such as -fnested-functions that is not found on some compilers.
|
||||
|
||||
On 2012 July 20, the judges rescinded the encouragement of
|
||||
nested functions. Such constructions, while interesting and sometimes
|
||||
amusing, will have to wait until they required by a C standard that are
|
||||
actually implemented in commonly used C compilers. Sorry!
|
||||
|
||||
| We prefer programs that do require a fish license for pet fish.
|
||||
|
||||
If your entry uses functions that have a variable number of
|
||||
arguments, be careful. Systems implement va_list as a wide variety
|
||||
of ways. Because of this, a number of operations using va_list are
|
||||
not portable and must not be used:
|
||||
|
||||
* assigning a non-va_list variable to/from a va_list variable
|
||||
* casting a non-va_list variable into/from a va_list variable
|
||||
* passing a va_list variable to a function expecting a non-va_list arg
|
||||
* passing a non-va_list variable to a function expecting a va_list arg
|
||||
* performing arithmetic on va_list variables
|
||||
* using va_list as a structure or union
|
||||
|
||||
In particular, do not treat va_list variables as if they were a char **'s.
|
||||
|
||||
Avoid using <varargs.h>. Use <stdarg.h> instead.
|
||||
|
||||
On 28 January 2007, the Judges rescinded the requirement that the
|
||||
'#" in a C preprocessor directive must be the 1st non-whitespace octet.
|
||||
|
||||
| The exit() function returns void. Some broken systems have exit()
|
||||
| return int, your entry should assume that exit() returns a void.
|
||||
|
||||
| This line has a change mark at the beginning.
|
||||
|
||||
Small programs are best when they are short, obscure and concise.
|
||||
While such programs are not as complex as other winners, they do
|
||||
serve a useful purpose. They are often the only program that people
|
||||
attempt to completely understand. For this reason, we look for
|
||||
programs that are compact, and are instructional.
|
||||
|
||||
One line programs should be short one line programs: say around 80 to 120
|
||||
octets long. Going well beyond 140 octets is a bit too long to be called
|
||||
a one-liner in our vague opinion.
|
||||
|
||||
We tend to dislike programs that:
|
||||
|
||||
* are very hardware specific
|
||||
* are very OS version specific
|
||||
(index/strchr differences are OK, but socket/streams specific
|
||||
code is likely not to be)
|
||||
* dump core or have compiler warnings
|
||||
(it is OK only if you warn us in the 'remark' header item)
|
||||
* won't compile or run under a POSIX P1003.1/P1003.2 like systems
|
||||
* depend on a utility or application not normally found on most
|
||||
most POSIX P1003.1/P1003.2 like systems
|
||||
* abuse the build file to get around the size limit
|
||||
* obfuscate by excessive use of ANSI tri-graphs
|
||||
* are longer than they need to be
|
||||
* are "blob-ier" than they need to be
|
||||
| * are rather similar to previous winners :-(
|
||||
| * are too similar to previous losers :-)
|
||||
|
||||
Unless you are cramped for space, or unless you are entering the
|
||||
'best one liner' category, we suggest that you format your program
|
||||
in a more creative way than simply forming excessively long lines.
|
||||
|
||||
At least one judge prefers to maintain the use of the leap-second
|
||||
as part of the world's time standard.
|
||||
|
||||
The "how to build" make process should not be used to try and get
|
||||
around the size limit. It is one thing to make use of a several -D's
|
||||
on the compile like to help out, but it is quite another to use many
|
||||
bytes of -D's in order to try and squeeze the source under the size limit.
|
||||
|
||||
| The judges, as a group, have a history giving wide degree of latitude
|
||||
| to reasonable entries. And recently they have had as much longitutional
|
||||
| varation as it is possible to have on Earth. :-)
|
||||
|
||||
You should try to restrict commands used on the build file to
|
||||
POSIX-like or common Un*x-like commands. You can also compile
|
||||
and use your own programs. If you do, try to build and execute
|
||||
from the current directory. This restriction is not a hard and
|
||||
absolute one. The intent is to ensure that the building if your
|
||||
program is reasonably portable.
|
||||
|
||||
You are in a maze of twisty guidelines, all different.
|
||||
|
||||
| There are at least zero judges who think that Fideism has little
|
||||
| or nothing to do with the IOCCC judging process.
|
||||
|
||||
Don't forget that the building of your program should be done
|
||||
***without human intervention***. So don't do:
|
||||
|
||||
prog: prog.c
|
||||
#echo this next line requires data from standard input
|
||||
cat > prog.c
|
||||
${CC} prog.c -o prog
|
||||
|
||||
However, you can do something cute such as making your program
|
||||
| do something dumb (or cute) when it is built 'automatically'. And
|
||||
when it is run with a human involved, do something more clever.
|
||||
For example, one could use the build instructions:
|
||||
|
||||
prog: prog.c
|
||||
${CC} prog.c -DNON_HUMAN_COMPILE -o prog
|
||||
@echo "See remarks section about alternate ways to compile"
|
||||
|
||||
and then include special notes in the program "remarks" for
|
||||
alternate / human intervention based building.
|
||||
|
||||
We want to get away from source that is simply a compact blob of
|
||||
| octets. Really try to be more creative than blob coding. *HINT!*
|
||||
|
||||
Please do not use things like gzip to get around the size limit.
|
||||
Be more creative.
|
||||
|
||||
We really dislike entries that make blatant use of including
|
||||
large data files to get around the source code size limit.
|
||||
|
||||
Did we remember to indicate that programs that blatantly use
|
||||
some complex state machine to do something simple are boring?
|
||||
We think we did. :-)
|
||||
|
||||
| All generalizations are false, including this one. -- Mark Twain
|
||||
|
||||
Given two versions of the same program, one that is a compact blob
|
||||
of code, and the other that is formatted more like a typical C
|
||||
program, we tend to favor the second version. Of course, a third
|
||||
version of the same program that is formatted in an interesting
|
||||
and/or obfuscated way, would definitely win over the first two!
|
||||
Remember, you can submit more than one entry. See the rules for details.
|
||||
|
||||
We suggest that you avoid trying for the 'smallest self-replicating'
|
||||
source. The smallest, a zero byte entry, won in 1994.
|
||||
|
||||
| Programs that claim to be the smallest C source that does something, really
|
||||
| better be the smallest such program or they risk being rejected because
|
||||
they do not work as documented.
|
||||
|
||||
Please note that the C source below, besides lacking in obfuscation,
|
||||
is NOT the smallest C source file that when compiled and run, dumps core:
|
||||
|
||||
main;
|
||||
|
||||
We do not like writable strings. That is, we don't want stuff like:
|
||||
|
||||
char *T = "So many primes, so little time!";
|
||||
...
|
||||
T[14] = ';';
|
||||
|
||||
Please don't make use of this feature, even if your system allows it.
|
||||
However, initialized char arrays are OK to write over. This is OK:
|
||||
|
||||
char b[] = "Is this OK";
|
||||
b[9] = 'K';
|
||||
|
||||
| There is still a typo in this sentence.
|
||||
|
||||
X client entries should be as portable as possible. Entries that
|
||||
adapt to a wide collection of environments will be favored. For
|
||||
example, don't depend on a particular type or size of display.
|
||||
Don't assume the use of a particular browser. Instead assume a
|
||||
generic browser that forms to a widely used W3C standard.
|
||||
Don't assume a particular sound sub-system or video driver is installed
|
||||
in the OS. Instead, make use of a well known and widely available open
|
||||
source program (one that actually works) to display audio/visual data.
|
||||
|
||||
X client entries should avoid using X related libraries and
|
||||
software that is not in wide spread use.
|
||||
|
||||
This is the only guideline that contains the word fizzbin.
|
||||
|
||||
We don't like entries that use proprietary toolkits such as the M*tif,
|
||||
Xv*ew, or OpenL*ok toolkits, since not everyone has them. Use of an
|
||||
open source toolkit that is widely and freely available instead.
|
||||
|
||||
You should avoid depending on a particular window manager.
|
||||
|
||||
X client entries should not to depend on particular items on
|
||||
.Xdefaults. If you must do so, be sure to note the required lines
|
||||
in the program "remarks".
|
||||
|
||||
Try to avoid entries that play silent sound segments or play the
|
||||
Happy Birthday song; music that some people believe is copyrighted
|
||||
(even if such copyrights appear to be bogus and/or blatant abuses of
|
||||
the copyright system).
|
||||
|
||||
While we recognize that UN*X is not a universal operating system, the
|
||||
contest does have a bias towards such systems. In an effort to expand
|
||||
the scope of the contest, we phrase our bias in terms of POSIX P1003.1
|
||||
and P1003.2 standards. This will allow certain non-UN*X OS users to
|
||||
submit entries. On the other hand, this is a guideline and not a rule.
|
||||
We will not reject an entry based on some POSIX technicality.
|
||||
|
||||
When dealing with OS and application environments, we suggest that you
|
||||
be reasonable with a nod towards vanilla UN*X-like systems. POSIX will
|
||||
evolve but not as much as the contest.
|
||||
|
||||
| You very well might not be completely prohibited from failing to not
|
||||
| partly misunderstand this particular guideline. You are not mandated to
|
||||
determine that this or the previous sentence is false and misleading.
|
||||
| Nevertheless, it might not be wise to not fail to consider failing to do so.
|
||||
|
||||
We like programs that:
|
||||
|
||||
* are as concise and small as they need to be
|
||||
* do something at least quasi-interesting
|
||||
* are portable
|
||||
* are unique or novel in their obfuscation style
|
||||
* MAKE USE OF A NUMBER OF DIFFERENT TYPES OF OBFUSCATION <== HINT!!
|
||||
* make us laugh and/or throw up :-) (humor really helps!)
|
||||
| * make us want to eat good chocolate.
|
||||
|
||||
Some types of programs can't excel (anti-tm) in some areas. Your
|
||||
program doesn't have to excel in all areas, but doing well in several
|
||||
areas really does help.
|
||||
|
||||
You are better off explaining what your entry does in the program
|
||||
"remarks" section rather than leaving it obscure for the judges
|
||||
as we might miss something and/or be too tired to notice.
|
||||
|
||||
| Please avoid this specific individual guideline, if you can.
|
||||
|
||||
We freely admit that interesting, creative or humorous comments in
|
||||
the program "remarks" help your chances of winning. If you had to
|
||||
read so many twisted entries, you too would enjoy a good laugh or two.
|
||||
We think the readers of the contest winners do as well. We do read
|
||||
the program "remarks" during the judging process, so it is worth your
|
||||
while to write remarkable program "remarks".
|
||||
|
||||
We dislike C code with trailing control-M's (\r or \015) that results
|
||||
in compilation failures. Some non-Un*x/non-Linux tools such as
|
||||
MS Visual C and MS Visual C++ leave trailing control-M's on lines.
|
||||
Users of such tools should strip off such control-M's before submitting
|
||||
their entries. In some cases tools have a "Save As" option that will
|
||||
prevent such trailing control-M's being added.
|
||||
|
||||
We dislike entries that depend on non-portable libcurses features such
|
||||
as halfdelay(). One should restrict libcurses to portable features
|
||||
found on BSD or Linux curses.
|
||||
|
||||
Rule 13 states any C source that fails to compile because of unescaped
|
||||
octets with the high bit set (octet value >= 128) will be rejected.
|
||||
Instead of unescaped octets, you should use \octal or \hex escapes:
|
||||
|
||||
/* 123456789 123456789 123456789 123456 */
|
||||
char *foo = "This string is 36 octets in length \263";
|
||||
/* This octet requires 4 octets of source ^^^^ */
|
||||
if (strlen(foo) == 36) printf("foo is 36 octets plus a final NUL\n");
|
||||
else printf("This code should not print this message\n");
|
||||
|
||||
It is a very good idea to, in your remarks file, tell us why you
|
||||
think your entry is obfuscated. This is particularly true if
|
||||
your entry is has some very subtle obfuscations that we might
|
||||
otherwise overlook. <<-- Hint!
|
||||
|
||||
Anyone can format their code into a dense blob. A really clever
|
||||
author will try format their entry using a "normal" formatting style
|
||||
such that at first glance (if you squint and don't look at the details)
|
||||
the code might pass for non-obfuscated C. Deceptive comments,
|
||||
and mis-leading formatting, in some cases, may be a plus. On the
|
||||
other hand, a misleading code style requires more source bytes.
|
||||
|
||||
If you do elect to use misleading formatting and comments, we
|
||||
suggest you remark on this point in your remarks where you talk
|
||||
about why you think your entry is obfuscated. On the other hand,
|
||||
if you are pushing up against the size limits, you may be forced
|
||||
into creating a dense blob. Such are the trade offs that obfuscators face!
|
||||
|
||||
We prefer code that can run on either a 64-bit or 32-bit processor.
|
||||
However, it is unwise to assume it will run on an i386 or x86 architecture.
|
||||
|
||||
| We believe that Mark Twain's remark:
|
||||
|
||||
| Get your facts first, then you can distort them as you please.
|
||||
|
||||
| is a good guideline for those writing code for the IOCCC.
|
||||
|
||||
While programs that only run in a specific word size are OK. If you have
|
||||
| to pick, choose a 64-bit word size.
|
||||
|
||||
If we are feeling ornery we might choose to compile your program
|
||||
for running on an Arduino or a PDP-11. Heck, should we ever find
|
||||
an emulator of 60-bit CDC Cyber CPU running a POSIX-like OS, we
|
||||
might just try your entry on that emulator as well :-)
|
||||
|
||||
If your entry MUST run only in 32-bit mode on an Intel processor, add the
|
||||
following compiler flag:
|
||||
|
||||
-arch i386
|
||||
|
||||
to your "how to build" make compile line. For example:
|
||||
|
||||
prog: prog.c
|
||||
${CC} prog.c -arch i386 -o prog
|
||||
|
||||
Be even more creative!
|
||||
|
||||
|
||||
ABUSING THE RULES:
|
||||
|
||||
Legal abuse of the rules is somewhat encouraged. Legal rule abuse may
|
||||
involve, but is not limited to, doing things that are technically
|
||||
allowed by the rules and yet do not fit the spirit of what we intended
|
||||
to be submitted.
|
||||
|
||||
Legal rule abuse is encouraged to help promote creativity. Rule abuse
|
||||
entries, regardless of if they receive an award, result in changes to
|
||||
the next year's rules and guidelines.
|
||||
|
||||
Legal abuse of the rules is NOT an invitation to violate the rules.
|
||||
An entry that violates the rules in the opinion of the judges, WILL be
|
||||
disqualified. RULE ABUSE CARRIES A CERTAIN LEVEL OF RISK! If you
|
||||
have an entry that might otherwise be interesting, you might want to
|
||||
submit two versions; one that does not abuse the rules and one that
|
||||
does.
|
||||
|
||||
If you intend to abuse the rules, indicate so in the program
|
||||
"remarks". You must try to justify why you consider your rule abuse
|
||||
to be allowed under the rules. That is, you must plead your case as
|
||||
to why your entry is valid. Humor and/or creativity help plead a
|
||||
case.
|
||||
|
||||
Abusing the web submission procedure tends to annoy us more
|
||||
than amuse us. Spend your creative energy on content of your
|
||||
entry rather than on the submission process itself.
|
||||
|
||||
We are often asked why the contest rules and guidelines seem too
|
||||
strange or contain mistakes, flaws or grammatical errors. One reason
|
||||
is that we sometimes make genuine mistakes. But in many cases such
|
||||
problems, flaws or areas of confusion are deliberate. Changes to
|
||||
rules and guidelines in response to rule abuses, are done in a minimal
|
||||
fashion. Often we will deliberately leave behind holes (or introduce
|
||||
new ones) so that future rule abuse may continue. A cleaver author
|
||||
should be able to read them and "drive a truck through the holes" in
|
||||
the rules and guidelines.
|
||||
|
||||
At the risk of stating the obvious, this contest is a parody of the
|
||||
software development process. The rules and guidelines are only a
|
||||
small part of the overall contest. Even so, one may think the contest
|
||||
rules and guideline process as a parody of the sometimes tragic
|
||||
mismatch between what a customer (or marketing) wants and what
|
||||
engineering delivers. Real programmers must face obfuscated
|
||||
and sometimes conflicting specifications and requirements from marketing,
|
||||
sales, product management an even from customers themselves on a
|
||||
all to regular basis. This is one of the reasons why the rules and
|
||||
guidelines are written in obfuscated form.
|
||||
|
||||
|
||||
JUDGING PROCESS:
|
||||
|
||||
Entries are judged by Leonid A. Broukhis, Simon Cooper, Landon Curt Noll.
|
||||
|
||||
| Each entry submitted is given a random id number and subdirectory. The
|
||||
entry files including, but not limited to prog.c, Makefile (that we
|
||||
form from around your "how to build" information), as well as any
|
||||
| data files that you submit are all placed under their own directory.
|
||||
stored and judged from this directory.
|
||||
|
||||
Any information about the authors is not read by the judges until
|
||||
the judging process is complete, and then only from entries that have
|
||||
won an award.
|
||||
|
||||
Because we do not read this information for entries that do not win,
|
||||
| we do not know who did not win.
|
||||
|
||||
The above process helps keep us biased for/against any one particular
|
||||
individual. Therefore you MUST refrain from putting any information
|
||||
that reveals your identity in your entry.
|
||||
|
||||
Now some people point out that coding style might reveal the information
|
||||
about the others. However we consider this to be simply circumstantial
|
||||
and outside the scope of the above paragraph.
|
||||
|
||||
Some people, in the past, have attempted to obfuscate their identity by
|
||||
including comments of famous Internet personalities such as Peter Honeyman
|
||||
(http://www.citi.umich.edu/u/honey/). The judges are on to this
|
||||
trick and therefore consider any obfuscated source or data file
|
||||
claiming to be from Honeyman to not be form Honeyman. This of course
|
||||
creates an interesting paradox known as the "obfuscated Peter Honeyman
|
||||
paradox". Should Peter Honeyman actually submit an obfuscated entry,
|
||||
| he alone is excluded from the above, as we will likely believe
|
||||
it just another attempt at confusion. This guideline is known
|
||||
as the "Peter Honeyman is exempt" guideline.
|
||||
|
||||
BTW: None of the entries claiming to be from Peter Honeyman have ever
|
||||
won an award. So it is theoretically possible that Peter Honeyman
|
||||
did submit an entry in the past. In the past, Peter had denied
|
||||
submitting anything to the IOCCC. Perhaps those entries were
|
||||
submitted by one of his students?
|
||||
|
||||
| We seemed to have digressed again ... :-) Returning to the judging process:
|
||||
|
||||
We prefer to be kept in the dark as much as you are until the final
|
||||
awards are given. We enjoy the surprise of finding out in the end,
|
||||
who won and where they were from.
|
||||
|
||||
We attempt to keep all entries anonymous, unless they win an award.
|
||||
Because the main 'prize' of winning is being announced, we make all
|
||||
attempts to send non-winners into oblivion. We remove all non-winning
|
||||
files, and shred all related paper. By tradition, we do not even
|
||||
reveal the number of entries that we received.
|
||||
|
||||
During the judging process. a process that spans multiple sessions
|
||||
over a few weeks, post general updates from our @IOCCC twitter account.
|
||||
|
||||
Once we have selected the winners, for each category we will tweet:
|
||||
|
||||
category name
|
||||
name(s) of the authors (or anonymous if requested)
|
||||
twitter handle(s) (if provided and if anonymity was not requested)
|
||||
country code(s) of the author(s)
|
||||
|
||||
After the initial announcement, we attempt to send EMail to the
|
||||
authors of the winning entries. One reason we do this is to give
|
||||
the authors a chance to comment on the way we have presented their
|
||||
entry. They are given the chance to correct mistakes and typos. We
|
||||
often accept their suggestions/comments about our remarks as well.
|
||||
This is done prior to posting the winners to the wide world.
|
||||
|
||||
Judging consists of a number of elimination rounds. During a round,
|
||||
the collection of entries are divided into two roughly equal piles;
|
||||
the pile that advances on to the next round, and the pile that does
|
||||
not. We also re-examine the entries that were eliminated in the
|
||||
previous round. Thus, an entry gets at least two readings.
|
||||
|
||||
A reading consists of a number of actions:
|
||||
|
||||
* reading the "how to build" information and forming a Makefile
|
||||
* reading prog.c, the C source
|
||||
* reviewing the "remarks" information
|
||||
* briefly looking any any supplied data files
|
||||
* passing the source thru the C pre-processor
|
||||
skipping over any #include files
|
||||
* performing a number of C beautify/cleanup edits on the source
|
||||
* passing the beautified source thru the C pre-processor
|
||||
skipping over any #include files
|
||||
* compiling/building the source
|
||||
* running the program
|
||||
* Doing other things that only IOCCC judges know about :-)
|
||||
|
||||
In later rounds, other actions are performed including performing
|
||||
miscellaneous tests on the source and binary.
|
||||
|
||||
Until we reduce the stack of entries down to about 25 entries, entries
|
||||
are judged on an individual basis. An entry is set aside because it
|
||||
does not, in our opinion, meet the standard established by the round.
|
||||
When the number of entries thins to about 25 entries, we begin to form
|
||||
award categories. Entries begin to compete with each other for awards.
|
||||
An entry will often compete in several categories.
|
||||
|
||||
The actual award category list will vary depending on the types of entries
|
||||
we receive. A typical category list might be:
|
||||
|
||||
* best small one line program
|
||||
* best small program
|
||||
* strangest/most creative source layout
|
||||
* most useful obfuscated program
|
||||
* best game that is obfuscated
|
||||
* most creatively obfuscated program
|
||||
* most deceptive C code (code with deceptive comments and source code)
|
||||
* best X client (see OUR LIKES AND DISLIKES)
|
||||
* best abuse of ISO/IEC 9899-1999 ("ISO C99") C or ANSI C
|
||||
* best abuse of the C preprocessor
|
||||
* worst abuse of the rules
|
||||
* (anything else so strange that it deserves an award)
|
||||
|
||||
We do not limit ourselves to this list. For example, a few entries are so
|
||||
good/bad that they are declared winners at the start of the final round.
|
||||
We will invent awards categories for them, if necessary.
|
||||
|
||||
In the final round process, we perform the difficult tasks of
|
||||
reducing the remaining entries (typically about 25) down to to about
|
||||
half that number: declaring those remaining to be winners.
|
||||
|
||||
Often we are confident that the entries that make it into
|
||||
the final round are definitely better than the ones that do not
|
||||
make it. The selection of the winners out of the final round, is
|
||||
less clear cut.
|
||||
|
||||
Sometimes a final round entry is good enough to win, but is beat out
|
||||
by a similar, but slightly better entry. For this reason, it is
|
||||
sometimes worthwhile to re-enter an improved version of an entry
|
||||
that failed to win in a previous year. This assumes, of course,
|
||||
that the entry is worth improving in the first place!
|
||||
|
||||
More than one IOCCC judge has been known to bribe another IOCCC judge
|
||||
into voting for a winning entry by offering a bit high quality chocolate.
|
||||
This technique is highly discouraged for use by non-IOCCC judges.
|
||||
|
||||
More often than not, we select a small entry (usually one line), a
|
||||
strange/creative layout entry. We sometimes also select an
|
||||
entry that abuses the contest guidelines in an interesting way,
|
||||
or that stretches the content rules that while legal, is
|
||||
nevertheless goes against the intent of the rules.
|
||||
|
||||
In the end, we traditionally pick one entry as 'best'. Sometimes such
|
||||
an entry simply far exceeds any of the other entries. More often, the
|
||||
'best' is picked because it does well in a number of categories.
|
||||
|
||||
|
||||
ANNOUNCEMENT OF WINNERS:
|
||||
|
||||
The judges will tweet initial announcement of who won, the name
|
||||
of their award, and a very brief description of the winning entry
|
||||
from the @IOCCC twitter handle. Non-twitter users should visit:
|
||||
|
||||
https://twitter.com/ioccc
|
||||
|
||||
Non-twitter users should force their browsers to reload the above URL
|
||||
to be sure they are seeing the most recent tweets.
|
||||
|
||||
The judges will then post an initial announcement of who won, the name
|
||||
of their award, and a very brief description of the winning entry
|
||||
on the IOCCC web site:
|
||||
|
||||
http://www.ioccc.org/whowon.html
|
||||
|
||||
We will also attempt to submit a brief announcement story to /.:
|
||||
|
||||
http://slashdot.org
|
||||
|
||||
that, depending on the willingness of the /. editors, may be posted
|
||||
to their site at the same time.
|
||||
|
||||
Note that initial announcement will NOT contain source. This is because
|
||||
the winning authors are given a chance to review the judges comments,
|
||||
and test our Makefile. This review process typically takes a few weeks.
|
||||
|
||||
Sometime after the initial announcement, and once the the review
|
||||
by the winners has been completed, the winning source will be
|
||||
posted to the IOCCC web site:
|
||||
|
||||
http://www.ioccc.org/years.html
|
||||
|
||||
NOTE: previous winners are available at that URL
|
||||
|
||||
We will also tweet, via @IOCCC, when the winning source is available.
|
||||
|
||||
It is pointless to ask the IOCCC judges how many entries we receive.
|
||||
| Other government TLA or FLA snooping organizations are prohibited from
|
||||
| either confirming, denying or revealing any knowledge of this data point.
|
||||
|
||||
Often, winning entries are published in selected magazines from around
|
||||
the world. Winners have appeared in books ("The New Hackers Dictionary")
|
||||
and on T-Shirts. More than one winner has been turned in a tattoo!
|
||||
|
||||
Last, but not least, winners receive international fame and flames! :-)
|
||||
|
||||
|
||||
FOR MORE INFORMATION:
|
||||
|
||||
You may contact the judges by sending EMail to the following address:
|
||||
|
||||
| q.2014@ioccc.org (do not submit entries to this address)
|
||||
|
||||
| You must include the words 'ioccc 2014 question' in the subject of your
|
||||
EMail message when sending EMail to the judges.
|
||||
|
||||
Questions and comments about the contest are welcome. Comments about
|
||||
confusing rules and guidelines are also welcome.
|
||||
|
||||
The rules and the guidelines may (and often do) change from year to
|
||||
year. You should be sure you have the current rules and guidelines
|
||||
prior to submitting entries.
|
||||
|
||||
Check out the IOCCC Web page:
|
||||
|
||||
http://www.ioccc.org
|
||||
|
||||
It has rules, guidelines and winners of previous contests (1984 to date).
|
||||
|
||||
For the updates and breaking IOCCC news, you are encouraged to follow
|
||||
the twitter handle:
|
||||
|
||||
@IOCCC
|
||||
|
||||
You do not have to be a twitter user to follow @IOCCC. Non-twitter
|
||||
users should access:
|
||||
|
||||
https://twitter.com/ioccc
|
||||
|
||||
Non-twitter users should force their browsers to reload the above URL
|
||||
to be sure they are seeing the most recent tweets.
|
||||
|
||||
Leonid A. Broukhis
|
||||
Simon Cooper
|
||||
chongo (Landon Curt Noll) /\cc/\
|
||||
@@ -0,0 +1,77 @@
|
||||
* {
|
||||
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
body {
|
||||
max-width: 50em;
|
||||
margin: 0 auto;
|
||||
color: #111;
|
||||
}
|
||||
|
||||
pre, code {
|
||||
font-family: Monaco, Courier New, monospace;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 40px;
|
||||
font-weight: bold;
|
||||
letter-spacing: -1px;
|
||||
margin-bottom: -5px;
|
||||
}
|
||||
h1 code {
|
||||
font-size: 40px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: rgb(43,105,145);
|
||||
font-weight: bold;
|
||||
margin-bottom: -5px;
|
||||
}
|
||||
h2 code {
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
/* color: rgb(43,105,145); */
|
||||
font-weight: bold;
|
||||
margin-bottom: -5px;
|
||||
}
|
||||
h3 code {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: blue;
|
||||
text-decoration: underline;
|
||||
}
|
||||
a:visited {
|
||||
color: navy;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
pre {
|
||||
border-radius: 10px;
|
||||
-webkit-border-radius: 10px;
|
||||
-moz-border-radius: 10px;
|
||||
box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.3);
|
||||
-webkit-box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.3);
|
||||
-moz-box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.3);
|
||||
border-width: 1px;
|
||||
border-color: rgb(16,48,0);
|
||||
border-style: solid;
|
||||
padding: 0.6em;
|
||||
padding-left: 1em;
|
||||
margin-left: 5%;
|
||||
margin-right: 8%;
|
||||
background-color: rgb(55,39,0);
|
||||
overflow: auto;
|
||||
color: rgb(255,183,0);
|
||||
}
|
||||
|
||||
p, li {
|
||||
font-size: 14px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,522 @@
|
||||
/*
|
||||
* iocccsize - IOCCC Source Secondary Size
|
||||
*
|
||||
* This IOCCC size tool source file is version 2014-09-23-v19.
|
||||
* Public Domain 1992, 2013, 2014 by Anthony Howe. All rights released.
|
||||
* With IOCCC minor mods in 2013,2014 by chongo (Landon Curt Noll) /\oo/\
|
||||
*
|
||||
* SYNOPSIS
|
||||
*
|
||||
* ioccc [-krs] < input
|
||||
*
|
||||
* -k keep comment blocks
|
||||
* -r count C reserved words as 1 byte
|
||||
* -s suppress source output, write only the IOCCC 2nd size count
|
||||
*
|
||||
* DESCRIPION
|
||||
*
|
||||
* Taking input from standard input, apply the IOCCC Source Size Rule
|
||||
* for 2001. The program's offical length is written to standard error.
|
||||
* Also filter out C comment blocks (-k to keep) sending the modified
|
||||
* source to standard output.
|
||||
*
|
||||
* The 2001 Source Size Rule was:
|
||||
*
|
||||
* Your entry must be <= 4096 bytes in length. The number of octets
|
||||
* excluding whitespace (tab, space, newline, formfeed, return), and
|
||||
* excluding any ';', '{' or '}' followed by whitespace or end of file,
|
||||
* must be <= 2048.
|
||||
*
|
||||
* 2013 Source Size Rule is (-r):
|
||||
*
|
||||
* Your entry must be <= 4096 bytes in length. The number of octets
|
||||
* excluding whitespace (tab, space, newline, formfeed, return), and
|
||||
* excluding any ';', '{' or '}' followed by whitespace or end of file,
|
||||
* and where C reserved words, including a subset of preprocessor words,
|
||||
* count as 1 byte, must be <= 2053 (first prime after 2048).
|
||||
*/
|
||||
|
||||
/*
|
||||
* The official IOCCC rule 2 secondary limit on C code size
|
||||
*
|
||||
* The IOCCC size tool should be compiled as:
|
||||
*
|
||||
* cc -pedantic -Wall -std=c99 iocccsize.c -o iocccsize
|
||||
*
|
||||
* This tool computes a 2nd size C code. To check your program source
|
||||
* against the 2nd limit of rule 2, use the -i command line option.
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* ./iocccsize -i < prog.c
|
||||
*
|
||||
* The IOCCC size tool, when using the -i option, may be summarized as:
|
||||
*
|
||||
* The size tool counts C language keywords (primary, secondary, and
|
||||
* selected preprocessor keywords) as 1. The size tool counts all
|
||||
* other octets as 1 excluding ASCII whitespace, and excluding any
|
||||
* ';', '{' or '}' followed by ASCII whitespace, and excluding any
|
||||
* ';', '{' or '}' octet immediately before the end of file.
|
||||
*
|
||||
* ASCII whitespace includes ASCII tab, ASCII space, ASCII newline,
|
||||
* ASCII formfeed, and ASCII carriage return.
|
||||
*
|
||||
* In cases where the above summary and the algorithm implemented by
|
||||
* the IOCCC size tool source code conflict, the algorithm implemented
|
||||
* by the IOCCC size tool source code is preferred by the judges.
|
||||
*
|
||||
* See the current IOCCC rules and guidelines for more information.
|
||||
* In particular, see the current IOCCC size rule for information about
|
||||
* the maximum value that this tool should print for an entry to be valid.
|
||||
*/
|
||||
|
||||
/*
|
||||
* IOCCC Judge's remarks:
|
||||
*
|
||||
* This code contains undocumented features. On the other hand, this code
|
||||
* is RTFS (for certain values of RTFS). One might say that this code
|
||||
* perfectly documents itself. :-)
|
||||
*
|
||||
* Many thanks to Anthony Howe for taking the time to put his OCD
|
||||
* (Obfuscated Coding Determination) into this code!
|
||||
*/
|
||||
|
||||
/*
|
||||
* HINT: The algorithm implemented by this code may or not be obfuscated.
|
||||
* The algorithm may not or may appear to be obfuscated.
|
||||
*
|
||||
* In particular:
|
||||
*
|
||||
* We did not invent the algorithm.
|
||||
* The algorithm consistently finds Obfuscation.
|
||||
* The algorithm killed Obfuscation.
|
||||
* The algorithm is banned in C.
|
||||
* The algorithm is from Bell Labs in Jersey.
|
||||
* The algorithm constantly finds Obfuscation.
|
||||
* This is not the algorithm.
|
||||
* This is close.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#define FLAG_SILENCE 1
|
||||
#define FLAG_KEEP 2
|
||||
#define FLAG_RESERVED 4
|
||||
#define FLAG_IOCCC_SIZE 8
|
||||
|
||||
#define BUFFER_SIZE 512
|
||||
|
||||
char usage[] =
|
||||
"usage: ioccc [-ikrs] < prog.c\n"
|
||||
"\n"
|
||||
"-i\t\tprint just the official secondary IOCCC size to stdout\n"
|
||||
"\t\t NOTE: -i implies -r -s\n"
|
||||
"-k\t\tkeep block comments\n"
|
||||
"-r\t\tcount C reserved words as 1 byte\n"
|
||||
"-s\t\tsuppress source output, write only the offical size\n"
|
||||
;
|
||||
|
||||
#define STRLEN(s) (sizeof (s)-1)
|
||||
|
||||
typedef struct {
|
||||
size_t length;
|
||||
const char *word;
|
||||
} Word;
|
||||
|
||||
/*
|
||||
* C reserved words, plus a few #preprocessor tokens, that count as 1
|
||||
*
|
||||
* NOTE: For a good list of reserved words in C, see:
|
||||
*
|
||||
* http://www.bezem.de/pdf/ReservedWordsInC.pdf
|
||||
*
|
||||
* by Johan Bezem of JB Enterprises:
|
||||
*
|
||||
* See http://www.bezem.de/en/
|
||||
*/
|
||||
/*
|
||||
* The following editorial plea expresses a view shared by more than zero
|
||||
* IOCCC judges. It may not represent the opinion of all those involved
|
||||
* with this code nor the International Obfuscated C Code Contest as a whole:
|
||||
*
|
||||
* The long list of reserved words below should be a source
|
||||
* of embarrassment to some of those involved in standardizing C.
|
||||
* The growing list of reserved words, along with an expanding set of
|
||||
* linguistic inventions has the appearance of feature
|
||||
* creep that, if left unchecked, risks turning a beautifully elegant
|
||||
* language into a steaming pile of biological excretion.
|
||||
*
|
||||
* The history of the IOCCC has taught us that even minor changes
|
||||
* to the language are not always well understood by compiler writers,
|
||||
* let alone the standards body who publishes them. We have enormous
|
||||
* sympathy for C compiler writers who must keep up with the creeping
|
||||
* featurism. We are aware of some C standards members who share
|
||||
* these concerns. Alas, they seem to be a minority.
|
||||
*
|
||||
* The C standards body as a whole, before they emit yet more mountains of new
|
||||
* standardese, might wish consider the option of mothballing their committee.
|
||||
* Or if they must produce a new standard, consider naming whatever
|
||||
* follows c11 as CNC (C's Not C). :-)
|
||||
*/
|
||||
static Word cwords[] = {
|
||||
/* Yes Virginia, we left #define off the list on purpose! */
|
||||
{ STRLEN("#elif"), "#elif" },
|
||||
{ STRLEN("#else"), "#else" },
|
||||
{ STRLEN("#endif"), "#endif" },
|
||||
{ STRLEN("#error"), "#error" },
|
||||
{ STRLEN("#ident"), "#ident" },
|
||||
{ STRLEN("#if"), "#if" },
|
||||
{ STRLEN("#ifdef"), "#ifdef" },
|
||||
{ STRLEN("#include"), "#include" },
|
||||
{ STRLEN("#line"), "#line" },
|
||||
{ STRLEN("#pragma"), "#pragma" },
|
||||
{ STRLEN("#sccs"), "#sccs" },
|
||||
{ STRLEN("#warning"), "#warning" },
|
||||
/**/
|
||||
{ STRLEN("_Alignas"), "_Alignas" },
|
||||
{ STRLEN("_Alignof"), "_Alignof" },
|
||||
{ STRLEN("_Atomic"), "_Atomic" },
|
||||
{ STRLEN("_Bool"), "_Bool" },
|
||||
{ STRLEN("_Complex"), "_Complex" },
|
||||
{ STRLEN("_Generic"), "_Generic" },
|
||||
{ STRLEN("_Imaginary"), "_Imaginary" },
|
||||
{ STRLEN("_Noreturn"), "_Noreturn" },
|
||||
{ STRLEN("_Pragma"), "_Pragma" },
|
||||
{ STRLEN("_Static_assert"), "_Static_assert" },
|
||||
{ STRLEN("_Thread_local"), "_Thread_local" },
|
||||
/**/
|
||||
{ STRLEN("alignas"), "alignas" },
|
||||
{ STRLEN("alignof"), "alignof" },
|
||||
{ STRLEN("and"), "and" },
|
||||
{ STRLEN("and_eq"), "and_eq" },
|
||||
{ STRLEN("auto"), "auto" },
|
||||
{ STRLEN("bitand"), "bitand" },
|
||||
{ STRLEN("bitor"), "bitor" },
|
||||
{ STRLEN("bool"), "bool" },
|
||||
{ STRLEN("break"), "break" },
|
||||
{ STRLEN("case"), "case" },
|
||||
{ STRLEN("char"), "char" },
|
||||
{ STRLEN("compl"), "compl" },
|
||||
{ STRLEN("const"), "const" },
|
||||
{ STRLEN("continue"), "continue" },
|
||||
{ STRLEN("default"), "default" },
|
||||
{ STRLEN("do"), "do" },
|
||||
{ STRLEN("double"), "double" },
|
||||
{ STRLEN("else"), "else" },
|
||||
{ STRLEN("enum"), "enum" },
|
||||
{ STRLEN("extern"), "extern" },
|
||||
{ STRLEN("false"), "false" },
|
||||
{ STRLEN("float"), "float" },
|
||||
{ STRLEN("for"), "for" },
|
||||
{ STRLEN("goto"), "goto" },
|
||||
{ STRLEN("I"), "I" },
|
||||
{ STRLEN("if"), "if" },
|
||||
{ STRLEN("inline"), "inline" },
|
||||
{ STRLEN("int"), "int" },
|
||||
{ STRLEN("long"), "long" },
|
||||
{ STRLEN("noreturn"), "noreturn" },
|
||||
{ STRLEN("not"), "not" },
|
||||
{ STRLEN("not_eq"), "not_eq" },
|
||||
{ STRLEN("or"), "or" },
|
||||
{ STRLEN("or_eq"), "or_eq" },
|
||||
{ STRLEN("register"), "register" },
|
||||
{ STRLEN("restrict"), "restrict" },
|
||||
{ STRLEN("return"), "return" },
|
||||
{ STRLEN("short"), "short" },
|
||||
{ STRLEN("signed"), "signed" },
|
||||
{ STRLEN("sizeof"), "sizeof" },
|
||||
{ STRLEN("static"), "static" },
|
||||
{ STRLEN("static_assert"), "static_assert" },
|
||||
{ STRLEN("struct"), "struct" },
|
||||
{ STRLEN("switch"), "switch" },
|
||||
{ STRLEN("thread_local"), "thread_local" },
|
||||
{ STRLEN("true"), "true" },
|
||||
{ STRLEN("typedef"), "typedef" },
|
||||
{ STRLEN("union"), "union" },
|
||||
{ STRLEN("unsigned"), "unsigned" },
|
||||
{ STRLEN("void"), "void" },
|
||||
{ STRLEN("volatile"), "volatile" },
|
||||
{ STRLEN("while"), "while" },
|
||||
{ STRLEN("xor"), "xor" },
|
||||
{ STRLEN("xor_eq"), "xor_eq" },
|
||||
/**/
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
Word *
|
||||
find_member(Word *table, const char *string)
|
||||
{
|
||||
Word *w;
|
||||
for (w = table; w->length != 0; w++) {
|
||||
if (strncmp(string, w->word, w->length) == 0
|
||||
&& !isalnum(string[w->length]) && string[w->length] != '_')
|
||||
return w;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t
|
||||
read_line(char *buf, size_t size)
|
||||
{
|
||||
int ch;
|
||||
size_t length;
|
||||
|
||||
if (buf == NULL || size == 0)
|
||||
return 0;
|
||||
|
||||
for (size--, length = 0; length < size; ) {
|
||||
if ((ch = fgetc(stdin)) == EOF)
|
||||
break;
|
||||
if (ch == '\0')
|
||||
ch = ' ';
|
||||
buf[length++] = ch;
|
||||
if (ch == '\n')
|
||||
break;
|
||||
}
|
||||
|
||||
buf[length] = '\0';
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
/*
|
||||
* Count octets and strip comments. The stripped C input is sent to
|
||||
* standard output. If -s is set, then suppress the source output.
|
||||
* The various counters are sent to standard error.
|
||||
*
|
||||
* The counter output format is:
|
||||
*
|
||||
* lcount wcount bcount icount isaved rcount rsaved
|
||||
*
|
||||
* where
|
||||
* lcount line count (same as wc)
|
||||
* wcount word count (same as wc)
|
||||
* bcount byte count (same as wc)
|
||||
* icount IOCCC secondary size rule count
|
||||
* isaved bytes saved by secondary size rule (bcount - icount)
|
||||
* rcount number of C reserved words
|
||||
* rsaved number of octets saved with -r
|
||||
*/
|
||||
int
|
||||
count(int flags)
|
||||
{
|
||||
Word *w;
|
||||
int span;
|
||||
char *p, buf[BUFFER_SIZE+1];
|
||||
int lcount, wcount, bcount;
|
||||
int is_comment, is_word, dquote, escape;
|
||||
int count, keywords, saved, kw_saved;
|
||||
|
||||
/* Start of buffer sentinel. */
|
||||
buf[0] = ' ';
|
||||
buf[BUFFER_SIZE] = 0; /* paranoia */
|
||||
|
||||
count = saved = 0;
|
||||
keywords = kw_saved = 0;
|
||||
lcount = wcount = bcount = 0;
|
||||
is_comment = is_word = dquote = escape = 0;
|
||||
|
||||
/*
|
||||
* "no matter how well you may think you understand this code,
|
||||
* you don't, so don't mess with it." :-)
|
||||
*/
|
||||
while (0 < read_line(buf+1, sizeof (buf)-1)) {
|
||||
if (!(flags & FLAG_KEEP)) {
|
||||
/* Leading whitespace before comment block? */
|
||||
span = strspn(buf+1, "\t ");
|
||||
|
||||
/* Split / * across reads? */
|
||||
if (buf[1+span] == '/' && buf[2+span] == '\0') {
|
||||
(void) ungetc('/', stdin);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* no comment is a comment */
|
||||
if (buf[1+span] == '/' && buf[2+span] == '/')
|
||||
continue;
|
||||
if (buf[1+span] == '/' && buf[2+span] == '*') {
|
||||
/* Strip leading whitespace before comment block. */
|
||||
is_comment = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (p = buf+1; *p != '\0'; p++) {
|
||||
/* Within quoted string? */
|
||||
if (dquote) {
|
||||
/* Escape _this_ character. */
|
||||
if (escape)
|
||||
escape = 0;
|
||||
|
||||
/* Escape next character. */
|
||||
else if (*p == '\\')
|
||||
escape = 1;
|
||||
|
||||
/* Close quoted string? */
|
||||
else if (*p == '"')
|
||||
dquote = 0;
|
||||
}
|
||||
|
||||
/* Not quote string. */
|
||||
else {
|
||||
/* In C comment block? */
|
||||
if (is_comment) {
|
||||
/* Split * / across reads? */
|
||||
if (*p == '*' && p[1] == '\0') {
|
||||
ungetc('*', stdin);
|
||||
break;
|
||||
}
|
||||
|
||||
/* End of comment block? */
|
||||
if (*p == '*' && p[1] == '/') {
|
||||
is_comment = 0;
|
||||
|
||||
if (!(flags & FLAG_KEEP)) {
|
||||
/* Strip whitespace and newline
|
||||
* trailing closing comment.
|
||||
*/
|
||||
p += 1 + strspn(p+2, " \t\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (!(flags & FLAG_KEEP)) {
|
||||
/* Strip octets in comment block. */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* Split / / or / * across reads? */
|
||||
else if (*p == '/' && p[1] == '\0') {
|
||||
ungetc('/', stdin);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Start of comment line? */
|
||||
else if (*p == '/' && p[1] == '/') {
|
||||
if (!(flags & FLAG_KEEP)) {
|
||||
/* Strip comment to end of buffer. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Start of comment block? */
|
||||
else if (*p == '/' && p[1] == '*') {
|
||||
/* Begin comment block. */
|
||||
is_comment = 1;
|
||||
|
||||
if (!(flags & FLAG_KEEP)) {
|
||||
/* Strip comment block. */
|
||||
p++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* C reserved word? */
|
||||
else if (!isalnum(p[-1]) && p[-1] != '_'
|
||||
&& (w = find_member(cwords, p)) != NULL) {
|
||||
keywords++;
|
||||
if (flags & FLAG_RESERVED) {
|
||||
bcount += w->length;
|
||||
if (!is_word) {
|
||||
is_word = 1;
|
||||
wcount++;
|
||||
}
|
||||
|
||||
if (!(flags & FLAG_SILENCE))
|
||||
fputs(w->word, stdout);
|
||||
|
||||
/* Count reserved word as one. */
|
||||
kw_saved += w->length - 1;
|
||||
p += w->length - 1;
|
||||
count++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* Open quoted string? */
|
||||
else if (*p == '"') {
|
||||
dquote = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(flags & FLAG_SILENCE))
|
||||
fputc(*p, stdout);
|
||||
|
||||
bcount++;
|
||||
if (*p == '\n')
|
||||
lcount++;
|
||||
|
||||
/* Ignore all whitespace. */
|
||||
if (isspace(*p)) {
|
||||
is_word = 0;
|
||||
saved++;
|
||||
continue;
|
||||
} else if (!is_word) {
|
||||
is_word = 1;
|
||||
wcount++;
|
||||
}
|
||||
|
||||
/* Ignore curly braces and semicolons when followed
|
||||
* by any whitspace or EOF.
|
||||
*/
|
||||
if (strchr("{;}", *p) != NULL
|
||||
&& (isspace(p[1]) || p[1] == '\0')) {
|
||||
saved++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Count this octet. */
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
/* final count */
|
||||
if (flags & FLAG_IOCCC_SIZE) {
|
||||
/* output the official IOCCC size tool size to standard out */
|
||||
printf("%d\n", count);
|
||||
} else {
|
||||
/* The Ugly Truth */
|
||||
fprintf(stderr, "%d %d %d %d %d %d %d\n",
|
||||
lcount, wcount, bcount, count, saved,
|
||||
keywords, kw_saved);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int ch;
|
||||
int this = 0; /* "You are not expected to understand this" :-) */
|
||||
|
||||
/* parse args */
|
||||
while ((ch = getopt(argc, argv, "ikrs")) != -1) {
|
||||
switch (ch) {
|
||||
case 'i':
|
||||
this |= (FLAG_RESERVED | FLAG_SILENCE |
|
||||
FLAG_IOCCC_SIZE);
|
||||
break;
|
||||
case 'k':
|
||||
this |= FLAG_KEEP;
|
||||
break;
|
||||
case 'r':
|
||||
this |= FLAG_RESERVED;
|
||||
break;
|
||||
case 's':
|
||||
this |= FLAG_SILENCE;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s\n", usage);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* count as directed - 1 Muha .. 2 Muhaha .. 3 Muhahaha ... */
|
||||
(void) count(this);
|
||||
|
||||
/* All Done!!! All Done!!! -- Jessical Noll, age 2 */
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
.POSIX :
|
||||
|
||||
#######################################################################
|
||||
|
||||
CFLAGS := -pedantic -Wall -std=c99 -g
|
||||
LDFLAGS :=
|
||||
LIBS :=
|
||||
IT := iocccsize
|
||||
|
||||
#######################################################################
|
||||
|
||||
all: ${IT}$E
|
||||
|
||||
${IT}$E: ${IT}.c
|
||||
${CC} ${CFLAGS} -o ${IT}$E ${IT}.c
|
||||
|
||||
#
|
||||
# Exercise the IOCCC size tool.
|
||||
#
|
||||
test: test-k test-wc test-rcount
|
||||
|
||||
#
|
||||
# -k should pass through the source with block comments intact.
|
||||
#
|
||||
test-k: ${IT}$E
|
||||
@{ t="-k keep comments" ;\
|
||||
if ./${IT} -k <${IT}.c 2>/dev/null | diff - ${IT}.c ; then echo "-OK- $$t" ; else echo "FAIL $$t" ; fi ;\
|
||||
}
|
||||
|
||||
#
|
||||
# First 3 counters should match wc(1)
|
||||
#
|
||||
test-wc: ${IT}$E
|
||||
@{ t="wc counts" ;\
|
||||
a=$$(./${IT} -s -k <${IT}.c 2>&1 | cut -d' ' -f1-3) ;\
|
||||
b=$$(wc ${IT}.c | sed -e's/^ *//; s/ */ /g' | cut -d' ' -f1-3) ;\
|
||||
if [ "$$a" = "$$b" ]; then echo "-OK- $$t"; else echo "FAIL $$t: expected '$$b', got '$$a'"; fi ;\
|
||||
}
|
||||
|
||||
#
|
||||
# Show counters for different option combinations.
|
||||
#
|
||||
test-show: ${IT}$E
|
||||
./${IT} -s <${IT}.c
|
||||
./${IT} -s -r <${IT}.c
|
||||
./${IT} -s -k <${IT}.c
|
||||
./${IT} -s -r -k <${IT}.c
|
||||
|
||||
#
|
||||
# Reserved word counter should be same for all option combinations.
|
||||
#
|
||||
test-rcount: ${IT}$E
|
||||
@{ t="rcount" ;\
|
||||
./${IT} -s <${IT}.c 2>&1 | cut -d" " -f 6 >/tmp/$$$$.tmp ;\
|
||||
./${IT} -s -r <${IT}.c 2>&1 | cut -d" " -f 6 >>/tmp/$$$$.tmp ;\
|
||||
./${IT} -s -k <${IT}.c 2>&1 | cut -d" " -f 6 >>/tmp/$$$$.tmp ;\
|
||||
./${IT} -s -r -k <${IT}.c 2>&1 | cut -d" " -f 6 >>/tmp/$$$$.tmp ;\
|
||||
n=$$(sort -u /tmp/$$$$.tmp | wc -l | sed -e's/^ *//') ;\
|
||||
if [ $$n -eq 1 ]; then echo "-OK- $$t"; else echo "FAIL $$t: expected 1 unique line, got $$n"; echo "see make test-show"; fi ;\
|
||||
rm -f /tmp/$$$$.tmp ;\
|
||||
}
|
||||
|
||||
clean:
|
||||
rm -f iocccsize.o
|
||||
rm -rf iocccsize.dSYM
|
||||
|
||||
clobber: clean
|
||||
rm -f iocccsize
|
||||
|
||||
install:
|
||||
@echo "no thank you on the install :-)"
|
||||
@@ -0,0 +1,213 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2014 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
|
||||
|
||||
# Set SDL_LIBDIR to the directory where the SDL library resides
|
||||
#
|
||||
SDL_LIBDIR= $(shell sdl-config --libs)
|
||||
|
||||
# Set SDL_INCDIR to top level directory under where the SDL/SDL.h include file resides
|
||||
#
|
||||
SDL_INCDIR= $(shell sdl-config --cflags)
|
||||
|
||||
# Compiler warnings
|
||||
#
|
||||
#CWARN=
|
||||
CWARN= -Wall
|
||||
#CWARN= -Wall -pedantic
|
||||
|
||||
# compiler standard
|
||||
#
|
||||
#CSTD=
|
||||
#CSTD= -ansi
|
||||
CSTD= -std=c11
|
||||
|
||||
# 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= -lSDL
|
||||
|
||||
# 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= prog
|
||||
DATA=
|
||||
ALT_OBJ= prog.orig.o
|
||||
ALT_ENTRY= prog.orig
|
||||
|
||||
|
||||
#################
|
||||
# build the entry
|
||||
#################
|
||||
#
|
||||
all: ${ENTRY} ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
${ENTRY}: ${ENTRY}.c
|
||||
${CC} ${CFLAGS} ${SDL_INCDIR} ${SDL_LIBDIR} $< -o $@ ${LIBS}
|
||||
|
||||
# alternative executable
|
||||
#
|
||||
alt: ${ALT_ENTRY}
|
||||
@${TRUE}
|
||||
|
||||
${ALT_ENTRY}: ${ALT_ENTRY}.c
|
||||
${CC} ${CFLAGS} ${SDL_INCDIR} ${SDL_LIBDIR} $< -o $@ ${LIBS}
|
||||
|
||||
# data files
|
||||
#
|
||||
data: ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
${RM} -f ${ENTRY}.o ${ALT_OBJ}
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${ENTRY} ${ALT_ENTRY}
|
||||
|
||||
nuke: clobber
|
||||
@${TRUE}
|
||||
|
||||
dist_clean: nuke
|
||||
@${TRUE}
|
||||
|
||||
install:
|
||||
@echo "Surely we are joking Dr. Science!"
|
||||
@${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 sometimes mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Readers shall not be disallowed from failong 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_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 "You are holding it wrong!"; \
|
||||
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 Pauline!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
@@ -0,0 +1,162 @@
|
||||
0 276 46 2 0 0
|
||||
24 276 46 2 0 0
|
||||
48 276 46 2 0 0
|
||||
72 276 46 2 0 0
|
||||
96 276 46 2 0 0
|
||||
120 276 46 2 0 0
|
||||
144 276 46 2 0 0
|
||||
168 276 46 2 0 0
|
||||
192 276 46 2 0 0
|
||||
216 276 46 2 0 0
|
||||
240 276 46 2 0 0
|
||||
264 276 46 2 0 0
|
||||
288 276 46 2 0 0
|
||||
312 276 47 2 0 0
|
||||
|
||||
384 276 45 2 0 0
|
||||
408 276 46 2 0 0
|
||||
432 276 46 2 0 0
|
||||
456 276 46 2 0 0
|
||||
480 276 46 2 0 0
|
||||
504 276 47 2 0 0
|
||||
|
||||
456 252 27 2 0 0
|
||||
480 252 27 2 0 0
|
||||
504 252 27 2 0 0
|
||||
480 228 27 2 0 0
|
||||
504 228 27 2 0 0
|
||||
504 204 27 2 0 0
|
||||
|
||||
528 132 25 2 0 0
|
||||
552 132 25 2 0 0
|
||||
576 132 25 2 0 0
|
||||
600 132 25 2 0 0
|
||||
624 132 25 2 0 0
|
||||
648 132 25 2 0 0
|
||||
|
||||
576 200 39 64 0 0
|
||||
600 200 39 64 0 0
|
||||
624 200 39 64 0 0
|
||||
|
||||
576 224 39 64 0 0
|
||||
600 224 39 64 0 0
|
||||
624 224 39 64 0 0
|
||||
|
||||
672 132 27 2 0 0
|
||||
672 108 25 2 0 0
|
||||
|
||||
672 276 45 2 0 0
|
||||
696 276 46 2 0 0
|
||||
720 276 46 2 0 0
|
||||
744 276 46 2 0 0
|
||||
768 276 46 2 0 0
|
||||
792 276 46 2 0 0
|
||||
816 276 46 2 0 0
|
||||
840 276 46 2 0 0
|
||||
864 276 46 2 0 0
|
||||
888 276 46 2 0 0
|
||||
912 276 46 2 0 0
|
||||
936 276 46 2 0 0
|
||||
960 276 46 2 0 0
|
||||
984 276 46 2 0 0
|
||||
|
||||
792 180 25 2 0 0
|
||||
816 180 27 2 0 0
|
||||
816 156 25 2 0 0
|
||||
840 156 27 2 0 0
|
||||
840 132 25 2 0 0
|
||||
864 132 25 2 0 0
|
||||
888 132 25 2 0 0
|
||||
912 132 25 2 0 0
|
||||
936 132 25 2 0 0
|
||||
960 132 25 2 0 0
|
||||
984 132 25 2 0 0
|
||||
|
||||
936 84 33 0 0 0
|
||||
960 84 34 0 0 0
|
||||
984 84 35 0 0 0
|
||||
936 108 41 0 0 0
|
||||
960 108 42 0 0 0
|
||||
960 108 42 16 0 0
|
||||
984 108 43 0 0 0
|
||||
|
||||
696 252 30 2 0 0
|
||||
720 252 31 2 0 0
|
||||
696 228 30 2 0 0
|
||||
720 228 31 2 0 0
|
||||
|
||||
96 204 25 130 0 0
|
||||
120 204 26 4 8 19
|
||||
144 204 25 2 0 0
|
||||
168 204 26 4 64 39
|
||||
192 204 26 4 64 39
|
||||
216 204 25 2 0 0
|
||||
|
||||
24 60 28 0 0 0
|
||||
48 60 29 0 0 0
|
||||
|
||||
48 120 28 0 0 0
|
||||
72 120 29 0 0 0
|
||||
|
||||
140 90 28 0 0 0
|
||||
164 90 29 0 0 0
|
||||
|
||||
192 40 28 0 0 0
|
||||
216 40 29 0 0 0
|
||||
|
||||
384 120 28 0 0 0
|
||||
408 120 29 0 0 0
|
||||
|
||||
442 20 28 0 0 0
|
||||
466 20 29 0 0 0
|
||||
|
||||
744 90 28 0 0 0
|
||||
768 90 29 0 0 0
|
||||
|
||||
792 40 28 0 0 0
|
||||
816 40 29 0 0 0
|
||||
|
||||
192 132 26 4 64 39
|
||||
216 132 25 2 0 0
|
||||
240 132 25 2 0 0
|
||||
264 132 25 2 0 0
|
||||
|
||||
528 60 26 4 64 39
|
||||
552 60 26 4 64 39
|
||||
|
||||
332 84 25 2 0 0
|
||||
356 84 27 2 0 0
|
||||
356 60 25 2 0 0
|
||||
380 60 25 2 0 0
|
||||
404 60 25 2 0 0
|
||||
|
||||
356 0 39 64 0 0
|
||||
380 0 39 64 0 0
|
||||
404 0 39 64 0 0
|
||||
|
||||
48 252 22 0 0 0
|
||||
72 252 23 0 0 0
|
||||
|
||||
730 252 22 0 0 0
|
||||
754 252 23 0 0 0
|
||||
|
||||
144 252 20 0 0 0
|
||||
168 252 21 0 0 0
|
||||
|
||||
900 252 20 0 0 0
|
||||
924 252 21 0 0 0
|
||||
|
||||
384 252 20 0 0 0
|
||||
408 252 21 0 0 0
|
||||
|
||||
240 252 17 1 1 0
|
||||
|
||||
202 108 17 1 1 0
|
||||
|
||||
624 108 17 1 -1 0
|
||||
|
||||
800 252 17 1 1 0
|
||||
|
||||
16 252 0 0 0 0
|
||||
|
||||
-1 -1 -1 -1 -1 -1
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,329 @@
|
||||
<!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>Homage to a classic game</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Homage to a classic game</h1>
|
||||
|
||||
<p>Sandro Maffiodo<br>
|
||||
<a href="mailto:smaffer@gmail.com">smaffer@gmail.com</a><br>
|
||||
<a href="http://www.assezeta.com/sandromaffiodo">http://www.assezeta.com/sandromaffiodo</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>cat mario.level | ./prog 320 200 800 300 128 144 mario.rgba mario8.wav 10343679
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>cat giana.level | ./prog 320 200 1000 300 192 168 giana.rgba giana8.wav 5459393
|
||||
|
||||
cat mario.level | ./prog 320 200 800 300 128 144 mario.rgba mario8.wav 10343679 && telnet towel.blinkenlights.nl
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>A classic for a particular generation. Like all good programs, being data
|
||||
driven means you can do fun things in small spaces.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Remarks</h3>
|
||||
|
||||
<p>Use tabsize=4 to see the magic</p>
|
||||
|
||||
<pre><code>./expand -t 4 < prog.c
|
||||
</code></pre>
|
||||
|
||||
<p>The program returns 0 if the user win or <em>not-zero</em> if loose so you can test it and make something useful (or not), like that:</p>
|
||||
|
||||
<pre><code>cat mario.level | ./prog 320 200 800 300 128 144 mario.rgba mario8.wav 10343679 && telnet towel.blinkenlights.nl
|
||||
</code></pre>
|
||||
|
||||
<p>This is an engine for <strong>Platform Games</strong>. It can be used to create games like the legendary <a href="http://en.wikipedia.org/wiki/Super_Mario_Bros.">Super Mario Bros</a>.
|
||||
With this simple and clear sourcecode you can create all the games you want, for free!</p>
|
||||
|
||||
<p>In my two tests i tried to create one level of <a href="http://en.wikipedia.org/wiki/Super_Mario_Bros.">Super Mario Bros</a> and one of <a href="http://en.wikipedia.org/wiki/The_Great_Giana_Sisters">The Great Giana The Sisters</a>.
|
||||
Both games are classic <em>platform games</em> and both share the same fundamental rules:</p>
|
||||
|
||||
<ul>
|
||||
<li>there is a player</li>
|
||||
<li>there is a powerup that can change the look of the player and/or give to him/her more power!</li>
|
||||
<li>there are walls, floors and ceilings. the player can move and jump over these type of obstacles but cannot walk through them</li>
|
||||
<li>there are enemies and, if the player collides with an enemy, the player dies or loses its powers</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Regards running under Mac OS X</h3>
|
||||
|
||||
<p>The color of the sky is wrong on MacOS. You need to flip some bytes from the last parameter of the program:</p>
|
||||
|
||||
<pre><code>MARIO LAST PARAMETER: 4292124159
|
||||
|
||||
GIANA LAST PARAMETER: 3243070463
|
||||
</code></pre>
|
||||
|
||||
<h3>Regarding how to compile</h3>
|
||||
|
||||
<p>The code requires libSDL1.X.</p>
|
||||
|
||||
<p>The build process will generate some warnings (60~ on clang) about:</p>
|
||||
|
||||
<ul>
|
||||
<li><strong>incompatible pointer types</strong>: because all pointers are declared to <em>int</em> or <em>char</em>, to save tokens</li>
|
||||
<li><strong>type specifier missing, defaults to ‘int’</strong>: because i need to save tokens</li>
|
||||
<li><strong>using the result of an assignment as a condition without parentheses</strong>: because while(c=getchar()) is not evil</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>How it works</h3>
|
||||
|
||||
<h2>Parameters</h2>
|
||||
|
||||
<ol>
|
||||
<li>Window width</li>
|
||||
<li>Window height</li>
|
||||
<li>Level width</li>
|
||||
<li>Level height</li>
|
||||
<li>Sprites image width</li>
|
||||
<li>Sprites image height</li>
|
||||
<li>Filename of the sprites image (raw RGBA image)</li>
|
||||
<li>Filename of the music (WAVE 8000 Hz 8bit Mono)</li>
|
||||
<li>Sky color. This number depends on the system where you run the program. See <strong>NOTE on MacOS</strong></li>
|
||||
</ol>
|
||||
|
||||
|
||||
<h2>Sprites</h2>
|
||||
|
||||
<p>The program read a single image that contains all the game sprites. The image must be a grid of 8xN sprites. The size of a single sprite must be square. The program calculates the size in this way:</p>
|
||||
|
||||
<pre><code>sprite_size = image_width / 8
|
||||
</code></pre>
|
||||
|
||||
<p>Each sprite is identified by its position inside the grid, counting line by line, from left to right (for example sprite 0 is the top left sprite in the grid, sprite 8 is the first sprite of the second row of the grid).</p>
|
||||
|
||||
<p>Some positions of the grid have a predefined purpose:</p>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="left">Position </th>
|
||||
<th align="left"> Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="left">0 </td>
|
||||
<td align="left"> Player stand right</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">1 </td>
|
||||
<td align="left"> Player walk right frame 0</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">2 </td>
|
||||
<td align="left"> Player walk right frame 1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">3 </td>
|
||||
<td align="left"> Player jump right</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">4 </td>
|
||||
<td align="left"> Player stand left</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">5 </td>
|
||||
<td align="left"> Player walk left frame 0</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">6 </td>
|
||||
<td align="left"> Player walk left frame 1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">7 </td>
|
||||
<td align="left"> Player jump left</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">8 <em>(second row)</em> </td>
|
||||
<td align="left"> Super player stand right</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">9 </td>
|
||||
<td align="left"> Super player walk right frame 0</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">10 </td>
|
||||
<td align="left"> Super player walk right frame 1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">11 </td>
|
||||
<td align="left"> Super player jump right</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">12 </td>
|
||||
<td align="left"> Super player stand left</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">13 </td>
|
||||
<td align="left"> Super player walk left frame 0</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">14 </td>
|
||||
<td align="left"> Super player walk left frame 1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">15 </td>
|
||||
<td align="left"> Super player jump left</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">24 </td>
|
||||
<td align="left"> Player dead</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">32 </td>
|
||||
<td align="left"> Player win</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">40 </td>
|
||||
<td align="left"> Super player win</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<p>All the others sprites can be used as you want, depending on the game you want to create.</p>
|
||||
|
||||
<h2>Levels</h2>
|
||||
|
||||
<p>The program reads the level description from <strong>stdin</strong>.</p>
|
||||
|
||||
<p>The level description is a sequence of rows where each row describe an object. You can input as many objects as you want but the maximum number of objects handled by the program is 333. You can modify this value by editing the source here:</p>
|
||||
|
||||
<pre><code>C[333*7],d=333;
|
||||
</code></pre>
|
||||
|
||||
<p>Each row have six columns:</p>
|
||||
|
||||
<ol>
|
||||
<li>Screen X: x position of the object in the level</li>
|
||||
<li>Screen Y: y position of the object in the level</li>
|
||||
<li>Sprite: id of the sprite to be used for the object</li>
|
||||
<li>CLASSFLAGS: a bitmask that describe how the object behaves</li>
|
||||
<li>CLASSPARAM0: a parameter that depends on CLASSFLAGS</li>
|
||||
<li>CLASSPARAM1: a parameter that depends on CLASSFLAGS</li>
|
||||
</ol>
|
||||
|
||||
|
||||
<p>CLASSFLAGS must be a combination (bitwise or) of some of these constants:</p>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="left">NAME </th>
|
||||
<th align="left"> CONSTANT </th>
|
||||
<th align="left"> CLASS</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="left">ENEMY </td>
|
||||
<td align="left"> 1 </td>
|
||||
<td align="left"> An enemy. CLASSPARAM0 can be 0 if the enemy don’t move, 1 if the initial move direction is right, -1 if direction is left. All enemies that walk will change its direction after 20 pixels. The sprite of an enemy must have 2 others adjacent sprites: SPRITE-1, used when the enemy die, and SPRITE+1, used when it walks</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">BLOCK </td>
|
||||
<td align="left"> 2 </td>
|
||||
<td align="left"> A wall. Player can walk over the object but can not pass through it</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">GIFT BLOCK </td>
|
||||
<td align="left"> 4 </td>
|
||||
<td align="left"> When the player hits the object from below, a new object is created. CLASSFLAGS of the new object is defined in CLASSPARAM0. The sprite used for the new object is defined in CLASSPARAM1. The sprite of the gift object must have an adjacent sprite: SPRITE+1, used when the block is hit</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">POWERUP </td>
|
||||
<td align="left"> 8 </td>
|
||||
<td align="left"> This is the classic Mario’s mushroom. When the player hit the powerup object, the player become <em>Super player</em>. If CLASSFLAGS has the bit ZOOM, the player height will be doubled.<br>The <em>Super player</em> can hit the enemies without die, but when this happens, the <em>Super player</em> goes back to being normal</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">END </td>
|
||||
<td align="left"> 16 </td>
|
||||
<td align="left"> When the player hits this object the level ends. Player win</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">ZOOM </td>
|
||||
<td align="left"> 32 </td>
|
||||
<td align="left"> This flag can be used with POWERUP to indicate a powerup that will doubles the size of the player (like Mario’s mushroom)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">DESTROY </td>
|
||||
<td align="left"> 64 </td>
|
||||
<td align="left"> When the player hits the object the object disappear. This is the classic Mario’s coin, but the engine does not counts the points, so, from the user point of view, this object is useless</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">DESTROYUP </td>
|
||||
<td align="left"> 128 </td>
|
||||
<td align="left"> This object is like a BLOCK but when the player hits the object from below, the object disappear</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<p>If CLASSFLAGS is zero the object has only an aesthetic function.</p>
|
||||
|
||||
<p>The last row of the level descriptor must have all its columns set equal to -1.</p>
|
||||
|
||||
<h3>Limitations</h3>
|
||||
|
||||
<p>Some classical features are missing: throw objects, shoot, multiple lives, points counter. You can add those features if you want!</p>
|
||||
|
||||
<p>The program allow to run one level only. It’s easy to add a menu and multiple levels but the size of the engine will grow too much.</p>
|
||||
|
||||
<p>When the <em>Super player</em> become bigger (ZOOM flag), the player can collide with blocks and get stuck inside them. This is a KNOWN BUG. When your player become bigger, stay away from blocks!</p>
|
||||
|
||||
<p>There is one audio track only (game effects are missing).</p>
|
||||
|
||||
<h3>Credits</h3>
|
||||
|
||||
<p>Some of the sprites used in the examples are identical to those of the original games, others were designed by me.</p>
|
||||
|
||||
<p>The music used in the examples have been resampled, starting from the original versions for the <a href="http://en.wikipedia.org/wiki/Amiga">Commodore Amiga</a> and <a href="http://en.wikipedia.org/wiki/Nintendo_Entertainment_System">Nintendo NES</a>.</p>
|
||||
|
||||
<p><a href="http://en.wikipedia.org/wiki/Super_Mario_Bros.">Super Mario Bros</a> is a game created by Nintendo Entertainment, my use of the sprites does not intend to infringe the intellectual property of Nintendo but only demonstrate the operation of the program. From my point of view this is a tribute to the legendary game <a href="http://en.wikipedia.org/wiki/Super_Mario_Bros.">Super Mario Bros</a>!</p>
|
||||
|
||||
<p><a href="http://en.wikipedia.org/wiki/The_Great_Giana_Sisters">The Great Giana The Sisters</a> is the game created by Time Warp Productions and also for this game worth my previous notes. Long live <a href="http://en.wikipedia.org/wiki/The_Great_Giana_Sisters">The Great Giana The Sisters</a> !! :)</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,177 @@
|
||||
# Homage to a classic game
|
||||
|
||||
Sandro Maffiodo
|
||||
<smaffer@gmail.com>
|
||||
<http://www.assezeta.com/sandromaffiodo>
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
### To build:
|
||||
|
||||
make
|
||||
|
||||
### To run:
|
||||
|
||||
cat mario.level | ./prog 320 200 800 300 128 144 mario.rgba mario8.wav 10343679
|
||||
|
||||
### Try:
|
||||
|
||||
cat giana.level | ./prog 320 200 1000 300 192 168 giana.rgba giana8.wav 5459393
|
||||
|
||||
cat mario.level | ./prog 320 200 800 300 128 144 mario.rgba mario8.wav 10343679 && telnet towel.blinkenlights.nl
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
A classic for a particular generation. Like all good programs, being data
|
||||
driven means you can do fun things in small spaces.
|
||||
|
||||
## Author's comments:
|
||||
### Remarks
|
||||
|
||||
Use tabsize=4 to see the magic
|
||||
|
||||
./expand -t 4 < prog.c
|
||||
|
||||
The program returns 0 if the user win or *not-zero* if loose so you can test it and make something useful (or not), like that:
|
||||
|
||||
cat mario.level | ./prog 320 200 800 300 128 144 mario.rgba mario8.wav 10343679 && telnet towel.blinkenlights.nl
|
||||
|
||||
This is an engine for **Platform Games**. It can be used to create games like the legendary [Super Mario Bros](http://en.wikipedia.org/wiki/Super_Mario_Bros.).
|
||||
With this simple and clear sourcecode you can create all the games you want, for free!
|
||||
|
||||
In my two tests i tried to create one level of [Super Mario Bros](http://en.wikipedia.org/wiki/Super_Mario_Bros.) and one of [The Great Giana The Sisters](http://en.wikipedia.org/wiki/The_Great_Giana_Sisters).
|
||||
Both games are classic *platform games* and both share the same fundamental rules:
|
||||
|
||||
- there is a player
|
||||
- there is a powerup that can change the look of the player and/or give to him/her more power!
|
||||
- there are walls, floors and ceilings. the player can move and jump over these type of obstacles but cannot walk through them
|
||||
- there are enemies and, if the player collides with an enemy, the player dies or loses its powers
|
||||
|
||||
### Regards running under Mac OS X
|
||||
|
||||
The color of the sky is wrong on MacOS. You need to flip some bytes from the last parameter of the program:
|
||||
|
||||
MARIO LAST PARAMETER: 4292124159
|
||||
|
||||
GIANA LAST PARAMETER: 3243070463
|
||||
|
||||
### Regarding how to compile
|
||||
|
||||
The code requires libSDL1.X.
|
||||
|
||||
The build process will generate some warnings (60~ on clang) about:
|
||||
|
||||
- **incompatible pointer types**: because all pointers are declared to *int* or *char*, to save tokens
|
||||
- **type specifier missing, defaults to 'int'**: because i need to save tokens
|
||||
- **using the result of an assignment as a condition without parentheses**: because while(c=getchar()) is not evil
|
||||
|
||||
### How it works
|
||||
|
||||
## Parameters
|
||||
|
||||
1. Window width
|
||||
2. Window height
|
||||
3. Level width
|
||||
4. Level height
|
||||
5. Sprites image width
|
||||
6. Sprites image height
|
||||
7. Filename of the sprites image (raw RGBA image)
|
||||
8. Filename of the music (WAVE 8000 Hz 8bit Mono)
|
||||
9. Sky color. This number depends on the system where you run the program. See **NOTE on MacOS**
|
||||
|
||||
## Sprites
|
||||
|
||||
The program read a single image that contains all the game sprites. The image must be a grid of 8xN sprites. The size of a single sprite must be square. The program calculates the size in this way:
|
||||
|
||||
sprite_size = image_width / 8
|
||||
|
||||
Each sprite is identified by its position inside the grid, counting line by line, from left to right (for example sprite 0 is the top left sprite in the grid, sprite 8 is the first sprite of the second row of the grid).
|
||||
|
||||
Some positions of the grid have a predefined purpose:
|
||||
|
||||
Position | Description
|
||||
:-----------------|:--------------
|
||||
0 | Player stand right
|
||||
1 | Player walk right frame 0
|
||||
2 | Player walk right frame 1
|
||||
3 | Player jump right
|
||||
4 | Player stand left
|
||||
5 | Player walk left frame 0
|
||||
6 | Player walk left frame 1
|
||||
7 | Player jump left
|
||||
8 *(second row)* | Super player stand right
|
||||
9 | Super player walk right frame 0
|
||||
10 | Super player walk right frame 1
|
||||
11 | Super player jump right
|
||||
12 | Super player stand left
|
||||
13 | Super player walk left frame 0
|
||||
14 | Super player walk left frame 1
|
||||
15 | Super player jump left
|
||||
24 | Player dead
|
||||
32 | Player win
|
||||
40 | Super player win
|
||||
|
||||
All the others sprites can be used as you want, depending on the game you want to create.
|
||||
|
||||
## Levels
|
||||
|
||||
The program reads the level description from **stdin**.
|
||||
|
||||
The level description is a sequence of rows where each row describe an object. You can input as many objects as you want but the maximum number of objects handled by the program is 333. You can modify this value by editing the source here:
|
||||
|
||||
C[333*7],d=333;
|
||||
|
||||
Each row have six columns:
|
||||
|
||||
1. Screen X: x position of the object in the level
|
||||
2. Screen Y: y position of the object in the level
|
||||
3. Sprite: id of the sprite to be used for the object
|
||||
4. CLASSFLAGS: a bitmask that describe how the object behaves
|
||||
5. CLASSPARAM0: a parameter that depends on CLASSFLAGS
|
||||
6. CLASSPARAM1: a parameter that depends on CLASSFLAGS
|
||||
|
||||
CLASSFLAGS must be a combination (bitwise or) of some of these constants:
|
||||
|
||||
NAME | CONSTANT | CLASS
|
||||
:----------|:----------|:---------
|
||||
ENEMY | 1 | An enemy. CLASSPARAM0 can be 0 if the enemy don't move, 1 if the initial move direction is right, -1 if direction is left. All enemies that walk will change its direction after 20 pixels. The sprite of an enemy must have 2 others adjacent sprites: SPRITE-1, used when the enemy die, and SPRITE+1, used when it walks
|
||||
BLOCK | 2 | A wall. Player can walk over the object but can not pass through it
|
||||
GIFT BLOCK | 4 | When the player hits the object from below, a new object is created. CLASSFLAGS of the new object is defined in CLASSPARAM0. The sprite used for the new object is defined in CLASSPARAM1. The sprite of the gift object must have an adjacent sprite: SPRITE+1, used when the block is hit
|
||||
POWERUP | 8 | This is the classic Mario's mushroom. When the player hit the powerup object, the player become *Super player*. If CLASSFLAGS has the bit ZOOM, the player height will be doubled.<br>The *Super player* can hit the enemies without die, but when this happens, the *Super player* goes back to being normal
|
||||
END | 16 | When the player hits this object the level ends. Player win
|
||||
ZOOM | 32 | This flag can be used with POWERUP to indicate a powerup that will doubles the size of the player (like Mario's mushroom)
|
||||
DESTROY | 64 | When the player hits the object the object disappear. This is the classic Mario's coin, but the engine does not counts the points, so, from the user point of view, this object is useless
|
||||
DESTROYUP | 128 | This object is like a BLOCK but when the player hits the object from below, the object disappear
|
||||
|
||||
If CLASSFLAGS is zero the object has only an aesthetic function.
|
||||
|
||||
The last row of the level descriptor must have all its columns set equal to -1.
|
||||
|
||||
### Limitations
|
||||
|
||||
Some classical features are missing: throw objects, shoot, multiple lives, points counter. You can add those features if you want!
|
||||
|
||||
The program allow to run one level only. It's easy to add a menu and multiple levels but the size of the engine will grow too much.
|
||||
|
||||
When the *Super player* become bigger (ZOOM flag), the player can collide with blocks and get stuck inside them. This is a KNOWN BUG. When your player become bigger, stay away from blocks!
|
||||
|
||||
There is one audio track only (game effects are missing).
|
||||
|
||||
### Credits
|
||||
|
||||
Some of the sprites used in the examples are identical to those of the original games, others were designed by me.
|
||||
|
||||
The music used in the examples have been resampled, starting from the original versions for the [Commodore Amiga](http://en.wikipedia.org/wiki/Amiga) and [Nintendo NES](http://en.wikipedia.org/wiki/Nintendo_Entertainment_System).
|
||||
|
||||
[Super Mario Bros](http://en.wikipedia.org/wiki/Super_Mario_Bros.) is a game created by Nintendo Entertainment, my use of the sprites does not intend to infringe the intellectual property of Nintendo but only demonstrate the operation of the program. From my point of view this is a tribute to the legendary game [Super Mario Bros](http://en.wikipedia.org/wiki/Super_Mario_Bros.)!
|
||||
|
||||
[The Great Giana The Sisters](http://en.wikipedia.org/wiki/The_Great_Giana_Sisters) is the game created by Time Warp Productions and also for this game worth my previous notes. Long live [The Great Giana The Sisters](http://en.wikipedia.org/wiki/The_Great_Giana_Sisters) !! :)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(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/
|
||||
-->
|
||||
@@ -0,0 +1,205 @@
|
||||
0 284 34 2 0 0
|
||||
16 284 34 2 0 0
|
||||
32 284 34 2 0 0
|
||||
48 284 34 2 0 0
|
||||
64 284 34 2 0 0
|
||||
80 284 34 2 0 0
|
||||
96 284 34 2 0 0
|
||||
112 284 34 2 0 0
|
||||
128 284 34 2 0 0
|
||||
144 284 34 2 0 0
|
||||
160 284 34 2 0 0
|
||||
176 284 34 2 0 0
|
||||
192 284 34 2 0 0
|
||||
208 284 34 2 0 0
|
||||
224 284 34 2 0 0
|
||||
240 284 34 2 0 0
|
||||
256 284 34 2 0 0
|
||||
272 284 35 2 0 0
|
||||
|
||||
112 268 30 1 1 0
|
||||
|
||||
320 284 41 2 0 0
|
||||
|
||||
352 284 41 2 0 0
|
||||
|
||||
400 284 33 2 0 0
|
||||
416 284 34 2 0 0
|
||||
432 284 34 2 0 0
|
||||
448 284 34 2 0 0
|
||||
464 284 34 2 0 0
|
||||
480 284 34 2 0 0
|
||||
496 284 34 2 0 0
|
||||
512 284 34 2 0 0
|
||||
528 284 34 2 0 0
|
||||
544 284 34 2 0 0
|
||||
560 284 34 2 0 0
|
||||
576 284 34 2 0 0
|
||||
592 284 35 2 0 0
|
||||
|
||||
624 148 49 2 0 0
|
||||
624 164 49 2 0 0
|
||||
624 180 49 2 0 0
|
||||
640 180 49 2 0 0
|
||||
624 196 49 2 0 0
|
||||
640 196 49 2 0 0
|
||||
656 196 49 2 0 0
|
||||
624 212 50 2 0 0
|
||||
640 212 50 2 0 0
|
||||
656 212 50 2 0 0
|
||||
|
||||
672 284 53 2 0 0
|
||||
688 284 53 2 0 0
|
||||
704 284 53 2 0 0
|
||||
720 284 53 2 0 0
|
||||
736 284 53 2 0 0
|
||||
752 284 53 2 0 0
|
||||
768 284 53 2 0 0
|
||||
784 284 53 2 0 0
|
||||
|
||||
32 148 64 0 0 0
|
||||
48 148 66 0 0 0
|
||||
|
||||
80 92 64 0 0 0
|
||||
96 92 66 0 0 0
|
||||
|
||||
112 132 64 0 0 0
|
||||
128 132 65 0 0 0
|
||||
144 132 66 0 0 0
|
||||
|
||||
176 92 64 0 0 0
|
||||
192 92 65 0 0 0
|
||||
208 92 66 0 0 0
|
||||
|
||||
224 152 64 0 0 0
|
||||
240 152 66 0 0 0
|
||||
|
||||
240 32 64 0 0 0
|
||||
256 32 66 0 0 0
|
||||
|
||||
320 92 64 0 0 0
|
||||
336 92 66 0 0 0
|
||||
|
||||
384 108 64 0 0 0
|
||||
400 108 65 0 0 0
|
||||
416 108 66 0 0 0
|
||||
|
||||
416 32 64 0 0 0
|
||||
432 32 66 0 0 0
|
||||
|
||||
288 196 25 2 0 0
|
||||
304 196 25 2 0 0
|
||||
320 196 25 130 0 0
|
||||
336 196 25 2 0 0
|
||||
352 196 25 2 0 0
|
||||
|
||||
350 180 30 1 -1 0
|
||||
|
||||
512 66 51 2 0 0
|
||||
528 66 52 2 0 0
|
||||
544 66 50 2 0 0
|
||||
560 66 51 2 0 0
|
||||
576 66 52 2 0 0
|
||||
592 66 50 2 0 0
|
||||
|
||||
544 50 38 1 1 0
|
||||
|
||||
576 106 64 0 0 0
|
||||
592 106 66 0 0 0
|
||||
|
||||
522 156 43 2 0 0
|
||||
538 156 44 2 0 0
|
||||
|
||||
448 196 25 2 0 0
|
||||
464 196 25 2 0 0
|
||||
480 196 25 2 0 0
|
||||
|
||||
400 156 43 2 0 0
|
||||
416 156 44 2 0 0
|
||||
|
||||
452 108 43 2 0 0
|
||||
468 108 44 2 0 0
|
||||
|
||||
192 228 25 130 0 0
|
||||
208 228 26 4 64 36
|
||||
224 228 25 2 0 0
|
||||
240 228 26 4 40 28
|
||||
|
||||
304 140 27 2 0 0
|
||||
320 140 26 4 64 36
|
||||
336 140 27 2 0 0
|
||||
|
||||
0 268 69 0 0 0
|
||||
16 268 70 0 0 0
|
||||
32 268 71 0 0 0
|
||||
|
||||
176 268 69 0 0 0
|
||||
192 268 71 0 0 0
|
||||
|
||||
432 268 69 0 0 0
|
||||
448 268 70 0 0 0
|
||||
464 268 71 0 0 0
|
||||
|
||||
64 228 26 4 64 36
|
||||
80 228 25 2 0 0
|
||||
96 228 25 2 0 0
|
||||
|
||||
512 268 54 2 0 0
|
||||
528 268 55 2 0 0
|
||||
512 252 46 2 0 0
|
||||
528 252 47 2 0 0
|
||||
|
||||
400 228 26 4 40 28
|
||||
|
||||
464 268 38 1 -1 0
|
||||
|
||||
512 268 54 2 0 0
|
||||
528 268 55 2 0 0
|
||||
512 252 46 2 0 0
|
||||
528 252 47 2 0 0
|
||||
|
||||
640 16 64 0 0 0
|
||||
656 16 65 0 0 0
|
||||
672 16 66 0 0 0
|
||||
|
||||
672 106 50 2 0 0
|
||||
688 106 51 2 0 0
|
||||
704 106 52 2 0 0
|
||||
720 106 50 2 0 0
|
||||
736 106 51 2 0 0
|
||||
752 106 52 2 0 0
|
||||
768 106 50 2 0 0
|
||||
784 106 50 2 0 0
|
||||
|
||||
778 90 38 1 -1 0
|
||||
680 90 38 1 1 0
|
||||
|
||||
720 50 26 4 64 36
|
||||
736 50 27 2 0 0
|
||||
752 50 26 4 64 36
|
||||
|
||||
704 268 25 0 0 0
|
||||
720 268 25 0 0 0
|
||||
736 268 68 0 0 0
|
||||
736 268 68 16 0 0
|
||||
752 268 25 0 0 0
|
||||
768 268 25 0 0 0
|
||||
704 252 25 0 0 0
|
||||
720 252 25 0 0 0
|
||||
736 252 67 0 0 0
|
||||
752 252 25 0 0 0
|
||||
768 252 25 0 0 0
|
||||
704 236 45 0 0 0
|
||||
720 236 45 0 0 0
|
||||
736 236 45 0 0 0
|
||||
752 236 45 0 0 0
|
||||
768 236 45 0 0 0
|
||||
700 220 56 0 0 0
|
||||
720 220 56 0 0 0
|
||||
736 220 56 0 0 0
|
||||
752 220 56 0 0 0
|
||||
771 220 56 0 0 0
|
||||
|
||||
16 268 0 0 0 0
|
||||
|
||||
-1 -1 -1 -1 -1 -1
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,72 @@
|
||||
#include /*!!TAB=4!*/<stdio.h>
|
||||
#include /*{{IOCCC2}}*/<SDL.h>
|
||||
#define b/*{{IOCCC257}}*/ if (
|
||||
#define a(b, c) for (b = 0 ; /*IOCCC/2014*/b<d; b++,c)
|
||||
e,h,f,g,i,j,k,l,m,n,o,p=1,*q,r,s=5, t,*u,x,y,z,A,B, C[
|
||||
333*7],d=333; D,E,F,G [2 ],H, I, J, K, L, M,N= 1,O,P,Q
|
||||
,*R;char * S, **T; /*33*/ ;
|
||||
SDL_Surface*U,* V; int*W( X
|
||||
){ u=C+X *7; b*u){ u++; x =u[0]; y=u[1
|
||||
]; H=u [2]; z =(H%8) *
|
||||
i; A=( H/8)*i ; B=u[ 3
|
||||
]/**/; return u; ; } return
|
||||
0; } Y (){ O=50; r= 0; t=1 ;
|
||||
} Z (X ,m, n,o)/**/ { /**/ ;
|
||||
return W(X)&&B&&(m< x+i&&n <
|
||||
y+i&&x<m+i&& y<n+o); } int*ba(int*u){ int X
|
||||
,*bb=C; a(X, bb+=7){ b!*bb){ *bb=1; R
|
||||
=bb +1; H=6; while(H--)*R++=*u++; /*W
|
||||
N N
|
||||
E E
|
||||
S S
|
||||
*/return bb; } } return 0; } bc(e){ q[2]=e; } bd
|
||||
(be,bf){ int X,bg; m+=be; n+=bf; I=e
|
||||
-i; m=m<0?0:(m>I?I:m); a(X,0){ b Z(X
|
||||
,m,n,o)){ bg=B&1; b D&&bg) continue;
|
||||
m-=be; n-=bf; b B&8){ u[-1]=0; j=1; bc(8); b B&32){ n-= i;
|
||||
o=i*2; } } b B&16&&!O){ bc(32+(o>i?8:0)); Y(); u[- 1]=0; }
|
||||
b(B&128&&bf&&s<0)||(B&64))u[-1]=0; b bg&&!O){ b bf&&s >0){
|
||||
u[2]--; u[3]=bf=0; s=-6; } else { b j){ bc(0); b o>i) n+=o=i; D=30; j=0;
|
||||
} else { bc(24); Y(); L=-1; } } } b B&4){ b bf&&s<0){ int I[]={ x,y-i,u[
|
||||
5],u[4],rand()%2?1:-1,2} ; u[2]++; u[3]=2; ba(I); } } b bf)s=1; break; }
|
||||
} } bh (m,e,k, bi){ H=k/ 2; G[bi]=m>e-H? k
|
||||
- e:(m>H?H-m:0 ); } bj(X,be ,bf){ int bk ;
|
||||
u [0]+=be; u[1 ]+=bf; W(X); E=x,F=y,I=0; a
|
||||
( bk,0){ b I=(X!=bk&&Z(bk,E,F,i)&&(B&6 )
|
||||
) )break; } W(X); b I){ b bf)u[1]-=bf; b
|
||||
be ){ u[0]-=be; u[4]*=-1*be; } } W( X); }
|
||||
bl (){ int bm=n,X; SDL_FillRect(U,0,M); X=4; while( X
|
||||
-- )bd(r,0); X=3; while(X--)bd(0,s); b n>h&&!O)Y () ;
|
||||
t =bm==n; q[0]=m; q[1]=n; bh(m,e,k,0); bh(n,h,l,1) ;
|
||||
a(X,0){ b W(X)){ b B&9){ bj(X,u[4],0); bj(X,0,2); } b B&1){ *u +=u[4]; b
|
||||
++u[5]>20){ u[4]*= -1; u[5]=0; } z+=K
|
||||
%2?i:0; } J=i; b q ==u){ J=o; b!O){ b
|
||||
r)z+=i*(K%2); b!t) z=48; z+=p<0?i*4:0
|
||||
; }} b q!=u||!(D&& 0==D%3)){ SDL_Rect
|
||||
bn={ z,A,i,J} ,bo= { G[0]+x,G[1]+y,i,
|
||||
J}; SDL_BlitSurface (V,&bn,U,&bo); } }
|
||||
} b(s+=2)>2)s=2; K ++; D-=D?1:0; b O)
|
||||
b!-- O) exit(L); } bp(X){ return strtol
|
||||
(T[X],0,0); } bq(int H , int*br,int bs ){ int bt;
|
||||
bt=Q-P; b bt>bs) bt= bs; SDL_MixAudio(br,S +P,bt,
|
||||
128); P+=bt; b P>=Q)P=0; } SDL_AudioSpec bu={8000
|
||||
,8,1,0,256,0,0,bq} ,bv ; main(int bw,char**bx){ T
|
||||
|
||||
|
||||
=bx; int by,H=255, bz=H<<8 ,bA =bz <<8,bB= bA<<8,
|
||||
bC=bp(5),bD=bp(6); SDL_Event bE; o =i= bC / 8; k = bp(1)
|
||||
,l=bp(2),e=bp(3),h =bp (4); M= bp(9); /**/ SDL_Init(/*<2053"*/
|
||||
0xffff ); b!*(char*) &N){ H=bB; bz =bA; bA =bz>>8;
|
||||
bB=255 ; } U=SDL_SetVideoMode(k,l,0,0); V=/*NES HISTORY
|
||||
SANDRO */ SDL_CreateRGBSurface(1 <<15 , bC, bD, 32,H,bz
|
||||
,bA,bB); fread(V-> pixels,bC*bD*4,1,fopen(T [7],"r" )); SDL_OpenAudio(&
|
||||
bu,0); SDL_LoadWAV (T[8],& bv,&S,&Q ); /**/ SDL_PauseAudio(0);
|
||||
for(; ; ){ int u[6 ],*I; H =0 ; while (H < 6) scanf(/*0*/
|
||||
"%d ", u+H++); b u[5]< 0)break ; I=ba(
|
||||
u);b!u [3]){ q =I+1; m =u[0 ]; n=u[1];
|
||||
} } for (; ; ){ while/* !MAFFIO DO.S*/(
|
||||
SDL_PollEvent(&bE) ) { by= bE.type ==3; b!O &&(by|| bE.
|
||||
type==2)){ I = bE. key/**/ .keysym .sym; b I== 276)r=
|
||||
by?0:(p=-1); b I== 275 )r= by?0:(p =1); b I==32)by?
|
||||
|
||||
0:(t?(s=-9):0); b I==27)exit(0); } } bl(); SDL_Flip(U); SDL_Delay(60); } }
|
||||
@@ -0,0 +1,72 @@
|
||||
#include /*!!TAB=4!*/<stdio.h>
|
||||
#include /*IOCCC2*/"SDL/SDL.h"
|
||||
#define b/*{{IOCCC257}}*/ if (
|
||||
#define a(b, c) for (b = 0 ; /*IOCCC/2014*/b<d; b++,c)
|
||||
e,h,f,g,i,j,k,l,m,n,o,p=1,*q,r,s=5, t,*u,x,y,z,A,B, C[
|
||||
333*7],d=333; D,E,F,G [2 ],H, I, J, K, L, M,N= 1,O,P,Q
|
||||
,*R;char * S, **T; /*33*/ ;
|
||||
SDL_Surface*U,* V; int*W( X
|
||||
){ u=C+X *7; b*u){ u++; x =u[0]; y=u[1
|
||||
]; H=u [2]; z =(H%8) *
|
||||
i; A=( H/8)*i ; B=u[ 3
|
||||
]/**/; return u; ; } return
|
||||
0; } Y (){ O=50; r= 0; t=1 ;
|
||||
} Z (X ,m, n,o)/**/ { /**/ ;
|
||||
return W(X)&&B&&(m< x+i&&n <
|
||||
y+i&&x<m+i&& y<n+o); } int*ba(int*u){ int X
|
||||
,*bb=C; a(X, bb+=7){ b!*bb){ *bb=1; R
|
||||
=bb +1; H=6; while(H--)*R++=*u++; /*W
|
||||
N N
|
||||
E E
|
||||
S S
|
||||
*/return bb; } } return 0; } bc(e){ q[2]=e; } bd
|
||||
(be,bf){ int X,bg; m+=be; n+=bf; I=e
|
||||
-i; m=m<0?0:(m>I?I:m); a(X,0){ b Z(X
|
||||
,m,n,o)){ bg=B&1; b D&&bg) continue;
|
||||
m-=be; n-=bf; b B&8){ u[-1]=0; j=1; bc(8); b B&32){ n-= i;
|
||||
o=i*2; } } b B&16&&!O){ bc(32+(o>i?8:0)); Y(); u[- 1]=0; }
|
||||
b(B&128&&bf&&s<0)||(B&64))u[-1]=0; b bg&&!O){ b bf&&s >0){
|
||||
u[2]--; u[3]=bf=0; s=-6; } else { b j){ bc(0); b o>i) n+=o=i; D=30; j=0;
|
||||
} else { bc(24); Y(); L=-1; } } } b B&4){ b bf&&s<0){ int I[]={ x,y-i,u[
|
||||
5],u[4],rand()%2?1:-1,2} ; u[2]++; u[3]=2; ba(I); } } b bf)s=1; break; }
|
||||
} } bh (m,e,k, bi){ H=k/ 2; G[bi]=m>e-H? k
|
||||
- e:(m>H?H-m:0 ); } bj(X,be ,bf){ int bk ;
|
||||
u [0]+=be; u[1 ]+=bf; W(X); E=x,F=y,I=0; a
|
||||
( bk,0){ b I=(X!=bk&&Z(bk,E,F,i)&&(B&6 )
|
||||
) )break; } W(X); b I){ b bf)u[1]-=bf; b
|
||||
be ){ u[0]-=be; u[4]*=-1*be; } } W( X); }
|
||||
bl (){ int bm=n,X; SDL_FillRect(U,0,M); X=4; while( X
|
||||
-- )bd(r,0); X=3; while(X--)bd(0,s); b n>h&&!O)Y () ;
|
||||
t =bm==n; q[0]=m; q[1]=n; bh(m,e,k,0); bh(n,h,l,1) ;
|
||||
a(X,0){ b W(X)){ b B&9){ bj(X,u[4],0); bj(X,0,2); } b B&1){ *u +=u[4]; b
|
||||
++u[5]>20){ u[4]*= -1; u[5]=0; } z+=K
|
||||
%2?i:0; } J=i; b q ==u){ J=o; b!O){ b
|
||||
r)z+=i*(K%2); b!t) z=48; z+=p<0?i*4:0
|
||||
; }} b q!=u||!(D&& 0==D%3)){ SDL_Rect
|
||||
bn={ z,A,i,J} ,bo= { G[0]+x,G[1]+y,i,
|
||||
J}; SDL_BlitSurface (V,&bn,U,&bo); } }
|
||||
} b(s+=2)>2)s=2; K ++; D-=D?1:0; b O)
|
||||
b!-- O) exit(L); } bp(X){ return strtol
|
||||
(T[X],0,0); } bq(int H , int*br,int bs ){ int bt;
|
||||
bt=Q-P; b bt>bs) bt= bs; SDL_MixAudio(br,S +P,bt,
|
||||
128); P+=bt; b P>=Q)P=0; } SDL_AudioSpec bu={8000
|
||||
,8,1,0,256,0,0,bq} ,bv ; main(int bw,char**bx){ T
|
||||
|
||||
|
||||
=bx; int by,H=255, bz=H<<8 ,bA =bz <<8,bB= bA<<8,
|
||||
bC=bp(5),bD=bp(6); SDL_Event bE; o =i= bC / 8; k = bp(1)
|
||||
,l=bp(2),e=bp(3),h =bp (4); M= bp(9); /**/ SDL_Init(/*<2053"*/
|
||||
0xffff ); b!*(char*) &N){ H=bB; bz =bA; bA =bz>>8;
|
||||
bB=255 ; } U=SDL_SetVideoMode(k,l,0,0); V=/*NES HISTORY
|
||||
SANDRO */ SDL_CreateRGBSurface(1 <<15 , bC, bD, 32,H,bz
|
||||
,bA,bB); fread(V-> pixels,bC*bD*4,1,fopen(T [7],"r" )); SDL_OpenAudio(&
|
||||
bu,0); SDL_LoadWAV (T[8],& bv,&S,&Q ); /**/ SDL_PauseAudio(0);
|
||||
for(; ; ){ int u[6 ],*I; H =0 ; while (H < 6) scanf(/*0*/
|
||||
"%d ", u+H++); b u[5]< 0)break ; I=ba(
|
||||
u);b!u [3]){ q =I+1; m =u[0 ]; n=u[1];
|
||||
} } for (; ; ){ while/* !MAFFIO DO.S*/(
|
||||
SDL_PollEvent(&bE) ) { by= bE.type ==3; b!O &&(by|| bE.
|
||||
type==2)){ I = bE. key/**/ .keysym .sym; b I== 276)r=
|
||||
by?0:(p=-1); b I== 275 )r= by?0:(p =1); b I==32)by?
|
||||
|
||||
0:(t?(s=-9):0); b I==27)exit(0); } } bl(); SDL_Flip(U); SDL_Delay(60); } }
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
@@ -0,0 +1,204 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2014 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
|
||||
#CWARN= -Wall -pedantic
|
||||
|
||||
# compiler standard
|
||||
#
|
||||
#CSTD=
|
||||
#CSTD= -ansi
|
||||
CSTD= -std=c11
|
||||
|
||||
# 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} \
|
||||
-Wno-implicit-function-declaration -Wno-implicit-int -Wno-return-type \
|
||||
--include string.h
|
||||
|
||||
# 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= prog
|
||||
DATA=
|
||||
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}
|
||||
@${TRUE}
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
${RM} -f ${ENTRY}.o ${ALT_OBJ}
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${ENTRY} ${ALT_ENTRY}
|
||||
|
||||
nuke: clobber
|
||||
@${TRUE}
|
||||
|
||||
dist_clean: nuke
|
||||
@${TRUE}
|
||||
|
||||
install:
|
||||
@echo "Surely we are joking Dr. Science!"
|
||||
@${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 sometimes mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Readers shall not be disallowed from failong 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_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 "You are holding it wrong!"; \
|
||||
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 Pauline!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
@@ -0,0 +1,116 @@
|
||||
<!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 entry</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most tweetable entry</h1>
|
||||
|
||||
<p>Sandro Maffiodo<br>
|
||||
<a href="mailto:smaffer@gmail.com">smaffer@gmail.com</a><br>
|
||||
<a href="http://www.assezeta.com/sandromaffiodo">http://www.assezeta.com/sandromaffiodo</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./prog arg
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>cat image.rgb | ./prog ' .,:;!$#@'
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>On the face of it :-) given what this program one might wonder what makes this winner special.
|
||||
But when you realize the source is small enough to tweet on twitter you understand.</p>
|
||||
|
||||
<p>Who will be the first to tweet this source? How many re-tweets will such tweet get?
|
||||
And how many people will really understand the tweet?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Remarks</h3>
|
||||
|
||||
<p>This program convert an image to an ASCII ART. The program reads a raw RGB image from <strong>stdin</strong> and print the ASCII ART to <strong>stdout</strong>.</p>
|
||||
|
||||
<p>The build process will raise some warnings about:</p>
|
||||
|
||||
<ul>
|
||||
<li>declaration specifier missing, defaulting to ‘int’</li>
|
||||
<li>implicitly declaring library function</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>The program crash if run without parameters.</p>
|
||||
|
||||
<h3>Screen size</h3>
|
||||
|
||||
<p>If you have a terminal geometry than if different from the common 80x25 you can modify the <em>output width</em> by changing the value of the first variable:</p>
|
||||
|
||||
<pre><code>d=80
|
||||
</code></pre>
|
||||
|
||||
<h3>Something to try</h3>
|
||||
|
||||
<p>Type this:</p>
|
||||
|
||||
<pre><code>cat image.rgb | ./prog " .:;Y0"
|
||||
</code></pre>
|
||||
|
||||
<p>You can use your own image. Convert the image to a raw RGB image, using imagemagick it’s very simple:</p>
|
||||
|
||||
<pre><code>convert -geometry 80x source.jpg image.rgb
|
||||
</code></pre>
|
||||
|
||||
<p>This program require one parameter, or crash. The parameter of the program is the <em>convertion ramp</em>. You can use different ramps or create your own (for ex. using some letters of your name).
|
||||
These are some ramps you can try:</p>
|
||||
|
||||
<pre><code>./prog " :1"
|
||||
./prog " .:;Y0"
|
||||
./prog " .:-=+*#%@"
|
||||
./prog " .,:!-iots&8%#@$"
|
||||
./prog "$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,"^`'. "
|
||||
</code></pre>
|
||||
|
||||
<h3>121 byte version</h3>
|
||||
|
||||
<p>An alternative version of this program is only 121bytes long:</p>
|
||||
|
||||
<pre><code>d=80,e,j;g(){j+=getchar();}main(){for(;;){j=0;g();if(j<0)break;g(g());putchar(" .:#@"[j/3*5>>8]);if(!(++e%d))puts("");}}
|
||||
</code></pre>
|
||||
|
||||
<p>This alternative version have a <strong>fixed ramp</strong>. It’s smaller but it’s not so fun to use…</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,81 @@
|
||||
# Most tweetable entry
|
||||
|
||||
Sandro Maffiodo
|
||||
<smaffer@gmail.com>
|
||||
<http://www.assezeta.com/sandromaffiodo>
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
### To build:
|
||||
|
||||
make
|
||||
|
||||
### To run:
|
||||
|
||||
./prog arg
|
||||
|
||||
### Try:
|
||||
|
||||
cat image.rgb | ./prog ' .,:;!$#@'
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
On the face of it :-) given what this program one might wonder what makes this winner special.
|
||||
But when you realize the source is small enough to tweet on twitter you understand.
|
||||
|
||||
Who will be the first to tweet this source? How many re-tweets will such tweet get?
|
||||
And how many people will really understand the tweet?
|
||||
|
||||
## Author's comments:
|
||||
### Remarks
|
||||
|
||||
This program convert an image to an ASCII ART. The program reads a raw RGB image from **stdin** and print the ASCII ART to **stdout**.
|
||||
|
||||
The build process will raise some warnings about:
|
||||
|
||||
- declaration specifier missing, defaulting to 'int'
|
||||
- implicitly declaring library function
|
||||
|
||||
The program crash if run without parameters.
|
||||
|
||||
### Screen size
|
||||
|
||||
If you have a terminal geometry than if different from the common 80x25 you can modify the *output width* by changing the value of the first variable:
|
||||
|
||||
d=80
|
||||
|
||||
### Something to try
|
||||
|
||||
Type this:
|
||||
|
||||
cat image.rgb | ./prog " .:;Y0"
|
||||
|
||||
You can use your own image. Convert the image to a raw RGB image, using imagemagick it's very simple:
|
||||
|
||||
convert -geometry 80x source.jpg image.rgb
|
||||
|
||||
This program require one parameter, or crash. The parameter of the program is the *convertion ramp*. You can use different ramps or create your own (for ex. using some letters of your name).
|
||||
These are some ramps you can try:
|
||||
|
||||
./prog " :1"
|
||||
./prog " .:;Y0"
|
||||
./prog " .:-=+*#%@"
|
||||
./prog " .,:!-iots&8%#@$"
|
||||
./prog "$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,"^`'. "
|
||||
|
||||
### 121 byte version
|
||||
|
||||
An alternative version of this program is only 121bytes long:
|
||||
|
||||
d=80,e,j;g(){j+=getchar();}main(){for(;;){j=0;g();if(j<0)break;g(g());putchar(" .:#@"[j/3*5>>8]);if(!(++e%d))puts("");}}
|
||||
|
||||
This alternative version have a **fixed ramp**. It's smaller but it's not so fun to use...
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(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/
|
||||
-->
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
d=80,e,j;g(){j+=getchar();}main(a,b)char**b;{for(;;){j=0;g();if(j<0)break;g(g());putchar(b[1][j/3*strlen(b[1])>>8]);if(!(++e%d))puts("");}}
|
||||
@@ -0,0 +1,205 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2014 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
|
||||
#CWARN= -Wall -pedantic
|
||||
CWARM= -Wall -Wextra -pedantic -Wshadow
|
||||
|
||||
# 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} \
|
||||
-Wno-empty-body -Wno-logical-op-parentheses -Wno-int-conversion
|
||||
|
||||
# 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= prog
|
||||
DATA=
|
||||
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}
|
||||
@${TRUE}
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
${RM} -f ${ENTRY}.o ${ALT_OBJ}
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${ENTRY} ${ALT_ENTRY}
|
||||
|
||||
nuke: clobber
|
||||
${RM} -f morgan
|
||||
@${TRUE}
|
||||
|
||||
dist_clean: nuke
|
||||
@${TRUE}
|
||||
|
||||
install:
|
||||
@echo "Surely we are joking Dr. Science!"
|
||||
@${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 sometimes mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Readers shall not be disallowed from failong 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_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 "You are holding it wrong!"; \
|
||||
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 Pauline!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
@@ -0,0 +1,128 @@
|
||||
<!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 likely to succeed</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most likely to succeed</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
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./prog [arg ..]
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>make
|
||||
cp -f prog morgan
|
||||
./morgan clobber
|
||||
ls
|
||||
|
||||
./morgan all install
|
||||
ls
|
||||
|
||||
./prog love haste waste supernova
|
||||
ls
|
||||
|
||||
make
|
||||
./prog magic
|
||||
ls
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>Think of this as a Maker Faire’s make. :-)</p>
|
||||
|
||||
<p>It works reasomably well. While not super ultra-featured, it does fair well with the Makefile we supplied.
|
||||
Not only that, it helped uncover a bug we had in our special Makefile rules.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Remarks</h3>
|
||||
|
||||
<p>This program is a tiny <code>make</code> clone.</p>
|
||||
|
||||
<p>It is able to parse a subset of the <code>make</code> syntax and will execute rules for
|
||||
goals given in arguments if they need to (based on timestamp of dependencies
|
||||
of rule targets).</p>
|
||||
|
||||
<h2>Supported features</h2>
|
||||
|
||||
<ul>
|
||||
<li>Variable assignments (only recursive ones). Variable references with recursion.</li>
|
||||
<li>Environment variables are available.</li>
|
||||
<li>It is possible to specify variables in command line: <code>name=value</code>.</li>
|
||||
<li>Variables given in command line will have precedence over variables defined
|
||||
in makefile, which will have precedence over environment variables.</li>
|
||||
<li>If no goal given in command line, the first target defined will be used.</li>
|
||||
<li>Comments, escaped comments, escaped new lines.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>It should be able to build programs of previous years with the provided <code>Makefile</code>
|
||||
found in previous contest archives. Simply use this program instead of <code>make</code>.
|
||||
It will recursively use itself for submake (the <code>MAKE=</code> assignment inside
|
||||
<code>Makefile</code> will be ignored to continue using itself).</p>
|
||||
|
||||
<h2>Limitations / Known issues</h2>
|
||||
|
||||
<ul>
|
||||
<li>There is a lot of memory leak (not a single free).</li>
|
||||
<li>The opened file is not closed.</li>
|
||||
<li>The input file shall be named <code>Makefile</code>.</li>
|
||||
<li>No diagnostic message, but the exit status is non zero to indicates failure
|
||||
(failed command in a rule or missing target).</li>
|
||||
<li>Only <code>$<</code> and <code>$@</code> are supported for automatic variables in commands.</li>
|
||||
<li>No parallel execution (<code>-j</code> option).</li>
|
||||
<li>No <code>:=</code> <code>+=</code> <code>?=</code> syntax for variable assignment.</li>
|
||||
<li>No built-in function available.</li>
|
||||
<li>No pattern targets.</li>
|
||||
<li>No pattern substitution variables.</li>
|
||||
<li>No built-in rules.</li>
|
||||
<li>No built-in variables (except the one from environment).</li>
|
||||
<li>No conditional directives.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Compilation warnings</h3>
|
||||
|
||||
<p>with gcc 4.8.2 on Linux Ubuntu 14.04 64-bit :
|
||||
* prog.c:22:15: warning: return makes integer from pointer without a cast [enabled by default]
|
||||
* prog.c:23:72: warning: signed and unsigned type in conditional expression [-Wsign-compare]
|
||||
* prog.c:12:11: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]</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,96 @@
|
||||
# Most likely to succeed
|
||||
|
||||
Yves-Marie Morgan
|
||||
<yves-marie.morgan@parrot.com>
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
### To build:
|
||||
|
||||
make
|
||||
|
||||
### To run:
|
||||
|
||||
./prog [arg ..]
|
||||
|
||||
### Try:
|
||||
|
||||
make
|
||||
cp -f prog morgan
|
||||
./morgan clobber
|
||||
ls
|
||||
|
||||
./morgan all install
|
||||
ls
|
||||
|
||||
./prog love haste waste supernova
|
||||
ls
|
||||
|
||||
make
|
||||
./prog magic
|
||||
ls
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
Think of this as a Maker Faire's make. :-)
|
||||
|
||||
It works reasomably well. While not super ultra-featured, it does fair well with the Makefile we supplied.
|
||||
Not only that, it helped uncover a bug we had in our special Makefile rules.
|
||||
|
||||
## Author's comments:
|
||||
### Remarks
|
||||
|
||||
This program is a tiny `make` clone.
|
||||
|
||||
It is able to parse a subset of the `make` syntax and will execute rules for
|
||||
goals given in arguments if they need to (based on timestamp of dependencies
|
||||
of rule targets).
|
||||
|
||||
## Supported features
|
||||
|
||||
* Variable assignments (only recursive ones). Variable references with recursion.
|
||||
* Environment variables are available.
|
||||
* It is possible to specify variables in command line: `name=value`.
|
||||
* Variables given in command line will have precedence over variables defined
|
||||
in makefile, which will have precedence over environment variables.
|
||||
* If no goal given in command line, the first target defined will be used.
|
||||
* Comments, escaped comments, escaped new lines.
|
||||
|
||||
It should be able to build programs of previous years with the provided `Makefile`
|
||||
found in previous contest archives. Simply use this program instead of `make`.
|
||||
It will recursively use itself for submake (the `MAKE=` assignment inside
|
||||
`Makefile` will be ignored to continue using itself).
|
||||
|
||||
## Limitations / Known issues
|
||||
|
||||
* There is a lot of memory leak (not a single free).
|
||||
* The opened file is not closed.
|
||||
* The input file shall be named `Makefile`.
|
||||
* No diagnostic message, but the exit status is non zero to indicates failure
|
||||
(failed command in a rule or missing target).
|
||||
* Only `$<` and `$@` are supported for automatic variables in commands.
|
||||
* No parallel execution (`-j` option).
|
||||
* No `:=` `+=` `?=` syntax for variable assignment.
|
||||
* No built-in function available.
|
||||
* No pattern targets.
|
||||
* No pattern substitution variables.
|
||||
* No built-in rules.
|
||||
* No built-in variables (except the one from environment).
|
||||
* No conditional directives.
|
||||
|
||||
### Compilation warnings
|
||||
|
||||
with gcc 4.8.2 on Linux Ubuntu 14.04 64-bit :
|
||||
* prog.c:22:15: warning: return makes integer from pointer without a cast [enabled by default]
|
||||
* prog.c:23:72: warning: signed and unsigned type in conditional expression [-Wsign-compare]
|
||||
* prog.c:12:11: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(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/
|
||||
-->
|
||||
@@ -0,0 +1,56 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define A calloc(1, sizeof(m))
|
||||
#define D m.
|
||||
#define L ->
|
||||
#define P malloc(
|
||||
#define R &&
|
||||
#define S ++
|
||||
#define U for(
|
||||
#define V if(
|
||||
#define W L i
|
||||
#define X L a
|
||||
#define Y L b
|
||||
#define Z L c
|
||||
|
||||
typedef struct T*_; struct T{ int t,i; char*a; _*b,c,d,e,f; } m,x,y; struct stat z; int u; void * H;
|
||||
int K(int c){ return strchr(" \n\t",c); } void B(_ s,_ p) { s Y=realloc(s Y,S s W*sizeof(_)); s Y [s
|
||||
W-1]=p; } _ C(char*d,int l){ _ s=A; s X=d?d:P 1); s W=l<0?d?strlen(d):0:l; return s; } _ E(_ s){ _ r
|
||||
=A; int i=0; U; i<s W; ){ U; i<s W R K(s X[i]); )i S; int j=i; U; j<s W R !K(s X[j]); )j S; V j-i)B(
|
||||
r,C(s X+i,j-i)); i=S j; } return r; } int F(_ a,_ b){ return a W==b W R !memcmp(a X,b X,a W); } void
|
||||
I( _ s,char c ) { char*d=P 1); *d=c ; B(s,C(d,1) ); } void
|
||||
J ( char*d,int l ,int o,_ v){ _ n= C(d,l); _ w; U l= 0; l
|
||||
<D d W; ) { w= D d Y[l S ]; V F( w Z,n)){ V o>w W) return; goto O; } }
|
||||
B( D d,w= A ); w Z=n; O:w W =o ; w L d=v; } int M( _ b,int p,char*t,int
|
||||
g ){ _ f= A; f L e= A; f X=t; int h=g ,i=0,j=0,n=b
|
||||
W ; char c=0, d,*o =b X ; U; p<n; ){ t=j?"":f X ;
|
||||
int k=p; _ r=H ; U; p <n; ){ int l = 0; U; p<n R o[p]==92 ; ){ l S; p S; } c=o
|
||||
[p S ]; V c^10||! l% 2 ||!g){ d=c== 35 R !i R!g|| c== 10 R g^2; V d||strchr(t,c
|
||||
)) { r=C(o+k,p-k- d*l/ 2-1); V d R l%2) { r X[r W-1] =c^35 ?32:
|
||||
c; c =0; } break; } } c=0; } V!j)B (f L e,r?r:C(o+k, n-k) ); r
|
||||
=A; switch(c){ case 35:j S; case 0:break; case 10:goto O; case 36:switch(d=o[p S]){ case 36:I(f L e,
|
||||
d); break; default:I(r Z=A,d); goto o; case 40:case 123:r L f=f; r L e=A; r X=d^40?"}$":")$"; f=r; }
|
||||
break; default:V f L f){ r Z=f L e; f=f L f; o:r L t S; B(f L e,r); } else goto O; } i=f L f R g==1;
|
||||
g=i?0:h; } O: x.c=f L e; x.t=c; return p; } _ N(_ s){ _ o=C(H,0); U int i=0; i<s W; ){ _ p=s Y[i S];
|
||||
V p L t){ _ n=N(p Z); p=C(H,0); U int j=0; j<D d W; ){ _ w=D d Y[j S]; V F(w Z,n)){ M(w L d,0,"$",2)
|
||||
; p=N(x.c); break; } } } o X=realloc(o X,o W+=p W); memcpy(o X+o W-p W,p X,p W); } return o; } _ O(_
|
||||
t){ U int i=0; i<D e W; ){ _ s=D e Y[i S]; V F(s Z,t))return s; }_ s=A; s Z=t; s L d=A; s L t--; B(D
|
||||
e,s); return s; } void Q(_ s){ _ d=s Z; V!stat(memcpy(calloc(1,d W+1),d X,d W),&z))s L t=z.st_mtime;
|
||||
V!s W S){ u=!s L d W R s L t<0; int i=0,j,k=s L t<0; _ c=H,t; U; !u R i<s L d W; ){ _ a=s L d Y[i S]
|
||||
; U j=0; !u R j<a L d W; ){ Q(t=O(a L d Y[j S])); k|=t L t<0||t L t>s L t; } V a Z W){ c=a Z; V a L
|
||||
d W)J("<", 1, 0, *a L d Y); } } U j=0; !u R c R k R j<c W; ){ J("@",1,0,d); s=N(c Y[j S]); U; s W R
|
||||
strchr("@+-",*s X); )s X S; u=system(s X); } } } void G(_ b){ U; b W R K(*b X); ){ b X S; b W--; } }
|
||||
|
||||
int main(int i,char**a,char**e){ D d=A; D e=A; D c=A; char p[]="NBLF\1Nblfgjmf\1",*q=p; U; (*q++)--;
|
||||
); J(p,4,0,C(*a S,-1)); U i=0; i<3; i+=2){ U; *a; ){ q=*a; U; *q R*q^61; )q S; V*q)J(*a,q-*a,i+1,C(q
|
||||
+1,-1)); else V!i)B(D c,C(*a,-1)); a S; } a=e; } stat(p+5,&z); i=z.st_size; _ b=C(H,0),c,d; b W=read
|
||||
(open(p+5,0),b X=P i),i); U; u<i; ){ V b X[u]^9){ U; u<i R K(b X[u]); )u S; u=M(b,u,"=:$",0); y = x;
|
||||
switch(x.t){ case 58:u=M(b,u,"$",0); D f=c=A; c L d=E(N(x.c)); c Z=A; d=E(N(y.c)); U; d W--; )B(O(*d
|
||||
Y S) L d,c); break; case 61:u=M(b,u,"",0); G(c=N(x.c)); G(d=N(y.c)); U; d W--R K(d X[d W]); ); J(d X
|
||||
,S d W,2,c); } } else { u=M(b,S u,"$",1); I(x.c,0); B(D f Z,x.c); } } V!D c W R D e W)B(D c,D e Y[0]
|
||||
Z); U u=0; !u R D c W--; )Q(O(*D c Y S)); return u; }
|
||||
+235
@@ -0,0 +1,235 @@
|
||||
| 23rd International Obfuscated C Code Contest Official Rules
|
||||
|
||||
| Copyright (C) 2006-2014 Leonid A. Broukhis, Simon Cooper, Landon Curt Noll
|
||||
|
||||
All Rights Reserved. Permission for personal, education or non-profit use is
|
||||
granted provided this this copyright and notice are included in its entirety
|
||||
and remains unaltered. All other uses must receive prior permission in
|
||||
writing from the contest judges.
|
||||
|
||||
Obfuscate: tr.v. -cated, -cating, -cates. 1. a. To render obscure.
|
||||
b. To darken. 2. To confuse: his emotions obfuscated his
|
||||
judgment. [LLat. obfuscare, to darken : ob(intensive) +
|
||||
Lat. fuscare, to darken < fuscus, dark.] -obfuscation n.
|
||||
obfuscatory adj.
|
||||
|
||||
|
||||
| This rules file is version 2014-08-29-v18.
|
||||
|
||||
| Most of the changes from the previous IOCCC rules
|
||||
| been marked with a "|" on the left hand side of the line.
|
||||
|
||||
|
||||
GOALS OF THE CONTEST:
|
||||
|
||||
* To write the most Obscure/Obfuscated C program under the rules below.
|
||||
* To show the importance of programming style, in an ironic way.
|
||||
* To stress C compilers with unusual code.
|
||||
* To illustrate some of the subtleties of the C language.
|
||||
* To provide a safe forum for poor C code. :-)
|
||||
|
||||
| The 23rd IOCCC contest entry window is:
|
||||
|
||||
| 2014-Sep-01 02:03:04 UTC to 2014-Oct-19 18:17:16 UTC
|
||||
|
||||
| These rules are provisional, and might be adjusted.
|
||||
|
||||
| The final rules will be availble along with the submission server and
|
||||
| updated iocccsize.c tool on or slightly before 2014-Sep-15 15:15:15 UTC.
|
||||
|
||||
|
||||
RULES:
|
||||
|
||||
To help us with the volume of entries, we ask that you follow these rules:
|
||||
|
||||
1) Your entry must be a complete program.
|
||||
|
||||
2) The size of your program source must be <= 4096 bytes in length.
|
||||
|
||||
When your program source is fed as input to the current IOCCC size
|
||||
tool, and the IOCCC size tool -i command line option is used, the value
|
||||
printed should be <= 2053.
|
||||
|
||||
The source to the current IOCCC size tool is found at this URL:
|
||||
|
||||
| http://www.ioccc.org/2014/iocccsize.c
|
||||
|
||||
3) Submissions should be performed using the instructions outlined at:
|
||||
|
||||
https://submit.ioccc.org/
|
||||
|
||||
| That URL should be active on or slightly before 2014-Sep-15 15:15:15 UTC
|
||||
|
||||
4) If your entry is selected as a winner, it will be modified as follows:
|
||||
|
||||
Your 'build' instructions will be incorporated into a makefile.
|
||||
|
||||
Your source code will be renamed from prog.c to a name
|
||||
of our choice (usually related to your family name or
|
||||
anonymous) followed by a optional digit if there are conflicting
|
||||
winning entries. The resulting binary will be renamed from prog to a
|
||||
equivalent of our choice.
|
||||
|
||||
If needed, indicate in your remarks file how your entry
|
||||
must be changed to accommodate the above.
|
||||
|
||||
5) Your entry must not modify the content or filename of any part of your
|
||||
original entry including, but not limited to prog.c, the Makefile
|
||||
(we create from your how to build instructions), as well as any data
|
||||
files you submit.
|
||||
|
||||
If you entry wishes to modify such content, it must first copy the
|
||||
file to a new filename and then modify that copy.
|
||||
|
||||
| 6) I am not a rule, I am a free being!!
|
||||
|
||||
| while (!understand(ioccc(rule(number(6))))) { laugh(); }
|
||||
|
||||
7) The obfuscated C program must be an original work that you own.
|
||||
|
||||
You (the authors) must own the contents of your submission OR
|
||||
you must have permission from the owners to submit their content
|
||||
under the Creative Commons Attribution-ShareAlike 3.0 Unported
|
||||
(CC BY-SA 3.0) license (see rule 18).
|
||||
|
||||
If you submit any content that is owned by others, you MUST
|
||||
detail that ownership (i.e., who owns what) and document the
|
||||
permission you obtained.
|
||||
|
||||
| 8) Entries must be received prior to 2014-Oct-19 18:17:16 UTC.
|
||||
|
||||
A confirmation of submission will be sent to the submitter's
|
||||
email address before the close of the contest.
|
||||
|
||||
| 9) Each person may submit up to and including 8.00 entries per contest.
|
||||
Each entry must be submitted separately.
|
||||
|
||||
10) Entries requiring human interaction to be initially compiled are
|
||||
not permitted.
|
||||
|
||||
11) Programs that require special privileges (setuid, setgid, super-user,
|
||||
| special owner, special group, etc.) are still highly discouraged. We
|
||||
| do not guarantee these functions will behave as you expect on our test
|
||||
| platforms. If your program needs special permissions please document
|
||||
| them in the remarks file.
|
||||
|
||||
12) Legal abuse of the rules is somewhat encouraged. An entry that, in
|
||||
the opinion of the judges, violates the rules will be disqualified.
|
||||
Entries that attempt to abuse the rules must try to justify why
|
||||
their rule abuse is legal in the remarks file.
|
||||
|
||||
13) Any C source that fails to compile because of unescaped octets with
|
||||
the high bit set (octet value >= 128) will be rejected.
|
||||
|
||||
14) Any C source that fails to compile because of lines with trailing
|
||||
control-M's (i.e., lines with a tailing octet 015) will be rejected.
|
||||
|
||||
Please do not put trailing control-M's in your remarks file.
|
||||
|
||||
15) When you submit your entry you must have a valid email address
|
||||
that can both send and receive email. The online submission
|
||||
method is a two phase process that requires the use of an
|
||||
approval code. This code will be emailed to you as part of
|
||||
phase 1.
|
||||
|
||||
Entries submitted without a working or valid email address will
|
||||
be disqualified.
|
||||
|
||||
The judges are not responsible for delays in email, please plan
|
||||
enough time for one automated exchange of email as part of your
|
||||
submission.
|
||||
|
||||
| After your email address has been confirmed, the submission code will
|
||||
| be valid for submitting and editing the entry for the lifetime of the
|
||||
| competition.
|
||||
|
||||
| 16) You are STRONGLY encouraged to submit a previously unpublished and
|
||||
| original entry. Submissions that are similar to previous entries are
|
||||
| discouraged. As we judge anonymously, submissions that have already
|
||||
| been published may be disqualified.
|
||||
|
||||
17) The total size of your submission: the sum of the size of the program,
|
||||
hints, comments, build and info files MUST be less than or equal
|
||||
to 1048576 octets in size.
|
||||
|
||||
18) The entirety of your entry must be submitted under the Creative Commons
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0):
|
||||
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
You must not submit anything that cannot be submitted under that license.
|
||||
|
||||
19) The remarks file must be written in markdown format. See:
|
||||
|
||||
http://daringfireball.net/projects/markdown/basics
|
||||
|
||||
for more information.
|
||||
|
||||
| We currently use "Discount" to convert markdown to HTML
|
||||
|
|
||||
| http://www.pell.portland.or.us/~orc/Code/discount/
|
||||
|
||||
20) The how to build instructions must be in make form.
|
||||
|
||||
The target of the make file must be called prog. The original
|
||||
C source file must be called prog.c.
|
||||
|
||||
To invoke the C compiler, use ${CC}.
|
||||
To invoke the C preprocessor use ${CPP}.
|
||||
|
||||
Do not assume that . (the current working directory) is in the $PATH.
|
||||
|
||||
Use a shell command syntax that is compatible with bash.
|
||||
|
||||
Assume that commands commonly found in POSIX-like / Linux-like systems
|
||||
are available in the search path.
|
||||
|
||||
Do not assume any particular given value of ${CFLAGS} or other
|
||||
commonly used make variables.
|
||||
|
||||
21) Your entry must not create nor modify files above the current directory
|
||||
with the exception of the /tmp and the /var/tmp directories. Your entry
|
||||
may create subdirectories below the current directory, or in /tmp,
|
||||
or in /var/tmp provided that "." is not the first octet in any
|
||||
directory name.
|
||||
|
||||
|
||||
FOR MORE INFORMATION:
|
||||
|
||||
The judging will be done by Leonid A. Broukhis, Simon Cooper, Landon
|
||||
Curt Noll.
|
||||
|
||||
Please send questions or comments about the contest, to:
|
||||
|
||||
| q.2014@ioccc.org (for questions only!)
|
||||
|
||||
You must include the words:
|
||||
|
||||
| ioccc 2014 question
|
||||
|
||||
in the subject of your EMail message when sending EMail to the judges.
|
||||
|
||||
The rules and the guidelines may (and often do) change from year to
|
||||
year. You should be sure you have the current rules and guidelines
|
||||
prior to submitting entries. To obtain them, visit the IOCCC web page:
|
||||
|
||||
http://www.ioccc.org
|
||||
|
||||
It has rules, guidelines and winners of previous contests (1984 to date).
|
||||
|
||||
For the updates and breaking IOCCC news, you are encouraged to follow
|
||||
the twitter handle:
|
||||
|
||||
@IOCCC
|
||||
|
||||
You do not have to be a twitter user to follow @IOCCC. Non-twitter
|
||||
users should access:
|
||||
|
||||
https://twitter.com/ioccc
|
||||
|
||||
Non-twitter users should force their browsers to reload the above URL
|
||||
to be sure they are seeing the most recent tweets.
|
||||
|
||||
Leonid A. Broukhis
|
||||
Simon Cooper
|
||||
chongo (Landon Curt Noll) /\cc/\
|
||||
@@ -0,0 +1,205 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2014 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
|
||||
CHMOD= chmod
|
||||
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
|
||||
#CWARN= -Wall -pedantic
|
||||
|
||||
# compiler standard
|
||||
#
|
||||
#CSTD=
|
||||
#CSTD= -ansi
|
||||
CSTD= -std=c11
|
||||
|
||||
# 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=
|
||||
#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= sinon
|
||||
DATA= glock.sh hecate.sh
|
||||
ALT_OBJ= run run.c
|
||||
ALT_ENTRY= prog
|
||||
|
||||
|
||||
#################
|
||||
# build the entry
|
||||
#################
|
||||
|
||||
all: data
|
||||
@${TRUE}
|
||||
|
||||
${ENTRY}: ${ENTRY}.c
|
||||
@rm -f $@
|
||||
perl $< | bash
|
||||
|
||||
# alternative executable
|
||||
#
|
||||
alt: ${ALT_ENTRY}
|
||||
@${TRUE}
|
||||
|
||||
# data files
|
||||
#
|
||||
data: ${DATA}
|
||||
${CP} ${ALT_ENTRY}.c ${ENTRY}.c
|
||||
${CHMOD} +x ${DATA}
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
${RM} -f ${ENTRY}.o ${ALT_OBJ} ${ENTRY}.c
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${ENTRY} ${ALT_ENTRY}
|
||||
|
||||
nuke: clobber
|
||||
@${TRUE}
|
||||
|
||||
dist_clean: nuke
|
||||
@${TRUE}
|
||||
|
||||
install:
|
||||
@echo "Surely we are joking Dr. Science!"
|
||||
@${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 sometimes mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Readers shall not be disallowed from failong 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_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 "You are holding it wrong!"; \
|
||||
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 Pauline!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
@@ -0,0 +1 @@
|
||||
gcc -O0 run.c -o run > /dev/null && ./run | tee run.c
|
||||
@@ -0,0 +1 @@
|
||||
gcc -O2 run.c -o run > /dev/null && ./run | tee run.c
|
||||
@@ -0,0 +1,154 @@
|
||||
<!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 choice of optimization</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best choice of optimization</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 sinon
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>cp sinon.c run.c
|
||||
</code></pre>
|
||||
|
||||
<p>Then keep running ./glock.sh or ./hecate.sh within a minute with
|
||||
slight pauses between invocations.</p>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>cp sinon.c run.c; ./hecate.sh; ./glock.sh; sleep 3; ./glock.sh; sleep 1; ./hecate.sh
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>Try to figure out how this entry determines the optimization level with
|
||||
which it had been compiled. Is this an example of undefined behavior
|
||||
or unspecified behavior?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Summary</h3>
|
||||
|
||||
<p>Sinon is a game of timing, the goal is to eliminate all enemies in
|
||||
under one minute.</p>
|
||||
|
||||
<p>To start, compile and run the program. To resume, compile and run the
|
||||
output repeatedly until you have won/lost the game. For example:</p>
|
||||
|
||||
<pre><code>cp sinon.c run.c
|
||||
gcc -O0 run.c -o run && ./run | tee run.c
|
||||
gcc -O2 run.c -o run && ./run | tee run.c
|
||||
...
|
||||
</code></pre>
|
||||
|
||||
<h3>Details</h3>
|
||||
|
||||
<p>Sinon is played by compiling and running the output repeatedly. Two
|
||||
factors determine what actions are taken:</p>
|
||||
|
||||
<ul>
|
||||
<li>Time since last compilation.</li>
|
||||
<li>Whether compiler optimizations are enabled or not.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>If you fire too quickly, the weapon will jam. If you fire too slowly,
|
||||
you will not be able to eliminate all the enemies in time. Thus the
|
||||
primary objective of the game is to time your compilations just right.</p>
|
||||
|
||||
<p>Sinon has two weapons that are selected based on compiler optimization
|
||||
level:</p>
|
||||
|
||||
<ul>
|
||||
<li><p>“gcc -O2” or “clang -O2” will fire Hecate II, a powerful rifle that
|
||||
requires longer time to cool off.</p></li>
|
||||
<li><p>“gcc -O0” or “clang -O0” will fire Glock 18C, a less powerful pistol
|
||||
that requires less time to cool off.</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Because the weapons cool off independently, the best strategy is to
|
||||
alternate between the two weapons. It is fairly easy to win the game
|
||||
with this strategy even with occasional jams.</p>
|
||||
|
||||
<p>If your compiler does not have the right optimizations, only Glock 18C
|
||||
would be available. It is still possible to win, but your timing will
|
||||
need to be more precise. This is effectively playing the game on
|
||||
“hard” mode. It is worth trying this mode even if you have the right
|
||||
compilers.</p>
|
||||
|
||||
<h3>Compatibility</h3>
|
||||
|
||||
<p>Sinon has been tested and verified to work on these platforms:</p>
|
||||
|
||||
<ul>
|
||||
<li>gcc 4.4.3 on Linux.</li>
|
||||
<li>gcc 4.4.5 on Linux.</li>
|
||||
<li>gcc 4.8.2 on Linux.</li>
|
||||
<li>gcc 4.8.3 on Cygwin/MingW.</li>
|
||||
<li>clang 3.4-1 on Linux.</li>
|
||||
<li>clang 3.4.2 on Cygwin.</li>
|
||||
<li>gcc 4.3.5 on JS/Linux (playable but likely unwinnable, because it
|
||||
takes too long to compile).</li>
|
||||
<li>tcc 0.9.25 on JS/Linux (no optimization, so only “hard” mode is
|
||||
available).</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Sinon is intended to be played in a 80x25 terminal.</p>
|
||||
|
||||
<h3>Miscellaneous features</h3>
|
||||
|
||||
<p>Sinon might be the first game that uses compiler optimization level as
|
||||
a primary input.</p>
|
||||
|
||||
<p>Sinon has a demo mode that plays the game automatically. Make sure
|
||||
that there are no files named “run” and “run.c” in current directory
|
||||
(they will be overwritten) and run:</p>
|
||||
|
||||
<pre><code>perl sinon.c | bash
|
||||
</code></pre>
|
||||
|
||||
<p>File size and CRC32 of sinon.c are embedded in line 7.</p>
|
||||
|
||||
<p>Process for making Sinon is included in spoiler.html.</p>
|
||||
|
||||
<p>Layout of this code is based on Asada Shino, also known as “Sinon”,
|
||||
from Sword Art Online.</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,120 @@
|
||||
# Best choice of optimization
|
||||
|
||||
Don Yang
|
||||
<omoikane@uguu.org>
|
||||
<http://uguu.org/>
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
### To build:
|
||||
|
||||
make sinon
|
||||
|
||||
### To run:
|
||||
|
||||
cp sinon.c run.c
|
||||
|
||||
Then keep running ./glock.sh or ./hecate.sh within a minute with
|
||||
slight pauses between invocations.
|
||||
|
||||
### Try:
|
||||
|
||||
cp sinon.c run.c; ./hecate.sh; ./glock.sh; sleep 3; ./glock.sh; sleep 1; ./hecate.sh
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
Try to figure out how this entry determines the optimization level with
|
||||
which it had been compiled. Is this an example of undefined behavior
|
||||
or unspecified behavior?
|
||||
|
||||
## Author's comments:
|
||||
### Summary
|
||||
|
||||
Sinon is a game of timing, the goal is to eliminate all enemies in
|
||||
under one minute.
|
||||
|
||||
To start, compile and run the program. To resume, compile and run the
|
||||
output repeatedly until you have won/lost the game. For example:
|
||||
|
||||
cp sinon.c run.c
|
||||
gcc -O0 run.c -o run && ./run | tee run.c
|
||||
gcc -O2 run.c -o run && ./run | tee run.c
|
||||
...
|
||||
|
||||
|
||||
### Details
|
||||
|
||||
Sinon is played by compiling and running the output repeatedly. Two
|
||||
factors determine what actions are taken:
|
||||
|
||||
+ Time since last compilation.
|
||||
+ Whether compiler optimizations are enabled or not.
|
||||
|
||||
If you fire too quickly, the weapon will jam. If you fire too slowly,
|
||||
you will not be able to eliminate all the enemies in time. Thus the
|
||||
primary objective of the game is to time your compilations just right.
|
||||
|
||||
Sinon has two weapons that are selected based on compiler optimization
|
||||
level:
|
||||
|
||||
+ "gcc -O2" or "clang -O2" will fire Hecate II, a powerful rifle that
|
||||
requires longer time to cool off.
|
||||
|
||||
+ "gcc -O0" or "clang -O0" will fire Glock 18C, a less powerful pistol
|
||||
that requires less time to cool off.
|
||||
|
||||
Because the weapons cool off independently, the best strategy is to
|
||||
alternate between the two weapons. It is fairly easy to win the game
|
||||
with this strategy even with occasional jams.
|
||||
|
||||
If your compiler does not have the right optimizations, only Glock 18C
|
||||
would be available. It is still possible to win, but your timing will
|
||||
need to be more precise. This is effectively playing the game on
|
||||
"hard" mode. It is worth trying this mode even if you have the right
|
||||
compilers.
|
||||
|
||||
|
||||
### Compatibility
|
||||
|
||||
Sinon has been tested and verified to work on these platforms:
|
||||
|
||||
+ gcc 4.4.3 on Linux.
|
||||
+ gcc 4.4.5 on Linux.
|
||||
+ gcc 4.8.2 on Linux.
|
||||
+ gcc 4.8.3 on Cygwin/MingW.
|
||||
+ clang 3.4-1 on Linux.
|
||||
+ clang 3.4.2 on Cygwin.
|
||||
+ gcc 4.3.5 on JS/Linux (playable but likely unwinnable, because it
|
||||
takes too long to compile).
|
||||
+ tcc 0.9.25 on JS/Linux (no optimization, so only "hard" mode is
|
||||
available).
|
||||
|
||||
Sinon is intended to be played in a 80x25 terminal.
|
||||
|
||||
|
||||
### Miscellaneous features
|
||||
|
||||
Sinon might be the first game that uses compiler optimization level as
|
||||
a primary input.
|
||||
|
||||
Sinon has a demo mode that plays the game automatically. Make sure
|
||||
that there are no files named "run" and "run.c" in current directory
|
||||
(they will be overwritten) and run:
|
||||
|
||||
perl sinon.c | bash
|
||||
|
||||
File size and CRC32 of sinon.c are embedded in line 7.
|
||||
|
||||
Process for making Sinon is included in spoiler.html.
|
||||
|
||||
Layout of this code is based on Asada Shino, also known as "Sinon",
|
||||
from Sword Art Online.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(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/
|
||||
-->
|
||||
@@ -0,0 +1,43 @@
|
||||
#/*
|
||||
q{G.
|
||||
*/include<stdio.h> /*G!*/
|
||||
#define G(g,o)/**/int g=o;/**/
|
||||
#define q(b)int o[]={0,0,0,0,\
|
||||
0};char*p=#b,P[9999],*d=P,*e[]={"('A`)"\
|
||||
,"(A`)","('A)","('A`)"},b/*3792/e887094c*/
|
||||
q(*s=__TIME__;extern void w(){G(g,*o)for(;g--
|
||||
;);}extern void x(){}extern void y(){}static void z
|
||||
(char*p){for(;(*d=*p++)!=0;d++)*d-=061*(59==*d||*d==81);}int
|
||||
main(){char N[]="<;iQ=/*do<;dQ=ook8?boc;aQ=odr8>oc;_Q<ox8>oc"
|
||||
";^Q<d|8=o;]Q<dj8<Pk8<c]'?;QQdi8?P'Q)d8<9`8?c;Qdh8=P']Q<`c8>PQ9_8"
|
||||
">b;og8=''`Q<`b8?'QQ9_8?c;dPe8dQa8<P]Q<``8=;'f8>QQ`]8?ocQQ_8=''_Q`8aQ"
|
||||
"CYOUQWIN!]Q=;of8BQQ)88bc]QA98P'Qo]8>oQQ_8CP;QQ98b`_8@P8(Q`]'^Q=`']QB)88"
|
||||
"bQQ]`8J;QQ`88bc99bd(`8iQ@''QQo^8E'`8c;QQ'Q``8?QQ`'kQ<o]8B9PQQ`';_Q<`_8<cbQ"
|
||||
"<o_Q<o_QBdo`QQ';`Q=9`]8=bobQ_o_Q<o]8=';bQC(88cQ`bcgQ>oP']8<;cQ>98)^Q?''oc`Q>"
|
||||
"oc']Q]8<;cQ>`8bbQA``QQ''`Q?88P;dQ=`)nQ?*/;;"/*}}=~/./;print"cp\40sinon.c\40r",
|
||||
"un.c\n";for($i=1;$i<21;$i++){for($j=0;$j<2;$j++){print"gcc\x20-O",$j*2,
|
||||
"\40run.c\x20-o run&&./run|tee run.c\n"if!($i%(2+$j));}print"sleep $j\n";
|
||||
} __DATA__ 8M*/;G(Z,60*(60*(10**s+s[1])+s[3]*10+s[4])+s[6]*10+s[7]-1933008
|
||||
)G(l,(Z+86400-*o)%86400)G(M,o[3] *17+o[4]*11) G(O,(&x-&w)-(&y-&x)?1:0)G(
|
||||
m,*o)G(n,m)G(i,0)G(j,O)if(M>197)for( p=N;*p; )if(*p>92){*N=p[1 ];N[1]
|
||||
=0;for( O=*p++-90;0<O--;z( N));p++;}else{ s= p;for(O= *p++-59;O--;p++)
|
||||
p[-1]=*p;p[-1]=0;z(s);}else{ if(M==0){*o=Z;l=0; }if(o[O+3]&&o[ O+1]+(O?3:5
|
||||
)>l)Z=O;else++o[O+3];o[O+1] =l; if(l<60)d+= sprintf(d,"#include<stdio.h>"
|
||||
"\12#define G(g,o) int g=o;\n#d" "efine \161(b" ")int\40o[]={%d,%d,%d,%d,%d};char"
|
||||
"*p=#b,P[9999],*d=P,*e[]=" "{\"%s\", \"" "%s" "\",\"%s\",\"%s\"}, b\nq(%s)\n"
|
||||
,*o,o[01],o[2],o[3], o[4] ,e[3],e[1], e[2],*e,p);z("/*;; ");for(i=0; i++<18
|
||||
;z(";"))for(j=0;j++<11;n=(n*193+287) %384 ){m=(97+(67*m ))%198;for
|
||||
(O=0;O++<n%03;z("Q") );s=d;for(z(e[ ( n/3)&3]);m<M &&s-d;*s++
|
||||
=040);}if(l<60) {for (z(";Time:Q") ;(l++<60);z ("#"));for
|
||||
(z(";Heca"/* */ "t" "eQII:" "Q") ;o[3 ]++ <=24;z("#"));z
|
||||
(Z?"":"Q(j" "a" "m" "me" /* @ */"d" ")");for(z(
|
||||
";GlockQ18" "C:" /* * */ "Q");o[4]++<
|
||||
25;z("#") );z( Z- 1? ";":"Q(jam"
|
||||
"med);") /* */ ;} else z(";"
|
||||
";Gam" /* */ "eQover."
|
||||
";;" /* (- */);for
|
||||
(O= 0;O <77;O
|
||||
++) z("Q");z( "*" ""
|
||||
"/" );}
|
||||
puts (P);;
|
||||
return+0;})
|
||||
@@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html><head>
|
||||
<title>Replay text</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<style type="text/css">
|
||||
.tmp{color:#00f}.final{color:#000}</style>
|
||||
</head><body>
|
||||
<noscript><span style="color:red">JavaScript required</span></noscript>
|
||||
<script type="text/javascript">
|
||||
var realtime_step=80;var fps=1000/realtime_step;var current_event=0;var current_time;var step=0;var slots=new Array(226);var update_slots=new Array(slots.length);var max_time=6687500;var max_file_size=149;var timer=null;var follow=1;var fast_scroll=1;var opacity=100;var opacity_timer=null;var string_table=
|
||||
[" */);for","e[3],e[1],e[2],*e,","ts[3] - \'0\') * 60 * 10 +","if( seed1 < score )","*o,o[1],o[2],o[3], o[4] ,e[3],e[1], e[2],*e,p);z(\"/*;; \");for(i=0; i++<18",";} else z(\";\"","static void WRit","a",")%198;for","n","(","++ = \'#\';","=","o[3],o[4],","0","rite(\"Glock 18C: \");","\"#define G(g,o) int g=o;\\n#d\"","/","d","p","1","[","]","char *ts = __TIME__;","for( p=N;*p;","m","u",", 0)","l","w","}","{\"(\'A`)\", \"(A`)\", \"(\'A)\", \"(\'A`)\"}","\'","3)&3]);m<M ","-","Write(\"#\");","\\","60*(60*(10**s+s[1])+s[3]*10+s[4])+s[6]*10+s[7]-1933008","9","X","2","#define G(O, o) int O = (o);","<",".","7","j","%","&&s-d;*s++","h","8","O",">","x","y"," {for (z(\";Time:Q\") ;(l++<60);z (\"#\"));for","$","I"," for(z(\";Time: \"); l++ < 60; z(\"#\"));for"," int elapsed = (timestamp + 86400 - state[0 /* start timestamp */]) % 8764","#define q(Q) char*z","4","g","z(\"/*;;\");"," seed 1 ="," for(z(\";Glock 18C: \"); o[4]++ < 25; z(\"#\"));z( Z- 1? \";\":\"Q(jam\"","G(l,(Z+86400-*o)%86400)G(M,o[3]*17+o[4]*11)G(O,(&x-&w)-(&y-&x)?1:0)G(m,*o)G(n,m)G(i,0)G(j,O)","Q","k","v"," INT TIM"," })",":","C","R","_"," (ts[3] - \'0\') * 60 + 1"," for($i=1;$i<21;$i++){for($j=0;$j<2;$j++){print\"gcc-O\",$j*2,\" a.c -o a\","," for(z(e[(n / 3) & 3]);m < M "," for(z(\";Hecate II: \"); o[3]++ < 25; z(\"#\"));z"," WRite"," int elapsed = (timestamp + 360"," for( p=N;*p; )if(*p>92){*N=p[1 ];N[1]","T"," q(*s=__TIME__;extern void w(){G(g, *o)"," {for (z(\";Time:Q\") ;(l++<60);z (\"#\"));for"," ;);}extern void x() {}"," ;o[3 ]++"," \"int state[]={%d,%d,%d,%d,%d};Q\\n\""," enemy[0], enemy[1], enemy[0], enemy[0],"," ;o[3 ]++"," WRite(\"\\n\"Hec"," for( p=N;*p;"," for(j = 0; j++ < 11;n = (n * 193 + 287) % 384){"," for(z(\";Hecate II: \") ;o[3 ]++"," }else{ s= p;"," /* Game over *vi"," for( p=N;*p;"," if( !M ){*o = Z;"," int i.,"," int state[] = {0, 0, 0, 0, 0}; \\"," int timestamp = (ts[0] - \'0\') * 3600 + 10","5","q"," \" (jammed)\");"," \"*e[]={\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",\\\"%s\\\"}, b\\nq(%s)\\n\""," \"*e[]={\\\"%s\\\",\\\"\" \"%s\" \"\\\",\\\"%s\\\",\\\"%s\\\"}, b\\nq(%s)\\n\""," #include<stdi.h"," );o[4]++<"," ++) z(\"Q\");z( \"*\" \"\""," z(\";Time:Q\")"," );o[4]++<"," o[3],o[4],e[3],e[1], e[2],*e,p);z(\"/*;; \");for(i=0; i++<18"," );o[4]++<"," );o[4]++<"," ;);}extern void x(){}extern void y(){}static void z(char *p)"," main(){char N[] = \"<;iQ=/*do<;dQ=ook8?boc;aQ=odr8>oc;_Q<ox8>oc;^Q<d|8=o;]Q<dj8<Pk8<c]\'?;QQdi8?P\'Q)d8<9`8?c;Qdh8=P\']Q<`c8>PQ9_8>b;og8=\'\'`Q<`b8?\'QQ9_8?c;dPe8dQa8<P]Q<``8=;\'f8>QQ`]8?ocQQ_8=\'\'_Q`8aQCYOUQWIN!]Q=;of8BQQ)88bc]QA98P\'Qo]8>oQQ_8CP;QQ98b`_8@P8(Q`]\'^Q=`\']QB)88bQQ]`8J;QQ`88bc99bd(`8iQ@\'\'QQo^8E\'`8c;QQ\'Q``8?QQ`\'kQ<o]8B9PQQ`\';_Q<`_8<cbQ<o_Q<o_QBdo`QQ\';`Q=9`]8=bobQ_o_Q<o]8=\';bQC(88cQ`bcgQ>oP\']8<;cQ>98)^Q?\'\'oc`Q>oc\']Q]8<;cQ>`8bbQA``QQ\'\'`Q?88P;dQ=`)nQ?*/;;\";"," );o[4]++<"," (char*p){for(; (*d = *p++); d++)"," (char*p){for(;(*d=*p++);d++)*d-=49*(59==*d||*d==81);}int main()"," );o[4]++<"," );o[4]++<"," \"\\40run.c\\40-o run&&./run|tee run.c\\n\"if!($i%(2+$j));}}print\"sleep 2\\n\";"," if(l<60) {for (z(\";Time:Q\") ;(l++<60);z (\"#\"));for"," m < M && s - d;*s++"," );o[4]++<"," p[-1] = *["," (O=0;O++<n%3;z(\"Q\") );s=d;for(z(e[ ( n/3)&3]);m<M &&s-d;*s++"," <18;z(\";\"))"," );o[4]++<"," \"#define G(g,o)\"\"int g=o;\\n#d\""," \"#define G(g,o)int g=o;\\n#d\"\"efine \\161(b\""," \"#define q(Q) char*z ="," enemy[0], enemy[1], enemy[2], enemy[3],"," for(O = 0;Line truncated
|
||||
var events=
|
||||
[0,500,0,0,0,0,0,500,1,3,0,0,500,500,0,0,0,0,0,2773500,1,3,41,1,500,100,0,0,0,1,0,2773000,2,3,3,1,100,100,0,0,0,2,0,2772900,2,3,9,1,100,100,0,0,0,3,0,2772800,2,3,23,1,100,100,0,0,0,4,0,2772700,2,3,28,1,100,100,0,0,0,5,0,2772600,2,3,26,1,100,100,0,0,0,6,0,2772500,2,3,18,1,100,100,0,0,0,7,0,2772400,2,3,1,1,100,100,0,0,0,8,0,2772300,2,3,42,4,100,100,0,0,0,9,0,2772200,2,3,6,1,100,100,0,0,0,10,0,2772100,2,3,2,1,100,125,0,0,0,11,0,2772000,2,3,18,1,125,125,0,0,0,12,0,2771875,2,3,3,1,125,125,0,0,0,13,0,2771750,2,3,13,1,125,125,0,0,0,14,0,2771625,2,3,43,1,125,125,0,0,0,15,0,2771500,2,3,48,1,125,125,0,0,0,16,0,2771375,2,3,51,4,125,125,0,0,0,17,0,2772250,1,4,0,0,125,125,0,0,1,0,0,125,1,33,0,0,125,166,0,0,2,0,0,5956500,1,33,3,1,166,167,0,0,2,1,0,5956334,2,33,9,1,167,167,0,0,2,2,0,5956167,2,33,2,1,167,166,0,0,2,3,0,5956000,2,33,0,1,166,167,0,0,2,4,0,5955834,2,33,25,1,167,167,0,0,2,5,0,5955667,2,33,7,1,167,111,0,0,2,6,0,5955500,2,33,3,1,111,111,0,0,2,7,0,5955389,2,33,9,1,111,111,0,0,2,8,0,5955278,2,33,10,1,111,111,0,0,2,9,0,5955167,2,33,8,1,111,111,0,0,2,10,0,111,1,34,0,0,111,111,0,0,3,0,0,5983778,1,34,31,1,111,111,0,0,3,1,0,111,1,224,0,0,111,111,0,0,4,0,0,2942223,1,224,30,1,111,112,0,0,4,0,112,333,0,0,4,0,333,333,0,0,4,0,0,1667,1,36,0,0,333,1334,0,0,4,0,1334,2000,0,0,4,0,0,2000,1,36,50,1,2000,1000,0,0,4,1,0,1000,1,36,0,0,1000,125,0,0,4,0,0,1246666,1,36,0,3,125,125,0,0,4,3,0,1246541,2,36,23,1,125,125,0,0,4,4,0,1246416,2,36,48,1,125,125,0,0,4,5,0,1246291,2,36,7,1,125,125,0,0,4,6,0,1246166,2,36,15,1,125,125,0,0,4,7,0,1246041,2,36,0,1,125,125,0,0,4,8,0,1245916,2,36,4,1,125,125,0,0,4,9,0,1245791,2,36,2,1,125,166,0,0,4,10,0,1245666,2,36,6,1,166,167,0,0,4,11,0,1245500,2,36,0,1,167,167,0,0,4,12,0,1245333,2,36,12,1,167,166,0,0,4,13,0,1245166,2,36,0,1,166,167,0,0,4,14,0,1245000,2,36,74,1,167,167,0,0,4,15,0,1244833,2,36,74,1,167,142,0,0,4,16,0,1244666,2,36,82,1,142,143,0,0,4,17,0,1244524,2,36,56,1,143,143,0,0,4,18,0,1244381,2,36,457,1,143,143,0,0,4,19,0,1244238,2,36,456,1,143,143,0,0,4,20,0,1244095,2,36,74,1,143,143,0,0,4,21,0,1243952,2,36,74,1,143,143,0,0,4,22,0,1243809,2,36,5,1,143,166,0,0,4,23,0,1428,1,46,0,3,166,167,0,0,5,3,0,1262,2,46,56,1,167,167,0,0,5,4,0,1095,2,46,3603,1,167,166,0,0,5,5,0,928,2,46,82,1,166,167,0,0,5,6,0,762,2,46,0,1,167,167,0,0,5,7,0,595,2,46,82,1,167,142,0,0,5,8,0,428,2,46,56,1,142,143,0,0,5,9,0,286,2,46,457,1,143,143,0,0,5,10,0,143,2,46,456,1,143,143,0,0,5,11,0,143,1,46,69,10,143,143,0,0,5,10,0,143,1,46,69,9,143,143,0,0,5,9,0,143,1,46,69,8,143,143,0,0,5,8,0,143,1,46,69,7,143,250,0,0,5,7,0,250,1,46,69,6,250,250,0,0,5,6,0,250,1,46,69,5,250,250,0,0,5,5,0,250,1,46,415,4,250,250,0,0,5,4,0,5250,1,46,0,3,250,90,0,0,5,3,0,5000,2,46,3,1,90,91,0,0,5,4,0,4910,2,46,9,1,91,91,0,0,5,5,0,4819,2,46,2,1,91,91,0,0,5,6,0,4728,2,46,0,1,91,91,0,0,5,7,0,4637,2,46,2,1,91,91,0,0,5,8,0,4546,2,46,3,1,91,91,0,0,5,9,0,4455,2,46,25,1,91,91,0,0,5,10,0,4364,2,46,1,1,91,91,0,0,5,11,0,4273,2,46,6,1,91,91,0,0,5,12,0,4182,2,46,2,1,91,91,0,0,5,13,0,4091,2,46,7,1,91,166,0,0,5,14,0,4000,2,46,25,1,166,167,0,0,5,15,0,3834,2,46,19,1,167,167,0,0,5,16,0,3667,2,46,0,1,167,166,0,0,5,17,0,3500,2,46,12,1,166,167,0,0,5,18,0,3334,2,46,0,1,167,167,0,0,5,19,0,3167,2,46,10,1,167,200,0,0,5,20,0,3000,2,46,2,1,200,200,0,0,5,21,0,2800,2,46,6,1,200,200,0,0,5,22,0,2600,2,46,21,1,200,200,0,0,5,23,0,2400,2,46,14,1,200,200,0,0,5,24,0,2200,2,46,22,1,200,200,0,0,5,25,0,2000,2,46,0,1,200,200,0,0,5,26,0,1800,2,46,34,1,200,200,0,0,5,27,0,1600,2,46,0,1,200,200,0,0,5,28,0,1400,2,46,32,1,200,200,0,0,5,29,0,1200,2,46,14,1,200,500,0,0,5,30,0,1000,2,46,32,1,500,500,0,0,5,31,0,500,2,46,0,1,500,250,0,0,5,32,0,3000,1,46,150,31,250,250,0,0,5,31,0,2750,2,46,8,1,250,250,0,0,5,32,0,2500,2,46,0,1,250,250,0,0,5,33,0,2250,2,46,4,1,250,250,0,0,5,34,0,2000,2,46,0,1,250,250,0,0,5,35,0,1750,2,46,33,1,250,250,0,0,5,36,0,1500,2,46,37,1,250,250,0,0,5,37,0,1250,2,46,14,1,250,142,0,0,5,38,0,1000,2,46,14,1,142,143,0,0,5,39,0,858,2,46,0,1,143,143,0,0,5,40,0,715,2,46,11,1,143,143,0,0,5,41,0,572,2,46,0,1,143,143,0,0,5,42,0,429,2,46,20,1,143,143,0,0,5,43,0,286,2,46,14,1,143,143,0,0,5,44,0,143,2,46,0,1,143,333,0,0,5,45,0,333,1,46,100,44,333,333,0,0,5,44,0,333,1,46,100,43,333,334,0,0,5,43,0,334,1,46,100,42,334,500,0,0,5,42,0,500,1,46,100,41,500,500,0,0,5,41,0,2000,1,46,150,40,500,200,0,0,5,40,0,1500,2,46,4,1,200,200,0,0,5,41,0,1300,2,46,0,1,200,200,0,0,5,42,0,1100,2,46,20,1,200,200,0,0,5,43,0,900,2,46,14,1,200,200,0,0,5,44,0,700,2,46,0,1,200,250,0,0,5,45,0,500,2,46,11,1,250,250,0,0,5,46,0,250,2,46,0,1,250,250,0,0,5,47,0,1134833,1,46,150,46,250,250,0,0,5,46,0,1107,1,49,0,3,250,142,0,0,6,3,0,857,2,49,0,3,142,143,0,0,6,6,0,715,2,49,0,3,143,143,0,0,6,9,0,572,2,49,0,3,143,143,0,0,6,12,0,429,2,49,0,3,143,143,0,0,6,15,0,286,2,49,0,3,143,143,0,0,6,18,0,143,2,49,0,3,143,143,0,0,6,21,0,143,1,49,0,20,143,200,0,0,6,20,0,1135833,1,49,0,19,200,200,0,0,6,19,0,1135633,2,49,10,1,200,200,0,0,6,20,0,1135433,2,49,2,1,200,200,0,0,6,21,0,1135233,2,49,6,1,200,200,0,0,6,22,0,1135033,2,49,21,1,200,166,0,0,6,23,0,1134833,2,4Line truncated
|
||||
events.push(1);events.push(0);function e(id){return document.getElementById(id);}function Init(){var t0=0;for(var i=0;i<events.length;i+=6){events[i]+=t0;t0=events[i];if(events[i+1]==0) events[i+1]=max_time+1;else events[i+1]+=events[i];}var background='<pre style="margin:0px">\n';for(var i=0;i<max_file_size;i++)
|
||||
background+="\n";background+="<\57pre>";var layer_style="position:absolute;top:0px;left:0px;margin:0px;";document.write(
|
||||
'<div style="position:fixed;top:0px;right:0px;padding:2px;background-color:#fff;border:1px solid #00f;z-index:3" onmouseover="ForegroundControl()" onmouseout="BackgroundControl()" id=control><input type=button value="play 1x" onclick="Play(1)"> <input type=button value="play 3x" onclick="Play(3)"> <input type=button value="play 10x" onclick="Play(10)"> <input type=button value="play 30x" onclick="Play(30)"> <input type=button value="play 60x" onclick="Play(60)"> <input type=button value="pause" onclick="Pause()"> <input type=button value="rewind" onclick="Rewind()"><br><input type=checkbox id=follow name=follow onclick="Follow(this.checked)" checked> <label for=follow>Follow cursor (<span id=cursor_text><\57span>)<\57label> <input type=checkbox id=fast name=fast onclick="FastScroll(this.checked)" checked> <label for=fast>Fast scroll<\57label> <input type=checkbox id=tmp name=tmp onclick="Highlight(this.checked)" checked> <label for=tmp>Highlight transient lines<\57label><br><input type=range name=position id=position min=0 max='+max_time+' step=1 value=0 style="width:400px" onchange="InputSeek(this.value)"> <span id=time><\57span><\57div><div style="position:relative;border:1px solid">'+background+
|
||||
'<pre style="'+layer_style+'background-color:#fff;color:#fff;z-index:1" id=cursor><\57pre><pre style="'+layer_style+'color:#000;z-index:2" id=text><\57pre><\57div>');var output=e("text");for(var i=0;i<slots.length;i++){var span=document.createElement("span");span.id="slot"+i;output.appendChild(span);}Rewind();}function Animate(){Seek(current_time+step);UpdateProgress();}function Play(speed){step=realtime_step*speed;if(timer)
|
||||
clearTimeout(timer);timer=setTimeout("Animate()",realtime_step);}function Pause(){if(step!=0){step=0;Seek(current_time);UpdateProgress();}else{Play(1);}}function Reset(){for(var i=0;i<slots.length;i++){slots[i]=null;update_slots[i]="";var x=e("slot"+i);x.innerHTML="";x.className="tmp";x.style.display="none";}current_event=0;}function Scroll(){var c=e("cursor_block");if(c){var y=c.offsetTop;y-=64;if(y<0) y=0;var delta=y-window.scrollY;if(!fast_scroll||(delta>-80 && delta<window.innerHeight-64))
|
||||
delta/=fps;if(Math.abs(delta)>0){window.scrollTo(window.scrollX,window.scrollY+delta);return true;}}return false;}function ResetScroll(){if(Scroll())
|
||||
timer=setTimeout("ResetScroll()",realtime_step);}function Rewind(){Reset();step=0;Seek(0);UpdateProgress();if(follow)
|
||||
ResetScroll();}function NextFrame(){if(step>0){if(timer)
|
||||
clearTimeout(timer);timer=setTimeout("Animate()",realtime_step);}if(follow)
|
||||
Scroll();}function Seek(position){current_time=position;if(current_time<0)
|
||||
current_time=0;if(current_time>=max_time){current_time=max_time;step=0;}var t=Math.floor(current_time/1000);var s=t%60;var m=Math.floor(t/60);t=m+(s>9?":":":0")+s;e("time").innerHTML=t;if(events[current_event]>current_time){if(current_event>0 && events[current_event-6]<current_time){NextFrame();return;}Reset();}var min_slot=slots.length;var max_slot=0;var cursor_event=-1;for(;events[current_event]<=current_time;current_event+=6){var end_time=events[current_event+1];if(end_time<=current_time)
|
||||
continue;var type=events[current_event+2];if(type==0||type>3){cursor_event=current_event;}else{var i=events[current_event+3];if(type==3){slots[i]=null;}else{var text=string_table[events[current_event+4]].substr(
|
||||
0,events[current_event+5]);if(type==1||slots[i]==null) slots[i]=text;else slots[i]+=text;}if(min_slot>i) min_slot=i;if(max_slot<i) max_slot=i;update_slots[i]=(end_time>=max_time?2:1);}}for(var i=min_slot;i<=max_slot;i++){if(update_slots[i]){var span=e("slot"+i);if(slots[i]!=null){span.innerHTML=slots[i]+"\n";span.style.display="inline";span.className=(update_slots[i]==1?"tmp":"final");}else{span.innerHTML="";span.style.display="none";}update_slots[i]=0;}}if(cursor_event>=0){var text="";var y;var x=events[cursor_event+5];if(events[cursor_event+2]==0){y=events[cursor_event+4];for(var i=0;i<y;i++)
|
||||
text+="\n";for(var i=0;i<x;i++)
|
||||
text+=" ";text+='<span style="background-color:#0f0" id=cursor_block> <\57span>';}else{var s=events[cursor_event+3];for(var i=y=0;i<s;i++){if(slots[i]!=null){y++;text+="\n";}}var line=slots[s]||"";var offset=events[cursor_event+4];while(line.length<=offset)
|
||||
line+=" ";text+=line.substr(0,offset)+
|
||||
'<span style="background-color:#0f0;color:#0f0" id=cursor_block>'+
|
||||
line.substr(offset,events[cursor_event+2]-3)+
|
||||
'<\57span>';}e("cursor").innerHTML=text;e("cursor_text").innerHTML=(y+1)+','+(x+1);}NextFrame();}function InputSeek(position){var t=parseInt(position);if(t>=0)
|
||||
Seek(t);}function UpdateProgress(){e("position").value=current_time;}function Follow(state){follow=state;}function FastScroll(state){fast_scroll=state;}function Highlight(state){var x=document.styleSheets;for(var i=0;i<x.length;i++){var y=x[i].cssRules;for(var j=0;j<y.length;y++){if(y[j].selectorText==".tmp"){y[j].style.color=state?"#00f":"#000";return;}}}}function ForegroundControl(){e("control").style.opacity="1.0";opacity=100;if(opacity_timer){clearTimeout(opacity_timer);opacity_timer=null;}}function BackgroundControl(){e("control").style.opacity=opacity/100;if(opacity>35){opacity-=5;opacity_timer=setTimeout("BackgroundControl()",100);}}Init();</script>
|
||||
</body></html>
|
||||
@@ -0,0 +1,207 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2014 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
|
||||
#CWARN= -Wall -pedantic
|
||||
CWARN= -Wall -Wno-format-extra-args -Wno-parentheses -Wno-return-type
|
||||
|
||||
# compiler standard
|
||||
#
|
||||
#CSTD=
|
||||
#CSTD= -ansi
|
||||
CSTD= -std=c11
|
||||
|
||||
# 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= -ldl
|
||||
|
||||
# default flags for ANSI C compilation
|
||||
#
|
||||
CFLAGS= ${CWARN} ${CSTD} ${ARCH} ${OPT} '-DCC="${CC} -fPIC"'
|
||||
|
||||
# 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= prog
|
||||
DATA=
|
||||
ALT_OBJ= prog.orig.o
|
||||
ALT_ENTRY= prog.orig
|
||||
|
||||
|
||||
#################
|
||||
# build the entry
|
||||
#################
|
||||
#
|
||||
all: ${ENTRY} ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
${ENTRY}: ${ENTRY}.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
||||
|
||||
# alternative executable
|
||||
#
|
||||
alt: ${ALT_ENTRY}
|
||||
@${TRUE}
|
||||
|
||||
${ALT_ENTRY}: ${ALT_ENTRY}.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
||||
|
||||
# data files
|
||||
#
|
||||
data: ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
${RM} -f ${ENTRY}.o ${ALT_OBJ} t.o
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${ENTRY} ${ALT_ENTRY}
|
||||
${RM} -f err static_assert t.c thread_local volatile
|
||||
|
||||
nuke: clobber
|
||||
@${TRUE}
|
||||
|
||||
dist_clean: nuke
|
||||
@${TRUE}
|
||||
|
||||
install:
|
||||
@echo "Surely we are joking Dr. Science!"
|
||||
@${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 sometimes mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Readers shall not be disallowed from failong 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_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 "You are holding it wrong!"; \
|
||||
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 Pauline!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
@@ -0,0 +1,266 @@
|
||||
<!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 dynamic</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most dynamic</h1>
|
||||
|
||||
<p>Cel Skeggs<br>
|
||||
<a href="mailto:ioccc@celskeggs.com">ioccc@celskeggs.com</a><br>
|
||||
<a href="http://www.celskeggs.com">http://www.celskeggs.com</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./prog
|
||||
</code></pre>
|
||||
|
||||
<p>HINT: Try pressing the left and right arrow keys as needed.
|
||||
Also try pressing space/enter to select options.
|
||||
Pressing Q or Escape may end the fun before you are ready. :-)</p>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>When the code looks like lemons, it is probably because the LEMONPEOPLE,
|
||||
or at least the LEMONLORD was involved. :-)</p>
|
||||
|
||||
<p>Look at some of the C pre-processor macros in the source code.
|
||||
Ask yourself why C source is being passed as arguments to some
|
||||
of those macros.</p>
|
||||
|
||||
<p>Now you may observe, while it is running, that some C source code
|
||||
is being written to a file and then compiled. And yet that compiled
|
||||
code is somehow executed from main. But how? How is main able to
|
||||
call code that was written and compiled just in time for execution?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>TABLE OF CONTENTS</h3>
|
||||
|
||||
<ul>
|
||||
<li>Backstory</li>
|
||||
<li>Known compiler warnings</li>
|
||||
<li>Obfuscation</li>
|
||||
<li>Troubleshooting guide (IMPORTANT!)</li>
|
||||
<li>Q&A</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>BACKSTORY</h3>
|
||||
|
||||
<p>It was ten yours ago when THE LEMONPEOPLE invaded, juicing all in their path.</p>
|
||||
|
||||
<p>Attempting to free the Earth from their tyranny, you have endured pulpy and
|
||||
sour battles.</p>
|
||||
|
||||
<p>This has now culminated in you reaching the throne room of THE LEMONLORD.</p>
|
||||
|
||||
<p>Armed with your right-facing curly brace, you charge into battle.</p>
|
||||
|
||||
<p>(Use left and right arrow keys and space/enter to select options. Press Q or
|
||||
Escape to quit.)</p>
|
||||
|
||||
<h3>KNOWN COMPILER WARNINGS</h3>
|
||||
|
||||
<p>Unfortunately, it became very difficult to get this entry to fit within the
|
||||
size requirements. It’s currently at 2052 according to iocccsize, and 3994
|
||||
according to wc -c.</p>
|
||||
|
||||
<p>The current size is a third to a half of the original size before compression.</p>
|
||||
|
||||
<p>Due to this, it does LOTS of things that subtly annoy compilers!</p>
|
||||
|
||||
<ul>
|
||||
<li><p>(10) data argument not used by format string</p>
|
||||
|
||||
<p>This occurs because some of the fprintf invocations don’t use all their
|
||||
parameters. The program should still work fine!</p></li>
|
||||
<li><p>(1) using the result of an assignment as a condition without parentheses</p>
|
||||
|
||||
<p>Somewhere, I needed to set a variable and then branch on the result. The
|
||||
shortest way was to combine them. Some self-proclaimed “EXPERTS” think this
|
||||
is a bad programming practice, but what do they know? :P</p></li>
|
||||
<li><p>(1) implicit declaration of function ‘time’ is invalid in C99</p>
|
||||
|
||||
<p>An <code>#include</code> statement is expensive, and I’m broke.</p></li>
|
||||
<li><p>(1) control may reach end of non-void function</p>
|
||||
|
||||
<p>Turns out that sometimes, a return statement is too much. This will never
|
||||
actually occur, but some C compilers think they know more about my program
|
||||
than I do! :P</p></li>
|
||||
<li><p>(?) Under some systems, <code>-fPIC</code> is irrelevant for shared libraries. If so,
|
||||
you should remove it from the Makefile.</p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>OBFUSCATION? WHAT OBFUSCATION? THIS IS A PERFECTLY NORMAL C PROGRAM!</h2>
|
||||
|
||||
<h1>THE COOL PART</h1>
|
||||
|
||||
<p>Take a close look at how it works. Notice that it’s passing C code to certain
|
||||
macros…</p>
|
||||
|
||||
<p>Guess what? It’s a very simple kind of JIT compiler, though not used as deeply
|
||||
as would be cool.</p>
|
||||
|
||||
<p>Essentially, it generates C code at runtime, dumps it to a file, and then runs
|
||||
a C compiler on that file, telling the C compiler to generate a shared library.
|
||||
Then it loads the shared library with dlopen, and…</p>
|
||||
|
||||
<p>Ignores the result?</p>
|
||||
|
||||
<p>That can’t be right.</p>
|
||||
|
||||
<p>Well, it is. Instead of using dlsym like a normal programmer, I mark one of the
|
||||
generated functions with <code>__attribute__((constructor))</code>. This means that it
|
||||
gets called immediately on load, so it can make its functions available.</p>
|
||||
|
||||
<p>But wait - how can it link into the main program, either? It has no way to
|
||||
reference anything in the main executable!</p>
|
||||
|
||||
<p>But it does: I’m injecting certain addresses into the generated code, which it
|
||||
then casts to pointers and accesses! It uses this to make certain functions
|
||||
available to the main program, so the main program’s generated code will then
|
||||
enter itself where it’s needed.</p>
|
||||
|
||||
<h1>THE NOT-SO-COOL PART</h1>
|
||||
|
||||
<p>There are also lots of <code>#defines</code>.</p>
|
||||
|
||||
<p>No, these are not obfuscation. These are compression.</p>
|
||||
|
||||
<p>There is a little bit of obfuscation gained from using the stringification
|
||||
operator. (I can never remember what it’s actually called, but it’s the #
|
||||
operator in a preprocessor macro) - this allows me to pass C code in arguments
|
||||
to the macros, meaning that it gets interpreted as C code instead of a string
|
||||
by the iocccsize tool, so it gets counted as smaller! :D</p>
|
||||
|
||||
<h1>A SLIGHTLY COOL PART</h1>
|
||||
|
||||
<p>As part of the JIT compiling, the program hides the fact that it needs ncurses:
|
||||
it just links ncurses with one of the generated shared libraries, and then can
|
||||
access the contents of the ncurses library!</p>
|
||||
|
||||
<h1>WAIT WHAT</h1>
|
||||
|
||||
<p>Also, note where functions start and end…</p>
|
||||
|
||||
<p>I’ve messed with the syntax so that it’s not actually formatted properly. It
|
||||
almost looks like it is, but it isn’t.</p>
|
||||
|
||||
<p>This isn’t significant obfuscation as long as you run it through a C source
|
||||
code beautifier.</p>
|
||||
|
||||
<p>But wait… if you aren’t careful, running it through a C source code
|
||||
beautifier won’t work. Remember how I’m interlacing generated C code with
|
||||
actual C code? Note that this WRECKS some beautifiers. I hope you have a good
|
||||
one!</p>
|
||||
|
||||
<p>(There’s an obvious way around this but I’m not going to spell it out for you.
|
||||
That’d be too easy!)</p>
|
||||
|
||||
<h3>MISCELLANEOUS STUFF</h3>
|
||||
|
||||
<p>Do note that there are some other miscellaneous obfuscations, but they should
|
||||
be easy to understand once you figure out the ones above.</p>
|
||||
|
||||
<h3>TROUBLESHOOTING GUIDE</h3>
|
||||
|
||||
<p>This program is a very easy program to cause to fail!</p>
|
||||
|
||||
<p>Some things to check</p>
|
||||
|
||||
<ul>
|
||||
<li>On line 16, where it says <code>%cinclude "prog.c"</code>, is <code>prog.c</code> the name of the
|
||||
original source code file?</li>
|
||||
<li>Do you have ncurses installed?</li>
|
||||
<li><p>Does your system have <code>ncurses.h</code> (like a nice system) or
|
||||
<code>ncurses/ncurses.h</code> (like a rude system) ?</p>
|
||||
|
||||
<p>If it’s the latter (or some other path), you’ll need to update line 97.</p>
|
||||
|
||||
<p>(I had to do this under Cygwin.)</p></li>
|
||||
<li>Does your system need <code>-fPIC</code> (or other arcane invocations) to compile a
|
||||
shared library? If so, make sure that you include it in the -DCC argument in
|
||||
the build script.</li>
|
||||
<li>Does your system have a vague dislike for <code>-fPIC</code>? (Like Cygwin.) You might
|
||||
need to remove it from the build script.</li>
|
||||
<li>Does your system support <code>__attribute__((constructor))</code>? It needs to.</li>
|
||||
<li>Check the file <code>err</code>. Maybe it will help you figure out why a runtime-
|
||||
generated program failed. The failing program should be found in <code>t.c</code>.</li>
|
||||
<li>Can’t run a beautifier on the source code? I’m not going to help you there.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>I’ve tested it on the following platforms, in case you need to try it on one:</p>
|
||||
|
||||
<ul>
|
||||
<li>64-bit Windows 7 32-bit Cygwin with gcc 4.8.2 and standards c89, c90, c99,
|
||||
and c11. Note that the program ran as 32-bit due to the version of cygwin.</li>
|
||||
<li>64-bit Arch Linux with gcc 4.9.1 and standards c89, c90, c99, c11.</li>
|
||||
<li>64-bit Arch Linux with clang 3.5.0 and standards c89 and c11.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>I ran out of time to test it on more systems.</p>
|
||||
|
||||
<h3>Q&A</h3>
|
||||
|
||||
<ul>
|
||||
<li><p>Who am I?</p>
|
||||
|
||||
<p>Yes.</p></li>
|
||||
<li><p>Why doesn’t your program require a pet fish license?</p>
|
||||
|
||||
<p>THE LEMONLORD’s pet LEMONFISH was not rendered in the game, and so does not
|
||||
require a pet fish license.</p></li>
|
||||
<li><p>Was this inspired by anything?</p>
|
||||
|
||||
<p>Yes, this was inspired by a minigame from an open-source codebase of Space
|
||||
Station 13. I didn’t, however, look at the minigame at all during the
|
||||
development of this entry.</p></li>
|
||||
<li><p>What’s the length of this REMARKS file according to the iocccsize tool?</p>
|
||||
|
||||
<p><code>$ ./iocccsize -i <REMARKS.MD</code></p>
|
||||
|
||||
<p><code>5092</code></p></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<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,231 @@
|
||||
# Most dynamic
|
||||
|
||||
Cel Skeggs
|
||||
<ioccc@celskeggs.com>
|
||||
<http://www.celskeggs.com>
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
### To build:
|
||||
|
||||
make
|
||||
|
||||
### To run:
|
||||
|
||||
./prog
|
||||
|
||||
### Try:
|
||||
|
||||
./prog
|
||||
|
||||
HINT: Try pressing the left and right arrow keys as needed.
|
||||
Also try pressing space/enter to select options.
|
||||
Pressing Q or Escape may end the fun before you are ready. :-)
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
When the code looks like lemons, it is probably because the LEMONPEOPLE,
|
||||
or at least the LEMONLORD was involved. :-)
|
||||
|
||||
Look at some of the C pre-processor macros in the source code.
|
||||
Ask yourself why C source is being passed as arguments to some
|
||||
of those macros.
|
||||
|
||||
Now you may observe, while it is running, that some C source code
|
||||
is being written to a file and then compiled. And yet that compiled
|
||||
code is somehow executed from main. But how? How is main able to
|
||||
call code that was written and compiled just in time for execution?
|
||||
|
||||
## Author's comments:
|
||||
### TABLE OF CONTENTS
|
||||
|
||||
* Backstory
|
||||
* Known compiler warnings
|
||||
* Obfuscation
|
||||
* Troubleshooting guide (IMPORTANT!)
|
||||
* Q&A
|
||||
|
||||
### BACKSTORY
|
||||
|
||||
It was ten yours ago when THE LEMONPEOPLE invaded, juicing all in their path.
|
||||
|
||||
Attempting to free the Earth from their tyranny, you have endured pulpy and
|
||||
sour battles.
|
||||
|
||||
This has now culminated in you reaching the throne room of THE LEMONLORD.
|
||||
|
||||
Armed with your right-facing curly brace, you charge into battle.
|
||||
|
||||
(Use left and right arrow keys and space/enter to select options. Press Q or
|
||||
Escape to quit.)
|
||||
|
||||
### KNOWN COMPILER WARNINGS
|
||||
|
||||
Unfortunately, it became very difficult to get this entry to fit within the
|
||||
size requirements. It's currently at 2052 according to iocccsize, and 3994
|
||||
according to wc -c.
|
||||
|
||||
The current size is a third to a half of the original size before compression.
|
||||
|
||||
Due to this, it does LOTS of things that subtly annoy compilers!
|
||||
|
||||
* (10) data argument not used by format string
|
||||
|
||||
This occurs because some of the fprintf invocations don't use all their
|
||||
parameters. The program should still work fine!
|
||||
|
||||
* (1) using the result of an assignment as a condition without parentheses
|
||||
|
||||
Somewhere, I needed to set a variable and then branch on the result. The
|
||||
shortest way was to combine them. Some self-proclaimed "EXPERTS" think this
|
||||
is a bad programming practice, but what do they know? :P
|
||||
|
||||
* (1) implicit declaration of function 'time' is invalid in C99
|
||||
|
||||
An `#include` statement is expensive, and I'm broke.
|
||||
|
||||
* (1) control may reach end of non-void function
|
||||
|
||||
Turns out that sometimes, a return statement is too much. This will never
|
||||
actually occur, but some C compilers think they know more about my program
|
||||
than I do! :P
|
||||
|
||||
* (?) Under some systems, `-fPIC` is irrelevant for shared libraries. If so,
|
||||
you should remove it from the Makefile.
|
||||
|
||||
## OBFUSCATION? WHAT OBFUSCATION? THIS IS A PERFECTLY NORMAL C PROGRAM!
|
||||
|
||||
# THE COOL PART
|
||||
|
||||
Take a close look at how it works. Notice that it's passing C code to certain
|
||||
macros...
|
||||
|
||||
Guess what? It's a very simple kind of JIT compiler, though not used as deeply
|
||||
as would be cool.
|
||||
|
||||
Essentially, it generates C code at runtime, dumps it to a file, and then runs
|
||||
a C compiler on that file, telling the C compiler to generate a shared library.
|
||||
Then it loads the shared library with dlopen, and...
|
||||
|
||||
Ignores the result?
|
||||
|
||||
That can't be right.
|
||||
|
||||
Well, it is. Instead of using dlsym like a normal programmer, I mark one of the
|
||||
generated functions with `__attribute__((constructor))`. This means that it
|
||||
gets called immediately on load, so it can make its functions available.
|
||||
|
||||
But wait - how can it link into the main program, either? It has no way to
|
||||
reference anything in the main executable!
|
||||
|
||||
But it does: I'm injecting certain addresses into the generated code, which it
|
||||
then casts to pointers and accesses! It uses this to make certain functions
|
||||
available to the main program, so the main program's generated code will then
|
||||
enter itself where it's needed.
|
||||
|
||||
# THE NOT-SO-COOL PART
|
||||
|
||||
There are also lots of `#defines`.
|
||||
|
||||
No, these are not obfuscation. These are compression.
|
||||
|
||||
There is a little bit of obfuscation gained from using the stringification
|
||||
operator. (I can never remember what it's actually called, but it's the #
|
||||
operator in a preprocessor macro) - this allows me to pass C code in arguments
|
||||
to the macros, meaning that it gets interpreted as C code instead of a string
|
||||
by the iocccsize tool, so it gets counted as smaller! :D
|
||||
|
||||
# A SLIGHTLY COOL PART
|
||||
|
||||
As part of the JIT compiling, the program hides the fact that it needs ncurses:
|
||||
it just links ncurses with one of the generated shared libraries, and then can
|
||||
access the contents of the ncurses library!
|
||||
|
||||
# WAIT WHAT
|
||||
|
||||
Also, note where functions start and end...
|
||||
|
||||
I've messed with the syntax so that it's not actually formatted properly. It
|
||||
almost looks like it is, but it isn't.
|
||||
|
||||
This isn't significant obfuscation as long as you run it through a C source
|
||||
code beautifier.
|
||||
|
||||
But wait... if you aren't careful, running it through a C source code
|
||||
beautifier won't work. Remember how I'm interlacing generated C code with
|
||||
actual C code? Note that this WRECKS some beautifiers. I hope you have a good
|
||||
one!
|
||||
|
||||
(There's an obvious way around this but I'm not going to spell it out for you.
|
||||
That'd be too easy!)
|
||||
|
||||
### MISCELLANEOUS STUFF
|
||||
|
||||
Do note that there are some other miscellaneous obfuscations, but they should
|
||||
be easy to understand once you figure out the ones above.
|
||||
|
||||
### TROUBLESHOOTING GUIDE
|
||||
|
||||
This program is a very easy program to cause to fail!
|
||||
|
||||
Some things to check
|
||||
|
||||
* On line 16, where it says `%cinclude "prog.c"`, is `prog.c` the name of the
|
||||
original source code file?
|
||||
* Do you have ncurses installed?
|
||||
* Does your system have `ncurses.h` (like a nice system) or
|
||||
`ncurses/ncurses.h` (like a rude system) ?
|
||||
|
||||
If it's the latter (or some other path), you'll need to update line 97.
|
||||
|
||||
(I had to do this under Cygwin.)
|
||||
* Does your system need `-fPIC` (or other arcane invocations) to compile a
|
||||
shared library? If so, make sure that you include it in the -DCC argument in
|
||||
the build script.
|
||||
* Does your system have a vague dislike for `-fPIC`? (Like Cygwin.) You might
|
||||
need to remove it from the build script.
|
||||
* Does your system support `__attribute__((constructor))`? It needs to.
|
||||
* Check the file `err`. Maybe it will help you figure out why a runtime-
|
||||
generated program failed. The failing program should be found in `t.c`.
|
||||
* Can't run a beautifier on the source code? I'm not going to help you there.
|
||||
|
||||
I've tested it on the following platforms, in case you need to try it on one:
|
||||
|
||||
* 64-bit Windows 7 32-bit Cygwin with gcc 4.8.2 and standards c89, c90, c99,
|
||||
and c11. Note that the program ran as 32-bit due to the version of cygwin.
|
||||
* 64-bit Arch Linux with gcc 4.9.1 and standards c89, c90, c99, c11.
|
||||
* 64-bit Arch Linux with clang 3.5.0 and standards c89 and c11.
|
||||
|
||||
I ran out of time to test it on more systems.
|
||||
|
||||
### Q&A
|
||||
|
||||
* Who am I?
|
||||
|
||||
Yes.
|
||||
|
||||
* Why doesn't your program require a pet fish license?
|
||||
|
||||
THE LEMONLORD's pet LEMONFISH was not rendered in the game, and so does not
|
||||
require a pet fish license.
|
||||
|
||||
* Was this inspired by anything?
|
||||
|
||||
Yes, this was inspired by a minigame from an open-source codebase of Space
|
||||
Station 13. I didn't, however, look at the minigame at all during the
|
||||
development of this entry.
|
||||
|
||||
* What's the length of this REMARKS file according to the iocccsize tool?
|
||||
|
||||
`$ ./iocccsize -i <REMARKS.MD`
|
||||
|
||||
`5092`
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(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/
|
||||
-->
|
||||
@@ -0,0 +1,126 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <dlfcn.h>
|
||||
#include <time.h>
|
||||
|
||||
typedef int (*and_eq)();
|
||||
|
||||
typedef struct {
|
||||
and_eq T[15];
|
||||
int U[6];
|
||||
void *V;
|
||||
} W;
|
||||
|
||||
#define struct(z, x, y) FILE*q = fopen("t.c", "w"); E(%cinclude "prog.c"\n extern void bitand() __attribute__((constructor)); \n, 35, 9); z fclose(q); if (system(CC " -DCC= -shared t.c -o " #x " " #y " 2>err")) exit(3); { dlopen("./" #x, RTLD_LAZY); }
|
||||
#define E(x, v, w) fprintf(q, #x, v, w);
|
||||
#define H "THE LEMONLORD"
|
||||
#define Q (intptr_t)&
|
||||
#define O(x) = (J(x)(V.V) - 32 / x) / 2,
|
||||
#define R(x, y) E(J(3)(%d, %d, B(0) == x ? "{" #y "} " : " " #y); , o + 12, a += (3 + 5*x) | 1 )
|
||||
#define A(x) ((W *)x)->
|
||||
#define Z "%5d"
|
||||
#define B(x) V.U[x]
|
||||
#define J(x) V.T[x]
|
||||
#define restrict sprintf
|
||||
|
||||
char M[99] = " { { DEFEAT "H" } } ";
|
||||
|
||||
W V;
|
||||
|
||||
void xor_eq() {
|
||||
int a O(1) b O(2) o = b;
|
||||
if (J(14)) { J(14)();
|
||||
return;
|
||||
}
|
||||
|
||||
struct(E(
|
||||
|
||||
int k() {
|
||||
V = *(W *)%td;
|
||||
char *y = (char*) %td; , Q V, Q M)
|
||||
E(int x = %d; , a, a)
|
||||
char *x = "\0; ; ; ; ; ; ; ; ;; ; ; ; ; ; ; ; ; \0{ } \0{ } \0{ } \0{ } \0{ {HP} {MP} {HP} {MP} } \0{ } \0{ O O } \0{ /|-} {-|\\\\ } \0{ | | } \0{ / \\\\ / \\\\ } \0{ } \0{ } \0{ } \0; ; ; ; ; ; ; ; ;; ; ; ; ; ; ; ; ; \0";
|
||||
while (*++x) for (E(J(3)(%d, x, "%s"); , b++, x)*++x; ); {
|
||||
R(0, ATTACK)
|
||||
R(1, REGENERATE)
|
||||
R(2, HEAL)
|
||||
}
|
||||
E(J(3)(%d, %d - strlen(y) / 2, y); char d[99]; , o+2, a - 8)
|
||||
E(restrict(d, Z Z " " Z Z, B(1), B(3), B(2), B(4)); J(3)(%d, %d, d); , o + 4, a - 24)
|
||||
E(J(4)();
|
||||
}
|
||||
|
||||
void bitand() {
|
||||
A(%td)T[14] = k; } , Q V, V)
|
||||
, volatile, )
|
||||
xor_eq();
|
||||
}
|
||||
|
||||
#define S(x) 1 + rand() % (x)
|
||||
#define Y(x) restrict(M,#x,D)
|
||||
|
||||
void N() {
|
||||
int c = 0;
|
||||
xor_eq();
|
||||
if (B(5) = (B(1) * B(2) < 1)) {
|
||||
for (; !sleep(++c) && c < 3; xor_eq()) {
|
||||
char *D = ((B(1) < 1) + c) & 1 ? H " has" : "You have";
|
||||
c & 1 ? Y(%s died!) : Y(%s won!);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define X(a, n, b, g, f) switch (B(n) a) { case 0: D = S(16 - 4*n); B(2-n) -= D; Y(b hit for %d!); break; case 1: D = S(10-6*n); g; B(3+n) += D; Y(b f %d MP!); break; case 2: D = 33; if (B(3+n) > 1) { B(3+n) -= S(2); B(1+n) += D = S(18 + 6*n); Y(b heal %d!); } else { Y(b need more MP%c); u = 1; } break; } N(); if (B(5) | u | n) { return 2; }
|
||||
|
||||
int x() {
|
||||
int u = 0, D;
|
||||
X(, 0, You, , gain)
|
||||
sleep(1);
|
||||
X(< 9 ? 0 : B(2) < 20 ? B(4) < 2 ? B(3) >= 1 : 2 : B(4) < 5 && S(3) != 1 && !(B(3) < 1) ? 1 : S(8) > 6 && (B(3) || B(4) > 1) ? 1 + (B(4) > 9 || B(3) < 1) : 0, 1, They, if (B(3) < D) { D = B(3); } B(3) -= D, steal) } int w(int *p, and_eq *P) {
|
||||
int r = 9;
|
||||
struct(
|
||||
E(int f(int x) { switch(x) { , 0, 0)
|
||||
while (*p) {
|
||||
E(case %d: return ((and_eq) %td)(); , r += *(p++), Q **(P++)); }
|
||||
E(} return 1; } void bitand() { A(%td) T[13] = f; } , Q V, 1)
|
||||
, thread_local, )
|
||||
return p[-2];
|
||||
} int u() {
|
||||
return B(5) = 1;
|
||||
}
|
||||
|
||||
int main(int j, char **v) {
|
||||
srand(time(0));
|
||||
struct(
|
||||
E(#include <ncurses.h>\n void F() { endwin(); puts("Play again?"); } int g() { int o = getch(); return o == KEY_LEFT ? -1 : o == KEY_RIGHT ? -2 : o;
|
||||
}
|
||||
|
||||
void bitand() {
|
||||
and_eq *G = A(%td) T - 1; , Q V, 8);
|
||||
char *i = "\0keypad\0getmaxx\0getmaxy\0mvaddstr\0refresh\0g\0cbreak\0noecho\0nonl\0";
|
||||
memcpy(V.U, ((int[6]) { 0, 30, 50, 5, 10, 0}) , 6 * sizeof(int));
|
||||
while (*++i) {
|
||||
E(*++G = (and_eq) %s; , i, i);
|
||||
while (*++i);
|
||||
}
|
||||
E(initscr(); A(%td)V = stdscr; atexit(F); } , Q V, i)
|
||||
, static_assert, -lncurses)
|
||||
for (j = 6; j < 9; ) {
|
||||
J(j++)();
|
||||
}
|
||||
J(0)(V.V, 1);
|
||||
for (; !B(5); ) {
|
||||
xor_eq();
|
||||
j = J(5)();
|
||||
if (j & (~((1+~1U) >> 1))) {
|
||||
B(0) = (B(0) + j + 3) % 3;
|
||||
} else {
|
||||
J(13) || w((int[]) { 1, 3, 14, 5, 49, 32, 0} , (and_eq[]) { x, x, u, x, u, u} );
|
||||
J(13)(j);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
typedef int (*and_eq)();
|
||||
|
||||
typedef struct {
|
||||
and_eq T[15];
|
||||
int U[6];
|
||||
void *V;
|
||||
} W;
|
||||
|
||||
#define struct(z, x, y) FILE*q = fopen("t.c", "w"); E(%cinclude "prog.c"\n extern void bitand() __attribute__((constructor)); \n, 35, 9); z fclose(q); if (system(CC " -DCC= -shared t.c -o " #x " " #y " 2>err")) exit(3); { dlopen("./" #x, RTLD_LAZY); }
|
||||
#define E(x, v, w) fprintf(q, #x, v, w);
|
||||
#define H "THE LEMONLORD"
|
||||
#define Q (intptr_t)&
|
||||
#define O(x) = (J(x)(V.V) - 32 / x) / 2,
|
||||
#define R(x, y) E(J(3)(%d, %d, B(0) == x ? "{" #y "} " : " " #y); , o + 12, a += (3 + 5*x) | 1 )
|
||||
#define A(x) ((W *)x)->
|
||||
#define Z "%5d"
|
||||
#define B(x) V.U[x]
|
||||
#define J(x) V.T[x]
|
||||
#define restrict sprintf
|
||||
|
||||
char M[99] = " { { DEFEAT "H" } } ";
|
||||
|
||||
W V;
|
||||
|
||||
void xor_eq() {
|
||||
int a O(1) b O(2) o = b;
|
||||
if (J(14)) { J(14)();
|
||||
return;
|
||||
}
|
||||
|
||||
struct(E(
|
||||
|
||||
int k() {
|
||||
V = *(W *)%td;
|
||||
char *y = (char*) %td; , Q V, Q M)
|
||||
E(int x = %d; , a, a)
|
||||
char *x = "\0; ; ; ; ; ; ; ; ;; ; ; ; ; ; ; ; ; \0{ } \0{ } \0{ } \0{ } \0{ {HP} {MP} {HP} {MP} } \0{ } \0{ O O } \0{ /|-} {-|\\\\ } \0{ | | } \0{ / \\\\ / \\\\ } \0{ } \0{ } \0{ } \0; ; ; ; ; ; ; ; ;; ; ; ; ; ; ; ; ; \0";
|
||||
while (*++x) for (E(J(3)(%d, x, "%s"); , b++, x)*++x; ); {
|
||||
R(0, ATTACK)
|
||||
R(1, REGENERATE)
|
||||
R(2, HEAL)
|
||||
}
|
||||
E(J(3)(%d, %d - strlen(y) / 2, y); char d[99]; , o+2, a - 8)
|
||||
E(restrict(d, Z Z " " Z Z, B(1), B(3), B(2), B(4)); J(3)(%d, %d, d); , o + 4, a - 24)
|
||||
E(J(4)();
|
||||
}
|
||||
|
||||
void bitand() {
|
||||
A(%td)T[14] = k; } , Q V, V)
|
||||
, volatile, )
|
||||
xor_eq();
|
||||
}
|
||||
|
||||
#define S(x) 1 + rand() % (x)
|
||||
#define Y(x) restrict(M,#x,D)
|
||||
|
||||
void N() {
|
||||
int c = 0;
|
||||
xor_eq();
|
||||
if (B(5) = (B(1) * B(2) < 1)) {
|
||||
for (; !sleep(++c) && c < 3; xor_eq()) {
|
||||
char *D = ((B(1) < 1) + c) & 1 ? H " has" : "You have";
|
||||
c & 1 ? Y(%s died!) : Y(%s won!);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define X(a, n, b, g, f) switch (B(n) a) { case 0: D = S(16 - 4*n); B(2-n) -= D; Y(b hit for %d!); break; case 1: D = S(10-6*n); g; B(3+n) += D; Y(b f %d MP!); break; case 2: D = 33; if (B(3+n) > 1) { B(3+n) -= S(2); B(1+n) += D = S(18 + 6*n); Y(b heal %d!); } else { Y(b need more MP%c); u = 1; } break; } N(); if (B(5) | u | n) { return 2; }
|
||||
|
||||
int x() {
|
||||
int u = 0, D;
|
||||
X(, 0, You, , gain)
|
||||
sleep(1);
|
||||
X(< 9 ? 0 : B(2) < 20 ? B(4) < 2 ? B(3) >= 1 : 2 : B(4) < 5 && S(3) != 1 && !(B(3) < 1) ? 1 : S(8) > 6 && (B(3) || B(4) > 1) ? 1 + (B(4) > 9 || B(3) < 1) : 0, 1, They, if (B(3) < D) { D = B(3); } B(3) -= D, steal) } int w(int *p, and_eq *P) {
|
||||
int r = 9;
|
||||
struct(
|
||||
E(int f(int x) { switch(x) { , 0, 0)
|
||||
while (*p) {
|
||||
E(case %d: return ((and_eq) %td)(); , r += *(p++), Q **(P++)); }
|
||||
E(} return 1; } void bitand() { A(%td) T[13] = f; } , Q V, 1)
|
||||
, thread_local, )
|
||||
return p[-2];
|
||||
} int u() {
|
||||
return B(5) = 1;
|
||||
}
|
||||
|
||||
int main(int j, char **v) {
|
||||
srand(time(0));
|
||||
struct(
|
||||
E(#include <ncurses.h>\n void F() { endwin(); puts("Play again?"); } int g() { int o = getch(); return o == KEY_LEFT ? -1 : o == KEY_RIGHT ? -2 : o;
|
||||
}
|
||||
|
||||
void bitand() {
|
||||
and_eq *G = A(%td) T - 1; , Q V, 8);
|
||||
char *i = "\0keypad\0getmaxx\0getmaxy\0mvaddstr\0refresh\0g\0cbreak\0noecho\0nonl\0";
|
||||
memcpy(V.U, (int[6]) { 0, 30, 50, 5, 10, 0} , 6 * sizeof(int));
|
||||
while (*++i) {
|
||||
E(*++G = (and_eq) %s; , i, i);
|
||||
while (*++i);
|
||||
}
|
||||
E(initscr(); A(%td)V = stdscr; atexit(F); } , Q V, i)
|
||||
, static_assert, -lncurses)
|
||||
for (j = 6; j < 9; ) {
|
||||
J(j++)();
|
||||
}
|
||||
J(0)(V.V, 1);
|
||||
for (; !B(5); ) {
|
||||
xor_eq();
|
||||
j = J(5)();
|
||||
if (j & (~((1+~1U) >> 1))) {
|
||||
B(0) = (B(0) + j + 3) % 3;
|
||||
} else {
|
||||
J(13) || w((int[]) { 1, 3, 14, 5, 49, 32, 0} , (and_eq[]) { x, x, u, x, u, u} );
|
||||
J(13)(j);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2014 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
|
||||
#CWARN= -Wall -pedantic
|
||||
|
||||
# compiler standard
|
||||
#
|
||||
#CSTD=
|
||||
#CSTD= -ansi
|
||||
CSTD= -std=c11
|
||||
|
||||
# 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= prog
|
||||
DATA=
|
||||
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}
|
||||
@${TRUE}
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
${RM} -f ${ENTRY}.o ${ALT_OBJ}
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${ENTRY} ${ALT_ENTRY}
|
||||
|
||||
nuke: clobber
|
||||
@${TRUE}
|
||||
|
||||
dist_clean: nuke
|
||||
@${TRUE}
|
||||
|
||||
install:
|
||||
@echo "Surely we are joking Dr. Science!"
|
||||
@${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 sometimes mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Readers shall not be disallowed from failong 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_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 "You are holding it wrong!"; \
|
||||
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 Pauline!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
@@ -0,0 +1,120 @@
|
||||
<!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 handling of beeps</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best handling of beeps</h1>
|
||||
|
||||
<p>Daniel Vik<br>
|
||||
<a href="mailto:daniel@vik.cc">daniel@vik.cc</a><br>
|
||||
<a href="http://danielvik.com/">http://danielvik.com/</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./prog > foo.c
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>echo 'Want to hear me beep?' | ./prog > audio_file.raw
|
||||
|
||||
echo 'No. I want chocolate!' | ./prog | mplayer -demuxer rawaudio -
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This program sets a new tone for obfuscation. But do you understand
|
||||
what it says about obfuscation? Perhaps:</p>
|
||||
|
||||
<pre><code>./prog < prog.c > prog.raw
|
||||
</code></pre>
|
||||
|
||||
<p>might speak to your coding style? If not, then perhaps:</p>
|
||||
|
||||
<pre><code>./prog < remarks.markdown | mplayer -demuxer rawaudio -
|
||||
</code></pre>
|
||||
|
||||
<p>might help? :-)</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Remarks</h3>
|
||||
|
||||
<p>This program converts ascii text to morse audio file and vice versa. As far as
|
||||
I can tell, there are at least six chocolate references in this program.</p>
|
||||
|
||||
<p>This program can convert text to morse to a raw 44.1kHz stereo audio file.
|
||||
Via streaming to mplayer, you can listen to the morse audio.</p>
|
||||
|
||||
<p>Don’t forget the last ‘-’ as it makes mplayer read from stdin.)</p>
|
||||
|
||||
<h2>Convert audio file with morse signals to text</h2>
|
||||
|
||||
<pre><code>$ ./prog e < audio_file.raw
|
||||
</code></pre>
|
||||
|
||||
<p>or alternatively pass a .wav file as input.</p>
|
||||
|
||||
<p>The preferred input format 44.1kHz stereo, but it does a decent job on mono
|
||||
input and different frequencies as well.</p>
|
||||
|
||||
<h3>Portability</h3>
|
||||
|
||||
<p>The program is portable to most platforms. The only system dependency is that
|
||||
the program relies on writing binary data to stdout.</p>
|
||||
|
||||
<p>Microsoft compilers adds a carriage return to newlines, and to compile the
|
||||
program with this platform, the following line can be added after the main
|
||||
declaration in order for the program to run correctly:</p>
|
||||
|
||||
<pre><code>_setmode(_fileno(stdout), 0x8000);
|
||||
</code></pre>
|
||||
|
||||
<h3>Known Issues</h3>
|
||||
|
||||
<p>The program uses a quite simple algorithm for detecting tone on and off events
|
||||
in the morse signal. Hence the program does not work well with noisy input
|
||||
signals. I have tested it with several samples of man made morse recordings as
|
||||
well as computer generated ones.</p>
|
||||
|
||||
<p>Generally, any recording from ham radio transmissions does not decode due to
|
||||
noise and echoes. Other man made recordings may decode, but some characters
|
||||
can be incorrect due to too big variation in length of tones and pauses.
|
||||
However I found some man made recordings on that decode reasonable well.</p>
|
||||
|
||||
<p>If a recording don’t decode, you could try to pre-process the input with a
|
||||
narrow bandpass filter on the frequency of the transmission.</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,89 @@
|
||||
# Best handling of beeps
|
||||
|
||||
Daniel Vik
|
||||
<daniel@vik.cc>
|
||||
<http://danielvik.com/>
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
### To build:
|
||||
|
||||
make
|
||||
|
||||
### To run:
|
||||
|
||||
./prog > foo.c
|
||||
|
||||
### Try:
|
||||
|
||||
echo 'Want to hear me beep?' | ./prog > audio_file.raw
|
||||
|
||||
echo 'No. I want chocolate!' | ./prog | mplayer -demuxer rawaudio -
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
This program sets a new tone for obfuscation. But do you understand
|
||||
what it says about obfuscation? Perhaps:
|
||||
|
||||
./prog < prog.c > prog.raw
|
||||
|
||||
might speak to your coding style? If not, then perhaps:
|
||||
|
||||
./prog < remarks.markdown | mplayer -demuxer rawaudio -
|
||||
|
||||
might help? :-)
|
||||
|
||||
## Author's comments:
|
||||
### Remarks
|
||||
|
||||
This program converts ascii text to morse audio file and vice versa. As far as
|
||||
I can tell, there are at least six chocolate references in this program.
|
||||
|
||||
This program can convert text to morse to a raw 44.1kHz stereo audio file.
|
||||
Via streaming to mplayer, you can listen to the morse audio.
|
||||
|
||||
Don't forget the last '-' as it makes mplayer read from stdin.)
|
||||
|
||||
## Convert audio file with morse signals to text
|
||||
|
||||
$ ./prog e < audio_file.raw
|
||||
|
||||
or alternatively pass a .wav file as input.
|
||||
|
||||
The preferred input format 44.1kHz stereo, but it does a decent job on mono
|
||||
input and different frequencies as well.
|
||||
|
||||
### Portability
|
||||
|
||||
The program is portable to most platforms. The only system dependency is that
|
||||
the program relies on writing binary data to stdout.
|
||||
|
||||
Microsoft compilers adds a carriage return to newlines, and to compile the
|
||||
program with this platform, the following line can be added after the main
|
||||
declaration in order for the program to run correctly:
|
||||
|
||||
_setmode(_fileno(stdout), 0x8000);
|
||||
|
||||
### Known Issues
|
||||
|
||||
The program uses a quite simple algorithm for detecting tone on and off events
|
||||
in the morse signal. Hence the program does not work well with noisy input
|
||||
signals. I have tested it with several samples of man made morse recordings as
|
||||
well as computer generated ones.
|
||||
|
||||
Generally, any recording from ham radio transmissions does not decode due to
|
||||
noise and echoes. Other man made recordings may decode, but some characters
|
||||
can be incorrect due to too big variation in length of tones and pauses.
|
||||
However I found some man made recordings on that decode reasonable well.
|
||||
|
||||
If a recording don't decode, you could try to pre-process the input with a
|
||||
narrow bandpass filter on the frequency of the transmission.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(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/
|
||||
-->
|
||||
@@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
char X[] =
|
||||
" ETIANMSURWDKGOHVF:L:PJBXCYZQ::54:3:::2&:+::::16=/:::(:7:::8:90"
|
||||
"::::::::::::?_::::\"::.::::@:::'::-::::::::;!:):::::,:::::";
|
||||
|
||||
int j,w,h,f,u,d,g,e,n,i,l,a,r,p,c,m,o,t,s,Q=32,T[32],W[32],I=13000;
|
||||
|
||||
int main(int v, char** b) {
|
||||
|
||||
for (i=0;v>0&&v<5&&(v*=t=fread(X,1,1,stdin));)
|
||||
|
||||
for (v-1&&101==*1[b]?++g%1500?u+=(g&1^1)*(*X<0?-*X:*X):(f=e,e=w,w=d,d=u,
|
||||
m=(1 - h%2* 2 )*(d -f)/ (d<f ?d|1 : 1|f) > 5?T[ h%Q] =o+l , l=W[
|
||||
h++%Q]=o,o=0:m,o++,u=main(0,b)):(c=strrchr(X,~(Q&*X&*X/2)&*X)-X,j=255);
|
||||
v==1&&(c*j||main(*X-Q?8:24,b));j/=2)c<j?0:main(9+(c-j)/(j/2+1)%2*10,b);
|
||||
|
||||
for (a=u=0;i<=Q*Q&&!v;j>7&&j<13?s=c*s+T[i/Q]/2,s/=++c:0)
|
||||
!(i++%Q)?a=c>a?u=s,c:a,c=s=0:0,j=T[i%Q],j=j?T[i/Q]*10/j:0,j*=(j<5)*2+1;
|
||||
|
||||
for (r+=(h-r)/Q*Q;i<v/4*I;putchar((i/I<v%4)*i%2*85<<(i%176/88)),i++);
|
||||
|
||||
for (g*=!!v;r+t!=h+1&&h>5&&!v;r+t!=h+1?(W[r%Q]>2*u||r==h?p=n=n>6?0:
|
||||
putchar(X[p-1+(1<<n)])&0:0,W[r++%Q]>6*u?putchar(Q):0):0)
|
||||
*X=Q,p=r%2?++n,2*p+(W[r++%Q]>2*u):p;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META name="description" content="International Obfuscated C Code Contest">
|
||||
<META name="keywords" content="International, Obfuscated, C, c, IOCCC,ioccc, obfuscated, Obfuscate, obfuscate, Landon Curt Noll, chongo, Leonid A. Broukhis, leob, Simon Cooper, sc">
|
||||
<link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="hint.css" />
|
||||
|
||||
<TITLE>Who won the 23rd IOCCC</TITLE>
|
||||
</HEAD>
|
||||
<BODY TEXT="#000000">
|
||||
|
||||
<CENTER><IMG SRC="/png/ioccc.png" ALT="IOCCC" height=78 width=267>
|
||||
<P><i><FONT size=+3>The International Obfuscated C Code Contest</FONT></i>
|
||||
<P><B><FONT size=+4>The 23rd IOCCC Winners</FONT></B>
|
||||
<P><FONT size=+1>
|
||||
[ <A HREF="/judges.html">The judges</A> |
|
||||
<A HREF="/index.html">IOCCC home page</A> |
|
||||
<A HREF="/faq.html">FAQ</A> |
|
||||
<A HREF="/winners.html">People who have won</A> |
|
||||
<A HREF="/years.html">Winning entries</A> ]
|
||||
</FONT>
|
||||
</CENTER>
|
||||
|
||||
<P>
|
||||
<HR SIZE="1" WIDTH="90%">
|
||||
|
||||
<P>Here are the names and categories for the winners of the 23rd IOCCC:
|
||||
</P>
|
||||
|
||||
<UL>
|
||||
|
||||
<LI>
|
||||
<A HREF="endoh1/hint.html"><B>Most square (YODA award)</B></A>
|
||||
|
||||
<BLOCKQUOTE>Yusuke Endoh - QR encoder<BR>
|
||||
JP</BLOCKQUOTE>
|
||||
|
||||
<LI>
|
||||
<A HREF="morgan/hint.html"><B>Most likely to succeed</B></A>
|
||||
|
||||
<BLOCKQUOTE>Yves-Marie Morgan - make clone<BR>
|
||||
FR</BLOCKQUOTE>
|
||||
|
||||
<LI>
|
||||
<A HREF="maffiodo1/hint.html"><B>Homage to a classic game</B></A>
|
||||
|
||||
<BLOCKQUOTE>Sandro Maffiodo - homage to a popular game<BR>
|
||||
IT</BLOCKQUOTE>
|
||||
|
||||
<LI>
|
||||
<A HREF="birken/hint.html"><B>Best use of port 1701</B></A>
|
||||
|
||||
<BLOCKQUOTE>Alexander Prishchepov - Klingon web server<BR>
|
||||
US</BLOCKQUOTE>
|
||||
|
||||
<BLOCKQUOTE>Michael Birken - Klingon web server<BR>
|
||||
US</BLOCKQUOTE>
|
||||
|
||||
<LI>
|
||||
<A HREF="sinon/hint.html"><B>Best choice of optimization</B></A>
|
||||
|
||||
<BLOCKQUOTE>Don Yang - optimizer-controlled shooter game<BR>
|
||||
US</BLOCKQUOTE>
|
||||
|
||||
<LI>
|
||||
<A HREF="deak/hint.html"><B>Most underscored argument</B></A>
|
||||
|
||||
<BLOCKQUOTE>Ferenc Deak - CPP and C99 abuse<BR>
|
||||
NO</BLOCKQUOTE>
|
||||
|
||||
<LI>
|
||||
<A HREF="skeggs/hint.html"><B>Most dynamic</B></A>
|
||||
|
||||
<BLOCKQUOTE>Colby Skeggs - dynamic library abusing game<BR>
|
||||
US</BLOCKQUOTE>
|
||||
|
||||
<LI>
|
||||
<A HREF="maffiodo2/hint.html"><B>Most tweetable entry</B></A>
|
||||
|
||||
<BLOCKQUOTE>Sandro Maffiodo - ASCII art 1-line converter<BR>
|
||||
IT</BLOCKQUOTE>
|
||||
|
||||
<LI>
|
||||
<A HREF="vik/hint.html"><B>Best handling of beeps</B></A>
|
||||
|
||||
<BLOCKQUOTE>Daniel Vik - Morse audio transcoder<BR>
|
||||
US</BLOCKQUOTE>
|
||||
|
||||
<LI>
|
||||
<A HREF="endoh2/hint.html"><B>Best use of bioinformatics</B></A>
|
||||
|
||||
<BLOCKQUOTE>Yusuke Endoh - ASCII to DNA transcoder<BR>
|
||||
JP</BLOCKQUOTE>
|
||||
|
||||
<LI>
|
||||
<A HREF="wiedijk/hint.html"><B>Most functional</B></A>
|
||||
|
||||
<BLOCKQUOTE>Freek Wiedijk - Y combinator<BR>
|
||||
NL</BLOCKQUOTE>
|
||||
|
||||
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
<HR SIZE="1">
|
||||
|
||||
<!-- Authored by: <A HREF="http://www.sfik.com">sc</A> -->
|
||||
|
||||
<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>This work by <A HREF="/judges.html">Landon Curt Noll, Simon Cooper, and Leonid A. Broukhis</A>
|
||||
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>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -0,0 +1,202 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2014 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
|
||||
#CWARN= -Wall -pedantic
|
||||
|
||||
# compiler standard
|
||||
#
|
||||
#CSTD=
|
||||
#CSTD= -ansi
|
||||
CSTD= -std=c11
|
||||
|
||||
# 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= prog
|
||||
DATA=
|
||||
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}
|
||||
@${TRUE}
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
${RM} -f ${ENTRY}.o ${ALT_OBJ}
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${ENTRY} ${ALT_ENTRY}
|
||||
|
||||
nuke: clobber
|
||||
@${TRUE}
|
||||
|
||||
dist_clean: nuke
|
||||
@${TRUE}
|
||||
|
||||
install:
|
||||
@echo "Surely we are joking Dr. Science!"
|
||||
@${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 sometimes mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Readers shall not be disallowed from failong 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_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 "You are holding it wrong!"; \
|
||||
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 Pauline!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
@@ -0,0 +1,91 @@
|
||||
<!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 functional</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most functional</h1>
|
||||
|
||||
<p>Freek Wiedijk<br>
|
||||
<a href="mailto:freek@cs.ru.nl">freek@cs.ru.nl</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
<pre><code>make wiedijk
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./prog
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>gcc -E prog.c | indent | sed '1,/5.*prog/d'
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>C11 features definitely help this entry to be as concise as it is.</p>
|
||||
|
||||
<p>The judges would like to think that they had almost understood how this entry works.</p>
|
||||
|
||||
<p>If you win a bet by demonstrating this entry, please let us know.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Remarks</h3>
|
||||
|
||||
<ul>
|
||||
<li>computes the factorial function</li>
|
||||
<li>no loops, no explicit recursion</li>
|
||||
<li>untyped C without any casts, using a <code>w</code> word datatype</li>
|
||||
<li>varargs not essential, <code>w(*)(w,w*)</code> works just as well</li>
|
||||
<li>conforming ISO C</li>
|
||||
<li>no warnings when compiled with <code>-std=c99 -Wall -Wextra -pedantic</code></li>
|
||||
<li>comments in the code explain what this really is about</li>
|
||||
<li>C as a functional programming language:
|
||||
untyped lambda calculus compiled to executable C functions</li>
|
||||
<li>untagged closures (just a function pointer followed by some values)</li>
|
||||
<li>recursion implemented through Curry’s paradoxical combinator <code>Y</code></li>
|
||||
<li><p>the readable implementation of <code>Y</code> is on lines 29-30:</p>
|
||||
|
||||
<p> W_f = \x.f(xx)
|
||||
Y = \f.W_f W_f</p></li>
|
||||
<li><p>a mixture of strict and lazy evaluation, with a <code>_</code> force function
|
||||
(John Tromp notes that if Turing’s fixed-point combinator
|
||||
<code>(\xy.y\z.xxyz)(\xy.y\z.xxyz)</code> had been used,
|
||||
all applications could have been strict)</p></li>
|
||||
<li>uses <code>Y</code> to implement factorial on native <code>int</code>s</li>
|
||||
<li>10! seconds = 6 weeks</li>
|
||||
<li>answers the ultimate question of life, the universe and everything</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<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,62 @@
|
||||
# Most functional
|
||||
|
||||
Freek Wiedijk
|
||||
<freek@cs.ru.nl>
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
### To build:
|
||||
|
||||
make wiedijk
|
||||
|
||||
### To run:
|
||||
|
||||
./prog
|
||||
|
||||
### Try:
|
||||
|
||||
gcc -E prog.c | indent | sed '1,/5.*prog/d'
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
C11 features definitely help this entry to be as concise as it is.
|
||||
|
||||
The judges would like to think that they had almost understood how this entry works.
|
||||
|
||||
If you win a bet by demonstrating this entry, please let us know.
|
||||
|
||||
## Author's comments:
|
||||
### Remarks
|
||||
|
||||
- computes the factorial function
|
||||
- no loops, no explicit recursion
|
||||
- untyped C without any casts, using a `w` word datatype
|
||||
- varargs not essential, `w(*)(w,w*)` works just as well
|
||||
- conforming ISO C
|
||||
- no warnings when compiled with `-std=c99 -Wall -Wextra -pedantic`
|
||||
- comments in the code explain what this really is about
|
||||
- C as a functional programming language:
|
||||
untyped lambda calculus compiled to executable C functions
|
||||
- untagged closures (just a function pointer followed by some values)
|
||||
- recursion implemented through Curry's paradoxical combinator `Y`
|
||||
- the readable implementation of `Y` is on lines 29-30:
|
||||
|
||||
W_f = \x.f(xx)
|
||||
Y = \f.W_f W_f
|
||||
|
||||
- a mixture of strict and lazy evaluation, with a `_` force function
|
||||
(John Tromp notes that if Turing's fixed-point combinator
|
||||
`(\xy.y\z.xxyz)(\xy.y\z.xxyz)` had been used,
|
||||
all applications could have been strict)
|
||||
- uses `Y` to implement factorial on native `int`s
|
||||
- 10! seconds = 6 weeks
|
||||
- answers the ultimate question of life, the universe and everything
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(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/
|
||||
-->
|
||||
@@ -0,0 +1,34 @@
|
||||
#include<stdarg.h>/*Y=\f*/
|
||||
#include<stdio.h>/*.(\x.f(*/
|
||||
#define z return/*xx))(\x.*/
|
||||
#include<stdlib.h>/*f(xx))*/
|
||||
typedef union w w;union w{
|
||||
#define L(f,y,x,t) w _ ##\
|
||||
f(w x,...){va_list argh;w\
|
||||
y; va_start(argh,x);y= *\
|
||||
(va_arg(argh,w*));va_end\
|
||||
(argh);z(t);} w f (w fw)\
|
||||
{r((w){.c= &_## f}, fw);}
|
||||
int _; void*p;w(*c)(w,...
|
||||
#define r(x,y)w*k=malloc\
|
||||
(sizeof(w)<<1); k[0]= x\
|
||||
; k[1]=y; z((w) {.p= k})
|
||||
#define l(f,x,t)w _##f(\
|
||||
w x,...){z(t);}w f={.p\
|
||||
=(w[1]){{.c= &_##f}}};
|
||||
);};w a(w f,w x){w*d=f
|
||||
.p;z((*d->c)(x,d+1)
|
||||
|
||||
|
||||
) ; }
|
||||
w a_(w f,w fw){r(f,
|
||||
fw);}w _(w f){w*k=f.p,r=
|
||||
a(*k,k[1]); free(k) ;z(r);}
|
||||
L(F,f,x,(w){._=x._?x._*a(_(f),
|
||||
(w){._=x._-1})._:1})l(F_,f,F(f)
|
||||
)L( W,(f),/*=\*/x,a(f,a_(x,x))
|
||||
)l( Y,/*=\*/f,a(W(f),W(f))
|
||||
)int main(){printf("%.""f\n",
|
||||
a(a(Y,F_),(w){._=10})._
|
||||
/60./60/24/*d */
|
||||
) ; }
|
||||
Reference in new issue
Block a user