Add preview of 1984-2019
The 2020 winners are hinted it, but the source code is not there,
nor are the hints. Someone could look into the HTML and
see what was commented out, but that is not a problem because
WHO won is known and the name of their AWARD is known already.
Moreover a number of the winners have talked about what their
entirs do, so the commented out spoiler text is not a bit problem.
One will find HTML commented out with:
<!-- XXX remove when 2020 is ready
2020 links here
XXX remove when 2020 is ready -->
The "XXX remove when 2020 is ready" string is found at the
start and end comment blocks. Again, soneone could read
what was commented out, but that is OK since most of that
information is known or can be known. The following files
have such HTML comment blocks in them.
./winners.html
./years-spoiler.html
./years.html
In addition, ./all/summary.txt was modified to not
include the 2020 entries for the momemt.
The 2020 winner code AND write-ups are NOT part of this set.
p.s. The all/all.tar.bz2 does not contain the 2020 source code (yet?).
This commit is contained in:
1 parent
28efc67f5d
commit
c0663537cb
1683 files changed
+220064
No files matched your search
@@ -0,0 +1,351 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2012 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 -W
|
||||
CWARN= -Wall -W -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} ${LIBS}
|
||||
|
||||
# ANSI compiler
|
||||
#
|
||||
# Set CC to the name of your ANSI compiler.
|
||||
#
|
||||
# Some entries seem to need gcc. If you have gcc, set
|
||||
# both CC and MAY_NEED_GCC to gcc.
|
||||
#
|
||||
# If you do not have gcc, set CC to the name of your ANSI compiler, and
|
||||
# set MAY_NEED_GCC to either ${CC} (and hope for the best) or to just :
|
||||
# to disable such programs.
|
||||
#
|
||||
CC= cc
|
||||
#CC=clang
|
||||
MAY_NEED_GCC= gcc
|
||||
|
||||
|
||||
##############################
|
||||
# Special flags for this entry
|
||||
##############################
|
||||
#
|
||||
ENTRY= endoh2
|
||||
DATA=
|
||||
|
||||
ALT_C= pi.c 314.c 3141.c 31415.c 314159.c 3141592.c \
|
||||
31415926.c 314159265.c 3141592653.c 31415926535.c \
|
||||
e.c 271.c 2718.c 27182.c 271828.c 2718281.c \
|
||||
27182818.c 271828182.c 2718281828.c 27182818284.c
|
||||
|
||||
ALT_ENTRY= pi 314 3141 31415 314159 \
|
||||
3141592 31415926 314159265 3141592653 31415926535 \
|
||||
e 271 2718 27182 271828 \
|
||||
2718281 27182818 271828182 2718281828 27182818284
|
||||
|
||||
ALT_OBJ= pi.o 314.o 3141.o 31415.o 314159.o 3141592.o \
|
||||
31415926.o 314159265.o 3141592653.o 31415926535.o \
|
||||
e.o 271.o 2718.o 27182.o 271828.o 2718281.o \
|
||||
27182818.o 271828182.o 2718281828.o 27182818284.o
|
||||
|
||||
ALT_ENTRY= pi 314 3141 31415 314159 3141592 \
|
||||
31415926 314159265 3141592653 31415926535 \
|
||||
e 271 2718 27182 271828 2718281 \
|
||||
27182818 271828182 2718281828 27182818284
|
||||
|
||||
|
||||
#################
|
||||
# build the entry
|
||||
#################
|
||||
#
|
||||
all: ${ENTRY} ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
${ENTRY}: ${ENTRY}.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
pi.c: ${ENTRY}
|
||||
./$< > $@
|
||||
|
||||
pi: pi.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
314.c: pi
|
||||
./$< > $@
|
||||
|
||||
314: 314.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
3141.c: 314
|
||||
./$< > $@
|
||||
|
||||
3141: 3141.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
31415.c: 3141
|
||||
./$< > $@
|
||||
|
||||
31415: 31415.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
314159.c: 31415
|
||||
./$< > $@
|
||||
|
||||
314159: 314159.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
3141592.c: 314159
|
||||
./$< > $@
|
||||
|
||||
3141592: 3141592.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
31415926.c: 3141592
|
||||
./$< > $@
|
||||
|
||||
31415926: 31415926.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
314159265.c: 31415926
|
||||
./$< > $@
|
||||
|
||||
314159265: 314159265.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
3141592653.c: 314159265
|
||||
./$< > $@
|
||||
|
||||
3141592653: 3141592653.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
31415926535.c: 3141592653
|
||||
./$< > $@
|
||||
|
||||
31415926535: 31415926535.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
# you get the transcendental idea ... :-)
|
||||
|
||||
e.c: ${ENTRY}
|
||||
./$< e > $@
|
||||
|
||||
e: e.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
271.c: e
|
||||
./$< > $@
|
||||
|
||||
271: 271.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
2718.c: 271
|
||||
./$< > $@
|
||||
|
||||
2718: 2718.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
27182.c: 2718
|
||||
./$< > $@
|
||||
|
||||
27182: 27182.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
271828.c: 27182
|
||||
./$< > $@
|
||||
|
||||
271828: 271828.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
2718281.c: 271828
|
||||
./$< > $@
|
||||
|
||||
2718281: 2718281.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
27182818.c: 2718281
|
||||
./$< > $@
|
||||
|
||||
27182818: 27182818.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
271828182.c: 27182818
|
||||
./$< > $@
|
||||
|
||||
271828182: 271828182.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
2718281828.c: 271828182
|
||||
./$< > $@
|
||||
|
||||
2718281828: 2718281828.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
27182818284.c: 2718281828
|
||||
./$< > $@
|
||||
|
||||
27182818284: 27182818284.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
271828182845.c: 27182818284
|
||||
./$< > $@
|
||||
|
||||
271828182845: 271828182845.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
|
||||
# etc. ... :-)
|
||||
|
||||
# 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} ${ALT_C}
|
||||
|
||||
nuke: clobber
|
||||
@${TRUE}
|
||||
|
||||
dist_clean: nuke
|
||||
@${TRUE}
|
||||
|
||||
install:
|
||||
@echo "Surely you're joking Mr. Feynman!"
|
||||
@${TRUE}
|
||||
|
||||
# backwards compatibility
|
||||
#
|
||||
build: all
|
||||
@${TRUE}
|
||||
|
||||
|
||||
##################
|
||||
# 133t hacker rulz
|
||||
##################
|
||||
#
|
||||
love:
|
||||
@echo 'not war?'
|
||||
@${TRUE}
|
||||
|
||||
haste:
|
||||
$(MAKE) waste
|
||||
@${TRUE}
|
||||
|
||||
waste:
|
||||
@echo 'waste'
|
||||
@${TRUE}
|
||||
|
||||
easter_egg:
|
||||
@echo you expected to mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Readers shall be disallowed from not being unable to partly misunderstand this partocular final echo.
|
||||
|
||||
# Understand the history of "I Am the Walrus" and
|
||||
# and in particular John Lennon's remarks on that
|
||||
# song and you might be confused about these next
|
||||
# rules in a different way. :-)
|
||||
#
|
||||
supernova: nuke
|
||||
@-if [ -r .code_anal ]; then \
|
||||
${RM} -f .code_anal_v3; \
|
||||
else \
|
||||
echo "You are not expected to understand this"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
|
||||
deep_magic:
|
||||
@-if [ -r .code_anal ]; then \
|
||||
ccode_analysis --deep_magic 1c2c85c7a02c55d1add91967eca491d53c101dc1 --FNV1a_hash 256-bit "${ENTRY}"; \
|
||||
else \
|
||||
echo "Understand different"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
|
||||
magic: deep_magic
|
||||
@-if [ -r .code_anal ]; then \
|
||||
ccode_analysis --mode 21701 --level 23209 --FNV1a_hash 256-bit "${ENTRY}"; \
|
||||
else \
|
||||
echo "These aren't the droids you're looking for Mr. Spock!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
@@ -0,0 +1,25 @@
|
||||
#include<stdio.h> /******** SpigotQuine -- usage: ./spigot [pi or e] ********/
|
||||
char*s="G1%%xJ{;Q7wunmuGuu%%uu#include<stdio.h>/*Spigot_Quine*/#include<stdli"
|
||||
"b.h>/*_IOCCC2012_*/int*e," "i,j,k,n" ";char*q" ",*a,*d,*z,*p=%s%c;"
|
||||
"int" "%cmain(){a=calloc(" "1,1e4+n*2);;for(*"
|
||||
"a=\0@3,z=d=a+n+1,j=n*8-7;" "k=0,j-1" ";j-=2){" "for(a[1]+=2;--z-a;"
|
||||
"*z=k%%10,k/=10)k+=j/2**z;;for(;k=k%%j*" "10+*++z,z<d;*z=k/j" ");;\0@2,z="
|
||||
"d=a+n*2,*z=1,j=0;++j<n;){for(;k=k%%" "j*10+*z,a-z;*z" "--=k/j)a+"
|
||||
"+;for(k=0;z-d;*a--=k%%10,k/=10)k+" "=*++z+*a\0" "@;}d+=spr"
|
||||
"intf(q=d-20,p,p,34,32,n+1)+2;;;;" "for(n=n*2" "0-400;k<n"
|
||||
";++k%%n?j=+puts(" "d)<0:(d++"
|
||||
"[j]=47,d[j-2" "]=42),k%%"
|
||||
"20<1?puts(d" "-1),a++:0"
|
||||
"){for(i=-1" ";i++<32;!"
|
||||
"*z?q[662]" "=0,z=q+207:" "*z+z[1]<6" "5?z+=11:*"
|
||||
"z==34?p=0" ":0)d[i]=((k/2" "0-1?275*q[" "*a+10]-8*"
|
||||
"q[*a+0]-8" ":128)>>(i/11+k/" "4%%5*3))&1?k" "/3*!j&&p?"
|
||||
"j=34:(j=" "i+1,*z++):32;k/3*" "j--&&p?d[z--,j]=3" "4:0;}}int"
|
||||
"*y,n=%d;/*..~",*f="nnLa5~z23~|22t$q(s82r&q(s82q'q(s8;q(s8;q(s8:" "r(s8:r(s8:"
|
||||
"q)s89r)sLr#t+" "sLx,uJw-yGu/wnnnU",*g="nnLa<z::t$u88t(u67t*u57s,t56t,t56~v56"
|
||||
"tF6tF6tF8t1p" "Nu/qOv+rS}Xxnng";int main(int m,char**v){char a[2012],b[2012
|
||||
],*p=a,*r=m>1 &&*v[1]=='e'?g:f,*q=b,*t=r;;sprintf(a,"%s%s%s",s,r==g?s+281:
|
||||
s+168,s+386); sprintf(b,a+22,a,34,32,24);for(sprintf(a,"%.33s/*%.28s*/%.3"
|
||||
"3s/*%.28s*/%" ".33s\"%s*/",b,b+66,b+33,b+76,b+66,b+99);*r;r++){;for(m=0;m++
|
||||
<(*r-34)%77;*q++=*r>111?32:*p++)(q-b)%66<1?*q++=10:0;*r-110&&*r-126&&r-t<(t-g?
|
||||
62:45)?*q++=34,((q-b)%66<1?*q++=10,*q++=34:0):0;}*q=0;puts(b+1);}/*IOCCC2012*/
|
||||
@@ -0,0 +1,95 @@
|
||||
# This script finds table for 3x5 decimal fonts.
|
||||
|
||||
fonts = <<END
|
||||
### .#. ### ### #.# ### ### ### ### ###
|
||||
#.# ##. ..# ..# #.# #.. #.. #.# #.# #.#
|
||||
#.# .#. ### ### ### ### ### ..# ### ###
|
||||
#.# .#. #.. ..# ..# ..# #.# .#. #.# ..#
|
||||
### ### ### ### ..# ### ### .#. ### ###
|
||||
END
|
||||
fonts = fonts.lines.map {|l| l.scan(/\S{3}/) }.transpose
|
||||
fonts = fonts.join.scan(/.{15}/).map {|l| l.tr(".#", "01").reverse.to_i(2) }
|
||||
|
||||
|
||||
def printable?(x)
|
||||
35 <= x && x != 92 && x <= 126
|
||||
end
|
||||
|
||||
# Given integers d, e, and f, finds (x, y) s.t. x*d - y*e = f, where x and y
|
||||
# are both printable.
|
||||
def solve_identity(d, e, f)
|
||||
# First we solve Bezout's identity by using the extended gcd algorithm.
|
||||
# See the wikipedia entry in detail.
|
||||
g = d.gcd(e)
|
||||
return if f % g != 0 # No solution
|
||||
d, e, f = d / g, e / g, f / g
|
||||
a, b = d, -e
|
||||
x0, x1 = 1, 0
|
||||
y0, y1 = 0, 1
|
||||
while b != 0
|
||||
q = a / b
|
||||
a, b = b, a % b
|
||||
x0, x1 = x1, x0 - x1 * q
|
||||
y0, y1 = y1, y0 - y1 * q
|
||||
end
|
||||
|
||||
# Now we have solution candidates.
|
||||
# x = -f * x0 - e * t
|
||||
# y = -f * y0 - d * t
|
||||
# where t is a free parameter.
|
||||
# Then, we consider another constraint: x and y is both printable.
|
||||
|
||||
# We must satisfy: 35 <= x <= 126
|
||||
# -> ceil((35+f*x0) / e) <= -t <= floor((126+f*x0) / e)
|
||||
# -> ceil((35+f*x0) / e) * d - f*y0 <= y <= floor((126+f*x0) / e) * d - f*y0
|
||||
ymin = ( 35+f*x0+e+1) / e * d - f*y0
|
||||
ymax = (126+f*x0 ) / e * d - f*y0
|
||||
|
||||
return if ymax < ymin || ymax < 33 || ymin > 126 # No solution.
|
||||
|
||||
((ymax + f*y0) / -d).upto((ymin + f*y0) / -d) do |t|
|
||||
x = -f * x0 - e * t
|
||||
y = -f * y0 - d * t
|
||||
return [x, y] if printable?(x) && printable?(y) # Solution found.
|
||||
end
|
||||
|
||||
return # No solution.
|
||||
end
|
||||
|
||||
# Given integers f0, f1, ..., f9, by brute force, finds (u, v, d) s.t. there is
|
||||
# some xi and yi:
|
||||
# x0 * u - y0 * v = f0 + d
|
||||
# x1 * u - y1 * v = f1 + d
|
||||
# ...
|
||||
# x9 * u - y9 * v = f9 + d
|
||||
# where both xi and yi are printable.
|
||||
def find_params(fonts)
|
||||
1.upto(9) do |d|
|
||||
2.times do
|
||||
1.upto(999) do |u|
|
||||
1.upto(999) do |v|
|
||||
if fonts.all? {|f| solve_identity(u, v, f + d) }
|
||||
table = fonts.map do |f|
|
||||
solve_identity(u, v, f + d).reverse
|
||||
end.transpose.flatten.map {|c| c.chr }.join
|
||||
return u, v, d, table
|
||||
end
|
||||
end
|
||||
end
|
||||
d = -d
|
||||
end
|
||||
end
|
||||
puts "Not found."
|
||||
exit
|
||||
end
|
||||
|
||||
|
||||
puts "Searching..."
|
||||
|
||||
u, v, d, s = find_params(fonts)
|
||||
|
||||
puts "Found."
|
||||
puts
|
||||
puts "Let s = %p." % s
|
||||
puts "You can get the font data of dicimal character 'n' (0--9):"
|
||||
puts " %d * s[n+10] - %d * s[n] - %d" % [u, v, d]
|
||||
@@ -0,0 +1,174 @@
|
||||
<!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>PiE in the sky award</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>PiE in the sky 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 endoh2
|
||||
</code></pre>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./endoh2 > pi.c
|
||||
gcc -o pi pi.c
|
||||
./pi > 314.c
|
||||
...
|
||||
|
||||
./endoh2 e > e.c
|
||||
gcc -o e e.c
|
||||
./e > 271.c
|
||||
...
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>make pi
|
||||
make e
|
||||
make everything
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>A pi/e printing quasi-quine in ASCII art with a compressed font in it;
|
||||
what else to wish for in this program? Virtual machine emulation?</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<p>Yeah, “Again”. Sorry. But I don’t feel guilty or uncomfortable.</p>
|
||||
|
||||
<p>This entry is based on ‘over-used themes’ such as self reproducing
|
||||
program and pi or e computation. I know you’re tired of them.</p>
|
||||
|
||||
<p>But have you ever seen <strong>all-in-one</strong>?</p>
|
||||
|
||||
<h3>What it is</h3>
|
||||
|
||||
<p>This program generates a new program in the shape of the Greek letter
|
||||
<code>pi</code>. Then, the generated program:</p>
|
||||
|
||||
<ul>
|
||||
<li>computes 3 digits of pi and prints it as a ASCII-art program that:</li>
|
||||
<li>computes 4 digits of pi and prints it as a ASCII-art program that:</li>
|
||||
<li>computes 5 digits of pi and prints it as a ASCII-art program that:</li>
|
||||
<li>computes 6 digits of pi and prints it as a ASCII-art program that:</li>
|
||||
<li>etc.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>One more thing… When you give a command line option “e” to the
|
||||
first program, the generated one will compute Napier’s constant
|
||||
rather than pi.</p>
|
||||
|
||||
<h3>Obfuscation</h3>
|
||||
|
||||
<p>This program itself is in the shape of a spigot. This is derived
|
||||
from analogy with “spigot algorithm” which infinitely computes the
|
||||
value of a mathematical constant such as <code>pi</code> or <code>e</code>.</p>
|
||||
|
||||
<p><a href="http://en.wikipedia.org/wiki/Spigot_algorithm">http://en.wikipedia.org/wiki/Spigot_algorithm</a></p>
|
||||
|
||||
<p>The two sets of programs, 314*.c and 271*.c, are almost the same
|
||||
except its shape and constant computation part. I tailored the
|
||||
common part to parse in both shapes (“3.14…” and “2.71…”), by
|
||||
tweaking the computation order and adding meaningless code fragment.</p>
|
||||
|
||||
<p>On the other hand, to make it fit inside one screen (80 x 25), my
|
||||
program is shortened properly, more than it looks. (As you may
|
||||
know, Quine needs to make its program size doubled.)
|
||||
For example, this program involves 3x5 bitmap font data of ten
|
||||
characters (‘0’ – ‘9’), as just 20 bytes: “G1%xJ{;Q7wunmuGuu%uu”.
|
||||
We can decode character n as <code>275*s[n+10] - 8*s[n] - 8</code>. I solved the
|
||||
system of Bezout’s identities to find the magic string, with the
|
||||
aid of a brute force. See <code>find-font-table.rb</code> in detail.</p>
|
||||
|
||||
<p><a href="http://en.wikipedia.org/wiki/B%C3%A9zout's_identity">http://en.wikipedia.org/wiki/B%C3%A9zout's_identity</a></p>
|
||||
|
||||
<p>I used many other tricks for short coding.</p>
|
||||
|
||||
<p>I’m sorry that many ASCII-art-style winning entries of IOCCCs
|
||||
ignore preprocessor directives. In my program, #include is a part
|
||||
of ASCII-art with comment padded.</p>
|
||||
|
||||
<p>These design requirements made my program well-obfuscated
|
||||
willy-nilly.</p>
|
||||
|
||||
<h3>Portability</h3>
|
||||
|
||||
<p>I expect it to work in any major environment and C compiler.
|
||||
To build with no warning, it requires two C99 features: string
|
||||
literal more than 509 characters and omissible return in main
|
||||
function. In fact, recent compilers with “-std=c99 -Wall -W
|
||||
-Wextra -pedantic” would say nothing.</p>
|
||||
|
||||
<pre><code>gcc -std=c99 -Wall -W -Wextra -pedantic spigot.c
|
||||
clang -std=c99 -Wall -W -Wextra -pedantic spigot.c
|
||||
</code></pre>
|
||||
|
||||
<p>I’ve tested with gcc-4.6.3 and clang-3.0 on Linux (Ubuntu 12.04)
|
||||
and gcc-4.5.3 and clang-3.1 on Cygwin.</p>
|
||||
|
||||
<h3>Synopsis</h3>
|
||||
|
||||
<pre><code>gcc endoh2.c -o endoh2
|
||||
|
||||
./endoh2 > pi.c
|
||||
cat pi.c
|
||||
|
||||
gcc pi.c -o pi ; ./pi > 314.c ; cat 314.c
|
||||
gcc 314.c -o 314 ; ./314 > 3141.c ; cat 3141.c
|
||||
gcc 3141.c -o 3141 ; ./3141 > 31415.c ; cat 31415.c
|
||||
gcc 31415.c -o 31415 ; ./31415 > 314159.c ; cat 314159.c
|
||||
gcc 314159.c -o 314159 ; ./314159 > 3141592.c ; cat 3141592.c
|
||||
etc...
|
||||
|
||||
./endoh2 e > e.c
|
||||
cat e.c
|
||||
|
||||
gcc e.c -o e ; ./e > 271.c ; cat 271.c
|
||||
gcc 271.c -o 271 ; ./271 > 2718.c ; cat 2718.c
|
||||
gcc 2718.c -o 2718 ; ./2718 > 27182.c ; cat 27182.c
|
||||
gcc 27182.c -o 27182 ; ./27182 > 271828.c ; cat 271828.c
|
||||
gcc 271828.c -o 271828 ; ./271828 > 2718281.c ; cat 2718281.c
|
||||
etc...
|
||||
</code></pre>
|
||||
|
||||
<p>You can do <code>make everything</code> for the process (with no <code>cat</code>).</p>
|
||||
|
||||
<p>Note: The executable may return a failure (non-zero) exit status
|
||||
unless -std=c99 option is given.</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,147 @@
|
||||
# PiE in the sky award
|
||||
|
||||
Yusuke Endoh
|
||||
<mame@ruby-lang.org>
|
||||
<https://github.com/mame/>
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
### To build:
|
||||
|
||||
make endoh2
|
||||
|
||||
### To run:
|
||||
|
||||
./endoh2 > pi.c
|
||||
gcc -o pi pi.c
|
||||
./pi > 314.c
|
||||
...
|
||||
|
||||
./endoh2 e > e.c
|
||||
gcc -o e e.c
|
||||
./e > 271.c
|
||||
...
|
||||
|
||||
### Try:
|
||||
|
||||
make pi
|
||||
make e
|
||||
make everything
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
A pi/e printing quasi-quine in ASCII art with a compressed font in it;
|
||||
what else to wish for in this program? Virtual machine emulation?
|
||||
|
||||
## Author's comments:
|
||||
Yeah, "Again". Sorry. But I don't feel guilty or uncomfortable.
|
||||
|
||||
This entry is based on 'over-used themes' such as self reproducing
|
||||
program and pi or e computation. I know you're tired of them.
|
||||
|
||||
|
||||
But have you ever seen **all-in-one**?
|
||||
|
||||
|
||||
### What it is
|
||||
|
||||
This program generates a new program in the shape of the Greek letter
|
||||
`pi`. Then, the generated program:
|
||||
|
||||
- computes 3 digits of pi and prints it as a ASCII-art program that:
|
||||
- computes 4 digits of pi and prints it as a ASCII-art program that:
|
||||
- computes 5 digits of pi and prints it as a ASCII-art program that:
|
||||
- computes 6 digits of pi and prints it as a ASCII-art program that:
|
||||
- etc.
|
||||
|
||||
One more thing... When you give a command line option "e" to the
|
||||
first program, the generated one will compute Napier's constant
|
||||
rather than pi.
|
||||
|
||||
|
||||
### Obfuscation
|
||||
|
||||
This program itself is in the shape of a spigot. This is derived
|
||||
from analogy with "spigot algorithm" which infinitely computes the
|
||||
value of a mathematical constant such as `pi` or `e`.
|
||||
|
||||
<http://en.wikipedia.org/wiki/Spigot_algorithm>
|
||||
|
||||
The two sets of programs, 314\*.c and 271\*.c, are almost the same
|
||||
except its shape and constant computation part. I tailored the
|
||||
common part to parse in both shapes ("3.14..." and "2.71..."), by
|
||||
tweaking the computation order and adding meaningless code fragment.
|
||||
|
||||
On the other hand, to make it fit inside one screen (80 x 25), my
|
||||
program is shortened properly, more than it looks. (As you may
|
||||
know, Quine needs to make its program size doubled.)
|
||||
For example, this program involves 3x5 bitmap font data of ten
|
||||
characters ('0' -- '9'), as just 20 bytes: "G1%xJ{;Q7wunmuGuu%uu".
|
||||
We can decode character n as `275*s[n+10] - 8*s[n] - 8`. I solved the
|
||||
system of Bezout's identities to find the magic string, with the
|
||||
aid of a brute force. See `find-font-table.rb` in detail.
|
||||
|
||||
<http://en.wikipedia.org/wiki/B%C3%A9zout's_identity>
|
||||
|
||||
I used many other tricks for short coding.
|
||||
|
||||
I'm sorry that many ASCII-art-style winning entries of IOCCCs
|
||||
ignore preprocessor directives. In my program, #include is a part
|
||||
of ASCII-art with comment padded.
|
||||
|
||||
These design requirements made my program well-obfuscated
|
||||
willy-nilly.
|
||||
|
||||
|
||||
### Portability
|
||||
|
||||
I expect it to work in any major environment and C compiler.
|
||||
To build with no warning, it requires two C99 features: string
|
||||
literal more than 509 characters and omissible return in main
|
||||
function. In fact, recent compilers with "-std=c99 -Wall -W
|
||||
-Wextra -pedantic" would say nothing.
|
||||
|
||||
gcc -std=c99 -Wall -W -Wextra -pedantic spigot.c
|
||||
clang -std=c99 -Wall -W -Wextra -pedantic spigot.c
|
||||
|
||||
I've tested with gcc-4.6.3 and clang-3.0 on Linux (Ubuntu 12.04)
|
||||
and gcc-4.5.3 and clang-3.1 on Cygwin.
|
||||
|
||||
|
||||
### Synopsis
|
||||
|
||||
gcc endoh2.c -o endoh2
|
||||
|
||||
./endoh2 > pi.c
|
||||
cat pi.c
|
||||
|
||||
gcc pi.c -o pi ; ./pi > 314.c ; cat 314.c
|
||||
gcc 314.c -o 314 ; ./314 > 3141.c ; cat 3141.c
|
||||
gcc 3141.c -o 3141 ; ./3141 > 31415.c ; cat 31415.c
|
||||
gcc 31415.c -o 31415 ; ./31415 > 314159.c ; cat 314159.c
|
||||
gcc 314159.c -o 314159 ; ./314159 > 3141592.c ; cat 3141592.c
|
||||
etc...
|
||||
|
||||
./endoh2 e > e.c
|
||||
cat e.c
|
||||
|
||||
gcc e.c -o e ; ./e > 271.c ; cat 271.c
|
||||
gcc 271.c -o 271 ; ./271 > 2718.c ; cat 2718.c
|
||||
gcc 2718.c -o 2718 ; ./2718 > 27182.c ; cat 27182.c
|
||||
gcc 27182.c -o 27182 ; ./27182 > 271828.c ; cat 271828.c
|
||||
gcc 271828.c -o 271828 ; ./271828 > 2718281.c ; cat 2718281.c
|
||||
etc...
|
||||
|
||||
You can do `make everything` for the process (with no `cat`).
|
||||
|
||||
Note: The executable may return a failure (non-zero) exit status
|
||||
unless -std=c99 option is given.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(c) Copyright 1984-2015, [Leo Broukhis, Simon Cooper, Landon Curt Noll][judges] - All rights reserved
|
||||
This work is licensed under a [Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].
|
||||
|
||||
[judges]: http://www.ioccc.org/judges.html
|
||||
[cc]: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
-->
|
||||
Reference in new issue
Block a user