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,210 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2013 makefile
|
||||
#
|
||||
# This work by Landon Curt Noll, Simon Cooper, and Leonid A. Broukhis
|
||||
# is licensed under:
|
||||
#
|
||||
# Creative Commons Attribution-ShareAlike 3.0 Unported License.
|
||||
#
|
||||
# See: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
|
||||
################
|
||||
# tool locations
|
||||
################
|
||||
#
|
||||
SHELL= /bin/bash
|
||||
CP= cp
|
||||
CPP= cpp
|
||||
GUNZIP= gunzip
|
||||
LD= ld
|
||||
MAKE= make
|
||||
RM= rm
|
||||
SED= sed
|
||||
TAR= tar
|
||||
TRUE= true
|
||||
|
||||
# Set X11_LIBDIR to the directory where the X11 library resides
|
||||
#
|
||||
X11_LIBDIR= /usr/X11R6/lib
|
||||
|
||||
# Set X11_INCLUDEDIR to the directory where the X11 include files reside
|
||||
#
|
||||
X11_INCDIR= /usr/X11R6/include
|
||||
|
||||
# Compiler warnings
|
||||
#
|
||||
#CWARN=
|
||||
CWARN= -Wall -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= endoh1
|
||||
DATA=
|
||||
ALT_OBJ=
|
||||
ALT_ENTRY=hello echo tac
|
||||
|
||||
|
||||
#################
|
||||
# build the entry
|
||||
#################
|
||||
#
|
||||
all: ${ENTRY} ${ALT_ENTRY}
|
||||
@${TRUE}
|
||||
|
||||
${ENTRY}: ${ENTRY}.c
|
||||
${CC} ${CFLAGS} $< -o $@
|
||||
@$(MAKE) ${ALT_ENTRY}
|
||||
|
||||
# alternative executable
|
||||
#
|
||||
|
||||
hello: hello.lazy ${ENTRY}.c
|
||||
${CC} ${CFLAGS} -xc hello.lazy -o $@
|
||||
|
||||
echo: echo.lazy ${ENTRY}.c
|
||||
${CC} ${CFLAGS} -xc echo.lazy -o $@
|
||||
|
||||
tac: tac.lazy ${ENTRY}.c
|
||||
${CC} ${CFLAGS} -xc tac.lazy -o $@
|
||||
# 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. Lehmer!"
|
||||
@${TRUE}
|
||||
|
||||
# backwards compatibility
|
||||
#
|
||||
build: all
|
||||
@${TRUE}
|
||||
|
||||
|
||||
##################
|
||||
# 133t hacker rulz
|
||||
##################
|
||||
#
|
||||
love:
|
||||
@echo 'not war?'
|
||||
@${TRUE}
|
||||
|
||||
haste:
|
||||
$(MAKE) waste
|
||||
@${TRUE}
|
||||
|
||||
waste:
|
||||
@echo 'haste'
|
||||
@${TRUE}
|
||||
|
||||
easter_egg:
|
||||
@echo you expected to mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Readers shall not be disallowed from being unable to not partly misunderstand this partocular final echo.
|
||||
|
||||
# Understand the history of the Homebrew Computer Club
|
||||
# as well as the West Coast Computer Faire and
|
||||
# you might be confused different. :-)
|
||||
#
|
||||
supernova: nuke
|
||||
@-if [ -r .code_anal ]; then \
|
||||
${RM} -f .code_anal_v4; \
|
||||
else \
|
||||
echo "We are not expected to understand that"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
|
||||
deep_magic:
|
||||
@-if [ -r .code_anal ]; then \
|
||||
ccode_analysis --deep_magic 2ed3582ec5c094a093fea2a6bcb9f19439892873c9cc45ed1ceaafe08b7d52e1b2c7cd524be3b0b2 --FNV1a_hash 512-bit "${ENTRY}"; \
|
||||
else \
|
||||
echo "Park different"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
|
||||
magic: deep_magic
|
||||
@-if [ -r .code_anal ]; then \
|
||||
ccode_analysis --mode 391581 --level 216193 --FNV1a_hash 512-bit "${ENTRY}"; \
|
||||
else \
|
||||
echo "These aren't the primes you're looking for Paul Erdos!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#include "endoh1.c"
|
||||
|
||||
I
|
||||
|
||||
#include "endoh1.c"
|
||||
@@ -0,0 +1,87 @@
|
||||
#ifndef SKI
|
||||
#define A(x)B(x##0)B(x##1)B(x##2)B(x##3)B(x##4)B(x##5)
|
||||
#define B(x)C(x##0)C(x##1)C(x##2)C(x##3)C(x##4)C(x##5)
|
||||
#define C(x)D(x##0)D(x##1)D(x##2)D(x##3)D(x##4)D(x##5)
|
||||
#define D(x)Z(x##0)Z(x##1)Z(x##2)Z(x##3)Z(x##4)Z(x##5)
|
||||
#define p(x)(*(*(*(*(*(*x)())())())())())()
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define S (Y(s+6))
|
||||
#define K (Y(s+4))
|
||||
#define I (Y(s+2))
|
||||
|
||||
|
||||
|
||||
|
||||
#define Z(x)\
|
||||
f x;f Y(v);g\
|
||||
j;f \
|
||||
x##z( f\
|
||||
y){y =y?! x?x= y:Y( m(*( w)&\
|
||||
x,(( g)y) (0)) ):x;return y; /*ab c*/}
|
||||
/**/ typedef void *v ;int
|
||||
n=0; typedef v* w;typed\
|
||||
ef v(*g)();v s[]= {0,0, s+6, s+2,
|
||||
s+4,s,s+3,s+ 5,s+ 1};w m( v l ,v
|
||||
|
||||
|
||||
|
||||
|
||||
r){w e=ma\
|
||||
lloc (siz\
|
||||
eof( v)*3
|
||||
);*e =r;e [1
|
||||
]=l;return (e[2 ]=s, e);} /*de fghi jk*/ typ\
|
||||
edef v(p( p(p( p(p( p(p( p(p( p(p(f)))) ))) )))) );A(
|
||||
x)w u(){ return n --?m (j(0 ),u( )):s+3;}
|
||||
w z( w e) {w a,b , c,d;for (d =e=m(e,0
|
||||
);n= (w)d[ 2]-s ,n?* (n>1? n<4? b:a:
|
||||
c)?n <2?c[ 1]=m (*a, *c), *c=m (*b,
|
||||
*c):
|
||||
n>5?
|
||||
|
||||
|
||||
#undef Z
|
||||
#define Z(x\
|
||||
) &x ##z,
|
||||
a[1]= m(
|
||||
*a,!*d? d[1] =c=m (0,0 ),n= getchar(),n= n<0?
|
||||
256:n,c [2]= s+6, *d=u ():* d),*a=d[1]: n<5?n<3?n=z(*
|
||||
a)-s, putchar( 255< +n?( exit (n-4
|
||||
*64) ,0):n ),fflush (stdout) ,c[1 ]=
|
||||
*b:((n-3?b:c )[1] =*a) :(2[* a=z(*a)+1,a
|
||||
]=s+5),d =e:0 :e;d =d[1 ])c=b,b=a,a=
|
||||
d;a=
|
||||
*(w*
|
||||
|
||||
)e [1
|
||||
]; ;;
|
||||
/*lm no*/ return a;}f( *h [])( )={A (x)0};f Y(v x)
|
||||
{g y =(g) h[n++] ;y(! y? exit( puts ("out of c" ""
|
||||
"losure" )),x :x );return(f )y/* pq
|
||||
r*/;}int main () {z(((g )(S S(
|
||||
j=(g )S(S (K S)K))(K( S I I)) (S(K(S I))( S(
|
||||
K K) (S(K (S(S(K(Y(s+1 )) )(S( S S(K I)) (K (Y
|
||||
(s +5)) ))
|
||||
)) )K)) )(
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#if (!defined(__INCLUDE_LEVEL__) || !__INCLUDE_LEVEL__) && !defined(SKI)
|
||||
|
||||
K(I(I(I(S I I(S(K(S(S(K S)(S(S S S(K(S(K S)))(S(S S S(K(S(K S)))(S(K(S(S(K S)(S(S(K S)K)(K(S(S(K S)(S(K(S(S(S I(K K))(K K))))(S(K K)(S(S(K S)(S(K(S(S I(K K))))(S(K K)(S(S(K K))(K(S(S(S(S(K S)K)))I(S(S(K S)K)I)))))))(S(K K)(S(S(K K))(K(S(K(S(S(K S)K)I))(S(S(K S)K)(S I I(S(S(K S)K)I)))))))))))(S(K K)(S(K K)(S(S(K K))(K(S(K(S(S(K S)K)I))(S(S I I)I(S(S(K S)K)I)))))))))))))(S(K K)(S(K K)(S(K(S(S I(K(S(S I(K(K I)))(K S))))))K)))))(K(K(K K)))))(K(K(K(K I))))))))(S(K(S(K K)))(S(S(K S)(S(K K)(S(K S)(S(S(K K))I))))(K(S(K(S(S(K S)(S(K(S I))K))))(S(K K)K))))))(S(S I(K(S I I(S I I(S(S(K S)K)I)))))(K(K K)))S K K K I I I K K K I I I K K K I I I K K K I I K K K K K S K I I I K I K I I I K I K)I I I K I K I I I K I I I K I I S K I I I I I K I I I I I K I K I I I K I I I K I I S K I I)I K I K I I I K I K I I I K I K I I I K I I I K I I S K K K I I I K K K I I I K K K I I I K K K I I K K K K K S S K I I I K S)K I I K S K K K S K I I K S K I I I K S S K K K K K S K I I I I S K K K K K S K S K K K K K(K K))
|
||||
|
||||
#define SKI
|
||||
#endif
|
||||
|
||||
#ifdef SKI
|
||||
(Y(s)))))(0));return 0;}
|
||||
#else
|
||||
#define SKI
|
||||
#endif
|
||||
@@ -0,0 +1,5 @@
|
||||
#include "endoh1.c"
|
||||
|
||||
K(S(S I(K(S(K(S I I(S(S(K S)K)I)))(S(S(K S)K)(S(S(K S)K)(S(S I I)I(S(S(K S)K)I)))))))(K(S(S I(K(S(S(K S)K)(S(S(K S)K)I(S(K(S(S(K S)K)I))(S(S(K S)K)(S I I(S(S(K S)K)I))))))))(K(S(S(K S)(S(K(S I))K))(S(K K)(S(S(K S)(S(K(S I))K))(S(K K)(S(S(K S)(S(K(S I))(S(K K)(S(S I(K(S(S(K S)K))))(K(S(S(K S)K)(S(S(K S)K)I)))))))(K(K(S(S I(K(S(S(K S)K)(S(S I I)I(S(S(K S)K)I))(S(S(K S)K))(S I I(S(S(K S)K)(S(S(K S)K)I))))))(K(S(S I(K(S(K(S(S(K S)K)I))(S(S I I)I(S(S(K S)K)I)))))(K(S(S I(K(S(S(K S)K)(S(K(S I I(S(S(K S)K)I)))(S(S(K S)K)(S(S(K S)K)(S(S I I)I(S(S(K S)K)I))))))))(K(S(S I(K(S(S(K S)K)(S(K(S(S(K S)K)(S(S(K S)K)I)))(S(S(K S)K)(S(S(K S)K)I(S(S(K S)K)(S I I(S(S(K S)K)I)))))))))(K(S(S(K S)(S(K(S I))K))(S(K K)(S(S(K S)(S(K(S I))K))(S(K K)(S(S(K S)(S(K(S I))K))(K(K(S(S I(K(S(S(K S)K)(S(K(S(S(K S)K)I))(S(S I I)I(S(S(K S)K)I))))))(K(S(S I(K(S(K(S(S(K S)K)I))(S(S(K S)K)(S I I(S(S(K S)K)I))))))(K(S(S I(K(S I I(S I I(S(S(K S)K)I)))))(K S))))))))))))(S(S(K S)K)(S(S(K S)K)(S(S(K S)K)(S(S(S(K S)K))(S I I)(S(S(K S)K)I))))))))))))))))))))(S(K(S I I(S(S(K S)K)I)))(S I I(S(S(K S)K)(S(S(K S)K)I)))))))))
|
||||
|
||||
#include "endoh1.c"
|
||||
@@ -0,0 +1,254 @@
|
||||
<!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 lazy SKIer</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most lazy SKIer</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>
|
||||
|
||||
<p>This builds endoh1, echo, hello, and tac.</p>
|
||||
|
||||
<h3>To run:</h3>
|
||||
|
||||
<pre><code>./endoh1 [file.lazy]
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./endoh1 hello.lazy
|
||||
./hello
|
||||
echo Hello | ./echo
|
||||
./tac < endoh1.c
|
||||
</code></pre>
|
||||
|
||||
<p>Be patient with the last one.</p>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>We liked this entry because it can serve as a standalone program as well as an include file; and, as usual,
|
||||
because its input data is at least as obfuscated as the program itself.</p>
|
||||
|
||||
<p>This entry can be considered an abuse of the GCC’s optimizer; it takes GCC about 4x longer to compile it
|
||||
with -O3 than without, compared to clang’s 2x.</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Remarks</h3>
|
||||
|
||||
<pre><code>$ less prog.c
|
||||
$ gcc -o prog prog.c
|
||||
$ ./prog
|
||||
</code></pre>
|
||||
|
||||
<p>… Isn’t there any more to it?</p>
|
||||
|
||||
<p>Yes, of course.</p>
|
||||
|
||||
<p>This is a tool <em>for C programmers</em> to play the <a href="http://en.wikipedia.org/wiki/SKI_combinator_calculus">SKI combinator calculus</a>,
|
||||
especially, <a href="redacted">Lazy K</a>.</p>
|
||||
|
||||
<p>This program will shine when it is used as a library.
|
||||
For example, <code>hello.lazy</code> is a “Hello world” program written in Lazy K.</p>
|
||||
|
||||
<pre><code>$ lazy hello.lazy
|
||||
Hello, world!
|
||||
</code></pre>
|
||||
|
||||
<p>where <code>lazy</code> is <a href="redacted">a reference implementation of Lazy K</a>.
|
||||
At the same time, <code>hello.lazy</code> is <em>a valid C program</em> that uses <code>prog.c</code> as a library.</p>
|
||||
|
||||
<pre><code>$ gcc -o hello -xc hello.lazy
|
||||
$ ./hello
|
||||
Hello, world!
|
||||
</code></pre>
|
||||
|
||||
<p>In other words, this program is a kind of <a href="http://en.wikipedia.org/wiki/Polyglot_%28computing%29">polyglot</a>.</p>
|
||||
|
||||
<p>The usage is simple:
|
||||
you just have to wrap Lazy K program with <code>#include "prog.c"</code>.
|
||||
Note that <code>#</code> is a comment in Lazy K.</p>
|
||||
|
||||
<h3>Obfuscation</h3>
|
||||
|
||||
<p>… is inherent in SKI combinator calculus :-)</p>
|
||||
|
||||
<p>In addition, it uses various hacks to parse SKI code as C,
|
||||
and to satisfy IOCCC’s size rule.</p>
|
||||
|
||||
<ul>
|
||||
<li>Abuse of function pointers</li>
|
||||
<li>Code duplication by macros</li>
|
||||
<li>Short coding</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>These led to the good obfuscation.
|
||||
See Spoiler section in detail, if you need.</p>
|
||||
|
||||
<h3>Limitation</h3>
|
||||
|
||||
<p>This program supports only “Combinator-calculus style notation” of Lazy K.
|
||||
“Unlambda style” and “Iota and Jot” style are not supported.
|
||||
Also, it requires a space between identifiers.
|
||||
In short, use <code>(S K)</code> instead of <code>(SK)</code>, “`sk”, <code>**i*i*i*ii*i*i*ii</code>,
|
||||
or <code>11111100011100</code>.</p>
|
||||
|
||||
<p>Huge memory may be required to compile the program
|
||||
(about 300 MB on my machine).</p>
|
||||
|
||||
<p>In addition, there are some limitations (and workarounds)
|
||||
mentioned in Spoiler section.
|
||||
But I think it wouldn’t matter only when you run the attached programs.</p>
|
||||
|
||||
<h3>Portability</h3>
|
||||
|
||||
<p>I confirmed that the program successfully worked
|
||||
with the following compilers.</p>
|
||||
|
||||
<ul>
|
||||
<li>gcc 4.6.3 [Linux, Mac OS X]</li>
|
||||
<li>clang 3.0 [Linux, Mac OS X]</li>
|
||||
<li>tcc 0.9.26 [Linux]
|
||||
|
||||
<ul>
|
||||
<li>N.B. tcc 0.9.25 seems to have a bug and fails to run it.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Recent compilers with <code>-Wall -W -Wextra -pedantic</code> say nothing.</p>
|
||||
|
||||
<pre><code>gcc -Wall -W -Wextra -pedantic prog.c
|
||||
clang -Wall -W -Wextra -pedantic prog.c
|
||||
tcc -Wall -W -Wextra -pedantic prog.c
|
||||
</code></pre>
|
||||
|
||||
<p>I think it will work on almost all platforms. I confirmed:</p>
|
||||
|
||||
<ul>
|
||||
<li>Ubuntu Linux</li>
|
||||
<li>Mac OS X</li>
|
||||
<li>Raspberry PI</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>To check whether the program is specified on the command line
|
||||
or included from another source file,
|
||||
the program uses a predefined macro <code>__INCLUDE_LEVEL__</code>.
|
||||
It is a gcc extention, and also supported by clang.
|
||||
If your compiler does not support it,
|
||||
you cannot use the program as a library.
|
||||
But you can compile and run it as a standalone program, at least.
|
||||
In fact, tcc does not support the macro, but does work.</p>
|
||||
|
||||
<h3>Spoiler (rot13)</h3>
|
||||
|
||||
<p>Gur jubyr cebtenz vf vagrecergrq ol znpeb rkcnafvba.
|
||||
Sbe rknzcyr, <code>F (X V)</code> vf genafyngrq gb n abezny P pbqr, <code>(f)((x)(v))</code>,
|
||||
be fvzcyl <code>f(x(v))</code>.
|
||||
Guvf rkcerffvba ergheaf na nofgenpg flagnk gerr,
|
||||
naq <code>cebt.p</code> rinyhngrf vg.
|
||||
Guvf cebtenz hfrf irel fvzcyr “grez erjevgvat” nccebnpu
|
||||
sbe rinyhngvat FXV pbzovangbe pnyphyhf.
|
||||
Gur erjevgvat ehyrf ner fubja va gur funcr bs gur pbqr.</p>
|
||||
|
||||
<h4>Nohfr bs shapgvba cbvagref</h4>
|
||||
|
||||
<p>Pbafvqre n frdhrapr bs shapgvba nccyvpngvbaf va P:</p>
|
||||
|
||||
<pre><code>f(k)(k)(k)(k)...
|
||||
</code></pre>
|
||||
|
||||
<p>Jung glcr fubhyq <code>f</code> unir?
|
||||
Hasbeghangryl, P qbrf <em>abg</em> cebivqr n “erphefvir glcr”,
|
||||
fhpu nf <code>glcrqrs s (*s)();</code>.
|
||||
Fb, V hfrq n urniyl arfgrq shapgvba cbvagre glcr:</p>
|
||||
|
||||
<pre><code>glcrqrs ibvq *(*(*(*...(*(s))()...)())())
|
||||
</code></pre>
|
||||
|
||||
<p>Guvf yvzvgf ubj znal nethzragf bar shapgvba pna or pbafrphgviryl nccyvrq gb.
|
||||
Ohg lbh pna vapernfr gur ahzore ol gjrnxvat gur qrsvavgvba bs znpeb <code>c</code>.</p>
|
||||
|
||||
<h4>Pbqr qhcyvpngvba ol znpebf</h4>
|
||||
|
||||
<p>Arkg, jr arrq gb rapbqr “pybfherf”.
|
||||
N pybfher vf n shapgvba gbtrgure jvgu na raivebazrag
|
||||
juvpu vf n ersrerapr gb aba-ybpny inevnoyr.</p>
|
||||
|
||||
<p>Va guvf pnfr, jr arrq fbzrguvat gung:</p>
|
||||
|
||||
<ul>
|
||||
<li>vf pnyynoyr vgfrys,</li>
|
||||
<li>vagreanyyl cbffrffrf n ersrerapr gb nabgure pybfher nf n aba-ybpny inevnoyr, naq</li>
|
||||
<li>nccyvrf gur vagreany pybfher gb na nethzrag jura vg vf pnyyrq.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>Ubjrire, ab glcr va P vf pnyynoyr naq unf n ersrerapr ng gur fnzr gvzr.
|
||||
(Vg vf srnfvoyr ol qlanzvp pbqr trarengvba, ohg vg vf sne sebz cbegnoyr.)</p>
|
||||
|
||||
<p>Fb, V nqqerffrq guvf vffhr ol trarengvat znal shapgvba qrsvavgvbaf
|
||||
fgngvpnyyl ol (no)hfvat znpebf:</p>
|
||||
|
||||
<pre><code>ibvq *k1; ibvq s1(ibvq *l) { erghea nccyl(k1, l); }
|
||||
ibvq *k2; ibvq s2(ibvq *l) { erghea nccyl(k2, l); }
|
||||
ibvq *k3; ibvq s3(ibvq *l) { erghea nccyl(k3, l); }
|
||||
...
|
||||
ibvq *(u[]) = { s1, s2, s3, ... }
|
||||
</code></pre>
|
||||
|
||||
<p>naq ol nyybgvat rnpu bs gurz jura n pybfher vf arrqrq.</p>
|
||||
|
||||
<p>Guvf yrnqf gb nabgure yvzvgngvba:
|
||||
gur ahzore bs cer-qrsvarq pybfherf yvzvgf
|
||||
ubj znal vaqragvsvref (<code>F</code> <code>X</code> <code>V</code>) bar cebtenz pna hfr.
|
||||
Ohg lbh pna vapernfr guvf ahzore
|
||||
ol gjrnxvat gur qrsvavgvba bs znpeb <code>N</code> <code>O</code> <code>P</code> naq <code>Q</code>.
|
||||
(Abgr gung pybfherf ner nyybggrq bayl jura cnefvat;
|
||||
nsgre gur rinyhngvba fgnegf, “bhg bs pybfher” pnaabg bpphe.)</p>
|
||||
|
||||
<h4>Fubeg pbeqvat</h4>
|
||||
|
||||
<p>Guvf znetva vf gbb aneebj gb pbagnva n qrgnvyrq rkcynangvba.
|
||||
Vafgrnq, V whfg nfx lbh bar dhrfgvba.
|
||||
Pna lbh gryy jung <code>i f[]={0,0,f+6,f+2,f+4,f,f+3,f+5,f+1};</code> vf?
|
||||
V sbhaq guvf ol hfvat FZG fbyire.</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,216 @@
|
||||
# Most lazy SKIer
|
||||
|
||||
Yusuke Endoh
|
||||
<mame@ruby-lang.org>
|
||||
<https://github.com/mame/>
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
### To build:
|
||||
|
||||
make
|
||||
|
||||
This builds endoh1, echo, hello, and tac.
|
||||
### To run:
|
||||
|
||||
./endoh1 [file.lazy]
|
||||
|
||||
### Try:
|
||||
|
||||
./endoh1 hello.lazy
|
||||
./hello
|
||||
echo Hello | ./echo
|
||||
./tac < endoh1.c
|
||||
|
||||
Be patient with the last one.
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
We liked this entry because it can serve as a standalone program as well as an include file; and, as usual,
|
||||
because its input data is at least as obfuscated as the program itself.
|
||||
|
||||
This entry can be considered an abuse of the GCC's optimizer; it takes GCC about 4x longer to compile it
|
||||
with -O3 than without, compared to clang's 2x.
|
||||
|
||||
|
||||
|
||||
## Author's comments:
|
||||
### Remarks
|
||||
|
||||
$ less prog.c
|
||||
$ gcc -o prog prog.c
|
||||
$ ./prog
|
||||
|
||||
... Isn't there any more to it?
|
||||
|
||||
Yes, of course.
|
||||
|
||||
This is a tool *for C programmers* to play the [SKI combinator calculus][1],
|
||||
especially, [Lazy K][2].
|
||||
|
||||
This program will shine when it is used as a library.
|
||||
For example, `hello.lazy` is a "Hello world" program written in Lazy K.
|
||||
|
||||
$ lazy hello.lazy
|
||||
Hello, world!
|
||||
|
||||
where `lazy` is [a reference implementation of Lazy K][3].
|
||||
At the same time, `hello.lazy` is *a valid C program* that uses `prog.c` as a library.
|
||||
|
||||
$ gcc -o hello -xc hello.lazy
|
||||
$ ./hello
|
||||
Hello, world!
|
||||
|
||||
In other words, this program is a kind of [polyglot][4].
|
||||
|
||||
The usage is simple:
|
||||
you just have to wrap Lazy K program with `#include "prog.c"`.
|
||||
Note that `#` is a comment in Lazy K.
|
||||
|
||||
[1]: http://en.wikipedia.org/wiki/SKI_combinator_calculus
|
||||
[2]: redacted
|
||||
[3]: redacted
|
||||
[4]: http://en.wikipedia.org/wiki/Polyglot_%28computing%29
|
||||
|
||||
|
||||
### Obfuscation
|
||||
|
||||
... is inherent in SKI combinator calculus :-)
|
||||
|
||||
In addition, it uses various hacks to parse SKI code as C,
|
||||
and to satisfy IOCCC's size rule.
|
||||
|
||||
* Abuse of function pointers
|
||||
* Code duplication by macros
|
||||
* Short coding
|
||||
|
||||
These led to the good obfuscation.
|
||||
See Spoiler section in detail, if you need.
|
||||
|
||||
|
||||
### Limitation
|
||||
|
||||
This program supports only "Combinator-calculus style notation" of Lazy K.
|
||||
"Unlambda style" and "Iota and Jot" style are not supported.
|
||||
Also, it requires a space between identifiers.
|
||||
In short, use `(S K)` instead of `(SK)`, "\`sk", `**i*i*i*ii*i*i*ii`,
|
||||
or `11111100011100`.
|
||||
|
||||
Huge memory may be required to compile the program
|
||||
(about 300 MB on my machine).
|
||||
|
||||
In addition, there are some limitations (and workarounds)
|
||||
mentioned in Spoiler section.
|
||||
But I think it wouldn't matter only when you run the attached programs.
|
||||
|
||||
|
||||
### Portability
|
||||
|
||||
I confirmed that the program successfully worked
|
||||
with the following compilers.
|
||||
|
||||
* gcc 4.6.3 [Linux, Mac OS X]
|
||||
* clang 3.0 [Linux, Mac OS X]
|
||||
* tcc 0.9.26 [Linux]
|
||||
* N.B. tcc 0.9.25 seems to have a bug and fails to run it.
|
||||
|
||||
Recent compilers with `-Wall -W -Wextra -pedantic` say nothing.
|
||||
|
||||
gcc -Wall -W -Wextra -pedantic prog.c
|
||||
clang -Wall -W -Wextra -pedantic prog.c
|
||||
tcc -Wall -W -Wextra -pedantic prog.c
|
||||
|
||||
I think it will work on almost all platforms. I confirmed:
|
||||
|
||||
* Ubuntu Linux
|
||||
* Mac OS X
|
||||
* Raspberry PI
|
||||
|
||||
To check whether the program is specified on the command line
|
||||
or included from another source file,
|
||||
the program uses a predefined macro `__INCLUDE_LEVEL__`.
|
||||
It is a gcc extention, and also supported by clang.
|
||||
If your compiler does not support it,
|
||||
you cannot use the program as a library.
|
||||
But you can compile and run it as a standalone program, at least.
|
||||
In fact, tcc does not support the macro, but does work.
|
||||
|
||||
|
||||
### Spoiler (rot13)
|
||||
|
||||
Gur jubyr cebtenz vf vagrecergrq ol znpeb rkcnafvba.
|
||||
Sbe rknzcyr, `F (X V)` vf genafyngrq gb n abezny P pbqr, `(f)((x)(v))`,
|
||||
be fvzcyl `f(x(v))`.
|
||||
Guvf rkcerffvba ergheaf na nofgenpg flagnk gerr,
|
||||
naq `cebt.p` rinyhngrf vg.
|
||||
Guvf cebtenz hfrf irel fvzcyr "grez erjevgvat" nccebnpu
|
||||
sbe rinyhngvat FXV pbzovangbe pnyphyhf.
|
||||
Gur erjevgvat ehyrf ner fubja va gur funcr bs gur pbqr.
|
||||
|
||||
#### Nohfr bs shapgvba cbvagref
|
||||
|
||||
Pbafvqre n frdhrapr bs shapgvba nccyvpngvbaf va P:
|
||||
|
||||
f(k)(k)(k)(k)...
|
||||
|
||||
Jung glcr fubhyq `f` unir?
|
||||
Hasbeghangryl, P qbrf *abg* cebivqr n "erphefvir glcr",
|
||||
fhpu nf `glcrqrs s (*s)();`.
|
||||
Fb, V hfrq n urniyl arfgrq shapgvba cbvagre glcr:
|
||||
|
||||
glcrqrs ibvq *(*(*(*...(*(s))()...)())())
|
||||
|
||||
Guvf yvzvgf ubj znal nethzragf bar shapgvba pna or pbafrphgviryl nccyvrq gb.
|
||||
Ohg lbh pna vapernfr gur ahzore ol gjrnxvat gur qrsvavgvba bs znpeb `c`.
|
||||
|
||||
|
||||
#### Pbqr qhcyvpngvba ol znpebf
|
||||
|
||||
Arkg, jr arrq gb rapbqr "pybfherf".
|
||||
N pybfher vf n shapgvba gbtrgure jvgu na raivebazrag
|
||||
juvpu vf n ersrerapr gb aba-ybpny inevnoyr.
|
||||
|
||||
Va guvf pnfr, jr arrq fbzrguvat gung:
|
||||
|
||||
* vf pnyynoyr vgfrys,
|
||||
* vagreanyyl cbffrffrf n ersrerapr gb nabgure pybfher nf n aba-ybpny inevnoyr, naq
|
||||
* nccyvrf gur vagreany pybfher gb na nethzrag jura vg vf pnyyrq.
|
||||
|
||||
Ubjrire, ab glcr va P vf pnyynoyr naq unf n ersrerapr ng gur fnzr gvzr.
|
||||
(Vg vf srnfvoyr ol qlanzvp pbqr trarengvba, ohg vg vf sne sebz cbegnoyr.)
|
||||
|
||||
Fb, V nqqerffrq guvf vffhr ol trarengvat znal shapgvba qrsvavgvbaf
|
||||
fgngvpnyyl ol (no)hfvat znpebf:
|
||||
|
||||
ibvq *k1; ibvq s1(ibvq *l) { erghea nccyl(k1, l); }
|
||||
ibvq *k2; ibvq s2(ibvq *l) { erghea nccyl(k2, l); }
|
||||
ibvq *k3; ibvq s3(ibvq *l) { erghea nccyl(k3, l); }
|
||||
...
|
||||
ibvq *(u[]) = { s1, s2, s3, ... }
|
||||
|
||||
naq ol nyybgvat rnpu bs gurz jura n pybfher vf arrqrq.
|
||||
|
||||
Guvf yrnqf gb nabgure yvzvgngvba:
|
||||
gur ahzore bs cer-qrsvarq pybfherf yvzvgf
|
||||
ubj znal vaqragvsvref (`F` `X` `V`) bar cebtenz pna hfr.
|
||||
Ohg lbh pna vapernfr guvf ahzore
|
||||
ol gjrnxvat gur qrsvavgvba bs znpeb `N` `O` `P` naq `Q`.
|
||||
(Abgr gung pybfherf ner nyybggrq bayl jura cnefvat;
|
||||
nsgre gur rinyhngvba fgnegf, "bhg bs pybfher" pnaabg bpphe.)
|
||||
|
||||
|
||||
#### Fubeg pbeqvat
|
||||
|
||||
Guvf znetva vf gbb aneebj gb pbagnva n qrgnvyrq rkcynangvba.
|
||||
Vafgrnq, V whfg nfx lbh bar dhrfgvba.
|
||||
Pna lbh gryy jung `i f[]={0,0,f+6,f+2,f+4,f,f+3,f+5,f+1};` vf?
|
||||
V sbhaq guvf ol hfvat FZG fbyire.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(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,36 @@
|
||||
/rot13
|
||||
.s/rot13/click the text to rot13/
|
||||
a
|
||||
<span onclick="
|
||||
function rot13(txt) {
|
||||
var buf = '';
|
||||
var intag = 0, inent = 0;
|
||||
for (j = 0; j < txt.length; j++) {
|
||||
var c = txt.charCodeAt(j);
|
||||
if (intag) {
|
||||
if (c == 62) intag = 0;
|
||||
buf += String.fromCharCode(c);
|
||||
} else if (c == 60) {
|
||||
intag = 1;
|
||||
buf += '<';
|
||||
} else if (inent) {
|
||||
if (c == 59) inent = 0;
|
||||
buf += String.fromCharCode(c);
|
||||
} else if (c == 38) {
|
||||
inent = 1;
|
||||
buf += '&';
|
||||
} else if ((c >= 65 && c <= 90) || (c >= 97 && c <= 122)) {
|
||||
buf += String.fromCharCode((c<=90?90:122)>=(c+13)?c+13:c-13);
|
||||
} else {
|
||||
buf += String.fromCharCode(c);
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
this.innerHTML=rot13(this.innerHTML);">
|
||||
.
|
||||
$
|
||||
a
|
||||
</span>
|
||||
.
|
||||
wq
|
||||
@@ -0,0 +1,5 @@
|
||||
#include "endoh1.c"
|
||||
|
||||
S(K(S I I(S(K(S(S(S I(K(K(K(K I)))))(K(K(S I I(S I I(S(S(K S)K)I))))))))(S(S(K S)(S(K(S(S(S I(K K))(K(K(K(K I)))))))(S(S(K S)(S(K K)(S I I)))(K(S I(K(K I)))))))(S(K(S(S(K S)(S(K(S I))(S S(S(S I(K K)))(K K))))))(S(K(S(K K)))(S(S(K S)(S(K K)(S I I)))(K(S(S(K S)(S(K(S I))(S(K K)(S(S I(K K))(K(K I))))))(S(K K)(S I(K(K I)))))))))))))(S(K(S I I(S(K(S(S(K S)(S(K(S(S I(K(K(K(K I)))))))K))))(S(S(K S)(S(K(S(K S)))(S(S(K S)(S(K K)(S(K S)(S(K K)(S I I)))))(K(S(K(S(S(K S)(S(K(S I))(S S(S I)(K K))))))(S(K K)K))))))(K(K(S I(K(K I)))))))(K K)))(S I I(S(K(S(S(K S)(S(K K)(S(K(S I I(S I I(S(S(K S)K)I))(S(K(S I))K)))(S(K K)(S(K(S(S(S I(K(K(K(K I)))))(K(K K)))(S(S(K S)(S(K(S I))K))(K(K(K K))))))(S I(K(K K))))))))))(S(K(S(K(S(S(S I(K K))(K(S(K(S I))K)))))))(S(K(S(K(S(K K)))))(S(S(K S)(S(K(S(K S)))(S(K(S(K(S(S(K(S I(K K)))(S(S(S I(K K))(K(S I(K(K I)))))(K(S(S(K S)K)I(S(S(K S)K)(S I I(S(S(K S)K)I))(S(K(S(S I(K(K I)))))K))(S(S I(K K))(K(S I I(S(K(S(K(S(S I(K(K I)))))K))(S I I)))))))))))))(S(K(S(S(K S)(S S(S(S(K S)(S(K K)(S(K S)(S(K(S I))(S(K K)(S I(K(S(S I(K(S(K(S(S(K S)K)I))(S(S(K S)K)(S I I(S(S(K S)K)I))))))(K(K K)))))))))))(K K)))))(S(K K)(S(S(K S)(S(K K)(S(S I I)(K I))))(K(S I(K(K I))))))))))(S(S(K S)(S(K(S(K S)))(S(S(K S)(S(K K)(S(K S)(S(K K)(S I I)))))(K(S(S(K S)(S(K K)(S(K S)K)))(K(S(S(K S)(S(K K)(S(K S)(S(K(S I))(S S(S I)(K K))))))(K K))))))))(K(K(S I(K(K I))))))))))I))
|
||||
|
||||
#include "endoh1.c"
|
||||
Reference in new issue
Block a user