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,268 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2015 makefile
|
||||
#
|
||||
# This work by Landon Curt Noll, Simon Cooper, and Leonid A. Broukhis
|
||||
# is licensed under:
|
||||
#
|
||||
# Creative Commons Attribution-ShareAlike 3.0 Unported License.
|
||||
#
|
||||
# See: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
|
||||
################
|
||||
# tool locations
|
||||
################
|
||||
#
|
||||
SHELL= /bin/bash
|
||||
CP= cp
|
||||
CPP= cpp
|
||||
GUNZIP= gunzip
|
||||
BUNZIP2= bunzip2
|
||||
LD= ld
|
||||
MAKE= make
|
||||
RM= rm
|
||||
SED= sed
|
||||
TAR= tar
|
||||
TRUE= true
|
||||
MKDIR= mkdir
|
||||
MV= mv
|
||||
TR= tr
|
||||
GREP= grep
|
||||
SORT= sort
|
||||
UNIQ= uniq
|
||||
CUT=cut
|
||||
|
||||
# Set X11_LIBDIR to the directory where the X11 library resides
|
||||
#
|
||||
#X11_LIBDIR= /usr/X11R6/lib
|
||||
#X11_LIBDIR= /usr/X11/lib
|
||||
X11_LIBDIR= /opt/X11/lib
|
||||
|
||||
# Set X11_INCLUDEDIR to the directory where the X11 include files reside
|
||||
#
|
||||
#X11_INCDIR= /usr/X11R6/include
|
||||
#X11_INCDIR= /usr/X11/include
|
||||
X11_INCDIR= /opt/X11/include
|
||||
|
||||
# Compiler warnings
|
||||
#
|
||||
#CWARN=
|
||||
#CWARN= -Wall
|
||||
#CWARN= -Wall -Wextra
|
||||
CWARN= -Wall -Wextra -pedantic ${CSILENCE}
|
||||
#CWARN= -Wall -Wextra -Weverything
|
||||
#CWARN= -Wall -Wextra -Weverything -pedantic
|
||||
#CWARN= -Wall -Wextra -Weverything -pedantic ${CSILENCE}
|
||||
|
||||
# Silence warnings that ${CWARN} would normally complain about
|
||||
#
|
||||
#CSILENCE=
|
||||
CSILENCE= -Wno-keyword-macro -Wno-unused-macros
|
||||
|
||||
# compiler standard
|
||||
#
|
||||
#CSTD=
|
||||
#CSTD= -ansi
|
||||
#CSTD= -std=c11
|
||||
CSTD= -std=c1x
|
||||
|
||||
# compiler bit architecture
|
||||
#
|
||||
# Some entries require 32-bitness:
|
||||
# ARCH= -m32
|
||||
#
|
||||
# Some entries require 64-bitess:
|
||||
# ARCH= -m64
|
||||
#
|
||||
# By default we assume nothing:
|
||||
#
|
||||
ARCH=
|
||||
|
||||
# defines that are needed to compile
|
||||
#
|
||||
#CDEFINE=
|
||||
CDEFINE= -DX="$(X)" -DV="$(V)"
|
||||
|
||||
# include files that are needed to compile
|
||||
#
|
||||
#CINCLUDE=
|
||||
CINCLUDE= -include "${MACHINE}" -include "${TAPE}"
|
||||
|
||||
# optimization
|
||||
#
|
||||
# Most compiles will safely use -O2. Some can use only -O1 or -O.
|
||||
# A few compilers have broken optimizers or this entry make break
|
||||
# under those buggy optimizers and thus you may not want anything.
|
||||
# Reasonable compilers will allow for -O3.
|
||||
#
|
||||
#OPT=
|
||||
#OPT= -O
|
||||
#OPT= -O1
|
||||
#OPT= -O2
|
||||
OPT= -O3
|
||||
|
||||
# default flags for ANSI C compilation
|
||||
#
|
||||
CFLAGS= ${CWARN} ${CSTD} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT}
|
||||
|
||||
# Libraries needed to build
|
||||
#
|
||||
LIBS=
|
||||
#LIBS= -L ${X11_LIBDIR}
|
||||
|
||||
# ANSI compiler
|
||||
#
|
||||
# Set CC to the name of your ANSI compiler.
|
||||
#
|
||||
# Some entries seem to need gcc. If you have gcc, set
|
||||
# both CC and MAY_NEED_GCC to gcc.
|
||||
#
|
||||
# If you do not have gcc, set CC to the name of your ANSI compiler, and
|
||||
# set MAY_NEED_GCC to either ${CC} (and hope for the best) or to just :
|
||||
# to disable such programs.
|
||||
#
|
||||
CC= cc
|
||||
#CC=clang
|
||||
MAY_NEED_GCC= gcc
|
||||
|
||||
|
||||
##############################
|
||||
# Special flags for this entry
|
||||
##############################
|
||||
#
|
||||
ENTRY= prog
|
||||
CSRC= ${ENTRY}.c
|
||||
OBJ= ${ENTRY}.o
|
||||
DATA=
|
||||
ALT_OBJ=
|
||||
ALT_ENTRY=
|
||||
TARGET= ${ENTRY}
|
||||
|
||||
MACHINE = machine_beaver_4_2.h
|
||||
TAPE = tape_empty.h
|
||||
|
||||
#################
|
||||
# build the entry
|
||||
#################
|
||||
#
|
||||
all: ${TARGET} ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
${ENTRY}: ${CSRC}
|
||||
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
||||
|
||||
# alternative executable
|
||||
#
|
||||
alt: ${ALT_ENTRY}
|
||||
@${TRUE}
|
||||
|
||||
# data files
|
||||
#
|
||||
data: ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
# test the entry
|
||||
#
|
||||
.PHONY: run
|
||||
run: ${ENTRY}
|
||||
@ ./${ENTRY} | ${TR} -d '~'
|
||||
@ [ -z "${V}" ] || [ "${V}" -lt 1 ] || { echo "total:" $$(./${ENTRY} | ${TR} -dc '~' | wc -c) "steps"; }
|
||||
@ [ -z "${V}" ] || [ "${V}" -lt 2 ] || { ./${ENTRY} | ${GREP} '^~' | ${CUT} -f2 | ${SORT} | ${UNIQ} -c; }
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
${RM} -f ${OBJ} ${ALT_OBJ}
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${TARGET} ${ALT_ENTRY}
|
||||
|
||||
nuke: clobber
|
||||
@${TRUE}
|
||||
|
||||
dist_clean: nuke
|
||||
@${TRUE}
|
||||
|
||||
install:
|
||||
@echo "Surely we are joking Dr. May!"
|
||||
@${TRUE}
|
||||
|
||||
# backwards compatibility
|
||||
#
|
||||
build: all
|
||||
@${TRUE}
|
||||
|
||||
|
||||
##################
|
||||
# 133t hacker rulz
|
||||
##################
|
||||
#
|
||||
love:
|
||||
@echo 'not war?'
|
||||
@${TRUE}
|
||||
|
||||
haste:
|
||||
$(MAKE) waste
|
||||
@${TRUE}
|
||||
|
||||
waste:
|
||||
@echo 'haste'
|
||||
@${TRUE}
|
||||
|
||||
make:
|
||||
@echo 'Attend a maker faire'
|
||||
@${TRUE}
|
||||
|
||||
easter_egg:
|
||||
@echo you expected to sometimes mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Readers shall not be disallowed from not failing to be unable to not partly misunderstand this partocular final echo.
|
||||
|
||||
# Understand the history of the Homebrew Computer Club
|
||||
# as well as the West Coast Computer Faire and
|
||||
# you might be confused different. :-)
|
||||
#
|
||||
supernova: nuke
|
||||
@-if [ -r .code_anal ]; then \
|
||||
${RM} -f .code_anal_v5; \
|
||||
else \
|
||||
echo "planet deniers, like the IAU, are amusing"; \
|
||||
fi
|
||||
@echo A $@ helps ${MAKE} the elements that help form planets
|
||||
@${TRUE}
|
||||
|
||||
deep_magic:
|
||||
@-if [ -r .code_anal ]; then \
|
||||
ccode_analysis --deep_magic 2ed3582ec5c094a093fea2a6bcb9f19439892873c9cc45ed1ceaafe08b7d52e1b2c7cd524be3b0b2 --FNV1a_hash_512_bit "${ENTRY}"; \
|
||||
else \
|
||||
echo "You are holding it wrong!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
|
||||
magic: deep_magic
|
||||
@-if [ -r .code_anal ]; then \
|
||||
ccode_analysis --mode 216091 --level 216193 --FNV1a_hash_512_bit "${ENTRY}"; \
|
||||
else \
|
||||
echo "These aren't the primes you're looking for Pauline!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
|
||||
# The IOCCC resident astronomer states
|
||||
#
|
||||
charon: supernova
|
||||
@echo $@ is a dwarf planet
|
||||
@echo dwarf is a type of planet
|
||||
@echo $@ is a planet
|
||||
|
||||
pluto: supernova
|
||||
${MAKE} charon
|
||||
@echo $@ is a dwarf planet
|
||||
@echo dwarf is a type of planet
|
||||
@echo $@ is a planet
|
||||
@echo get used to having lots of planets because a $< can ${MAKE} a lot of them
|
||||
@@ -0,0 +1,151 @@
|
||||
<!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 Complete Use of CPP</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Most Complete Use of CPP</h1>
|
||||
|
||||
<p>Dominik Muth <a href="mailto:muth.ioccc@freenet.de">muth.ioccc@freenet.de</a></p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make -B [MACHINE=your_machine.h] [TAPE=your_tape.h] [X=[0|1|2|3|4|5|6|7|8|9]] [V=[0|1|2]] run
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>make -B V=2 run
|
||||
|
||||
strings prog | grep '(,)'
|
||||
|
||||
make -B MACHINE=machine_times2.h TAPE=tape_five.h V=1 run
|
||||
|
||||
make -B MACHINE=machine_chaos_5_2.h X=5 run
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>This is something we were fearing all along: that the C preprocessor is Turing-complete
|
||||
even without conditionals and recursive file inclusion as some kind of a
|
||||
<a href="https://en.wikipedia.org/wiki/Rewriting">rewriting system</a>. Now we have the proof!</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Preprocessor Turing Engine</h3>
|
||||
|
||||
<h4>Features</h4>
|
||||
|
||||
<ul>
|
||||
<li>Turing machine runs in preprocessor</li>
|
||||
<li>universal (unlimited configurable states, symbols, and tape)</li>
|
||||
<li>no <code>#if</code>s or other conditional directives, only <code>#define</code>s</li>
|
||||
<li>no recursive <code>#include</code></li>
|
||||
<li>single compiler run (no repeated preprocessing)</li>
|
||||
<li>no variadic macros</li>
|
||||
<li>verbosity levels:
|
||||
|
||||
<ul>
|
||||
<li><code>V=0</code> (default) only prints the final tape</li>
|
||||
<li><code>V=1</code> additionally prints one tilde character per machine step (slow)</li>
|
||||
<li><code>V=2</code> additionally prints details on each machine step (slow; generates large files)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>make target <code>run</code> runs <code>./prog</code> and filters a little statistics out of the verbose output</li>
|
||||
<li><code>X</code> (defaults to 3) sets the maximum number of steps: <em>M</em>(<code>X</code>) ~ 8<sup><code>X</code></sup></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h4>Limitations</h4>
|
||||
|
||||
<p>If the machine does not halt after <em>M</em>(<code>X</code>) steps, you will see unexpanded macros in the output.</p>
|
||||
|
||||
<h4>Compiler warnings</h4>
|
||||
|
||||
<p>If <code>V=1</code> or <code>V=2</code> is used, you may see “<code>warning: string length is greater than the length '4095' ISO C99 compilers are required to support</code>”.</p>
|
||||
|
||||
<h4>Programming</h4>
|
||||
|
||||
<p>Implementing your own Turing machine is easy. Take a look at the supplied header files for examples.</p>
|
||||
|
||||
<h5>Tape Symbols</h5>
|
||||
|
||||
<p>Every symbol used (except “<code>_</code>”) must be explicitly declared using</p>
|
||||
|
||||
<pre><code>#define sym_SYMBOL(sym, _SYMBOL) sym
|
||||
</code></pre>
|
||||
|
||||
<p>Example:</p>
|
||||
|
||||
<pre><code>#define sym_1(sym, _1) sym
|
||||
</code></pre>
|
||||
|
||||
<h5>Tape</h5>
|
||||
|
||||
<p>The initial content of the tape must be defined in the tape header using a triple like:</p>
|
||||
|
||||
<pre><code>#define tape ((((,),...l2), l1), c, (r1, (r2..., (,))))
|
||||
</code></pre>
|
||||
|
||||
<ul>
|
||||
<li><code>l1</code>, <code>l2</code>, … are the symbols to the left</li>
|
||||
<li><code>c</code> is the symbol at the current position</li>
|
||||
<li><code>r1</code>, <code>r2</code>, … are the symbols to the right</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>The empty pairs “<code>(,)</code>” represent the continuations of the tape, filled with underscore symbols (“<code>_</code>”). They are expanded on demand.</p>
|
||||
|
||||
<h5>State Machine</h5>
|
||||
|
||||
<p>All transitions are defined in the machine header using the syntax</p>
|
||||
|
||||
<pre><code>#define CURRENT_SCANNED (WRITE, MOVEMENT, NEXT)
|
||||
</code></pre>
|
||||
|
||||
<p>where</p>
|
||||
|
||||
<ul>
|
||||
<li><code>CURRENT</code> is the current state</li>
|
||||
<li><code>SCANNED</code> is the symbol at the current position</li>
|
||||
<li>the whitespace before the parentheses is significant</li>
|
||||
<li><code>WRITE</code> is the symbol to be written to the tape</li>
|
||||
<li><code>MOVEMENT</code> is “<code>L</code>” for left, “<code>R</code>” for right, or nothing</li>
|
||||
<li><code>NEXT</code> is the next state</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>There must be a state “<code>A</code>” defined, which becomes the initial state of the machine.</p>
|
||||
|
||||
<p>To halt the machine, use the keyword “<code>break</code>” as in</p>
|
||||
|
||||
<pre><code>#define A_1 (2, break)
|
||||
</code></pre>
|
||||
|
||||
<hr />
|
||||
|
||||
<!--
|
||||
(c) Copyright 1984-2016, [Leo Broukhis, Simon Cooper, Landon Curt Noll][judges] - All rights reserved
|
||||
This work is licensed under a [Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].
|
||||
|
||||
[judges]: http://www.ioccc.org/judges.html
|
||||
[cc]: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
-->
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2016,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,107 @@
|
||||
# Most Complete Use of CPP
|
||||
|
||||
Dominik Muth <muth.ioccc@freenet.de>
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
### To use:
|
||||
|
||||
make -B [MACHINE=your_machine.h] [TAPE=your_tape.h] [X=[0|1|2|3|4|5|6|7|8|9]] [V=[0|1|2]] run
|
||||
|
||||
### Try:
|
||||
|
||||
make -B V=2 run
|
||||
|
||||
strings prog | grep '(,)'
|
||||
|
||||
make -B MACHINE=machine_times2.h TAPE=tape_five.h V=1 run
|
||||
|
||||
make -B MACHINE=machine_chaos_5_2.h X=5 run
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
This is something we were fearing all along: that the C preprocessor is Turing-complete
|
||||
even without conditionals and recursive file inclusion as some kind of a
|
||||
[rewriting system](https://en.wikipedia.org/wiki/Rewriting). Now we have the proof!
|
||||
|
||||
## Author's comments:
|
||||
### Preprocessor Turing Engine
|
||||
|
||||
#### Features
|
||||
|
||||
- Turing machine runs in preprocessor
|
||||
- universal (unlimited configurable states, symbols, and tape)
|
||||
- no `#if`s or other conditional directives, only `#define`s
|
||||
- no recursive `#include`
|
||||
- single compiler run (no repeated preprocessing)
|
||||
- no variadic macros
|
||||
- verbosity levels:
|
||||
+ `V=0` (default) only prints the final tape
|
||||
+ `V=1` additionally prints one tilde character per machine step (slow)
|
||||
+ `V=2` additionally prints details on each machine step (slow; generates large files)
|
||||
- make target `run` runs `./prog` and filters a little statistics out of the verbose output
|
||||
- `X` (defaults to 3) sets the maximum number of steps: *M*(`X`) ~ 8<sup>`X`</sup>
|
||||
|
||||
#### Limitations
|
||||
|
||||
If the machine does not halt after *M*(`X`) steps, you will see unexpanded macros in the output.
|
||||
|
||||
#### Compiler warnings
|
||||
|
||||
If `V=1` or `V=2` is used, you may see "`warning: string length is greater than the length '4095' ISO C99 compilers are required to support`".
|
||||
|
||||
#### Programming
|
||||
|
||||
Implementing your own Turing machine is easy. Take a look at the supplied header files for examples.
|
||||
|
||||
##### Tape Symbols
|
||||
|
||||
Every symbol used (except "`_`") must be explicitly declared using
|
||||
|
||||
#define sym_SYMBOL(sym, _SYMBOL) sym
|
||||
|
||||
Example:
|
||||
|
||||
#define sym_1(sym, _1) sym
|
||||
|
||||
##### Tape
|
||||
|
||||
The initial content of the tape must be defined in the tape header using a triple like:
|
||||
|
||||
#define tape ((((,),...l2), l1), c, (r1, (r2..., (,))))
|
||||
|
||||
- `l1`, `l2`, ... are the symbols to the left
|
||||
- `c` is the symbol at the current position
|
||||
- `r1`, `r2`, ... are the symbols to the right
|
||||
|
||||
The empty pairs "`(,)`" represent the continuations of the tape, filled with underscore symbols ("`_`"). They are expanded on demand.
|
||||
|
||||
##### State Machine
|
||||
|
||||
All transitions are defined in the machine header using the syntax
|
||||
|
||||
#define CURRENT_SCANNED (WRITE, MOVEMENT, NEXT)
|
||||
|
||||
where
|
||||
|
||||
- `CURRENT` is the current state
|
||||
- `SCANNED` is the symbol at the current position
|
||||
- the whitespace before the parentheses is significant
|
||||
- `WRITE` is the symbol to be written to the tape
|
||||
- `MOVEMENT` is "`L`" for left, "`R`" for right, or nothing
|
||||
- `NEXT` is the next state
|
||||
|
||||
There must be a state "`A`" defined, which becomes the initial state of the machine.
|
||||
|
||||
To halt the machine, use the keyword "`break`" as in
|
||||
|
||||
#define A_1 (2, break)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(c) Copyright 1984-2016, [Leo Broukhis, Simon Cooper, Landon Curt Noll][judges] - All rights reserved
|
||||
This work is licensed under a [Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].
|
||||
|
||||
[judges]: http://www.ioccc.org/judges.html
|
||||
[cc]: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
-->
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 4 state, 2 symbol busy beaver, http://www.logique.jussieu.fr/~michel/ha.html#tm42
|
||||
*
|
||||
* halts after 107 steps
|
||||
*/
|
||||
|
||||
#define sym_1(sym, _1) sym
|
||||
|
||||
#define A__ (1, R, B)
|
||||
#define A_1 (1, L, B)
|
||||
|
||||
#define B__ (1, L, A)
|
||||
#define B_1 (_, L, C)
|
||||
|
||||
#define C__ (1,break)
|
||||
#define C_1 (1, L, D)
|
||||
|
||||
#define D__ (1, R, D)
|
||||
#define D_1 (_, R, A)
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 2 state, 4 symbol current champion, http://www.logique.jussieu.fr/~michel/ha.html#tm24
|
||||
*
|
||||
* halts after 3932964 steps
|
||||
*/
|
||||
|
||||
#define sym_1(sym, _1) sym
|
||||
#define sym_2(sym, _2) sym
|
||||
#define sym_3(sym, _3) sym
|
||||
|
||||
#define A__ (1, R, B)
|
||||
#define A_1 (2, L, A)
|
||||
#define A_2 (1, R, A)
|
||||
#define A_3 (1, R, A)
|
||||
|
||||
#define B__ (1, L, B)
|
||||
#define B_1 (1, L, A)
|
||||
#define B_2 (3, R, B)
|
||||
#define B_3 (1,break)
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* chaos machine, http://www.drb.insel.de/~heiner/BB/mabu90.html
|
||||
*
|
||||
* does not halt (http://www.drb.insel.de/~heiner/BB/TM4-proof.txt)
|
||||
*/
|
||||
|
||||
#define sym_1(sym, _1) sym
|
||||
|
||||
#define A__ (1, L, B)
|
||||
#define A_1 (1, R, B)
|
||||
|
||||
#define B__ (1, R, C)
|
||||
#define B_1 (_, L, E)
|
||||
|
||||
#define C__ (_, R, D)
|
||||
#define C_1 (_, L, A)
|
||||
|
||||
#define D__ (1, L, A)
|
||||
#define D_1 (_, R, D)
|
||||
|
||||
#define E__ (1,break)
|
||||
#define E_1 (_, L, C)
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* complex machine, http://www.drb.insel.de/~heiner/BB/mabu90.html
|
||||
*/
|
||||
|
||||
#define sym_1(sym, _1) sym
|
||||
|
||||
#define A__ (1, L, B)
|
||||
#define A_1 (1, R, A)
|
||||
|
||||
#define B__ (_, R, A)
|
||||
#define B_1 (_, L, C)
|
||||
|
||||
#define C__ (_, R, C)
|
||||
#define C_1 (1, L, D)
|
||||
|
||||
#define D__ (1, L, E)
|
||||
#define D_1 (_, R, A)
|
||||
|
||||
#define E__ (_, L, B)
|
||||
#define E_1 (1,break)
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* counting machine, http://www.drb.insel.de/~heiner/BB/mabu90.html
|
||||
*
|
||||
* does not halt
|
||||
*/
|
||||
|
||||
#define sym_1(sym, _1) sym
|
||||
|
||||
#define A__ (1, L, B)
|
||||
#define A_1 (1, R, A)
|
||||
|
||||
#define B__ (_, R, A)
|
||||
#define B_1 (_, L, C)
|
||||
|
||||
#define C__ (_, R, A)
|
||||
#define C_1 (1, L, D)
|
||||
|
||||
#define D__ (_, L, E)
|
||||
#define D_1 (1, R, B)
|
||||
|
||||
#define E__ (_, R, B)
|
||||
#define E_1 (1,break)
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* greatest common divisor
|
||||
*
|
||||
* based on http://www.ioccc.org/2001/herrmann1.gcd
|
||||
*/
|
||||
|
||||
// try tape_15_50.h or tape_77_55.h
|
||||
|
||||
#define A__ (_, R, A )
|
||||
#define A_1 (1, L, x9)
|
||||
|
||||
#define x0_1 (_, R, x1)
|
||||
|
||||
#define x1__ (_, R, xa)
|
||||
#define x1_1 (1, R, x2)
|
||||
|
||||
#define x2__ (_, R, x3)
|
||||
#define x2_1 (1, R, x2)
|
||||
|
||||
#define x3__ (_, R, x3)
|
||||
#define x3_1 (1, R, x4)
|
||||
|
||||
#define x4__ (1, L, x5)
|
||||
#define x4_1 (1, R, x4)
|
||||
|
||||
#define x5_1 (_, L, x6)
|
||||
|
||||
#define x6__ (_, R, xc)
|
||||
#define x6_1 (1, L, x7)
|
||||
|
||||
#define x7__ (_, L, x8)
|
||||
#define x7_1 (1, L, x7)
|
||||
|
||||
#define x8__ (_, L, x8)
|
||||
#define x8_1 (1, L, x9)
|
||||
|
||||
#define x9__ (1, R, x0)
|
||||
#define x9_1 (1, L, x9)
|
||||
|
||||
#define xa__ (_, R, xa)
|
||||
#define xa_1 (_, R, xb)
|
||||
|
||||
#define xb__ (_, R, xf)
|
||||
#define xb_1 (1, R, xc)
|
||||
|
||||
#define xc__ (_, R, xd)
|
||||
#define xc_1 (1, R, xc)
|
||||
|
||||
#define xd__ (_, L, xe)
|
||||
#define xd_1 (_, R, xd)
|
||||
|
||||
#define xe__ (_, L, xe)
|
||||
#define xe_1 (1, L, x7)
|
||||
|
||||
#define xf__ (_, break)
|
||||
#define xf_1 (_, R, xf)
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* greater machine, http://www.drb.insel.de/~heiner/BB/mabu90.html
|
||||
*
|
||||
* does not halt
|
||||
*/
|
||||
|
||||
#define sym_1(sym, _1) sym
|
||||
|
||||
#define A__ (1, L, B)
|
||||
#define A_1 (1, R, A)
|
||||
|
||||
#define B__ (_, R, C)
|
||||
#define B_1 (1, L, B)
|
||||
|
||||
#define C__ (1,break)
|
||||
#define C_1 (1, R, A)
|
||||
@@ -0,0 +1,40 @@
|
||||
#/*
|
||||
* this is a guide how to choose names for states and symbols
|
||||
*
|
||||
* state names must be valid to start a macro identifier, e.g., # is
|
||||
* invalid, 0 is invalid, _0 is valid (an empty string is also valid)
|
||||
*
|
||||
* tape symbols must not be empty and must be valid to end a macro
|
||||
* name, e.g., # is invalid, 0 is valid, _0 is valid
|
||||
*
|
||||
* exception: you can write almost any other sequence of tokens to the
|
||||
* tape, but you can not scan them back (you can not even define them
|
||||
* as symbols using the
|
||||
*
|
||||
*/ define sym_SYMBOL(sym, _SYMBOL) sym
|
||||
#/*
|
||||
* syntax)
|
||||
*
|
||||
* finally its perfectly ok to define macros for your states like this
|
||||
*
|
||||
*/ define ANOTHER_NAME_FOR_A A
|
||||
#/*
|
||||
* and for your symbols like this
|
||||
*
|
||||
*/ define FQDN www.ioccc.org.
|
||||
|
||||
#define you can run this example on an empty tape
|
||||
|
||||
#define A__ (SYMBOL, L,)
|
||||
#define __ (__, ,)
|
||||
#define ___ (, R, ANOTHER_NAME_FOR_A)
|
||||
#define A_SYMBOL (\x1b[4mhttp, R, I)
|
||||
#define I__ (:, R, O )
|
||||
#define O__ (/\x2f, R, C)
|
||||
#define C__ (FQDN, R, Z)
|
||||
#define Z__ (/, R, L)
|
||||
#define L__ (index.html, R, _2)
|
||||
#define _2__ (#enter\x1b[0m, R, _0)
|
||||
#define _0__ (R(A, tape), R, _1)
|
||||
#define _1__ ((,), R, _5)
|
||||
#define _5__ (W(You you!!!), break)
|
||||
@@ -0,0 +1,7 @@
|
||||
/*
|
||||
* minimal Turing machine example
|
||||
*
|
||||
* see also: tape_empty.h
|
||||
*/
|
||||
|
||||
#define A__ (_, break)
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 2 state, 4 symbol current runner-up, http://www.logique.jussieu.fr/~michel/ha.html#tm24
|
||||
*
|
||||
* halts after 7195 steps
|
||||
*/
|
||||
|
||||
#define sym_1(sym, _1) sym
|
||||
#define sym_2(sym, _2) sym
|
||||
#define sym_3(sym, _3) sym
|
||||
|
||||
#define A__ (1, R, B)
|
||||
#define A_1 (3, L, A)
|
||||
#define A_2 (1, L, A)
|
||||
#define A_3 (1, R, A)
|
||||
|
||||
#define B__ (2, L, A)
|
||||
#define B_1 (1,break)
|
||||
#define B_2 (3, R, A)
|
||||
#define B_3 (3, R, B)
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* multiply by 2
|
||||
*
|
||||
* based on http://www.ioccc.org/2001/herrmann1.times2
|
||||
*/
|
||||
|
||||
// try tape_five.h
|
||||
|
||||
#define A__ (_, R, A)
|
||||
#define A_1 (_, L, B)
|
||||
|
||||
#define B__ (1, L, C)
|
||||
|
||||
#define C__ (1, R, D)
|
||||
#define C_1 (1, L, C)
|
||||
|
||||
#define D__ (_, R, E)
|
||||
#define D_1 (1, R, D)
|
||||
|
||||
#define E__ (_,break)
|
||||
#define E_1 (_, L, B)
|
||||
@@ -0,0 +1,95 @@
|
||||
|
||||
|
||||
|
||||
# define S(M, L, N, R) J(M, P) (L, N, R )
|
||||
# define QL(L, R)/* L,*/QR(L, /*N,*/ R)//
|
||||
# define P( L, N, R) L, N, R//
|
||||
# define LP( L, N, R) U L, D L, (N, R)
|
||||
# define R( L, R)W (Y(J(E,X)(K(L, R ))))
|
||||
|
||||
# define RP( L, N, R)(L, N), H R, T R//
|
||||
# define HP( L, N, R) L, N, R//
|
||||
# define K( L, R)/* L,*/J(F, V)(L, R)J \
|
||||
( Q,sym_ ( K, M ( L, B R))) (L, R )
|
||||
# define Q( L, R)/* L,*/QR(L, /*N,*/ R)//
|
||||
|
||||
# define E( X)E3(X)
|
||||
# define break H ,
|
||||
# define E0(/**/X)X
|
||||
# define I( X, E) K
|
||||
# define EX(X)E3(X)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define E1(_I_)E0 (E0(E0(E0(E0(E0(E0 (E0( _I_ ))))))))
|
||||
#define E2(_O_)E1 (E1(E1(E1(E1(E1(E1 (E1( _O_ ))))))))
|
||||
#define E3(_C_)E2 (E2(E2(E2(E2(E2(E2 (E2( _C_ ))))))))
|
||||
|
||||
#define E4(_C_)E3 (E3(E3(E3(E3(E3(E3 (E3( _C_ ))))))))
|
||||
#define E5(_C_)E4 (E4(E4(E4(E4(E4(E4 (E4( _C_ ))))))))
|
||||
#define E6(_2_)E5 (E5(E5(E5(E5(E5(E5 (E5( _2_ ))))))))
|
||||
|
||||
#define E7(_0_)E6 (E6(E6(E6(E6(E6(E6 (E6( _0_ ))))))))
|
||||
#define E8(_1_)E7 (E7(E7(E7(E7(E7(E7 (E7( _1_ ))))))))
|
||||
#define E9(_5_)E8 (E8(E8(E8(E8(E8(E8 (E8( _5_ ))))))))
|
||||
|
||||
#define QS( L, R) (S (M( L, B R),\
|
||||
A R , A J(G(L, _) ,B R), C R ))
|
||||
#define QR( L, R) I sym_(,)(O, (C, \
|
||||
C)) (C J(G(L, _) ,B R),QS(L, R ))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define sym__(_ , __ ) _
|
||||
#define A(A, B , C ) A
|
||||
#define F(A, _) sym_(_,)
|
||||
|
||||
#define sym_(__ , _ ) _
|
||||
#define B(A, B , C ) B
|
||||
#define J(A, J) G(A, J)
|
||||
|
||||
#define sym___( ___, __)
|
||||
#define C(A, B , C ) C
|
||||
#define G(J, G) J ## G
|
||||
|
||||
#define RY(Y) Y
|
||||
#define Y( Y) Y
|
||||
#define LY(Y) Y
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# define Z( L, R) J (B L, /*N,*/ Y)
|
||||
# define N( L, R) J (G(L, _), B R)
|
||||
# define HY(L ) (A L, halting)
|
||||
# define T( R, L) G(sym_, R)(L, (,))
|
||||
# define H( R, L) G(sym_, R)(R, _ )
|
||||
|
||||
# define M( L, R) B J( G(L, _), R )
|
||||
# define D( L, R) G(sym_, R)(R, _ )
|
||||
# define U( L, R) G(sym_, R)(L, (,))
|
||||
# define F0(L, R) F( L, /*N,*/R )
|
||||
# define F1(L, R) F0( L, /*N,*/R)~
|
||||
|
||||
# define F2(L, R) F1( L, /*N,*\R)~
|
||||
# define F3(L,*/R )R\t<L[B R]>\t-> \
|
||||
Z (/*)*/ N( L, R) , R) (N( L, R) )\n
|
||||
# define FV(L, R) F( L, /*N,*/R )
|
||||
# define QH(L, R) QS( L, /*N,*/ R)
|
||||
|
||||
int puts (char*);
|
||||
# define W(W)O(W)
|
||||
int main () {puts
|
||||
# define O(W)#W//
|
||||
( R ( A, tape));}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#define sym_1(sym, _1) sym
|
||||
|
||||
#define tape ( (,), /*
|
||||
15: */ 1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, /*
|
||||
blank: */ (_, /*
|
||||
50: */ (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, /*
|
||||
*/ (,)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) )
|
||||
@@ -0,0 +1,7 @@
|
||||
#define sym_1(sym, _1) sym
|
||||
|
||||
#define tape ( (,), /*
|
||||
77: */ 1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1, /*
|
||||
blank: */ (_, /*
|
||||
55: */ (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, (1,(1,(1,(1,(1, /*
|
||||
*/ (,))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) )
|
||||
@@ -0,0 +1 @@
|
||||
#define tape ((,), _, (,))
|
||||
@@ -0,0 +1,3 @@
|
||||
#define sym_1(sym, _1) sym
|
||||
|
||||
#define tape ((,), 1, (1, (1, (1, (1, (,))))))
|
||||
Reference in new issue
Block a user