Merge pull request #1531 from xexyl/sykes106

This commit is contained in:
Landon Curt Noll authored and GitHub committed 2023-11-24 13:20:10 -07:00
commit 3cfbcd7b38
24 files changed
+572 -146

No files matched your search

+21 -13
View File
@@ -5,6 +5,17 @@ make
```
### Bugs and (Mis)features:
The current status of this entry is:
```
STATUS: uses gets() - change to fgets() if possible
```
For more detailed information see [2006 birken in bugs.md](/bugs.md#2006-birken).
## To use:
```sh
@@ -15,10 +26,7 @@ make
### Try:
```sh
./birken < counter.tofu
./birken < adder.tofu
./birken < buffer.tofu
./birken < computer.tofu
./try.sh
```
etc.
@@ -30,22 +38,22 @@ Q: EDAMAME?
A: Electronic Design Automation - Mechanical Abstract Machine Emulator
What is TUFO? It's not a veggy friendly food, nor it is Verilog or
VHDL. It is not even Pascal!
What is TOFU? It's not a veggie friendly food, nor it is
[Verilog](https://en.wikipedia.org/wiki/Verilog) or
[VHDL](https://en.wikipedia.org/wiki/VHDL) It is not even
[Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language))!
NOTE: On some systems, file(1) claims one of the .tofu files is Pascal
NOTE: On some systems, `file(1)` claims one of the `.tofu` files is Pascal
source. :-)
It may not be the most readable hardware description language, but it is
one of the easiest 55 page long manual to learn. :-)
one of the easiest 55 page long manuals to learn. :-)
For a small but non-trivial design, try implementing a
[Linear Feedback Shift Register](http://en.wikipedia.org/wiki/LFSR)
And for those who are still confused:
> <http://en.wikipedia.org/wiki/Edamame>
> <http://en.wikipedia.org/wiki/Tofu>
And for those who are still confused, see <http://en.wikipedia.org/wiki/Edamame>
and <http://en.wikipedia.org/wiki/Tofu>.
## Author's remarks:
@@ -64,7 +72,7 @@ The primary obfuscation is the data structure chosen for parsing the
input file and for executing the simulation. Oh man... coding that
data structure gave me such a bad headache. But, I figure, who needs
more than a pair anyway? Subtle obfuscations abound. Bonus points go
out the one who discovers the hidden program within the source.
out to the one who discovers the hidden program within the source.
Note that the shape of the source is a wave, not a waveform.
+68
View File
@@ -0,0 +1,68 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 2006/birken
#
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
# this way allows us to have the user specify a different compiler in an easy
# way.
if [[ -z "$CC" ]]; then
CC="cc"
fi
make CC="$CC" all >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
read -r -n 1 -p "Press any key to run: ./birken < adder.tofu 2>/dev/null: "
./birken < adder.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < buffer.tofu 2>/dev/null: "
./birken < buffer.tofu 2>/dev/null
echo 1>&2
echo "NOTE: the next one has longer output." 1>&2
read -r -n 1 -p "Press any key to run: ./birken < computer.tofu 2>/dev/null: "
./birken < computer.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < counter.tofu 2>/dev/null: "
./birken < counter.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < divider.tofu 2>/dev/null: "
./birken < divider.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < lfsr.tofu 2>/dev/null: "
./birken < lfsr.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < memory.tofu 2>/dev/null: "
./birken < memory.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < multiplier.tofu 2>/dev/null: "
./birken < multiplier.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < multiplier2.tofu 2>/dev/null: "
./birken < multiplier2.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < oneline.tofu 2>/dev/null: "
./birken < oneline.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < shift.tofu 2>/dev/null: "
./birken < shift.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < zuse.tofu 2>/dev/null: "
./birken < zuse.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < zuse2.tofu 2>/dev/null: "
./birken < zuse2.tofu 2>/dev/null
+20 -2
View File
@@ -5,6 +5,19 @@ make
```
### Bugs and (Mis)features:
The current status of this entry is:
```
STATUS: INABIAF - please **DO NOT** fix
```
For more detailed information see [2006 borsanyi in bugs.md](/bugs.md#2006-borsanyi).
## To use:
```sh
@@ -27,7 +40,7 @@ yourself! :-)
The resulting GIF file is likely to puzzle optical character
recognition tools. The amount of imagination necessary to
recognise the @ character will certainly challenge a few
recognise the `@` character will certainly challenge a few
anti-CAPTCHA tools.
@@ -50,6 +63,7 @@ line. To avoid complications with patent issues the [LZW
compression](https://en.wikipedia.org/wiki/Lempel-Ziv-Welch) feature is not
used. A typical email address is stored in less than 1-2 kilobytes.
### Usage:
```sh
@@ -63,8 +77,10 @@ the characters: `a-z_A-Z0-9@.-`.
The program is (like email addresses are) case insensitive.
### Obfuscation:
Multicore support is a must in present-day applications. This
entry supports up to 25 cores. The odd names in the bottom
part of the program do have a meaning, they are not there just
@@ -73,6 +89,7 @@ small, in fact, everything is a macro. Are you familiar with
the GIF format? Studying this program will give you a (very)
little insight.
### Questions:
After analyzing the source code, try to answer these questions:
@@ -81,9 +98,10 @@ After analyzing the source code, try to answer these questions:
2. Can you alter the look of the output characters?
3. What limits the number of input characters to 42?
### Portability:
The program uses posix threads (using the linker flag `-lpthread`).
The program uses POSIX threads (using the linker flag `-lpthread`).
The program accepts email addresses not longer than 42 bytes
composed from letters, digits, and the `@._-` symbols. An address
not obeying these rules will cause undefined behaviour. The
+3 -3
View File
@@ -15,7 +15,7 @@ make
### Try:
```sh
./hamre '-1+4/3*(2+1/(3/2*(7/2-7/3+1/6)))/2'
./try.sh
```
@@ -37,10 +37,10 @@ numbers](https://en.wikipedia.org/wiki/Rational_number). Believe it or not, that
is a useful tool to have around, and I haven't found a useful version, much less
an obfuscated one.
It is rather feature complete as [rational calculators go. The
It is rather feature complete as rational calculators go. The
supported operators are: `+`, `-` (binary and unary), `*`, `/` and `()`. Run it
by supplying an expression as the first argument, and the normalized
result will be written to stdout.
result will be written to `stdout`.
```sh
./hamre '-1+4/3*(2+1/(3/2*(7/2-7/3+1/6)))/2'
+58
View File
@@ -0,0 +1,58 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 2006/hamre
#
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
# this way allows us to have the user specify a different compiler in an easy
# way.
if [[ -z "$CC" ]]; then
CC="cc"
fi
make CC="$CC" all >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
echo "$ ./hamre '-1*42/3*(42*42*42)/42'" 1>&2
./hamre '-1*42/3*(42*42*42)/42'
echo 1>&2
read -r -n 1 -p "Press any key to continue: "
echo "$ ./hamre '-1+4/3*(2+1/(3/2*(7/2-7/3+1/6)))/2'" 1>&2
./hamre '-1+4/3*(2+1/(3/2*(7/2-7/3+1/6)))/2'
echo 1>&2
read -r -n 1 -p "Press any key to continue: "
echo "$ ./hamre '1/0' 1>&2" 1>&2
./hamre '1/0' 1>&2
echo 1>&2
echo "...why did you not get an answer?" 1>&2
echo 1>&2
LIFE=12
UNIVERSE=15
EVERYTHING=15
read -r -n 1 -p "Press any key to continue: "
echo "For the next two notice how similar they are: why do they give different answers?" 1>&2
echo "$ LIFE=12; UNIVERSE=15; EVERYTHING=15; ./hamre \"\$LIFE/\$UNIVERSE/\$EVERYTHING\"" 1>&2
./hamre "$LIFE/$UNIVERSE/$EVERYTHING"
echo "$ LIFE=12; UNIVERSE=15; EVERYTHING=15; ./hamre \"\$LIFE / \$UNIVERSE / \$EVERYTHING\"" 1>&2
./hamre "$LIFE / $UNIVERSE / $EVERYTHING"
echo 1>&2
read -r -n 1 -p "Press any key to continue: "
echo "And why do these next two give different answers?" 1>&2
echo "$ LIFE=12; UNIVERSE=15; EVERYTHING=15; ./hamre \"\$LIFE + \$UNIVERSE + \$EVERYTHING\"" 1>&2
./hamre "$LIFE + $UNIVERSE + $EVERYTHING"
echo "$ LIFE=12; UNIVERSE=15; EVERYTHING=15; ./hamre \"\$LIFE+\$UNIVERSE+\$EVERYTHING\"" 1>&2
./hamre "$LIFE+$UNIVERSE+$EVERYTHING"
echo "As it turns out, \$LIFE+\$UNIVERSE+\$EVERYTHING == 42/1 == 42!" 1>&2
exit 0
+12 -8
View File
@@ -8,14 +8,14 @@ make
## To use:
```sh
./meyer
./meyer [SEED]
```
### Try:
```sh
./meyer
./meyer [SEED]
```
For your first input try:
@@ -24,9 +24,14 @@ For your first input try:
a 0 1
```
where `a` is the row (`a`-`i`), `0` is the column (`0`-`8`) and `1` is the
number (`1`-`9`).
NOTE: if you do not input three different 'words' it will block. You can input
more text to fulfil the program's requirements.
NOTE: if your move is invalid it will prompt you again but not show the board.
## Judges' remarks:
@@ -65,13 +70,13 @@ it is obvious, that object-oriented code isn't '`WYWIWID`' ('what
you write is what it does'). It may be tempting to think that
```
Object o;
Object o;
```
might do something similar as
```c
struct not_an_object o;
struct not_an_object o;
```
But this program reveals that it doesn't. Even worse, this program only
@@ -86,14 +91,13 @@ include:
- virtual method tables (all the virtual method tables have been combined to a
single [vtable](https://en.wikipedia.org/wiki/Virtual_method_table)).
- runtime method binding.
-
[inheritance](https://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming))
and
[polymorphism](https://en.wikipedia.org/wiki/Polymorphism_(computer_science)).
- [inheritance](https://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming))
and [polymorphism](https://en.wikipedia.org/wiki/Polymorphism_(computer_science)).
It is left as an exercise to the reader to find a corresponding
implementation in a popular object-oriented programming language.
### Starting the game
```sh
+1
View File
@@ -1,3 +1,4 @@
monge
monge.alt
monge.orig
prog.orig
+6 -3
View File
@@ -42,7 +42,7 @@ CSILENCE= -Wno-bitwise-op-parentheses -Wno-conditional-type-mismatch \
-Wno-declaration-after-statement -Wno-dollar-in-identifier-extension \
-Wno-error -Wno-implicit-function-declaration \
-Wno-incompatible-pointer-types -Wno-int-conversion -Wno-parentheses \
-Wno-return-type -Wno-strict-prototypes
-Wno-return-type -Wno-strict-prototypes -Wno-implicit-int
# Common C compiler warning flags
#
@@ -119,8 +119,8 @@ OBJ= ${PROG}.o
DATA=
TARGET= ${PROG}
#
ALT_OBJ=
ALT_TARGET=
ALT_OBJ= ${PROG}.alt.o
ALT_TARGET= ${PROG}.alt
#################
@@ -143,6 +143,9 @@ ${PROG}: ${PROG}.c
alt: data ${ALT_TARGET}
@${TRUE}
${PROG}.alt: ${PROG}.alt.c
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
# data files
#
data: ${DATA}
+82 -21
View File
@@ -6,6 +6,9 @@ Make sure you have the SDL1 (not SDL2!) development environment installed.
make
```
There is alternate code that lets you redefine the width and height and number
of iterations to use. See [alternate code](#alternate-code) below.
### Bugs and (Mis)features:
@@ -42,6 +45,49 @@ That's not a bug, that's a feature.
```
## Alternate code:
This alternate code lets you specify the width and height of the image as well
as the number of iterations to perform.
### Alternate build:
To use the default values, the same as [monge.c](monge.c), just do:
```sh
make alt
```
But if you wish to actually make use of it you will want to redefine one or more
of the variables `W`, `H` and `I`. The defaults are (respectively) 400, 300 and
\128. If you wish to change the image size to 500x500 but keep the iterations
the same then do:
```sh
make clobber CDEFINE="-DW=500 -DH=500" alt
```
If you wish to keep the dimensions the same but change the iterations to 512:
```sh
make clobber CDEFINE="-DI=512" alt
```
If you specify a value less than 1 for any of these it sets it back to the
default. The value 1 was selected arbitrarily and such a small number as 1 will
not do anything useful but as long as it's at least 1 it'll not be redefined.
Does not try taking care of overflows but such large values would be impractical
anyway.
### Alternate use:
Use `monge.alt` exactly as you would `monge` above.
## Judges' remarks:
For those who are familiar with the previous [IOCCC winners](/winners.html),
@@ -81,6 +127,7 @@ needed.
4. Enjoy, unless you're more interested in trying to understand how it works. :)
### Introduction
This is a fractal generator that supports custom formulas and real time zoom.
@@ -103,68 +150,81 @@ as you like (as understood by the C function `isspace()`).
Supported operations and functions are:
```
Operation | Description
:-------- | :----------
`+,-,*,/` | Arithmetic operations, priority of `*`,`/` over `+,-` is
respected.
+,-,*,/ | Arithmetic operations, priority of * , / over +,- is
| respected.
|
`<,>` | Compares the real parts of two complex numbers (the imaginary part
<,> | Compares the real parts of two complex numbers (the imaginary part
| is ignored). Any number of conditions is allowed, the iteration
| will just stop as soon as one of them fails.
`Abs2` | Calculates the squared norm, i.e.: `Abs2(a+b*i)` is `(a*a+b*b)+0*i`.
`Re` | Extract the real part, i.e.: `Re(a+b*i)` is `a+0*i`.
`Im` | Extract the imaginary part, i.e.: `Im(a+b*i) is b+0*i`.
`Exp` | Calculates the complex exponential, i.e. `Exp(a+b*i)` is
| `e^a*(cos(b)+sin(b)*i)`
`Ln` | Calculates the principal value of the natural logarithm, i.e.
`Ln(a+b*i)` is `ln(a*a+b*b)/2` + `atan(b/a)*i`
Abs2 | Calculates the squared norm, i.e.: Abs2(a+b*i) is (a*a+b*b)+0*i.
Re | Extract the real part, i.e.: Re(a+b*i) is a+0*i.
Im | Extract the imaginary part, i.e.: Im(a+b*i) is b+0*i.
Exp | Calculates the complex exponential, i.e. Exp(a+b*i) is
| e^a*(cos(b)+sin(b)*i).
Ln | Calculates the principal value of the natural logarithm, i.e.
Ln(a+b*i) is ln(a*a+b*b)/2 + atan(b/a)*i.
```
Here are a few examples of fractals you can draw:
- Mandelbrot:
./monge "z=1" "z=z*z+c; Abs2(z)<4"
```sh
./monge "z=1" "z=z*z+c; Abs2(z)<4"
```
- Mandelbrot (return time variation):
./monge "z=c" "z=z*z+c; Abs2(z-c)>0.0001"
```sh
./monge "z=c" "z=z*z+c; Abs2(z-c)>0.0001"
```
- Julia, for `c=0.31+i*0.5`:
./monge "z=c; c=0.31+i*0.5" "z=z*z+c; Abs2(z)<4"
```sh
./monge "z=c; c=0.31+i*0.5" "z=z*z+c; Abs2(z)<4"
```
- Julia (return time variation), `for c=0.31+i*0.5`:
./monge "z=c; c=0.31+i*0.5" "z=z*z+c; Abs2(z-c)>0.0001"
```sh
./monge "z=c; c=0.31+i*0.5" "z=z*z+c; Abs2(z-c)>0.0001"
```
- Newton, for `x^3-1`:
./monge "z=c" "p=z; z=0.6666*z+0.3333/(z*z); Abs2(p-z) > 0.001"
```sh
./monge "z=c" "p=z; z=0.6666*z+0.3333/(z*z); Abs2(p-z) > 0.001"
```
- Newton-Mandelbrot:
```
```sh
./monge "z=0" "p=z; z=z-(z*z*z + (c-1)*z - c)/(3*z*z+c-1); Abs2(p-z) > 0.001"
```
- Phoenix, Mandelbrot version:
```
```sh
./monge "z=0; q=0" "t=z; z=z*z+Re(c)+Im(c)*q; q=t; Abs2(z)<4"
```
- Phoenix, Julia version for `c=0.56667-i*0.5`:
```
```sh
./monge "z=c; c=0.56667-i*0.5; q=0" "t=z; z=z*z+Re(c)+Im(c)*q; q=t; Abs2(z)<4"
```
### Compilation and portability
This program will only work on x86 (with an x87 FPU) or x86_64 machines,
but it requires the SDL library.
Another system requirement is the `mmap()` function (as `#define`d at the
Another system requirement is the `mmap(2)` function (as `#define`d at the
beginning of the program). If it is not available the macro `M(a)` will have to
be replaced with a system dependent function that allocates readable, writable
*AND* executable memory (it will not be possible to make this program run on
@@ -186,17 +246,18 @@ changing the definitions of `W`, `H` and `I` at the beginning of the code.
- Many SDL identifiers are hardcoded as number, this is safe up to ABI
incompatibility.
- Better optimization could be done treating known real numbers as just one
double, instead of adding a 0 imaginary part to treat them as complex
`double`, instead of adding a 0 imaginary part to treat them as complex
numbers.
- There should be some way to switch from Mandelbrot to Julia with chosen
parameter.
### Spoiler
Sure, I don't want to deprive you of the pleasure of digging
into the infernal mess created by my corrupted mind (writing
this remark I noticed that I was ending sentences with ';' instead
that with '.', and I worried for my sanity), but just in case...
of with '.', and I worried for my sanity), but just in case...
I used many obfuscation techniques, including a few ones that
are different from the tricks used in most common IOCCC program
+79
View File
@@ -0,0 +1,79 @@
#include <stdlib.h>
#include <SDL.h>
#include <sys/mman.h>
#define M(a) mmap(0, a, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0)
#ifndef W
#define W 400
#elif W < 1
#undef W
#define W 400
#endif
#ifndef H
#define H 300
#elif H < 1
#undef H
#define H 300
#endif
#ifndef I
#define I 128
#elif I < 1
#undef I
#define I 128
#endif
#define L char*
#define _ Sint32
#define h(a,b) for(a=0; a<b; a++)
#define O while(
#define b D[j][i][
#define J(b) a(#b)
SDL_Event
e;
SDL_Surface
*F; float f, m,
n,d,D[H][W][6],
v; L A; L X; L
V,G[H][W]; L
E ; L Q; double
R=2/( W-1. ),T=2/(H-1.),c,g, z=2 ,*
K,*Z,*S; _ B, C, o,i,j,q,k,l,x,y,*u,Y=512; P(
L f){ *(u=V)=f-X-5; V+=4; } a(L e){ O l=*e++)
l-38?l==36?s(2),o--:l-37?*V++=l==35?k=*e++
,k* 16+*e++-81:l^128:o>7?J(Yv]#JJ), P(S++):o++
:s(4); } s(_ n){ O o<n){ J(]#IB); P(--S); J(]);
*V ++=217+o++; } } p(L e,_ q,L *t){ _ x=9; do{ A="%]#IB"
; _ i =*e; 5==q?*K=strtod(e,t),e-*t?e=*t,a(A),P(K++), J(%Yn)
: i<6 ?p ( e+1,4,t),i-5||J(Y`YIY`YI), e=*t:i>96?a(A),P(Z+i-97),a
(A),P (Z+*e++-71) :(p(index( e, 40)+1,1,t), i^82?i^73?i^65?i^69?i^76?1:J
(%YhY`%YmY}]YYB%YBXHYIXH$^A$YqYJ$Ys):J(%Y{YJ%Yj^IY@Y|\\iYIYp%Yh$^AY}$]Y\\J$^I)
: J(XHYIXH^AYn):J(]YYn) : J (]XYn),e= index( *t,41 )+ 1): p ( e , q+ 1, &e); A
= "&%YCXJYLXIYK\\J$^I$^k$^A"; (x -=3)<1?J(&]X]Y),1L <<31<0? J(Zi_`#JO):J(_i]X),x
?J (#HH):J(#HC),J(#AD#IJPC) ,o-=4:--x?--x?--x?x-3?J(&%YA%YAXHYIXH^AYh$^q\\J$^IY`)
, a(A): 1:a(A):J(&$^j$^j):J(&$^B$^B); } O q==(x=*(*t=e++))/2); } main(_ r,L*U){
X =V=(Z =(S=(K=M(Y*32))+Y)+ Y)+Y; J(h#AA#AA#AA#AA#FJ:+-*/); h(q,2){ A =E =Q=U[ q+1]; O * A=*A^B++
[ ";<>+-*/" ]?*A:B,(B%=7)||(isspace(*E=*A)||++E,*A++)); E=V; O B=*Q){ if(Q[1]-61)p(
Q,1,&Q); else{ p(Q+2,1,&Q); h(j,2){ J(]#JJ); P(Z+B-71-j*26); o--; } } *Q&&Q++; }
} J(#PPJ#AP#IF); P (E -V+X +1); J(#IJPC); 0[u =X+7] =I; SDL_Init( 32 ); F=
SDL_SetVideoMode(W,H,8 ,0); A=F->pixels; B=F->pitch; O 1){ C^=3; h(j,H)h(i,
W )b C+2]=9; if(r=(k =SDL_GetMouseState(&x,&y))&5){ f=z/50; f=k&1 ?f:-f ;
c+=(x*T-T/R)*f; g += f*y*T-f; z*=f=1-f/z; v=1/f; h(j,H)h(i,W)h(q,4){ k=
x+(i- x)* f +q/2; l=y+(j-y)*f+q%2; if(k>=0&k<W&l>=0&l<H){ m=x+(k+D[
l][k ][ 3-C]-x)*v-i; n=y+( l+D[l][k][4 -C]-y)*v-j; d= m*m+ n*n;
if ( d<b C+2]){ b C]=m; b C+1]=n; b C+2]=d; G[j][i]=A[l*B+
k ]; } } } } h(j,H)h(i,W)if(q=b C+2]){ Z[2]=(i *T-T /
R)*z+c; Z[28]=z-j *T*z-g; Z[8]= 0; Z[34]=1; q =((_(*
)( ))X)(); A[j* B+i]=q? *u-q:0; h(q,3)b C+q]=0;
} else A[j*B+i]=G[j][i]; SDL_UpdateRect(F,
0,0,W,H); O(r?SDL_PollEvent:SDL_WaitEvent)(&e
)) { k=e.type; l=e.key.keysym.sym; if ( k==
12|k== 2& l ==27)return; if(
e.type-5?k==
2&(l==270|l==
269)?*u=l-270
? *u/2:*u*2:0:1
) break;
}
} }
+22 -25
View File
@@ -4,6 +4,9 @@
make
```
There is an alternate version that supports arrow keys. See the [alternate
code](#alternate-code) section below.
## To use:
@@ -11,26 +14,23 @@ make
./night
```
There is an alternate version that supports arrow keys. See the alternate code
section below.
### Try:
```sh
echo "Do or do not. There is no try."
```
## Alternate code:
To compile:
This version allows you to use arrow keys instead of the more awkward `wasd`
keys.
### Alternate build:
```sh
make alt
```
### Alternate use:
Use `night.alt` as you would `night` above.
@@ -41,22 +41,16 @@ algorithm](https://towardsdatascience.com/introduction-to-genetic-algorithms-inc
involved. Somewhere. But what does it do? Well, it might take you a while to
navigate the results, let alone the code.
### Cheating
There is a nice way to cheat. If you don't want to figure it out you can look at
[Yusuke Endoh](/winners.html#Yusuke_Endoh)'s analysis of this entry at
(translation from Japanese so it's not perfect)
<https://mame-github-io.translate.goog/ioccc-ja-spoilers/2006/night.html?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en-US&_x_tr_pto=wapp>.
## Author's remarks:
Don't worry; this is not a self-reproducing program, as you might at
first guess from the layout. I would never be so foolhardy as to
submit an entry on an over-used theme!
submit an entry on an overused theme!
Oh, wait a second... it is a maze-generating program. Oops!
### What it does:
This program solves an optimization problem, namely, generating a challenging
@@ -86,6 +80,7 @@ Finally, in the world of DNA, the medium is truly the message. There's
a short message encoded in here that will only appear when you
complete the optimal maze in the required 64 moves.
### Issues:
These depend on your compiler, and they were all intentionally
@@ -94,13 +89,14 @@ added for obfuscation purposes. No, really!
My compiler warns of nulls in a string literal, and the redefinition
of the macro `T`.
On one compiler, compilation took about two minutes.
With one compiler, compilation took about two minutes.
`sizeof(unsigned short)` must be 2, and `sizeof(unsigned long)` must be 4.
`CLOCKS_PER_SEC` is assumed to be `1000000`. If it's a lot less than that,
expect delays.
### Algorithmic obfuscation:
The representation of the maze layout in a 32-bit integer type is
@@ -113,6 +109,7 @@ The recursive function `CGAC()` replaces a nested for loop in a handy way.
The maze-solving function `TGA()` returns no solution both if no solution
exists, and if the search space grows too large, with a single test.
### Stylistic obfuscation:
Four-letter alphabets are confusing. I don't know how
@@ -124,11 +121,11 @@ Who needs `!=` when you've got `^`?
Who needs `if` when you've got `while`?
For that matter, who needs fixed-iteration-count for and while when
you can just duplicate code with the preprocessor? Duplication by this
macro causes one particular graphics line to be replicated 512
times. On my system the preprocessed code is over 80KB in length,
hindering the preprocessor's ability to deobfuscate.
For that matter, who needs fixed-iteration-count `for` and `while` when you can
just duplicate code with the preprocessor? Duplication by this macro causes one
particular graphics line to be replicated 512 times. On my system the
preprocessed code is over 80KB in length, hindering the preprocessor's ability
to deobfuscate.
Keypad support was removed to save space. To restore, modify the
following two macros to:
+1 -1
View File
@@ -59,7 +59,7 @@ ARCH=
# Defines that are needed to compile
#
CDEFINE= -DS=65000
CDEFINE= -DS=75000
# Include files that are needed to compile
#
+7 -5
View File
@@ -20,7 +20,7 @@ see the [original code](#original-code) section.
This alternate version, which we recommend that you use in order to see what is
happening with modern systems, and to not flash too quickly, which can be
problematic for some people, can be configured to different speeds by way of the
value used in `usleep()`. The default is `-DS=65000` but you can easily change
value used in `usleep()`. The default is `-DS=75000` but you can easily change
it. To do so try:
```sh
@@ -73,13 +73,13 @@ at first blush, this looks like a self-reproducing program.
## Author's remarks:
This program doesn't require any special build options, other than that it
uses `sin()` and `cos()` and hence requires the math library.
uses `sin(3)` and `cos(3)` and hence requires the math library.
You will almost certainly get a compiler warning because I declared a bunch
of global ints without types. The code looks better this way, though, I
of global `int`s without types. The code looks better this way, though, I
think. There are also no `#include`s, so there may be warnings for
undeclared references to `printf()`, etc. There's a chance that my failure to
include `math.h` or declare `sin()` or `cos()` will make the
undeclared references to `printf(3)`, etc. There's a chance that my failure to
include `math.h` or declare `sin(3)` or `cos(3)` will make the
[donut](https://en.wikipedia.org/wiki/Doughnut) not render
properly -- it's worked on every system I've tried so far though.
@@ -98,6 +98,7 @@ escape codes for clearing the screen and moving the cursor back to the top-left.
The donut isn't raytraced. It's much simpler than that.
### How is it obfuscated?
There are three main pieces to this program: the donut, the checkerboard, and
@@ -109,6 +110,7 @@ into the smallest I could make it by any means necessary.
The logo can actually be compressed much better (ironically, by doing
something simpler), but I didn't discover this until well after submitting.
### Puzzles
In increasing order of difficulty:
+2 -2
View File
@@ -1,6 +1,6 @@
stewart
stewart.html
maze.xbm
maze.png
*.xbm
*.png
stewart.orig
prog.orig
+56 -39
View File
@@ -12,6 +12,16 @@ make
convert file.xbm file.png
```
where `file` is one of:
```
altar box box2 box3 build carpet circles cross cross2 cross3
crystal curve diamonds diamonds2 dragon dragon2 dragon3
fern gasket gasket_mod gasket_mod2 ioccc maze octagon
pentagon pentagons rings rings2 spirals spirals2 spirals3
spirals4 squares stars stars2 tree tree2 tree3 tree4 triangle
```
NOTE: you cannot specify a different width from height; it's one number.
NOTE: `convert(1)` belongs to [ImageMagick](https://imagemagick.org/index.php).
@@ -20,17 +30,17 @@ NOTE: `convert(1)` belongs to [ImageMagick](https://imagemagick.org/index.php).
### Try:
```sh
./stewart 400 1000000 maze > maze.xbm\
./stewart 400 1000000 maze > maze.xbm
convert maze.xbm maze.png
./stewart 1024 1000000 gasket > gasket.xbm
convert gasket.xbm gasket.png
./stewart 1024 1500000 dragon3 > dragon3.xbm
convert dragon3.xbm dragon3.png
```
where `FILE` is one of:
altar box box2 box3 build carpet circles cross cross2 cross3
crystal curve diamonds diamonds2 dragon dragon2 dragon3
fern gasket gasket_mod gasket_mod2 ioccc maze octagon
pentagon pentagons rings rings2 spirals spirals2 spirals3
spirals4 squares stars stars2 tree tree2 tree3 tree4 triangle
Now open the images in your favourite graphics viewer or a web browser.
## Judges' remarks:
@@ -47,19 +57,24 @@ a reasonably experienced user who can parse formats in their mind. :-)
The program should be run with the following
```
./stewart <m> <n> <ifs>
m = The size of the picture (picture will be m X m in size).
n = The number of iterations to run (More will make for a
clearer picture).
ifs = The file to use as input.
```sh
./stewart <m> <n> <ifs>
```
The program will spit out a [XBM image](https://en.wikipedia.org/wiki/X_BitMap) on standard out.
Minimal checking is done on the arguments mainly that there are 3.
Wrong arguments will cause the program to bomb out.
where:
Ex:
```
m = The size of the picture (picture will be m X m in size).
n = The number of iterations to run (More will make for a
clearer picture).
ifs = The file to use as input.
```
The program will spit out an [XBM image](https://en.wikipedia.org/wiki/X_BitMap)
on standard out. Minimal checking is done on the arguments mainly that there
are 3. Wrong arguments will cause the program to bomb out.
#### Example:
```sh
./stewart 1024 1000000 gasket > gasket.xbm
@@ -68,7 +83,7 @@ Ex:
### Compilation/Testing
The program compiles without warning with `gcc -ansi -Wall`.
`lint` also seems to like the code. This must be a bug in lint.
`lint` also seems to like the code. This must be a bug in `lint`.
The program was tested on Linux on a x86 and NetBSD on an alpha.
Only gcc was tested for compilers (4.0.3 and 3.3.3).
@@ -93,13 +108,13 @@ another kind of fractal, those from the [Iterated Function System
The format of the input file is as follows:
```
<num ifs> <x min> <y min> <x max> <y max>
<a> <b> <c> <d> <e> <f> <p>
<a> <b> <c> <d> <e> <f> <p>
<a> <b> <c> <d> <e> <f> <p>
.
.
.
<num ifs> <x min> <y min> <x max> <y max>
<a> <b> <c> <d> <e> <f> <p>
<a> <b> <c> <d> <e> <f> <p>
<a> <b> <c> <d> <e> <f> <p>
.
.
.
```
This file describe an IFS.
@@ -107,20 +122,20 @@ This file describe an IFS.
One of the most well known would be the [Sierpinski Gasket](gasket):
```
3 0 0 1 1
.5 0 0 .5 0 0 .33
.5 0 0 .5 .5 0 .33
.5 0 0 .5 .25 .433 .34
3 0 0 1 1
.5 0 0 .5 0 0 .33
.5 0 0 .5 .5 0 .33
.5 0 0 .5 .25 .433 .34
```
or the [fern](fern):
```
4 -5.5 0 5.5 11
0 0 0 .16 0 0 .01
.85 .04 -.04 .85 0 1.6 .85
.2 -.26 .23 .22 0 1.6 .07
-.15 .28 .26 .24 0 .44 .07
4 -5.5 0 5.5 11
0 0 0 .16 0 0 .01
.85 .04 -.04 .85 0 1.6 .85
.2 -.26 .23 .22 0 1.6 .07
-.15 .28 .26 .24 0 .44 .07
```
etc...
@@ -136,9 +151,9 @@ Basically the break down is:
`num` is the number of equations in the `IFS`.
`x` (min, max) and `y` (min, max) define the ranges that will be displayed
in the `xbm`.
in the XBM image file.
The `a b c d e f` are used to iterative find points that lie in the `IFS`
The `a b c d e f` are used to iterative find points that lie in the IFS
from the algorithm
```
@@ -156,7 +171,7 @@ the args for `main()`). This causes me to do much casting and pointer
arithmetic to get the correct location and completely does away with
any meaning the variables could have. This also makes the code more
convenient to read in the current form vs preprocessed. After
preprocessing there will almost be 300 casts in the code and I believe
preprocessing there will be almost 300 casts in the code and I believe
they are all needed... (I would double check but my brain is kinda
mushy right now from chasing down a segfault in the code.)
@@ -165,6 +180,7 @@ all that common for a program to do. I mean google only has something
like 66,000 hits for "Iterated function system" so that means it is
obscure, right?
### Some other minor obfuscations
Since I formatted it as a "normal" program I did inject something that
@@ -181,12 +197,13 @@ information about the algorithm.
The use of many magic numbers. I figured if I get yelled about them in
a review they must be bad, right?
### Silly things
The use of decimal numbers where one would expect hex. Octal numbers
where one would expect decimal. Shifts instead of divides.
Using `xbm` as the output format. This might confuse someone who doesn't
Using xbm as the output format. This might confuse someone who doesn't
have an X background. It happens to be easy but is probably a very bad
choice from a file size standpoint. 1024x1024 image is 641k in size.
+15
View File
@@ -5,6 +5,19 @@ make
```
### Bugs and (Mis)features:
The current status of this entry is:
```
STATUS: INABIAF - please **DO NOT** fix
```
For more detailed information see [2006 sykes1 in bugs.md](/bugs.md#2006-sykes1).
## To use:
```sh
@@ -215,6 +228,7 @@ In the ASCII output care must be taken with drawing the edges of each
this is taken care of by color, which is graded from the back to the
front to ensure edge visibility.
### Notes
The whole program has just one function - `main()` - which is recursively
@@ -241,6 +255,7 @@ requirements.
The program is known to compile and run under gcc and Intel cc, as well
as PellesC on Windows.
### Bugs
The program is not at all a valid html document, but fortunately
+2 -1
View File
@@ -40,7 +40,8 @@ include ../../var.mk
#
CSILENCE= -Wno-bitwise-op-parentheses -Wno-char-subscripts -Wno-error \
-Wno-implicit-function-declaration -Wno-implicit-int -Wno-main \
-Wno-pedantic -Wno-deprecated-non-prototype
-Wno-pedantic -Wno-deprecated-non-prototype -Wno-unused-parameter \
-Wno-parentheses
# Common C compiler warning flags
#
+1 -1
View File
@@ -15,7 +15,7 @@ make
### Try:
```sh
./sykes2.sh
./try.sh
```
This will repeatedly remake the program and run it then sleep for one second for
+1 -1
View File
@@ -1 +1 @@
main(_){_^448&&main(-~_);putchar(--_%64?32|-~7[__TIME__-_/8%8][">'txiZ^(~z?"-48]>>";;;====~$::199"[_*2&8|_/64]/(_&2?1:8)%8&1:10);}
main(_,v)char**v;{_^448&&main(-~_,v);putchar(--_%64?32|-~7[__TIME__-_/8%8][">'txiZ^(~z?"-48]>>";;;====~$::199"[_*2&8|_/64]/(_&2?1:8)%8&1:10);}
-9
View File
@@ -1,9 +0,0 @@
#!/usr/bin/env bash
while :; do
clear
rm -f sykes2
make sykes2 2>/dev/null 1>&2
./sykes2
sleep 1
done
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 2006/sykes2
#
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
# this way allows us to have the user specify a different compiler in an easy
# way.
if [[ -z "$CC" ]]; then
CC="cc"
fi
make CC="$CC" sykes2 || exit 1
while :; do
clear
rm -f sykes2
make sykes2 2>/dev/null 1>&2 || exit 1
./sykes2
sleep 1
done
+1 -1
View File
@@ -35,7 +35,7 @@ be expected, and some dump core?
## Author's remarks:
Can you place a knight on a chess board and make it
to visit the 64 squares without repeating them?
visit the 64 squares without repeating them?
If not, this program does it, just run it with an argument
giving initial position.
+62 -1
View File
@@ -2305,22 +2305,83 @@ used decimal mode, or any of the "undocumented" instructions.
# 2006
## 2006 birken
### STATUS: uses gets() - change to fgets() if possible
### Source code: [2006/birken/birken.c](2006/birken/birken.c)
### Information: [2006/birken/README.md](2006/birken/README.md)
This entry uses `gets(3)` which is unsafe and provides annoying warnings, most
obnoxious in macOS as it shows it at runtime (redirecting `stderr` to
`/dev/null` will silence it). The following diff will almost work but it crashes
with at least `computer.tofu` input file:
```diff
12a13
#define gets(c) fgets((c),PI,stdin)&&(((c)[strlen((c))-1]='\0'),c!=NULL)
```
## 2006 borsanyi
### STATUS: INABIAF - please **DO NOT** fix
### Source code: [2006/borsanyi/borsanyi.c](2006/borsanyi/borsanyi.c)
### Information: [2006/borsanyi/README.md](2006/borsanyi/README.md)
The string specified must be <= 42 characters and may only consist of the
characters in the regex `a-z_A-Z0-9@.-`. Breaking these constraints will end up
with possibly corrupt GIF files.
## 2006 monge
### STATUS: doesn't work with some platforms - please help us fix
### Source code: [2006/monge/monge.c](2006/monge/monge.c)
### Information: [2006/monge/README.md](2006/monge/README.md)
This program requires being able to read, write and execute memory. With the
This program requires x86 (with an x87 FPU) or x86_64 machine and it requires
the SDL1 library.
This program also requires being able to read, write and execute memory. With the
Apple silicon chips this is not allowed. Fixing this might be quite challenging
but you are welcome to try and fix it.
If you do fix this it might be good to fix the alternate code as well or else
provide it as an additional alt version. Fixing this is very likely to be very
challenging and in some systems it will not be possible to fix but you are
welcome to try and fix it if you wish to!
### STATUS: INABIAF - please **DO NOT** fix
Incorrect formulas will ungracefully crash the program.
## 2006 sykes1
### STATUS: INABIAF - please **DO NOT** fix
### Source code: [2006/sykes1/sykes1.c](2006/sykes1/sykes1.c)
### Information: [2006/sykes1/README.md](2006/sykes1/README.md)
The author stated:
```
If you pick a number higher than 19186, the program will return a
solution but it will be a rotation of one of the first 19186. This is
because the cross shaped piece fits 48 ways in the 4x4 cube, but only
2 of those ways are unique - you can rotate one of those to make any
of the other 46. The algorithm used always places the cross piece
first, so the first two placings of that piece result in the 19186
unique solutions.
If you pick a number higher than 460464 (24x19186) the program will
return without outputting a solution. If you can wait that long.
```
## 2006 toledo2
### STATUS: INABIAF - please **DO NOT** fix
+31 -10
View File
@@ -2952,6 +2952,8 @@ it.
Cody fixed a segfault in macOS with this entry. The problem was a missing `+1`
for strlen() with malloc(). This prevented it from working.
Cody also added the [try.sh](2006/birken/try.sh) script.
## [2006/borsanyi](2006/borsanyi/borsanyi.c) ([README.md](2006/borsanyi/README.md]))
@@ -2964,15 +2966,24 @@ implicitly linked in.
Cody fixed this so that it will not crash without an arg after it was suggested
this should be fixed.
Cody also added the [try.sh](2006/hamre/try.sh) script.
## [2006/monge](2006/monge/monge.c) ([README.md](2006/monge/README.md]))
Cody pointed out that without SDL1 (**not** SDL2) this will not link because two
functions that are used were removed from SDL2. Since SDL1 is still available
and since changing the code to use SDL2 would be more complicated he decided to
change the Makefile to use `sdl-config` not `sdl2-config`. Nevertheless he
points out that the entry requires x86/x86_64 CPUs. Without it it might very
well segfault (for instance it segfaulted on his MacBook Pro with the M1 chip).
Cody added the [alternate code](2006/monge/README.md#alternate-code) that lets
one resize the image and redefine the number of iterations.
Cody also fixed the Makefile to use `sdl-config` (which is what the author
stated too though that was noticed later), not `sdl2-config` as two functions
that are used were removed from SDL2, thus making it not link. Since SDL2 is
still available and since changing the code to use SDL2 is much more complicated
and also makes the entry less like the original it was simply made to link in
SDL1.
Nevertheless this entry does require x86/x86_64 CPUS. This is a documented
feature but one which we will accept fixes to. See [2006/monge in
bugs.md](/bugs.md#2006-monge).
## [2006/night](2006/night/night.c) ([README.md](2006/night/README.md]))
@@ -2987,9 +2998,9 @@ Cody fixed this entry to work with clang which has a defect with the args to
`main()`: it requires specific types: `int` and `char **` for the first and
latter args.
The [alternate version](2006/sloane/sloane.alt.c), which allows one to see what
is going on in modern systems, and which we recommend one use _first_, was
provided by Cody.
Cody also provided the [alternate version](2006/sloane/sloane.alt.c), which
allows one to see what is going on in modern systems, and which we recommend one
use _first_.
Curiously, although clang requires the types of args to be strictly correct,
some versions do allow only one arg. This was done at first because it's not
@@ -3006,7 +3017,7 @@ Cody also made sure that the Makefile links in `libm` as not all systems do this
by default.
Since the author suggested that the lack of certain `#include`s might break the
program in some systems he added `-include ...` to the Makefile as well.
program in some systems he also added `-include ...` to the Makefile as well.
## [2006/stewart](2006/stewart/stewart.c) ([README.md](2006/stewart/README.md]))
@@ -3026,6 +3037,16 @@ The video was also no longer available but Cody found an alternative and added
it to the repo as well.
## [2006/sykes2](2006/sykes2/sykes2.c) ([README.md](2006/sykes2/README.md]))
Cody, out of an abundance of caution for `clang`'s defects, made `main()` have
to args instead of 1 as some versions report that `main()` must have 0, 2 or 3
args, even though at least one of those versions allows 1 arg only.
Cody also added the [try.sh](2006/sykes2/try.sh) script for easier use of the
entry to show the clock update in real time.
## [2006/toledo2](2006/toledo2/toledo2.c) ([README.md](2006/toledo2/README.md]))
Cody fixed a segfault in this program which was making it fail to work under