diff --git a/1984/anonymous/index.html b/1984/anonymous/index.html index 98e841340..f8b229774 100644 --- a/1984/anonymous/index.html +++ b/1984/anonymous/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,245 @@ - - + + + + + + - - -1984 anonymous - - + + + +1984/anonymous + + + + + -

1984 anonymous

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1984/anonymous

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1984/anonymous/index.html

- +
+ first entry + ↑ 1984 ↑ + decot → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Anonymous +1984
Location: US

+ + +

To build:

+
make all
+

To use:

+
./anonymous
+

Alternate code:

+

The original version of this entry was added, by request, in order to +show the code that was turned into the tattoo, +as the alternate code. See below for the tattoo side-by-side with the +code.

+

Alternate build:

+
make alt
+

Alternate use:

+

NOTE: this version might not work on some systems like macOS.

+
./anonymous.alt
+

Judges’ remarks:

+

The author was too embarrassed that they could write such trash, so I +promised to protect their identity. I will say that the author of this +program has a well known connection with the C programming language.

+

This program is a unique variation on the age old “hello, world!” +program. What reads like a read may be written like a write!

+

In 2005 someone by the name of Thomas Scovell got a tattoo of this +entry. See his web +page on the Internet Wayback Machine for more information on the +tattoo. Along with the code, this is what it looks like:

+
+1984-anonymous-tattoo.jpg + +
+

Author’s remarks:

+

On remaining anonymous:

+

Some years after this entry was published we asked the author if they +still wished to remain anonymous and they said:

+
+

Yes, I want to keep my anonymity. But you can tell them that I am +well known for my connection to the C language.

+
+

On the famous tattoo (see +above):

+

The author, when told about this tattoo, said:

+
+

I feel honored that my entry will be the first IOCCC winner to become +a tattoo. It is the first entry to become a tattoo isn’t it?

+
+

Landon Curt Noll, the one who told the author about the tattoo, wrote +back:

+
+

Yes, to our knowledge it is.

+
+

Regrets:

+

Landon Curt Noll wrote that the author regrets not making the program +a one-liner and not moving the int i into an arg of main +(so that the line would have started with main). On the other hand the +author likes the “two line look” and the way hell o was +split. :-) And they like the fact that it ends in a smily face: +;}.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1984/anonymous

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1984/decot/index.html b/1984/decot/index.html index d1fc6e396..e1b8b61d2 100644 --- a/1984/decot/index.html +++ b/1984/decot/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,221 @@ - - + + + + + + - - -1984 decot - - + + + +1984/decot + + + + + -

1984 decot

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1984/decot

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1984/decot/index.html

- +
+ ← anonymous + ↑ 1984 ↑ + laman → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Dave Decot
+Location: US

+ + +

To build:

+
make all
+

NOTE: there is an alternate version +which will only work if you have an old enough compiler or a compiler +that supports -traditional-cpp. The original code was fixed +in 2023 to not require this.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1984 +decot in bugs.md.

+

To use:

+
./decot
+

Alternate code:

+

This alternate code, the original, requires a compiler that supports +-traditional-cpp or an old enough compiler. If you have +such a compiler you can use this version.

+

Alternate build:

+
make alt
+

Alternate use:

+
./decot.alt
+

Judges’ remarks:

+

This program prints out a string of garbage.

+

The judges also offer this one comment: understand remarks!

+

Historical remarks:

+

Some new (in 1984) compilers disliked line 15 of the original source, +so we changed it from:

+
for(signal=0;*k * x * __FILE__ *i;) do {
+

to:

+
for(signal=0;*k *x * __FILE__ *i;) do {
+

To see what we mean look at the original +source file. The alternate code is the +version that has this modification. The fixed version has instead:

+
for(signal=0;*k *= * __FILE__ *i;) do {
+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1984/decot

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1984/laman/index.html b/1984/laman/index.html index 8f60b56bb..b5773b01f 100644 --- a/1984/laman/index.html +++ b/1984/laman/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,209 @@ - - + + + + + + - - -1984 laman - - + + + +1984/laman + + + + + -

1984 laman

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1984/laman

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1984/laman/index.html

- +
+ ← decot + ↑ 1984 ↑ + mullender → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Mike Laman
+Location: unknown

+ + +

To build:

+
make all
+

To use:

+
./laman <positive number>
+

Try:

+

The program accepts ONE POSITIVE number. Seeing is believing, so try +things like:

+
./try.sh
+
+./laman 4
+./laman 9
+./laman 16
+

This code should run you in circles.

+

Judges’ remarks:

+

Some new compilers (in 1984) dislike lines 6 and 10 of the source, so +we changed them from:

+
;++f)a[     b<<5|c]     =d++,b+     =e;for(     f=0;f<O
+<<5|c]^     =a[b<<5     |c]^=a[     (k-(b+1     ))<<5|c]
+

to:

+
;++f)a[     b<<5|c]     =d++,b+=    e;for(      f=0;f<O
+<<5|c]^=    a[b<<5      |c]^=a[     (k-(b+1     ))<<5|c]
+

I hope you have a C beautifier!

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1984/laman

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1984/mullender/index.html b/1984/mullender/index.html index 137b8b398..7a4c73616 100644 --- a/1984/mullender/index.html +++ b/1984/mullender/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,595 @@ - - + + + + + + - - -1984 mullender - - + + + +1984/mullender + + + + + -

1984 mullender

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1984/mullender

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1984/mullender/index.html

- +
+ ← laman + ↑ 1984 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Authors:

Name: Robbert van +Renesse
Location: US

Name: Sjoerd +Mullender
Location: NL

+ + +

To build:

+
make alt
+

NOTE: the original code will not work on any system other than VAX-11 and PDP-11 and this is why +we encourage you to use the alt version instead. See original code below for the original +version.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1984 mullender in bugs.md.

+

To use:

+
./mullender.alt [microseconds]
+

Hit ctrl-c/intr to exit the program.

+

The default microseconds is 190000 as this is approximately how long +it slept in the original entry but it can be no lower than 5000 as any +lower doesn’t work very well. This feature is so you can experiment with +different speeds in between writes. It can be useful if your CPU is too +fast :-)

+

The author stated that the original version also had a delay but the +difference is it required one to hit enter for it to print another line; +the alt code will start over once it times out or if one hits a key.

+

Note that the microseconds is argc and it uses atoi() +which does NOT check for overflow!

+

BTW: is there such a thing as too fast a CPU ? :-) Actually yes for +certain code which is probably not as uncommon as you think :-).

+

Try:

+
./mullender.alt
+
+./mullender.alt 5000    # wait for 5000 microseconds and see what happens
+
+./mullender.alt 20000   # wait for 20000 microseconds and see what happens
+
+./mullender.alt 100000  # wait for 100000 microseconds and see what happens
+

What happens if you hit enter after it reaches the end of the line? +Why? What happens after some time of waiting?

+

Original code:

+

This original code will only execute correctly if your machine is a +VAX-11 or PDP-11. In the following +years, 1985 on, machine dependent code was discouraged.

+

Original build:

+
make all
+

Original use:

+
./mullender
+

Judges’ remarks:

+

Without question, this C program is the one of the most obfuscated C +program that has ever been received! Like all great contest entries, it +resulted in a change of rules for the following year. To prevent a flood +of similar programs, the rules were changed, requesting non-machine +specific code.

+

This program was selected for the 1987 t-shirt collection.

+

The C startup routine (via crt0.o) transfers control +to a location named main. In this case, main +just happens to be in the data area. The array of shorts, +which has been further obfuscated by use of different data types, just +happens to form a meaningful set of PDP-11 and VAX instructions.

+

The first word is a PDP-11 branch +instruction that branches to the rest of the PDP +code.

+

On the VAX main is called with the calls +instruction which uses the first word of the subroutine as a mask of +registers to be saved. So on the VAX the first word can be anything. The +real VAX code starts with the second word.

+

This small program makes direct calls to the write() +Unix system call to produce a message on the screen. Can you guess what +is printed? We knew you couldn’t! :-)

+

What happens if you hit enter after it writes a line of output?

+

BTW: to this day, 2023, this remains one of my (Landon Curt Noll’s) +all time favorite entries!

+

gentab.c

+

In 2023 remarks were discovered from Sjoerd Mullender, one of the +authors, and so was the program that was used by the authors to generate +the array that he referred to. Because a.out.h, +which gentab.c uses, is not available in all +systems (like macOS) and more importantly because we wanted it to be as +close to as the original as possible we used a copy of https://raw.githubusercontent.com/dspinellis/unix-history-repo/Research-Release/usr/include/a.out.h +in the fabulous Unix +History Repo.

+

gentab build:

+

gentab.c can be built like:

+
make gentab
+

gentab use:

+
./gentab file
+

gentab try:

+
./gentab gentab > g.c
+

NOTE: it is highly unlikely that you will be able to run the output +of gentab but it should at least compile.

+

Author’s remarks:

+

Notes from the judges:

+

These remarks, found at https://lainsystems.com/posts/exploring-mullender-dot-c/, +were provided by Sjoerd Mullender years later. We thank the author of +the article for the quote! For a more detailed analysis, taken from the +book Obfuscated C and Other Mysteries, see below. We hope that this is +okay with the author of the book. Considering that the analysis is +entirely the authors’ comments we don’t think this will be a problem. +Unfortunately the excerpt was PDF and it did not copy paste well. We had +to go back and forth to type so it’s possible he made a typo though he +also fixed some typos found in the extract. As for the other +comments:

+

Remarks from the author:

+

I have never known a lot about the VAX assembly, so +we used the C compiler to create the VAX code. We didn’t write it +ourselves from scratch as we did with the PDP +code. This is the reason why the VAX code is more complex, +including the extra data after the PDP +code.

+

Robbert and I were students at the VU +(Free University in Amsterdam) at the time (mathematics with CS as +our major since there was no CS curriculum when we started). We had an +assignment to create a pair of programs for the computer networks +course. The programs were supposed to send data reliably from one +program to the other over an unreliable channel. This channel was +simulated with a pair of pipes.

+

We decided for fun to create an obfuscated +set of programs, only for the PDP, +to do this, but circumventing the channel (i.e. cheating, hence the +needed obfuscation.). Our programs worked and we handed them in.

+

Of course, the teacher had a good laugh and then rejected our +submission. (We knew him well, so we could get away with this.)

+

Then the IOCCC came along. I +don’t remember how we heard about it, but at the time there was a +world-wide messaging network Usenet where we read a bunch of newsgroups. +I’m sure it was announced +there and we saw it.

+

Since we had just recently created these obfuscated +programs) we decided we could use the same technique for an +obfuscated C program. We upped the ante a bit by making it +“portable”.

+

To add to the obfuscation), +we used different formats for the integers in the array: some in +decimal, some in octal, some in hexadecimal, and when the value would +fit, some as an ASCII character.

+

The rest is history.

+

Since this was the first contest, we hadn’t seen any old entries, nor +had any of the other contestants. Of course we knew about +#define and tricks you could do with that, but we didn’t +need that for this program. In fact, we made it as “standard” as +possible. At the time there was this program called cb or C +beautifier which would re-indent your program to make the layout look +better. Our program is idempotent under cb.

+

More detailed analysis

+

When this program is compiled, the compiler places the array +somewhere in memory, just like it places any compiled code somewhere in +memory. Usually, the C startup code (crt0.o) calls a routine +named main(). The loader fills in the address in the +startup code, but at least on the old systems where this program ran, it +doesn’t know that the main() in this program isn’t code but +data!

+

When the program is run, the C startup code transfers control to the +location main. The contents of the array just happen to be +machine instructions for both a PDP-11 and a VAX.

+

On the VAX, the +routine main() is called with the calls +instruction. This instruction uses the first (2-byte) word +of the called routine as a mask of registers +that are to be saved on the stack. +In other words, on the VAX the first word can be anything. On the PDP, +the first word is a branch +instruction +that branches over the VAX code. The PDP and VAX codes are thus +completely separate.

+

The PDP +and VAX codes implement +the same algorithm:

+
    for (;;) {
+    write(1, "  :-)\b\b\b\b", 9);
+    delay();
+    }
+

The result is that the symbols :-) move across the +screen. delay is implemented differently on the PDP, +where we used a nonexistent system call (sys 55), and on +the VAX where we used a +delay loop.

+

My co-author, Robbert, and I had earlier written a similar program +for an assignment on the PDP-11. Along +came the first Obfuscated C Code +Contest, and we decided that we should write a program like this, +but make it run on two different architectures.

+

We didn’t think long about what the program should do, so it does +something very simple.

+

We started with writing the PDP +code in assembly. We both knew PDP-11 assembly so that +was no problem. The assembly code we came up with is as follows:

+
pdp:
+    mov pc,r4
+    tst -(r4)
+    sub $9, r4
+    mov r4,0f
+    mov $1, r0
+    sys 4; 0:0; 9
+    mov $1000, r2
+1:
+    sys 55
+    sob r2,1b
+    br pdp
+

This is not the code we originally wrote, but it is the code that we +ultimately used in the program. The string to be printed is shared by +the VAX and the PDP +code and is located between the two sections.

+

First, the program deals with figuring out the address of the string. +Then the program +counter is saved in a scratch register. +Since the program counter points at the second instruction, +we subtract 2 from the scratch register in the second instruction. Then +we subtract the length of the string and store the result in the +location with label 0. This has to do with the calling sequence of system calls on the +PDP. +Following the sys instruction is the system call number (4 +for write()), the address of the buffer (pointed to by +label 0), and the length of the buffer (9). The file descriptor +is in register r0. The rest of the code implements a delay +loop. In each iteration, a non-existing system call (55) slows things +down.

+

We assembled this program and extracted the machine code from +the resulting object +file. We used this code in the VAX part. Since neither of +us were fluent in VAX assembly, we +wrote the VAX code in C and massaged the compiler output. The +VAX assembly program that we came up with is as follows:

+
vax: .word 0400 + (pdp - vax) / 2 - 1
+1:
+    pushl $9
+    pushal str
+    pushl $1
+    calls $3, write
+    cvtwl $32767, r2
+
+2:
+    decl r2
+    jneq 2b
+    jbr 1b
+
+write: .word 0
+    chmk $4
+    ret
+
+str: .ascii " :-)\b\b\b\b"
+
+pdp: .word 4548, 3044, 58820, 9, 4407, 6, 5568, 1, 35076, 0, 9, 5570, 512, 35117, 32386, 496
+

The first word (after the label vax) is the PDP +branch +instruction. PDP +branch instructions are octal 400+ the distance divided by +2. The string that both the PDP +and VAX programs use is +after the str label, and the PDP +code is after the pdp label.

+

On the VAX, the +program pushes +9 (the length of the string), the address of the string and 1 (the file descriptor +on the stack +and calls write(2). Since we didn’t know the exact calling +sequence for system +calls, we just copied the source for the write(2) +system call stub into our program. After write(2) finishes, +the program executes a delay loop, after which it jumps back to the +start of the program.

+

We assembled this program, and extracted the machine code from +the object file. +After this we only had to convert the machine code to ASCII and write a little +bit of C to glue everything together. We wanted to use different formats +for each constant in the resulting array, and we wanted to choose the +format randomly. So we wrote a program to choose an appropriate format +at random. The program we wrote for that follows. This program actually +also extracted the machine code from the object file.

+
+

NOTE from judges: see gentab.c for a copy of +this file that can be compiled in modern systems.

+
+
\#include <stdio.h>
+\#include <a.out.h>
+
+main(argc, argv) char **argv;
+{
+    register FILE *fp;
+    register short pos = 0, c, n;
+    register char *fmt;
+    if (argc != 2) {
+    fprintf (stderr, "Usage: %s file\n", argv[0]);
+    exit (1);
+    }
+
+    if ((fp = fopen(argv[1], "r")) == NULL) {
+    fprintf(stderr, "%s: can't open %s\n", argv[0], argv[1]);
+    exit(2);
+    }
+
+    fseek (fp, (long) sizeof (struct exec), 0);
+    printf("/* portable between VAX and PDP11 */\n\n");
+    printf ("short main[] = {\n");
+    for (;;) {
+    if (pos == 0)
+        printf("\t");
+
+    c=getc(fp) & 0377;
+    if (feof(fp)) break;
+    n = getc(fp) << 8|c;
+
+    switch (rand() % 5) {
+        case 0:
+        case 1:
+        fmt = "%d"; break;
+        case 2:
+        fmt = "%u"; break;
+        case 3:
+        fmt = "0%o"; break;
+        case 4:
+        fmt = "0x%x"; break;
+    }
+
+    if (32 <= n && n < 127 && (rand() % 4)) fmt = "'%c'";
+    printf(n < 8 ? "%d" : fmt, n);
+    printf(",");
+    if (pos++ == 8) {
+        printf("\n");
+        pos = 0;
+    }
+    else printf(" ");
+
+    printf("};\n");
+    }
+}
+

As can be seen, there is a slight preference for decimal, and also a +character format is sometimes used, but only if the data is a printable +ASCII character.

+

When we ran this program, we were almost completely satisfied with +the result. The only problem we had was that the program had chosen an +octal representation +for the first word. Since everybody knows what a PDP-11 branch +instruction looks like (everyone knows that the traditional magic word +for an executable, 0407, is a PDP-11 branch), +we changed that to decimal. After checking the size of the resulting +program we saw that it was one byte too long. The limit was 512 bytes, +and our program was 513 bytes. So we changed the word and +in the comment to &&.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1984/mullender

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1985/applin/index.html b/1985/applin/index.html index db3394a66..2ea186150 100644 --- a/1985/applin/index.html +++ b/1985/applin/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,195 @@ - - + + + + + + - - -1985 applin - - + + + +1985/applin + + + + + -

1985 applin

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1985/applin

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1985/applin/index.html

- +
+ first entry + ↑ 1985 ↑ + august → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Authors:

Name: Jack Applin
+Location: US +

Name: Robert +Heckendorn
Location: US

+ + +

To build:

+
make all
+

Try:

+
./applin
+

Judges’ remarks:

+

One liner programs are short but twisted. This “Hello, world!” +version certainly takes its time saying hello.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1985/applin

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1985/august/index.html b/1985/august/index.html index e56229ab5..13bfcafd5 100644 --- a/1985/august/index.html +++ b/1985/august/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,217 @@ - - + + + + + + - - -1985 august - - + + + +1985/august + + + + + -

1985 august

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1985/august

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1985/august/index.html

- +
+ ← applin + ↑ 1985 ↑ + lycklama → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Lennart +Augustsson
Location: SE

+ + +

To build:

+
make all
+

To use:

+
./august
+

Try:

+
./try.sh
+

If you have the primes(6) tool (sometimes part of BSD Games) you can see +what of the output in the first N (say 15 or +25) lines are primes:

+
./primes.sh # 15
+./primes.sh 25
+

Note that try.sh will run this script anyway, telling +you where to get primes(6) if you don’t have it installed, +but it will only run with the default value of 15, rather than trying +several different values.

+

Judges’ remarks:

+

An interesting use of a recursive call to main(). +Compile and execute without args. What is the initial value of +b? Does it alter the action of the program?

+

If you let it, the program will continue to print a numerical +sequence (can you guess in what base it is printed by looking at the +code?) until you run out of memory or until they sell your computer, +whichever comes first.

+

If you use the primes.sh script can you +figure out if there’s anything funny going on with the output?

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1985/august

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1985/lycklama/index.html b/1985/lycklama/index.html index 86438b0a3..d0792ae19 100644 --- a/1985/lycklama/index.html +++ b/1985/lycklama/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,225 @@ - - + + + + + + - - -1985 lycklama - - + + + +1985/lycklama + + + + + -

1985 lycklama

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1985/lycklama

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1985/lycklama/index.html

- +
+ ← august + ↑ 1985 ↑ + shapiro → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Ed Lycklama
+Location: unknown

+ + +

To build:

+
make alt
+

To use:

+
./lycklama.alt < some_file
+

To see why we recommend the alternate version instead of the original +version, see below and the Original code +section.

+

Try:

+

This alternate version, which we recommend you you try first, prior +to the original, slows down the output so that you can see what it +looked like back in 1985. This will be more enjoyable. It is slowed down +by the usleep(3) library call with a configurable time to +sleep. The default is 500 microseconds but you can reconfigure it +like:

+
make SLEEP=700 clobber alt
+

which would set it at 700. Then, whether you use the default value or +not, try:

+
./try.alt.sh
+

Original code:

+

As explained above, because modern systems run this entry way too +fast to fully appreciate what it does, we encourage you to first try the +alternate version. After this, however, you might wish to try the +original version, fixed for modern systems.

+

Original build:

+
make all
+

Original use:

+
./lycklama < some_file
+

Original try:

+
./lycklama < lycklama.c
+./lycklama < lycklama.alt.c
+./lycklama < lycklama.orig.c
+./lycklama < Makefile
+

Judges’ remarks:

+

Run the program, redirecting a file into it, and notice how it +redisplays it. The program itself looks like tty noise.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1985/lycklama

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1985/shapiro/index.html b/1985/shapiro/index.html index f4791b273..a064e8388 100644 --- a/1985/shapiro/index.html +++ b/1985/shapiro/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,222 @@ - - + + + + + + - - -1985 shapiro - - + + + +1985/shapiro + + + + + -

1985 shapiro

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1985/shapiro

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1985/shapiro/index.html

- +
+ ← lycklama + ↑ 1985 ↑ + sicherman → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Carl Shapiro
+Location: US

+ + +

To build:

+
make all
+

There is alternate code which allows one to change the size of the +maze. See Alternate code below.

+

To run:

+
./shapiro
+

Alternate code:

+

The code has a define C set to 39 but this can be +modified to change the size of the maze. The alt code allows one to +easily do this.

+

Alternate build:

+
make alt
+

Alternate try:

+

If you wish to change the value you can do it like:

+
make clobber SIZE=5 alt
+

Note that if it is not a number then obviously there will be a +compilation error. If it’s <= 0 || >= 5000 then it is set to 39, +the default.

+

You might also wish to try:

+
./try.alt.sh
+

This script will compile the program five times with a random value +and then prompt you in an infinite loop for values to try, exiting only +if non-digits are in the input.

+

Also try printing out various sized mazes and solving them with +pencil or pen or in your head.

+

Judges’ remarks:

+

As submitted, this program was 3 lines (2 of defines and 1 of code). +To make news & mail happy we split the last line into seven +lines.

+

This program was selected for the 1987 t-shirt collection.

+

We found this program is be simply amazeing! Run +this program without arguments and notice the output.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1985/shapiro

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1985/sicherman/index.html b/1985/sicherman/index.html index a5bdb1f43..aa580ada4 100644 --- a/1985/sicherman/index.html +++ b/1985/sicherman/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,243 @@ - - + + + + + + - - -1985 sicherman - - + + + +1985/sicherman + + + + + -

1985 sicherman

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1985/sicherman

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1985/sicherman/index.html

- +
+ ← shapiro + ↑ 1985 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Col. G. L. +Sicherman
Location: US

+ + +

To build:

+
make all
+

There is another version that will be compiled in case the first +fails. This should happen automatically. See Alternate code below for more details on +it.

+

To use:

+
./sicherman < file
+
+echo foo | ./sicherman
+
+./sicherman
+# type or paste some text, making sure to hit enter after each line typed
+

Try:

+
./try.sh
+

Alternate code:

+

The sicherman.alt.c is a slight change +in the fixed version (fixed so it does not require +-traditional-cpp) in that it has two args to +main() as some compilers object to certain number of args +in main(). This will be built in the case of the sicherman.c failing to compile. In this case +it’ll be compiled to sicherman to simplify it for the +larger audience.

+

Alternate build:

+

Although this will be built if the original fails to compile you can +do it manually like:

+
make alt
+

In this case it will be built as sicherman.alt.

+

Alternate use:

+
./sicherman.alt < file
+

Alternate try:

+
./try.alt.sh
+

Judges’ remarks:

+

This program abuses the C preprocessor so much that some +cpps fail to strip out all of the comments on the first +pass! If you were able to understand Decot’s entry in 1984, you will have a head +start on this one.

+

Be sure to run this program through lint! If your lint works +correctly, it should warn you that the argument ‘Manual’ isn’t used. +Like the program says, what’s that mean?

+

Run the program without arguments and enter the letters ‘a’ through +‘m’ on a line. Now enter the letters ‘n’ through ‘z’. But to borrow a +quote from Richard Stallman: If you think you understand what this code +does, then you don’t, so read it again! Explain why:

+
./sicherman < sicherman.c | ./sicherman | diff - ./sicherman.c
+

results in diff reporting a difference on some machines.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1985/sicherman

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1986/applin/index.html b/1986/applin/index.html index a710fc679..a0418b333 100644 --- a/1986/applin/index.html +++ b/1986/applin/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,194 @@ - - + + + + + + - - -1986 applin - - + + + +1986/applin + + + + + -

1986 applin

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1986/applin

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1986/applin/index.html

- +
+ first entry + ↑ 1986 ↑ + august → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jack Applin
+Location: US

+ + +

To build:

+
make all
+

To use:

+
./applin
+

Try:

+
./applin.c
+

Judges’ remarks:

+

The judges were so amused by this little program that we created an +award just for it. This program is portable to the C and Fortran 77 +compilers as well as executable by the Bourne shell!

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1986/applin

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1986/august/index.html b/1986/august/index.html index 3b0b74441..8e3659d90 100644 --- a/1986/august/index.html +++ b/1986/august/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,201 @@ - - + + + + + + - - -1986 august - - + + + +1986/august + + + + + -

1986 august

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1986/august

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1986/august/index.html

- +
+ ← applin + ↑ 1986 ↑ + bright → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Lennart +Augustsson
Location: SE

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1986 +august in bugs.md.

+

Try:

+
./august
+

Judges’ remarks:

+

This program computes a specific mathematical value. Simply compile +and give it an infinite amount of stack space and CPU time. Otherwise +just be satisfied with the approximation displayed just before the core +dump.

+

This program will pass lint on your system assuming your lint is +brave enough to try and parse it correctly.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1986/august

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1986/bright/index.html b/1986/bright/index.html index 7629c6ad3..862716966 100644 --- a/1986/bright/index.html +++ b/1986/bright/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,199 @@ - - + + + + + + - - -1986 bright - - + + + +1986/bright + + + + + -

1986 bright

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1986/bright

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1986/bright/index.html

- +
+ ← august + ↑ 1986 ↑ + hague → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Walter Bright
+Location: US

+ + +

To build:

+
make all
+

To use:

+
./bright some_file
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Compile this program and give a filename as an argument.

+

Mr. Bright exploits the C pre-processor, similar variables and +excessive shifting to obfuscate an otherwise useful binary display +program. This gives you a small example of what it is like to maintain +the Bourne shell! :-}

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1986/bright

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1986/hague/index.html b/1986/hague/index.html index 12fc973e4..80047d582 100644 --- a/1986/hague/index.html +++ b/1986/hague/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,209 @@ - - + + + + + + - - -1986 hague - - + + + +1986/hague + + + + + -

1986 hague

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1986/hague

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1986/hague/index.html

- +
+ ← bright + ↑ 1986 ↑ + holloway → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jim Hague
+Location: GB

+ + +

To build:

+
make all
+

To use:

+
./hague 2>/dev/null
+# enter some text
+

Try:

+
./try.sh
+

Note that you can run the program without feeding it anything and +then type in a message and line by line it will show the right output. +Notice also how certain characters will print a ?.

+

Judges’ remarks:

+

Compile this program and feed ASCII text into standard input. This +program is known to pass lint on some systems and abort lint on +others.

+

This program was selected for the 1987 t-shirt collection.

+

Think Morse code when you ponder this program. Note how the use of +similar variables can be obfuscating! The author noted that this program +implements the international Morse standard. Now for extra credit, what +Morse message does the program spell out?

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1986/hague

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1986/holloway/index.html b/1986/holloway/index.html index 3f78b0bad..3cb3fd27d 100644 --- a/1986/holloway/index.html +++ b/1986/holloway/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,194 @@ - - + + + + + + - - -1986 holloway - - + + + +1986/holloway + + + + + -

1986 holloway

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1986/holloway

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1986/holloway/index.html

- +
+ ← hague + ↑ 1986 ↑ + marshall → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Bruce +Holloway
Location: US

+ + +

To build:

+
make all
+

Try:

+
./holloway
+

Judges’ remarks:

+

Believe it or not, this is the old standard “Hello, world” program +performed in a very complex way. The judges and the author defy you to +determine how it does it. It is a good thing that K&R didn’t use +this version as the first C program!

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1986/holloway

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1986/marshall/index.html b/1986/marshall/index.html index 47cfeda45..84b95d1a6 100644 --- a/1986/marshall/index.html +++ b/1986/marshall/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,227 @@ - - + + + + + + - - -1986 marshall - - + + + +1986/marshall + + + + + -

1986 marshall

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1986/marshall

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1986/marshall/index.html

- +
+ ← holloway + ↑ 1986 ↑ + pawka → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Eric Marshall
+Location: US

+ + +

To build:

+
make all
+

NOTE: we FORCE disable the optimiser due to a funny problem with +different compilers and systems. See below and compilers.md for details.

+

There is an alternate version. The +reason is a funny problem: in modern systems, depending on the platform, +compiler and the optimiser, it would work with one compiler with the +optimiser but it would not work with the other; and if the optimiser +state is changed the previous problematic compiler might work but the +other one would not. We describe this in more detail in compilers.md and we encourage you to read it for +entertainment if nothing else.

+

To use:

+
./marshall
+

Alternate code:

+

Due to the different conflicting problems +with gcc and clang, we instead offer the problematic code as an +alternate version whereas marshall.c has both +the infinite loop and the complicated arg to _exit() +commented out, changing the value passed into _exit() to +1.

+

Alternate build:

+

To see if your compiler has the problems noted:

+
make alt
+

Alternate use:

+
./marshall.alt
+

Does it work in your system? That is does it not segfault, does it +print it only once and does it not enter an infinite loop? Or more +generally does it print the text exactly once and then exit?

+

Judges’ remarks:

+

This program prints the name of the picture. The layout is somewhat +pretty though it is not the usual sort of output one would expect from +printing a program!

+

This program was selected for the 1987 t-shirt collection.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1986/marshall

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1986/pawka/index.html b/1986/pawka/index.html index eaa8d4205..be93e3070 100644 --- a/1986/pawka/index.html +++ b/1986/pawka/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,193 @@ - - + + + + + + - - -1986 pawka - - + + + +1986/pawka + + + + + -

1986 pawka

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1986/pawka

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1986/pawka/index.html

- +
+ ← marshall + ↑ 1986 ↑ + stein → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Michael H. +Pawka
Location: unknown

+ + +

To build:

+
make all
+

Try:

+
./pawka
+

Judges’ remarks:

+

The judges found this entry to be one of hardest to read without the +aid of /lib/cpp and a good editor. When run, the program +asks if it is obfuscated, of all things!

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1986/pawka

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1986/stein/index.html b/1986/stein/index.html index 07eb7d400..26c6acec2 100644 --- a/1986/stein/index.html +++ b/1986/stein/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,202 @@ - - + + + + + + - - -1986 stein - - + + + +1986/stein + + + + + -

1986 stein

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1986/stein

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1986/stein/index.html

- +
+ ← pawka + ↑ 1986 ↑ + wall → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jan Stein
+Location: unknown

+ + +

To build:

+
make all
+

To use:

+
./stein $(printf "\015\015"); echo
+

Judges’ remarks:

+

NOTE: to avoid problems with news and mail, the single line was split +into 3 lines. Join all lines into a single line to recreate the original +file.

+

The \015 in the above printf(1) command +produces a control-N.

+

One some machines, a control-M control-N arg is needed to get the +command to output cleanly:

+
./stein $(printf "\014\015"); echo
+

Your system may require another set of characters. In time, you will +figure out what it does. :-)

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1986/stein

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1986/wall/index.html b/1986/wall/index.html index 6bc14d27a..3ecb85c01 100644 --- a/1986/wall/index.html +++ b/1986/wall/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,199 @@ - - + + + + + + - - -1986 wall - - + + + +1986/wall + + + + + -

1986 wall

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1986/wall

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1986/wall/index.html

- +
+ ← stein + ↑ 1986 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Larry Wall
+Location: US

+ + +

To build:

+
make all
+

To use:

+
./wall
+

Judges’ remarks:

+

The original version did not have a ‘;’ character in the first line. +This caused a number of System V C pre-preprocessors to gripe about a +syntax error.

+

This program is a masterpiece of obfuscation and humor. Larry Wall +(the hacker who gave us rn and patch) asks you to +compile and consider the warning message generated by the C compiler. +Then execute the program and type characters into its standard input. +You will see why the compiler documents the program.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1986/wall

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1987/biggar/index.html b/1987/biggar/index.html index 07cbad520..8a58c6a02 100644 --- a/1987/biggar/index.html +++ b/1987/biggar/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,212 @@ - - + + + + + + - - -1987 biggar - - + + + +1987/biggar + + + + + -

1987 biggar

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1987/biggar

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1987/biggar/index.html

- +
+ first entry + ↑ 1987 ↑ + heckbert → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Mark Biggar
+Location: unknown

+ + +

To build:

+
make all
+

To use:

+
some_command | ./biggar | od -c
+
+./biggar < file | od -c
+

Try:

+
./try.sh
+

Judges’ remarks:

+

By changing the compile line you can make this program do anything +you want. This is a very efficient way to transfer source, though it +increases the size of Makefiles.

+

With only slight variations, this program can be set to many uses. +Consider how easy it would be to release Unix source in +this form; so what if the Makefiles grow a little! :-)

+

One vendor’s lint got hung in an infinite loop over this entry!

+

FYI: We will let Mark get away with this truly sick entry this time, +but for the future on we have placed a limit on the size of a compile +line.

+

NOTE: originally we made a comment in Larry Wall’s entry regarding Mark’s +contribution but it seems to have been lost in time. If anyone knows +about its whereabouts we’d appreciate letting us know. Thanks!

+

Passes BSD and UTS lint. At least one version of lint is thrown into +an infinite loop by this entry.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1987/biggar

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1987/heckbert/index.html b/1987/heckbert/index.html index cfdd9d2e6..0e74f39fc 100644 --- a/1987/heckbert/index.html +++ b/1987/heckbert/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,209 @@ - - + + + + + + - - -1987 heckbert - - + + + +1987/heckbert + + + + + -

1987 heckbert

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1987/heckbert

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1987/heckbert/index.html

- +
+ ← biggar + ↑ 1987 ↑ + hines → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Paul Heckbert
+Location: US

+ + +

To build:

+
make all
+

On System V systems, we had to compile with +-Dindex=strchr. To compile on a 16 bit machine, change +300000 to 30000.

+

To use:

+
./heckbert col < file
+

where col is the number of columns to fold at and file is the file to +fold.

+

Try:

+
./try.sh
+

Judges’ remarks:

+

Folding at the wrong length may be equivalent to a “Spindle or +Mutilate” operation. For example:

+
./heckbert 40 < heckbert.c > ph.c ; make ph ; ./ph 20 < heckbert.c > bar.c ; make bar
+

Try not to Fold, +Spindle or Mutilate files. :-)

+

The judges used this program to fold up
+very long lines which the BSD fold(1)
+was unable to process. This program has
+been added to the contest tool chest.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1987/heckbert

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1987/hines/index.html b/1987/hines/index.html index 6c0b47ec3..bbf1f6b3a 100644 --- a/1987/hines/index.html +++ b/1987/hines/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,209 @@ - - + + + + + + - - -1987 hines - - + + + +1987/hines + + + + + -

1987 hines

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1987/hines

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1987/hines/index.html

- +
+ ← heckbert + ↑ 1987 ↑ + korn → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Spencer Hines
+Location: unknown

+ + +

To build:

+
make all
+

To use:

+
./hines file.c
+

Try:

+
./try.sh
+

Judges’ remarks:

+

This program was designed to maximize the bother function for +structured programmers. This program takes goto statements +to their logical conclusion. The layout and choice of names are +classic.

+

We consider this to be a beautiful counter-example for Frank Rubin’s +letter to ACM form titled: “‘GOTO +Considered Harmful’ Considered Harmful”. See the Communications +of the ACM, March 1987, Page 195-196.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1987/hines

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1987/korn/index.html b/1987/korn/index.html index 8eb3468b3..bf4849a7c 100644 --- a/1987/korn/index.html +++ b/1987/korn/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,226 @@ - - + + + + + + - - -1987 korn - - + + + +1987/korn + + + + + -

1987 korn

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1987/korn

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1987/korn/index.html

- +
+ ← hines + ↑ 1987 ↑ + lievaart → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: David Korn
+Location: US

+ + +

To build:

+
make all
+

To use:

+
./korn
+

Judges’ remarks:

+

The Judges believe that this is the best one line entry ever +received. Compile on a UNIX system, or at least one using a C +implementation that fakes it. Very few people are able to determine what +this program does by visual inspection. I suggest that you stop reading +this section right now and see if you are one of the few people who +can.

+

Several points are important to understand this program:

+
    +
  1. What is the symbol unix and what is its value in the +program? Clearly unix is not a function, and since +unix is not declared to be a data type (such as +int, char, struct foo, +enum, …) what must unix be?

  2. +
  3. What is the value of the symbol "have"? (hint: the +value is NOT 4 characters, or 'h', or a string) Consider +the fact that:

  4. +
+
char *x;
+

defines a pointer to a char (i.e. an address), and that +the = assigns things of compatible types. Since:

+
x = "have";
+

is legal C, what type of value is "have"?

+
    +
  1. Note that the following expressions yield the same value:
  2. +
+
x[3]    *(x+3)    *(3+x)
+

since addition is commutative. What can be said about this value?

+
3[x]
+

David +Korn’s /bin/ksh provides us +with a greatly improved version of the /bin/sh. The +source for v7’s /bin/sh +greatly inspired this contest.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1987/korn

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1987/lievaart/index.html b/1987/lievaart/index.html index 38f892312..7f43eba12 100644 --- a/1987/lievaart/index.html +++ b/1987/lievaart/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,222 @@ - - + + + + + + - - -1987 lievaart - - + + + +1987/lievaart + + + + + -

1987 lievaart

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1987/lievaart

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1987/lievaart/index.html

- +
+ ← korn + ↑ 1987 ↑ + wall → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Roemer B. +Lievaart
Location: NL

+ + +

To build:

+
make all
+

To use:

+
./lievaart
+# enter a level and start playing as described below
+

Try:

+

To see what it would have looked like without the size +restrictions:

+
./lievaart2
+# enter a level and start playing as described below
+

Judges’ remarks:

+

We believe that you too will be amazed at just how much power +Mr. Lievaart packed into 1024 bytes!

+

This Plays the game of Reversi (Othello)! +Compile and run. It then asks for a playing level. Enter 0-10 +(easy-hard). It then asks for your move. A move is a number within +11-88, or 99 to pass. Illegal moves (except for an illegal pass) are +rejected. Then the computer does its move (or a 0 to pass), until the +board is full.

+

It plays rather well, for such a small program! Lievaart had to leave +out the board printing routine, so you’ll have to take a real game board +to play it (or see below). … Also due to space-limitations (the rules +for 1987 had a limit of 1024 byes), Lievaart took out the +passing-handler, which makes its ending-game rather poor. But further it +knows all the rules, uses alpha-beta +pruning, and it plays for instance on mobility(!). Most important: +it can play a pretty good game of Reversi!

+

The Author was kind enough to supply the fully functional version of +the program. The file lievaart2.c contains +what the program would have been without the size restriction. This +version has the full end game logic and displays the board after each +move! See above for how to use this.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1987/lievaart

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1987/wall/index.html b/1987/wall/index.html index 81c2998de..fd7851645 100644 --- a/1987/wall/index.html +++ b/1987/wall/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,218 @@ - - + + + + + + - - -1987 wall - - + + + +1987/wall + + + + + -

1987 wall

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1987/wall

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1987/wall/index.html

- +
+ ← lievaart + ↑ 1987 ↑ + westley → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Larry Wall
+Location: US

+ + +

To build:

+
make all
+

To use:

+
./wall
+# enter some numbers
+
+./wall | some_command
+# enter some strings or numbers, depending on command
+

Try:

+
./try.sh
+

You may of course run the commands manually and enter text as you +wish. For instance you might try one or both of:

+
./wall | bc
+
+./wall | cat
+

and enter some input like:

+
x*x
+2^x
+quit # for the cat version
+

which the script does through a pipeline except that here you can +enter more text if you wish, line by line.

+

Judges’ remarks:

+

What we found amazing was how the flow of control was transferred +between subroutines. Careful inspection will show that the array of +pointers to functions named vi refers to functions which +seem to not be directly called. Even so, these pointers to functions are +being used as an argument to signal(3) (used both with and +without an arg - but how?). Can you determine why this is being done and +how it is being exploited?

+

Some compilers complained about this file, so we changed: +=++I to = ++I.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1987/wall

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1987/westley/index.html b/1987/westley/index.html index 500d2e36e..1ff5dd3d5 100644 --- a/1987/westley/index.html +++ b/1987/westley/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,193 @@ - - + + + + + + - - -1987 westley - - + + + +1987/westley + + + + + -

1987 westley

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1987/westley

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1987/westley/index.html

- +
+ ← wall + ↑ 1987 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Brian Westley
+Location: US

+ + +

To build:

+
make all
+

To use:

+
./westley
+

Judges’ remarks:

+

putchar() must exist in the C library and not just as a +macro. If it fails to compile, bug your OS/compiler vendor.

+

Line by line symmetry performed better than any C beautifier. Think +of if it as a C ink blot. :-)

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1987/westley

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1988/applin/index.html b/1988/applin/index.html index ae01c73b7..5ec9e4a62 100644 --- a/1988/applin/index.html +++ b/1988/applin/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,232 @@ - - + + + + + + - - -1988 applin - - + + + +1988/applin + + + + + -

1988 applin

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1988/applin

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1988/applin/index.html

- +
+ first entry + ↑ 1988 ↑ + dale → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jack Applin
+Location: US

+ + +

To build:

+
make all
+

A smaller version, originally called zsmall.c (and still +exists as such, as the source of the alt code), of applin.c, can be found in applin.alt.c. Your machine may have an easier +time with this program. See the Alternate +code section below for details.

+

Try:

+
./applin
+

Alternate code:

+

As noted above a smaller version can be used in case your +cpp has a hard time with this entry.

+

Alternate build:

+
make alt
+

Use applin.alt as you would applin +above.

+

History about the smaller +version:

+

Way back in 1988 ..

+

This entry took 75 minutes to compile on a Amdahl 5980-300E (a 55658 +Dhyrstone/sec/cpu machine) using the System V cpp. (The GNU +cpp when defined as BIG_CPP took only 45 +seconds.)

+

Your cpp may not be able to compile it due to a common +bug that results in cpp running out of space. The routine +zsmall is a smaller version of the applin.c entry.

+

Judges’ remarks:

+

This entry is by far the most unusual abuse of the C preprocessor +that we have received thus far. Nearly all of the real work is done in +the C preprocessor!

+

When we compiled applin.c on an Amdahl +5890-300E, we found that it spent over 75 minutes in the System V C +preprocessor! Besides showing that the standard System V +cpp is slow, it showed that it contained a memory usage +problem. The applin.c only uses 29 different +preprocessor symbols (besides stdio.h) and yet the +preprocessor ran out of space!

+

The GNU C preprocessor took under 45 seconds to perform the 2nd pass +on the Amdahl 5890-300E. But due to the ANSI-likeness of GNU +cpp (v. 1-21), it was not able to cleanly substitute a +symbol that began with a ‘#’. Clearly the GNU C preprocessor is +faster.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1988/applin

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1988/dale/index.html b/1988/dale/index.html index ec921b748..760150e9b 100644 --- a/1988/dale/index.html +++ b/1988/dale/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,208 @@ - - + + + + + + - - -1988 dale - - + + + +1988/dale + + + + + -

1988 dale

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1988/dale

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1988/dale/index.html

- +
+ ← applin + ↑ 1988 ↑ + isaak → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Paul Dale
+Location: AU

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1988 +dale in bugs.md.

+

Try:

+
./try.sh
+

Observe that three of the commands in the script are:

+
./dale these files are in this directory: *
+./dale $(printf "the following files exist in this directory:\n%s\n" *)
+./dale "$(printf "the following files exist in this directory:\n%s\n" *)"
+

As the script asks what do the last two do and why do they do it? Why +do they differ in format from the first command? Finally how can you get +the more likely desired behaviour?

+

Judges’ remarks:

+

This entry has a very twisted flow of control via recursion, +iteration and multi-processing. Try to understand what is being done +with the system calls.

+

NOTE: This program assumes the ASCII character set is being used.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1988/dale

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1988/isaak/index.html b/1988/isaak/index.html index 826a95959..35dbc58ae 100644 --- a/1988/isaak/index.html +++ b/1988/isaak/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,236 @@ - - + + + + + + - - -1988 isaak - - + + + +1988/isaak + + + + + -

1988 isaak

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1988/isaak

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1988/isaak/index.html

- +
+ ← dale + ↑ 1988 ↑ + litmaath → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Mark Isaak
+Location: unknown

+ + +

To build:

+
make all
+

There is an alternate version, the original, that can’t be compiled +in modern systems but can be if you have an old enough compiler. See Alternate code below.

+

To use:

+
./isaak
+

Alternate code:

+

The original version of this code is in isaak.alt.c. The original entry starts with the +line:

+
main(){};
+

This works on some systems. Why? Note that +#include <stdio.h> is given on the last line. Why is +this needed? Note the unusual calls to sprintf(3).

+

This version also relied on being able to define #define +to something else and using that macro for #define.

+

This version will not likely work on modern systems if you can even +get it to compile.

+

Alternate build:

+
make alt
+

Use isaak.alt as you would isaak above.

+

Judges’ remarks:

+

The program relies heavily on ASCII. Don’t even think of running it +on an EBCDIC machine.

+

Historical notes +about the original entry:

+

NOTE: If you named the file anything other than isaak.c, you had to change the #include +on line 6. This limitation has been fixed by using the +__FILE__ macro.

+

NOTE: The use of null comments to separate macros to construct +different tokens from a single macro (e.g., "O/**/O" +creates either ++ or -- by defining +O to be + or -) may cause some +strict ANSI C preprocessors to object.

+

NOTE: Most System V machines were not be able to execute this program +correctly due to the fact that BSD style systems have an +sprintf(3) that returns a char *. Due to the +above problems, we placed the output of this program in the file: +isaak.encode. To read this file do.

+
uudecode < isaak.encode
+cat isaak.output
+

Since this was fixed, this file is not strictly necessary. See the isaak.alt.c for the original source.

+

FYI: We are likely to be more strict about portability in the +future.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1988/isaak

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1988/litmaath/index.html b/1988/litmaath/index.html index 71937cc8a..c409a4356 100644 --- a/1988/litmaath/index.html +++ b/1988/litmaath/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,223 @@ - - + + + + + + - - -1988 litmaath - - + + + +1988/litmaath + + + + + -

1988 litmaath

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1988/litmaath

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1988/litmaath/index.html

- +
+ ← isaak + ↑ 1988 ↑ + phillipps → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Maarten +Litmaath
Location: CH

+ + +

To build:

+
make
+

To use:

+
./litmaath some text
+

There is an alternate version provided. See the Alternate code section below.

+

Try:

+
./litmaath eschew obfuscation
+

Alternate code:

+

This alternate code, added to help understand the entry and for fun, +is code that we suggested at the time of the entry publication but which +we never put in a file.

+

Alternate build:

+
make alt
+

Use litmaath.alt as you would litmaath +above.

+

Alternate try:

+
./litmaath.alt six was afraid of seven because seven eight nine
+

Judges’ remarks:

+

Note the unusual structure:

+
while (<condition>)
+     ;
+

Did you notice that the body is empty?

+

Furthermore, it’s interesting to note that only two variables are +used to achieve everything.

+

The best one can do to understand how the program works is to give it +two small strings as arguments, and follow the program closely. One +could make the body of the while loop an +fprintf with interesting variables like:

+
fprintf(stderr,
+     "argv=%lo *argv=%lo **argv=%c argv[1]=%lo *argv[1]=%c argc=%d\n",
+     (long) argv, (long) *argv, *argv && **argv ? **argv : '@',
+     (long) argv[1], argv[1] && *argv[1] ? *argv[1] : '@', argc);
+

… which is what the alternate code +is.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1988/litmaath

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1988/phillipps/index.html b/1988/phillipps/index.html index 48709edda..bb76a52a1 100644 --- a/1988/phillipps/index.html +++ b/1988/phillipps/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,192 @@ - - + + + + + + - - -1988 phillipps - - + + + +1988/phillipps + + + + + -

1988 phillipps

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1988/phillipps

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1988/phillipps/index.html

- +
+ ← litmaath + ↑ 1988 ↑ + reddy → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Ian Phillipps
+Location: unknown

+ + +

To build:

+
make all
+

Judges’ remarks:

+

Compile and run without parameters.

+

The program is smaller than even the ‘compressed’ form of its output, +and thus represents a new departure in text compression standards.

+

The judges thought that this program looked like what you would get +by pounding on the keys of an old typewriter at random.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1988/phillipps

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1988/reddy/index.html b/1988/reddy/index.html index e06b3b7e5..48c4c05ca 100644 --- a/1988/reddy/index.html +++ b/1988/reddy/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,196 @@ - - + + + + + + - - -1988 reddy - - + + + +1988/reddy + + + + + -

1988 reddy

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1988/reddy

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1988/reddy/index.html

- +
+ ← phillipps + ↑ 1988 ↑ + robison → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Gopi Reddy
+Location: unknown

+ + +

To build:

+
make all
+

Try:

+
./reddy
+char *(*(fun[16])();
+char *(*(*(*(*(*fun[32])))))();
+

What happens if you input, and what you do about it?

+
char *(*(*(*(*(*fun[32])))))());
+

Judges’ remarks:

+

This is a somewhat restricted version of a useful program that has +been posted to Usenet. What is unusual is what it is able to do so much +in such little space.

+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1988/reddy

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1988/robison/index.html b/1988/robison/index.html index 8057c6cf2..927f06567 100644 --- a/1988/robison/index.html +++ b/1988/robison/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,206 @@ - - + + + + + + - - -1988 robison - - + + + +1988/robison + + + + + -

1988 robison

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1988/robison

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1988/robison/index.html

- +
+ ← reddy + ↑ 1988 ↑ + spinellis → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Arch D. +Robison
Location: US

+ + +

To build:

+
make all
+

Try:

+
./robison 80 10
+./robison 40 16
+

The first and second parameters are optional. You might also try:

+
./robison 80 2   # <--- can you find the bug?
+./robison 80 -246
+

Judges’ remarks:

+

The following might make an interesting benchmark:

+
./robison 100
+

[Amdahl 5890-300E with System V cc: 8.40 seconds]

+

We suggest that you C pre-process and perhaps C-beautify this +program. All is not what it may appear to be in this program. Why does a +whi1e not take a while to execute?

+

Author’s remarks:

+

This program shows that C has many unnecessary constructs, in fact +only while,--, and >= are +required. (The two assignments at the beginning could be avoided if +atoi(3) was rewritten with this new paradigm.) Note that +the lack of both the controversial goto and assignment +statements makes the meaning crystal clear. The current
+ANSI committee should look into this practical simplification of C.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1988/robison

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1988/spinellis/index.html b/1988/spinellis/index.html index 03ce9f39a..0a27dd420 100644 --- a/1988/spinellis/index.html +++ b/1988/spinellis/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,231 @@ - - + + + + + + - - -1988 spinellis - - + + + +1988/spinellis + + + + + -

1988 spinellis

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1988/spinellis

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1988/spinellis/index.html

- +
+ ← robison + ↑ 1988 ↑ + westley → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Diomidis +Spinellis
Location: GR

+ + +

To build:

+
make clobber all
+

and follow the instructions this will give you.

+

If your compiler will not read from /dev/tty see the Alternate code section below.

+

To use:

+
./spinellis
+

Type in or copy paste some C code, perhaps from input.txt, and send EOF (typically ctrl-d).

+

Now run again:

+
./spinellis
+

Alternate code:

+

For clang or compilers that won’t read from /dev/tty, we +provide this version.

+

Alternate build:

+
make clobber alt
+

and follow the instructions.

+

Alternate use:

+
./spinellis.alt
+

Type in or copy paste some C code, perhaps from input.txt, and send EOF (typically ctrl-d).

+

Now run again:

+
./spinellis.alt
+

Judges’ remarks:

+

We enjoyed this entry this year; however in the future programs must +be able to be compiled from within a Makefile without the need of human +intervention.

+

Author’s remarks:

+

This program can be configured to do almost everything. The +configuration is done during compile time by typing in C code that one +would like the program to perform. A trivial example is given in the +`how to compile’ section but the possibilities are clearly limited only +by your imagination and programming skills.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1988/spinellis

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1988/westley/index.html b/1988/westley/index.html index a15568918..34832a3c2 100644 --- a/1988/westley/index.html +++ b/1988/westley/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,224 @@ - - + + + + + + - - -1988 westley - - + + + +1988/westley + + + + + -

1988 westley

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1988/westley

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1988/westley/index.html

- +
+ ← spinellis + ↑ 1988 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Brian Westley
+Location: US

+ + +

To build:

+
make all
+

NOTE: this version is a fixed version for modern C compilers. See the +Alternate code section below for how to +use the original and why one might wish to do so.

+

Try:

+
./westley
+

Also try:

+
./try.sh
+

to show the code with followed by the result so you can truly see the +magic.

+

Alternate code:

+

This version is the original which might not work as you expect +nowadays.

+

Alternate build:

+
make alt
+

Alternate use:

+

To see if your compiler has the problem described in the Judges’ +remarks below, try:

+
./westley.alt
+

Does it show the same output as westley?

+

Judges’ remarks:

+

Your compiler must parse

+
#define _ -a
+-_
+

as --a and not -(-a) or some other +tokenized form. Some strictly conforming ANSI C Preprocessors may object +to this: for such compilers, you can elide the non-standard +token-pasting requirement by changing the #define line to:

+
#define _ F-->00||F-OO--;
+

This is what the modified code in westley.c +does whereas the alt code is the original.

+

You might enjoy looking at the output of:

+
cc -E westley.alt.c
+

Author’s remarks:

+

No remarks were provided by the author.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1988/westley

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1989/fubar/index.html b/1989/fubar/index.html index aa5166fa5..0052e6960 100644 --- a/1989/fubar/index.html +++ b/1989/fubar/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,221 @@ - - + + + + + + - - -1989 fubar - - + + + +1989/fubar + + + + + -

1989 fubar

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1989/fubar

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1989/fubar/index.html

- +
+ first entry + ↑ 1989 ↑ + jar.1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jay Vosburgh
+Location: US

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: known bug - please help us fix
+

For more detailed information see 1989 +fubar in bugs.md.

+

To use:

+
./fubar <number>
+

Try:

+
./try.sh # run on 1 - 7 
+
+./fubar.sh 2 # run via script
+./fubar 2 # run directly
+

Judges’ remarks:

+

Run this with a single digit argument (or wait a long time and risk +an infinite loop as described in the bugs.md file).

+

The blank line at the beginning of the source is mandatory. Do you +know why?

+

NOTE: the file ouroboros.c is created by the program +itself so this is why it is not in the repository.

+

Author’s remarks:

+

In a nutshell, this is probably the slowest and most obnoxious +factorial program ever written. Unfortunately, the name of the C source +must be ouroboros.c; the name is hard-coded into the +program.

+

The source is a legal shell script and a legal C program. The shell +script compiles itself, and then executes the resulting binary, giving +the source as input. The program works by successively modifying #define +lines each pass through.

+

Both indent and cb will damage the program, +indent much more so.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1989/fubar

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1989/jar.1/index.html b/1989/jar.1/index.html index 0fb5aea30..b12171d93 100644 --- a/1989/jar.1/index.html +++ b/1989/jar.1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,245 @@ - - + + + + + + - - -1989 jar.1 - - + + + +1989/jar.1 + + + + + -

1989 jar.1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1989/jar.1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1989/jar.1/index.html

- +
+ ← fubar + ↑ 1989 ↑ + jar.2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jari Arkko
+Location: SE

+ + +

To build:

+

NOTE: this will run the program itself.

+
make clobber all
+

There is an alternate version with a slight difference that you may +wish to try. See the Alternate code +section below for more details.

+

To use:

+
./jar.1
+

Alternate code:

+

This alternate code, which prints something slightly different, is +provided as well.

+

Alternate build:

+

NOTE: this will run the program itself.

+
make clobber alt
+

Alternate use:

+
./jar.1.alt
+

Judges’ remarks:

+

On many systems the compiler will not allow you to send the object +file to /dev/tty. The author suggested:

+
cc -c -o /dev/tty jar.1.c
+

As a last resort the jar.1.sh script provided simulates +writing the raw binary of the .o file to the terminal.

+

Abuse of the rules winners usually result in a change of the rules. +Starting in 1990, compiling entries must result an regular file which +can be executed.

+

Under certain conditions that are dependent on such diverse things +such as:

+ +

the output of raw binary to a terminal can produce various effects +from the mildly annoying beeps to missing seeing the important output, +to various “ill effects” such as the crashing of the terminal +application. Instead we have opted to pipe raw binary thru the strings +utility before writing to standard output instead of +/dev/tty.

+

As a historical note, the Makefile does echo the original command to +standard output, the original shell command that once wrote raw binary +to the /dev/tty special file.

+

The use of piping raw binary thru stings makes the original 1989 +output more apparent, as was the case when using dumb CRT terminals +(some do dumb that they couldn’t even process simple ANSI escape +sequences) were more common.

+

Author’s remarks:

+

This program is (supposedly) the smallest C program able to print +“Hello world.”. The compilation itself produces the desired printout and +the program need not be actually run.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1989/jar.1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1989/jar.2/index.html b/1989/jar.2/index.html index 092c3e697..599b8c090 100644 --- a/1989/jar.2/index.html +++ b/1989/jar.2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,276 @@ - - + + + + + + - - -1989 jar.2 - - + + + +1989/jar.2 + + + + + -

1989 jar.2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1989/jar.2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1989/jar.2/index.html

- +
+ ← jar.1 + ↑ 1989 ↑ + ovdluhe → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Authors:

Name: Esko Nuutila
+Location: FI +

Name: Jari +Arkko
Location: SE

Name: Ora Lassila
+Location: US

+ + +

To build:

+
make all
+

To use:

+
./jar.2
+[enter some lisp]
+
+./jar.2 < some_lisp_file
+

NOTE: this entry will likely segfault on invalid input.

+

Try:

+
./try.sh
+
+./try.sh chocolate_cake.lisp
+
+./try.sh try.txt
+

Judges’ remarks:

+

This is the most useful program submitted this year. It is a rather +large subset of lisp. It has no error recovery, and performs rather +poorly in a number of cases. Even so, placing all this functionality in +such a small, densely packed program, is impressive enough to win the +Best of show award.

+

Author’s remarks:

+

This program implements a Lisp interpreter in 1465 bytes of source. +Some sophisticated features supported, e.g. functionals and recursion. +The special-forms/functions/variables implemented are:

+ +

Below are sample lisp expressions you might choose to try as input. +The program implements a conventional lisp listener, i.e. you type in +lisp expressions (followed by CR), the program evaluates them and prints +out the return values. End execution by typing an end-of-file +character.

+
(+ 2.5 3.1)
+(defun fib (n)
+   (if (< n 2)
+       1
+       (+ (fib (- n 2)) (fib (- n 1)))))
+(fib 10)
+(defun ! (x) (if (equal x 0) 1 (* x (! (- x 1)))))
+(! 7)
+(defun fn1 (fn) (+ (fn 1 2) (fn 3 4)))
+(defun fn2 (a b) (+ a b))
+(fn1 (function +))
+(fn1 (function fn2))
+(fn1 (function (lambda (z1 z2) (+ z1 z2))))
+(quote a)
+(cons (quote (a b)) (quote (c d e)))
+(cons (quote (f)) ())
+(car (quote (a b c)))
+(cdr (cdr (quote (g h i))))
+

Please do not leave any whitespace before the first parenthesis when +you type your input, or any other unnecessary whitespace. Please try to +avoid any undefined variables or functions, wrong number of arguments +etc. All these errors are likely to dump core (i.e. there are no error +checks in the program).

+

Traditional Lisp implementations use cons cells as the main data +structure. Lists are organized of pointer chains of these cells. In this +program, an alternate representation was chosen: char*'s. +All list operations, including the ones in the interpreter, are made +using string representations of the lists. These operations must count +parentheses and skip whitespace. This leads to extremely poor +performance!

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1989/jar.2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1989/ovdluhe/index.html b/1989/ovdluhe/index.html index cb642ee65..f41a64488 100644 --- a/1989/ovdluhe/index.html +++ b/1989/ovdluhe/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,242 @@ - - + + + + + + - - -1989 ovdluhe - - + + + +1989/ovdluhe + + + + + -

1989 ovdluhe

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1989/ovdluhe

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1989/ovdluhe/index.html

- +
+ ← jar.2 + ↑ 1989 ↑ + paul → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Oskar von der +Luehe
Location: unknown

+ + +

To build:

+
make all
+

To get this to compile with a modern CPP, we had to replace +#D with #define.

+

To use:

+

Run the program this way:

+
./ovdluhe < textfile
+

The program stops when it reaches the end of the template buffer by +chance or is killed.

+

Try:

+
./try.sh ; sleep 2 ; ./try.sh
+

Alternate code:

+

The author suggested that one varies the definition of P +from 2 through 10. As it’s a #define it’s easy to set +up.

+

Alternate build:

+
make P=9 clobber alt
+

You do not have to define P but if you do you can +replace the value with whatever you wish, as long as it’s a positive +int (or evaluates to a positive int like the +default (A<<AP) does). Too high a value will likely +cause the program to fail and a negative value will cause a compilation +error.

+

Alternate use:

+
./ovdluhe.alt
+

Alternate try:

+
./try.alt.sh
+
+P=5 ./try.alt.sh
+

NOTE: if you specify too high a value for P the program +might fail. If you specify a value < 0 it will fail to compile.

+

Judges’ remarks:

+

Run this program using your favorite text file as input. Files such +as mailboxes, man pages and usenet articles are especially recommended. +You will get different output each time you run it.

+

Author’s remarks:

+

This program implements an “Eddington ape” - it generates random text +from a supplied template. The template text file is read through stdin. +The larger the template, the better the result. A maximum of +2**12 chars are used. From the template, the program +calculates the statistics of chars that immediately follow a given +string (correlator string) of a certain length (currently 4 - can be +varied by changing the definition for P accordingly). A character is +randomly chosen, weighted by its probability to occur after the +correlator string. That character is printed to stdout and placed at the +end of the correlator string, whose first character is discarded. +Meaningful words are therefore usually preserved, the effect on +sentences can be dramatically random.

+

You might want to vary the definition of P between 2 and 10 and +observe the result.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1989/ovdluhe

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1989/paul/index.html b/1989/paul/index.html index f0dc01430..e1725a38e 100644 --- a/1989/paul/index.html +++ b/1989/paul/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,287 @@ - - + + + + + + - - -1989 paul - - + + + +1989/paul + + + + + -

1989 paul

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1989/paul

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1989/paul/index.html

- +
+ ← ovdluhe + ↑ 1989 ↑ + robison → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Paul E. Black
+Location: US

+ + +

To build:

+
make all
+

There is an alternate version with a trace routine that the author +had commented out. See alternate code +below for more details.

+

Try:

+
./paul
+

Alternate code:

+

This version was described by the author like:

+
+

I could have squeezed the program under 1024 bytes without the trace +subroutine, but I felt it was important for understanding the program. +Besides it is fun to watch the tape zooming back and forth as the +program runs. A much better debugger or trace could easily be added.

+
+

Alternate build:

+
make alt
+

Alternate use:

+
./paul.alt
+

Judges’ remarks:

+

The author’s comments is a detailed program explanation and spoiler. +If you want a real challenge, don’t read any further and try to +understand the program via the source.

+

Historical note:

+

The original source contained a long line which caused many mailers +to barf. The original file may be re-constructed by removing the +trailing \ on line 12 and joining lines 12 and 13 together +without a space.

+

However as this is no longer a problem the trailing \ +has been restored in all versions, both the original and the fixed for +modern systems version.

+

Author’s remarks:

+

This programs computes and prints Fibonacci numbers by simulating a +Turing machine with the proper program. Understanding the C program, +i.e., a Turing machine simulator, is only the first and simplest step. +The Turing machine program must be understood, too! (it is trivial, +perhaps even natural to write incredibly obscure Turing programs.)

+

If the program is invoked with an operand, the operand is used as the +Turing program. It includes a “trace” facility, subroutine +r (commented out for obscurity), to help write and debug +Turing programs. Just the thing for some fun in a Theory of Computation +class.

+

The Turing machine tape is represented as a doubly linked list of +pointers. The forward and backward links are XORed together +and stored in one pointer. If we always keep one of the links on hand, +we can recover the other link at any time. The variable q +is the scan head (and a pointer at some tape cell), and p +is a “previous” link. The state of the tape is stored in the low order +bit of the pointer. Since we always allocate an even number of bytes, +the low order bit carries no information (see portability below.) Memory representing a tape +cell is allocated when the cell is first scanned. Thus the simulation +begins with a tape effectively the size of virtual memory set to all +zeros. Since a header can be added to any Turing program to write +initial data and position the scan head, this is little loss of +generality.

+

The simulated Turing machine has a single tape with either a +1 or a 0 in each cell. The Turing machine +language format is a string of three bytes. The first byte is the +current state. The second byte is the next state. (The last bit of +states is ignored, i.e., B and C are the same +state, in an attempt to be able to have interesting words in the +program.) The third byte is composed of bits. Bit 1 +(2&byte) is the symbol scanned, i.e. an instruction is +selected for state and for a match with the symbol under the scan head. +Bit 2 (4&byte) is the new symbol to be +written to the cell. Bit 3 (8&byte) is the +direction to move the scan head: 0 for left and +1 for right. If bit 4 +(16&byte) is true, the next character is sent to +stdout. (I added this feature so programs could print +results.)

+

The Turing machine has next state j when it begins. The +cycle is (1) exit if the state is x, (2) find the next +instruction (given the state and the character under the scan head). +(The program string is searched forward for the next matching +instruction. If the end of the string is reached, the search begins +again at the first of the string. Thus states can be used as local +labels in different places.) (3) change to the next state, (4) print a +character if indicated, (5) write the tape symbol, and (6) move the scan +head. The cycle then repeats with step 1. A call to the trace routine is +just before step 2, but is commented out.

+

Quick outline of the Turing +program:

+

The previous and current Fibonacci numbers are kept in base 1 form +with the current on the right. The first three steps set up the first +two numbers, 1 and 1. Then [beginning with +@ (] a marker of III is created and the +current number is copied to the right of the marker. Then (beginning +with OV) the number is converted to binary by repeatedly +dividing by 2 leaving I for remainder 1, and II for +remainder 0. Next (beginning with WV) the +binary representation is printed and its symbols and the marker are +erased. Finally (beginning with EEn) the two numbers are +added and the current number copied to the left to become the previous. +Then the cycle repeats.

+

Portability

+

The program requires that the lowest bit of a pointer to be 0.

+

I could have squeezed the program under 1024 bytes without the trace +subroutine, but I felt it was important for understanding the program. +Besides it is fun to watch the tape zooming back and forth as the +program runs. A much better debugger or trace could easily be added.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1989/paul

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1989/robison/index.html b/1989/robison/index.html index cdb26f9a5..755bb8717 100644 --- a/1989/robison/index.html +++ b/1989/robison/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,242 @@ - - + + + + + + - - -1989 robison - - + + + +1989/robison + + + + + -

1989 robison

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1989/robison

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1989/robison/index.html

- +
+ ← paul + ↑ 1989 ↑ + roemer → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Arch D. +Robison
Location: US

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1989 robison in bugs.md.

+

To use:

+
./robison
+# enter valid expressions
+

Try:

+
./robison
+11x10
+# enter other expressions
+
+./try.sh
+
+echo 100 / 100 | ./robison # <-- what happens here ?
+

NOTE: This program will very likely crash or break into tiny bits :-) +if you feed it numbers with non-binary digits. This, as you might notice +if you try one of the above commands, can happen with other input as +well. If you wish to understand why this happens check the source +code.

+

Judges’ remarks:

+

Sites with punch card facilities will be happy to note that the +source deck can be re-collated with an ASCII sort.

+

Note that this program uses only a small subset of the constructs +that the C language supports.

+

For an interesting document on APL, see https://computerhistory.org/blog/the-apl-programming-language-source-code/.

+

Author’s remarks:

+

This program is a handy picoAPL interpreter written in +C--. It outputs the evaluation of an APL +expression from standard input. Functions are limited to dyadic ++,-,x, and unary -; +numerals must be binary. Parentheses may be used for grouping. For +example:

+
101x111-100
+

prints:

+
1111
+

That is 5x(7-4) is 15. (APL groups from +right to left.) Extending it to the full APL language should be +trivial.

+

The C-- language improves the C language by removing +superfluous and confusing features: arithmetic, logical operations, +shifts, relational operators, address-of, and flow control. In fact, the +only expressions retained are function calls, indirection, array +assignments, the ‘,’ operator, and sizeof. Despite these +restrictions, the C-- program does arithmetic on +arbitrarily large binary numbers.

+

To obtain a C-- reference, simply rip out the irrelevant +pages from your K&R C manual. To obtain a C-- compiler, +simply rip out the irrelevant bytes from your cc +compiler.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1989/robison

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1989/roemer/index.html b/1989/roemer/index.html index b3693d1bb..445e9cb51 100644 --- a/1989/roemer/index.html +++ b/1989/roemer/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,198 @@ - - + + + + + + - - -1989 roemer - - + + + +1989/roemer + + + + + -

1989 roemer

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1989/roemer

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1989/roemer/index.html

- +
+ ← robison + ↑ 1989 ↑ + tromp → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Roemer B. +Lievaart
Location: NL

+ + +

To build:

+
make all
+

Try:

+
./roemer
+

Judges’ remarks:

+

Do you know what this program does? If you do, look again, there is +more here than meets the PI.

+

Author’s remarks:

+

Passes lint, but not with the strictest options, for it contains some +“null-statements”, as well two identifiers which are, if compilers only +take 6 characters, the same. It also uses write(2), so not +totally system independent.

+

You are very much invited to pass this program through a C-beautifier +(first strip newlines and tabs, if your cb can’t do +that).

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1989/roemer

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1989/tromp/index.html b/1989/tromp/index.html index 2ef9b3ee2..2ec5f6645 100644 --- a/1989/tromp/index.html +++ b/1989/tromp/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,304 @@ - - + + + + + + - - -1989 tromp - - + + + +1989/tromp + + + + + -

1989 tromp

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1989/tromp

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1989/tromp/index.html

- +
+ ← roemer + ↑ 1989 ↑ + vanb → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: John Tromp
+Location: US

+ + +

To build:

+
make all
+

To use:

+
./tromp [drops_per_sec  [cmd_string]]
+

Try:

+
./tromp 5
+
+./tromp 10 "hkl jq"
+

The second command, ./tromp 10 "hkl jq", will set up the +keys kind of like vim:

+ +

NOTE: after the game ends a file called HI will be in +the directory with the high scores (up to 20 runs saved) so one can see +who has the highest score. The file might look like:

+
330 by luser
+136 by loser
+100 by winner
+

… or so, where in this case the luser +is the winner, the loser is in second place and the winner is the +loser :-)

+

Alternate code:

+

The author provided an alternate version of the code with some +improvements. See the judges’ additional remarks in the author’s +remarks, for more details.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use tromp.alt as you would tromp above.

+

NOTE: testing more than one user updating the high score file, one of +the benefits of the alt version, has not been done.

+

The original unmodified alternate code, which will no longer work +right if it even compiles, is provided later in the author’s +remarks.

+

Judges’ remarks:

+

This is a character terminal version of the TETRIS game. +It runs on a VT100 compatible terminal or emulator. It is best used at +4800 baud or more.

+

By default, drops_per_sec, the number of times a +tetrimino will drop in a second, is 2. The default +cmd_string is jkl pq. The first 6 characters +of cmd_string relate to the following 6 game commands:

+ +

Specifying cmd_string allows one to redefine the +commands. The pause command pauses the game, clears the screen and +prints the current score. To resume, type the pause character again, +which by default is p.

+

As was stated last year, we are likely to be more strict about +portability in the future. [ We mean it this time :-) ]

+

Author’s remarks:

+

This program plays the familiar game of TETRIS with the +following features:

+ +

Giving a full path name for the table will result in a system-wide +high-score allowing a competition between users.

+

Additional remarks from the +judges:

+

The author provided us with the following notes and new version of +the program:

+

Here is a somewhat improved version of my tetris entry. All the +changes are in the popen() at the end. Formerly a move was +done to the HI score file which is not permitted for other users. Now +other users can change the HI score file. The extra option +-m is passed to sort, so that it knows that its input files +are already sorted. The -o output option of sort is used +instead of a temporary file.

+

You may also want to consider giving just the raw option to +stty at the start and -raw at the end. This +further reduces the size of the program, but has the possible +disadvantage that the program can only by stopped by ‘q’ or by the `kill +-9’ command.

+
    long h[4];t(){h[3]-=h[3]/3000;setitimer(0,h,0);}c,d,l,v[]={(int)t,0,2},w,s,I,K
+    =0,i=276,j,k,q[276],Q[276],*n=q,*m,x=17,f[]={7,-13,-12,1,8,-11,-12,-1,9,-1,1,
+    12,3,-13,-12,-1,12,-1,11,1,15,-1,13,1,18,-1,1,2,0,-12,-1,11,1,-12,1,13,10,-12,
+    1,12,11,-12,-1,1,2,-12,-1,12,13,-12,12,13,14,-11,-1,1,4,-13,-12,12,16,-11,-12,
+    12,17,-13,1,-1,5,-12,12,11,6,-12,12,24};u(){for(i=11;++i<264;)if((k=q[i])-Q[i]
+    ){Q[i]=k;if(i-++I||i%12<1)printf("\033[%d;%dH",(I=i)/12,i%12*2+28);printf(
+    "\033[%dm  "+(K-k?0:5),k);K=k;}Q[263]=c=getchar();}G(b){for(i=4;i--;)if(q[i?b+
+    n[i]:b])return 0;return 1;}g(b){for(i=4;i--;q[i?x+n[i]:x]=b);}main(C,V,a)char*
+    *V,*a;{h[3]=1000000/(l=C>1?atoi(V[1]):2);for(a=C>2?V[2]:"jkl pq";i;i--)*n++=i<
+    25||i%12<2?7:0;srand(getpid());system("stty cbreak -echo stop u");sigvec(14,v,
+    0);t();puts("\033[H\033[J");for(n=f+rand()%7*4;;g(7),u(),g(0)){if(c<0){if(G(x+
+    12))x+=12;else{g(7);++w;for(j=0;j<252;j=12*(j/12+1))for(;q[++j];)if(j%12==10){
+    for(;j%12;q[j--]=0);u();for(;--j;q[j+12]=q[j]);u();}n=f+rand()%7*4;G(x=17)||(c
+    =a[5]);}}if(c==*a)G(--x)||++x;if(c==a[1])n=f+4**(m=n),G(x)||(n=m);if(c==a[2])G
+    (++x)||--x;if(c==a[3])for(;G(x+12);++w)x+=12;if(c==a[4]||c==a[5]){s=sigblock(
+    8192);printf("\033[H\033[J\033[0m%d\n",w);if(c==a[5])break;for(j=264;j--;Q[j]=
+    0);while(getchar()-a[4]);puts("\033[H\033[J\033[7m");sigsetmask(s);}}d=popen(
+    "stty -cbreak echo stop \023;sort -mnr -o HI - HI;cat HI","w");fprintf(d,
+    "%4d from level %1d by %s\n",w,l,getlogin());pclose(d);}
+

NOTE: the alternate version was fixed for modern systems in 2023.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1989/tromp

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1989/vanb/index.html b/1989/vanb/index.html index 2a7d9a822..34c505439 100644 --- a/1989/vanb/index.html +++ b/1989/vanb/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,205 @@ - - + + + + + + - - -1989 vanb - - + + + +1989/vanb + + + + + -

1989 vanb

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1989/vanb

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1989/vanb/index.html

- +
+ ← tromp + ↑ 1989 ↑ + westley → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: David Van +Brackle
Location: unknown

+ + +

To build:

+
make all
+

Try:

+
./try.sh
+

Judges’ remarks:

+

This program computes all proper subsets of the set of arguments +passed to it. Each subset is printed with one element on each line, +followed by a line of ten dashes.

+

Author’s remarks:

+

The program has the following charming and possibly non-portable +features:

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1989/vanb

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1989/westley/index.html b/1989/westley/index.html index 8f17f5075..fae5c9b11 100644 --- a/1989/westley/index.html +++ b/1989/westley/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,300 @@ - - + + + + + + - - -1989 westley - - + + + +1989/westley + + + + + -

1989 westley

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1989/westley

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1989/westley/index.html

- +
+ ← vanb + ↑ 1989 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Brian Westley
+Location: US

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: known bug - please help us fix
+

For more detailed information see 1989 westley in bugs.md.

+

Try:

+

Try compiling and running the 4 resulting programs like:

+
./compile.sh
+

If you need to specify an alternate compiler path, say because your +default compiler is clang (or in the case of macOS gcc is clang) you can +do so like:

+
CC=/opt/local/bin/gcc-mp-12 ./compile.sh
+

If you wish to delay the script or remove the delay you can do so +like:

+
DELAY=2 ./compile.sh
+

Finally try:

+
./westley
+# input some lines of text, sending EOF (usually ctrl-d) to end
+
+./try.sh # demo of some input
+

Judges’ remarks:

+

There is a secret way to get ONE of the versions to print out +“Hello, world!\n”. Can you find how to do it?

+

Author’s remarks:

+

This is a filter. If it is run with no arguments, it copies +stdin to stdout. With one argument, it ROT13’s +stdin to stdout. With two arguments, it +reverses stdin to stdout. With three +arguments, it does both. It requires the ASCII character set, with all +characters being in 0..255, and EOF must be +-1. Also requires two’s complement (I think).

+

The source code will run if ROT13’ed and/or reversed, using a +different algorithm for each version (hereafter referred to as +ver0 (original), ver1 (ROT13), +ver2 (reversed), and ver3 (ROT13 and +reversed)).

+

When compiling these versions, one needs to define +trgpune in the compile line (which the Makefile now has). +Example:

+
cc -Dtrgpune=putchar ver3.c -o ver3
+

trgpune is the ROT13 of getchar(), so +getchar() and putchar() are exchanged in the +ROT13 counterpart. It is easy to see that this is unavoidable. I must +have a #define for a library function; otherwise I would +have an unidentified extern for the ROT13 version. If I then define this +function, it won’t link in the library version for the ORIGINAL code, +since my definition will supersede the library function. Hence, the +compiler option gives me putchar(), and allows me to use +getchar(). I pass a dummy argument to +getchar() to eliminate “variable number of args” from lint +(unless it checks against the library). Otherwise, all versions of lint +complain that main() returns random value & constant in +conditional context (when I check for ROT13 version).

+

ver0 and ver1 use a range check and a +calculation to do ROT13, while ver2 and ver3 +use table lookup. All versions contain main() and its ROT13 +function, znva(). ver0/ver1 +(ver2/ver3) are (of course) syntactically +identical, since the syntax is in the non-alphabetic characters. +However, since one program starts at main() while it’s +ROT13 counterpart starts at znva(), znva() +calls main (znva() is also used for output).

+

All versions use recursion to work. If the program is NOT reversing +it’s output, it prints out the (possibly ROT13’d) character before +recursing, otherwise it prints it out afterward (or doesn’t recurse at +all when EOF is reached). Since most of this code is +identical, it is put into znva() and called with a first +parameter of 0 as a flag (as main(), it’s first argument +(argc) must be at least one).

+

I can’t use any flow control. If I used if(), I would +have a function vs() to define in the ROT13 version. But a +function called vs() turns into a function called +if() in the original, so it can’t be done. Therefore, I +do:

+
expr1 && expr2 && (expr3=etc);
+

which is the same as:

+
if (expr1 && expr2) expr3=etc;
+

A/UX on the Macintosh doesn’t get this right; it evaluates ALL +expressions if they aren’t in an assignment or conditional statement. +This might warrant a warning, since other compilers may do this. I found +MANY compilers botched:

+
expr1 && (expr2,expr3);
+

expr2 was OFTEN evaluated even if expr1 was +false. I removed such statements to make it more portable.

+

Variable names worth noting

+

irk and vex are ROT13 pairs and are +synonyms.

+

Near and Arne are ROT13 pairs and are +anagrams.

+

NOON and ABBA are ROT13 pairs and are +palindromes.

+

tang and gnat are both ROT13 and palindrome +pairs!

+

–

+

Normally (!), a reversible C program is done thus:

+
/**/ forward code /*/ edoc drawkcab /**/
+

If your compiler nests comments, it will get this wrong. However, I +have made some bits of the code palindromic, (or different, but +reversible) so it is more like:

+
/**/forward/*//**/ palindromic /**//*/drawkcab/**/
+

The code can therefore be interlaced. There are eight such +palindromic bits. You can find them within the +/*//**/ /**//*/ pairs.

+

The body of the code of ver0 and ver1 is a +large lumpy K (for Kernighan); the code of +ver2 and ver3 is a flat-topped and lumpier +R (for Ritchie). Judicious use of spaces and tabs helped +here. It barely fits on an 80x24 screen. Squint. Note that the code must +start with a blank line, or the reversed version will lack a terminating +newline.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1989/westley

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1990/baruch/index.html b/1990/baruch/index.html index 7a4d19e15..0db248022 100644 --- a/1990/baruch/index.html +++ b/1990/baruch/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,259 @@ - - + + + + + + - - -1990 baruch - - + + + +1990/baruch + + + + + -

1990 baruch

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1990/baruch

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1990/baruch/index.html

- +
+ first entry + ↑ 1990 ↑ + cmills → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Authors:

Name: Baruch +Nissenbaum
Location: IL

Name: Doron +Osovlanski
Location: IL

+ + +

To build:

+
make all
+

There is an alternate version for those using Turbo-C or MSC. See alternate code below for details.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1990 +baruch in bugs.md.

+

To use:

+
echo 4 | ./baruch
+echo 7 | ./baruch
+

Try:

+
echo 2 | ./baruch
+echo 3 | ./baruch
+

Why is there no output?

+

Alternate code:

+

This alternate code is for the very few users here who will need it. Nonetheless if +you’re using Turbo-C or MSC, the code is available, based on the +authors’ remarks except that the " #Q" string was not +changed as that showed worse looking output instead of improved output +though admittedly we have no way to test the compilers in question. +YMMV.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use baruch.alt as you would baruch.

+

Judges’ remarks:

+

This program reads an integer between 4 and 99 from the +stdin.

+

NOTE: The original program did not have a newline at the end of the +file. We added a final newline to the file to make unpacking easy.

+

Authors’ remarks:

+

The goal of this work was to write a program that solves the classic +n-queens +problem, with a board size of up to 99x99, while keeping the program +as short as possible.

+

The program finds all possibilities to place N chess queens on an NxN +chessboard so +that no queen is in range of any other queen (not in the same column row +or diagonal). For each solution the chess board and the place of the +queens is printed to stdout.

+

This program is about as simple and as readable as possible. To make +things even more simple we used a very limited subset of C:

+ +

In short, it contains no C language that might confuse the innocent +reader. :-)

+

This program demonstrates the claim that in C, any program can be +written using a single ‘for’ statement, as long as it is long +enough.

+

For PC users:

+

In order to compile the program under Turbo-C or MSC, +int should be inserted at the beginning of the program. For +better looking results it is recommended to replace the +" #Q" string with " \261\2".

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1990/baruch

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1990/cmills/index.html b/1990/cmills/index.html index 11ff73756..29339ee06 100644 --- a/1990/cmills/index.html +++ b/1990/cmills/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,216 @@ - - + + + + + + - - -1990 cmills - - + + + +1990/cmills + + + + + -

1990 cmills

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1990/cmills

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1990/cmills/index.html

- +
+ ← baruch + ↑ 1990 ↑ + dds → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Christopher +Mills
Location: US

+ + +

To build:

+
make all
+

To use:

+
./cmills [starting_cash]
+

Try:

+
./cmills 5000
+

Judges’ remarks:

+

The Makefile uses several -D defines. The following is +is a list of the macros that may be changed:

+ +

The macro V should remain void.

+

The author noted that a compiler being used assumed that +x=*p++ means x*=p++ but do you know why? This +is not so strange as it might seem if you look at C’s history. +Example code where this occurs is in John Lions’ Commentary on the Sixth +Edition UNIX Operating System.

+

Author’s remarks:

+

This is a blackjack program. It does splits, doubling down, +insurance, etc.

+

As best I can figure, it should be ANSI-compliant, as well as +portable to BSD & SysV (as well as the irritating compiler I was +using which assumes x=*p++ means x*=p++!). It +is reasonably robust in its error handling—it won’t let you split, +double, etc. unless you actually have the cash, etc. To terminate the +program, hit EOF or type 0 or a negative +number for you wager.

+

The way it deals with splits is particularly cool (IMHO). You can +split many times, and it will show all hands as they are played.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1990/cmills

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1990/dds/index.html b/1990/dds/index.html index 59e36564a..d756afa80 100644 --- a/1990/dds/index.html +++ b/1990/dds/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,282 @@ - - + + + + + + - - -1990 dds - - + + + +1990/dds + + + + + -

1990 dds

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1990/dds

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1990/dds/index.html

- +
+ ← cmills + ↑ 1990 ↑ + dg → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Diomidis +Spinellis
Location: GR

+ + +

To build:

+
make all
+

To use:

+
./dds
+

Try:

+

Give the following lines as input:

+
OLD LANDER.BAS
+RUN
+

NOTE: this entry is probably one of the only times CAPS LOCK might be +worth having (though still not useful enough to enable :-) ) as all +input has to be UPPER CASE.

+

Judges’ remarks:

+

Be sure not to run out of fuel!

+

Author’s remarks:

+

This is the DDS-BASIC Interpreter (Version 1.00).

+

Immediate commands:

+ +

Program commands:

+ +

Expressions (ranked by +precedence):

+ +

(* and + are also used for boolean AND and +boolean OR)

+

Boolean expressions evaluate to 0 for false and 1 for true.

+

Editing:

+ +

Input format:

+ +

Limits:

+ +

Error checking / error +reports:

+

No error checking is performed. It might dump core if a syntax or +semantic error is encountered.

+

Hosting Environment:

+

ANSI C, traditional K&R C or OSF ANDF ASCII or EBCIDIC character +set 48K bytes memory.

+

The Speed of DDS-BASIC Interpreter (Version 1.00) relative to +Microsoft Advanced BASIC 3.31 is approximately 60%.

+

The code size could be further reduced by doing ugly things like not +declaring the return type of functions, not freeing memory, defining +define, and joining lines. In its present 1536 character form the +program is reasonably portable (it may fail to run in a tagged object +architecture) and nicely formatted (it fits in an 80*25 +screen).

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1990/dds

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1990/dg/index.html b/1990/dg/index.html index 65e2db58f..77fdbcce5 100644 --- a/1990/dg/index.html +++ b/1990/dg/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,221 @@ - - + + + + + + - - -1990 dg - - + + + +1990/dg + + + + + -

1990 dg

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1990/dg

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1990/dg/index.html

- +
+ ← dds + ↑ 1990 ↑ + jaw → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: David +Goodenough
Location: unknown

+ + +

To build:

+
make all
+

To use:

+
echo foo bar | ./dg
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Some C preprocessors got confused about single quotes in certain +cases. In particular, the following source line:

+
b12(ase(bco(acp(bi(acp(bcp(acp(bpl(aqu(bqu(A))))))))))))))))))))))))))))))
+

sometimes has to be changed to:

+
b12(ase(bco(acp(bi(acp(bcp(acp(bpl('A'))))))))))))))))))))))))))))
+

particularly if the C preprocessor botches single quotes in cpp +expansions, which we have done for the wider audience.

+

Author’s remarks:

+

If my preprocessor could hack it, I could write this as one single +line rather than 4, but when I do that I get a complaint “defines nested +too deeply”.

+

Obfuscation spoiler:

+

This is another rot13 job (believe it or not) - the +#defines are a novel way of adding tokens: +#define b12(x) 12 x means that at some point in the source +a 12 is followed by the compressed nested +#defines. The b12 gets the previous +compression as an argument, and prepends the 12, thus +making another step in the recreation of the source. The +axx() #defines do the same, but add tokens +after.

+

As for the rot13 algorithm, it relies on index(3) to +find if the character is in the set A-Za-z. +l[] is an array that gets filled with:

+
"nopqrstuvwxyzzzzabcdefghijklmmmmNOPQRSTUVWXYZZZZABCDEFGHIJKLMMMM"
+

If index(3) says the char is in the alphabet, then XOR +the offset with 16 to translate, and output, otherwise pass +it unchanged.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1990/dg

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1990/jaw/index.html b/1990/jaw/index.html index f8d7e4645..e7561534b 100644 --- a/1990/jaw/index.html +++ b/1990/jaw/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,373 @@ - - + + + + + + - - -1990 jaw - - + + + +1990/jaw + + + + + -

1990 jaw

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1990/jaw

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1990/jaw/index.html

- +
+ ← dg + ↑ 1990 ↑ + pjr → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Authors:

Name: James A. +Woods
Location: unknown

Name: Karl F. Fox
+Location: unknown +

Name: Paul +Eggert
Location: unknown

+ + +

To build:

+
make all
+

Try:

+

To test the official C entry, one might try:

+
echo "Quartz glyph jocks vend, fix, BMW." | compress | ./btoa | ./jaw
+

which should apply the identity transformation to a minimal +holoalphabetic sentence.

+

Also try:

+
./try.sh
+

Judges’ remarks:

+

The program, in its base form, implements two useful utilities:

+ +

Included with this entry is a shell script (with comments edited down +to reduce it to 1530 bytes) which implements the complete shark utility. +The script, shark.sh, contains a +jaw.c embedded within it!

+

The sender must have compress and btoa. To +send, try:

+
./shark.sh jaw.* README.md > receive
+

The resulting file, receive, unpacks the input files +even if the receiver lacks uncompress and +btoa:

+
mkdir -p test
+cd test
+sh ../receive
+cmp ../jaw.c jaw.c
+cmp ../README.md README.md
+

NOTE: a limitation is that the script should be in the parent +directory of the directory it is run from.

+

Authors’ remarks:

+

ABSTRACT

+

Minimal, +Universal File Bundling (or, Functional Obfuscation in a Self-Decoding +Unix Shell Archive)

+

James A. Woods
+Universities Space Research Association
+NASA Ames Research Center

+
+
+

“Use an algorithm, go to jail.”

+

– anon., circa 1988, pre-Morris worm era

+
+
+

Myriad formats have been proposed for network-mailable data. A major +difficulty undermining the popularity of most file/message bundlers is +that the sender assumes prior installation of the computational dual of +such bundling software by the receiver. Command shell archives alleviate +this problem somewhat, but still require standardization for the +function of data compression and mail-transparency encoding. On Unix, +these coding format quandaries are overcome by planting a novel Trojan +Horse in the archive header to perform negotiation-less +decoding.

+

Specifically, we outline the development of an extraordinarily +compact portable bundler/extractor to (dis)assemble data-compressed, +binary-to-ASCII-converted, length-split, and checksummed directory +structures using standard Unix tools. Miniature versions of counterparts +to a Lempel-Ziv coder (compress or squeeze) +and an efficient bit packetizer (btoa) are compiled +on-the-fly at mail destination sites where they may not already exist. +These are written in purposefully obfuscated-C to accompany +similarly-shrunk shell command glue. This resulting shell archiver is +dubbed shark.

+

shark procedure overhead consumes as few as three dozen +shell commands (or ~1100 bytes), commensurate with the size +of many Internet mail headers; it amortizes favorably with message size. +shark is portable across Unix variants, while the +underlying technique is inherently generalizable to other encoding +schemes.

+

In the function-theoretic sense of minimal Chaitin/Kolmogorov +complexity, and within a modified Shannon model of communication, the +‘shark’ effort aims to construct a “shortest program” for source +decoding in the Turing-universal Unix environment.

+
+
+

Oh, the shark has pretty teeth, dear–
+And he shows them pearly white
+Just a jackknife has Macheath, dear–
+And he keeps it out of sight.
+
+– Bertolt Brecht, Threepenny Opera

+
+
+

Portability

+

We have ported this program to a wide variety of systems. Among these +are:

+ +

Obfuscation

+

We (the authors) feel this program is obfuscated for the following +reasons:

+
    +
  1. This is one of the few programs you’ll see WHOSE VERY UTILITY +DEPENDS ON ITS OBFUSCATION!

  2. +
  3. The contest entry may be used to send its wonderful self to +anyone in the Unix world! Virus writers need not apply…

  4. +
  5. The basic idea is twisted enough to be patentable, but is, out of +the kindness of our hearts (as well as to maintain eligibility for the +large IOCCC prize fund), dedicated to the public domain. Claude Shannon, +meet Alan Turing.

  6. +
  7. Meta-obfuscation is via obfuscated description (see +ABSTRACT).

  8. +
  9. “Literary” allusion. Production code contains a reference to +self-reference, preserved at amazing cost for sheer perversity.

  10. +
  11. Many, many micro obfuscations below, honed over three years time, +in shell as well as C. Ask about the ‘tar’ pit escape, the +argv[0] flip, Paul’s &4294967295 +portability hack, the “void where prohibited by flaw” fix, the +scanf() space-saver, shift shenanigans, signal madness, +exit()ing stage left, and source-to-source transformations +galore.

  12. +
+

For extra credit:

+

Construct sharkmail, to auto-split +sharkives into mailable segments and mail them. Here’s a +simple one, which could be extended to enable auto-reassembly with one +shell cmd at the far end.

+
#!/bin/sh
+m=$1; shift
+shark $* | split -800 - /tmp/shark$$
+n=`ls /tmp/shark$$* | wc -l | sed 's/ *//'`
+p=0
+for f in `ls /tmp/shark$$*`
+do
+     p=`expr $p + 1`
+     mail -s "bundle ($p of $n) from '`whoami`'" $m < $f
+done
+rm /tmp/shark$$*
+

Shark history:

+ +

To which we add:

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1990/jaw

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1990/pjr/index.html b/1990/pjr/index.html index 8ac87f00d..118099170 100644 --- a/1990/pjr/index.html +++ b/1990/pjr/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,230 @@ - - + + + + + + - - -1990 pjr - - + + + +1990/pjr + + + + + -

1990 pjr

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1990/pjr

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1990/pjr/index.html

- +
+ ← jaw + ↑ 1990 ↑ + scjones → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Peter J +Ruczynski
Location: GB

+ + +

To build:

+
make all
+

There is an alternate version that does +something different that can be used if your compiler is incapable of +compiling X=g()... in main(). It can be used +for another purpose too.

+

To use:

+
./pjr
+

Alternate code:

+

Note that some compilers will be unable to compile the expression +X=g()... in main() due to lack of temporary +stack space. One might want to try replacing main() +with:

+
main(){X=s().v().o().o().l().S().d().l().i().o().w().N();}
+

if this is a problem, which is what this alternate code is.

+

NOTE: it prints something else and it is what the author suggested +one try as well.

+

Alternate build:

+
make alt
+

Alternate use:

+
./pjr.alt
+

Judges’ remarks:

+

This program prints out a string. Can you figure out how it is +done?

+

By use of pointers to functions returning a struct of pointers to +functions!

+

Spoiler:

+

This program prints out the string:

+
+

the quick brown fox jumped over the lazy dog

+
+

Author’s remarks:

+

It is simple to make the program print other strings. Each +alphabetical character from a to z is printed out as its opposite:

+
a->z b->y c->x etc
+

To encode a new string input the string as it is meant to come +out:

+
X=s().v().o().o().l().S().d().l().i().o().w().N();
+

Note: S() represents a space and N() a +newline. This will now produce…

+
hello world
+

By the way, there is actually a piece of code which is not used in +the original program! I leave it as an intellectual exercise to the +reader to find out what it is.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1990/pjr

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1990/scjones/index.html b/1990/scjones/index.html index a9b9ebf71..eb3606b11 100644 --- a/1990/scjones/index.html +++ b/1990/scjones/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,220 @@ - - + + + + + + - - -1990 scjones - - + + + +1990/scjones + + + + + -

1990 scjones

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1990/scjones

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1990/scjones/index.html

- +
+ ← pjr + ↑ 1990 ↑ + stig → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Larry Jones
+Location: unknown

+ + +

To build:

+
make all
+

To use:

+
./scjones
+

Try:

+
./try.sh
+

Judges’ remarks:

+

The addition of trigraphs has made it easier to make programs hard to +read. It was a dark and stormy night for C when the ANSI C committee +added trigraphs to the standard. Too bad that they didn’t just simply +require a more reasonable ISO character set.

+

The Author sent us this note after he was informed that he won:

+
+

Although I am quite grateful for the “ANSI Committee’s Worst Abuse of +C” title (were you aware that I am a member of the committee or is the +double meaning unintentional?), I was really hoping for something more +along the lines of “Closest Resemblance to Line Noise.” :-)

+
+

… it was unintentional.

+

Author’s remarks:

+

Since this year’s contest is dedicated to ANSI C, here is a strictly +conforming entry. In accordance with the ANSI definition of a strictly +conforming program it does not produce output dependent on any +unspecified, undefined, or implementation defined behavior, and it does +not exceed any of the minimum implementation limits. It adheres to all +of the syntactic and semantic constraints of the standard: it +#includes the relevant headers for the functions it uses, +and it uses the EXIT_SUCCESS and EXIT_FAILURE +macros to return a correct success/fail status to the invoking program. +It also uses trigraphs for characters which are not in the +Invariant Code Set of ISO 646:1983, so it will +be portable to machines with deficient (from C’s standpoint) character +sets. In short, it should be very widely portable. As an extra added +attraction, all of the lines are under 72 characters long, which would +allow for sequence numbers to be punched in columns 73-80 :-).

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1990/scjones

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1990/stig/index.html b/1990/stig/index.html index af399b371..83992559a 100644 --- a/1990/stig/index.html +++ b/1990/stig/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,216 @@ - - + + + + + + - - -1990 stig - - + + + +1990/stig + + + + + -

1990 stig

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1990/stig

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1990/stig/index.html

- +
+ ← scjones + ↑ 1990 ↑ + tbr → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Stig Hemmer
+Location: NO

+ + +

To build:

+
make all
+

To use:

+
make all
+

NOTE: that’s not a typo or mistake but one can also do:

+
./o
+

Judges’ remarks:

+

We changed the alias that the author’s suggested alias from a C-shell +alias to a Bourne-like shell alias.

+

Note that shst.c is renamed to stig.c in the distribution.

+

WARNING: This program’s how to compile is too specific +to a particular shell. The obfuscation of this program is more related +to shell obfuscation than C obfuscation. This type of entry will not be +permitted in future contests.

+

Author’s remarks:

+

If you like shell programming you may also admire my creative +quoting. (I use echo to create an alias which when run +calls cc with the -D option to create a C macro with double +quotes in it. ARRRRRGGGHHH!)

+

The program is totally portable, but the compile commands are very +shell specific so don’t be TOO mad at me if they don’t work for you.

+

If you want to put these commands in a Makefile you must add 4 - four +- backslashes at the end on first line. (At least that’s what works +here.)

+

If everything works correctly it create an executable named +o which checks whether your compiler supports nested +comments. I’ve stolen the "/*/*/0*/**/1" from somewhere so +don’t give me any points for it. Of course neither ANSI nor K&R +support nested comments when properly implemented, but what the +heck.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1990/stig

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1990/tbr/index.html b/1990/tbr/index.html index 0b5e3fe65..8d684039c 100644 --- a/1990/tbr/index.html +++ b/1990/tbr/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,313 @@ - - + + + + + + - - -1990 tbr - - + + + +1990/tbr + + + + + -

1990 tbr

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1990/tbr

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1990/tbr/index.html

- +
+ ← stig + ↑ 1990 ↑ + theorem → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Authors:

Name: Byron +Rakitzis
Location: US

Name: Sean Dorward
+Location: unknown

+ + +

To build:

+
make all
+

The authors provided another version of this program. See the alternate version section below.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1990 +tbr in bugs.md.

+

A note about the +fixes of this entry in 2023:

+

In 2023 it was noticed that in some systems like macOS there was +confusing output due to a warning at runtime that was interspersed with +the output of the program. For instance it would show:

+
./tbr
+$ warning: this program uses gets(), which is unsafe.
+

which kind of hid the prompt. Thus the entry was changed to use +fgets(3) which is referred to later in this file.

+

Also exit(3) returns void but the entry was +using it in a binary expression so this entry would not compile in +modern systems. This fix is also referred to below, in the alternate version section.

+

To use:

+
./tbr
+$ enter some shell commands
+

NOTE: globs do not work with this entry. Why?

+

NOTE: exit does not work and neither does +logout. To exit try sending ctrl-d or ctrl-c (or kill it +from another terminal :-) ). But why does it not work with just +exit or logout? Hint: see the authors’ +remarks.

+

Try:

+
./tbr
+$ ls -l tbr tbr.c
+
+# notice how the following does not work:
+ls tbr*
+
+# try figuring out how this entry works in an editor:
+vi tbr.c
+
+# then figure out how to exit vi :-)
+

What happens if you try using cd - to return to previous +directory? What about cd with no args?

+

The authors include a section called BUGS that, +because they were documented, are not considered bugs as such in the +context of the contest.

+

Alternate code:

+

The authors supplied us with a slightly smaller unformatted version +of the program which we include below:

+
#define D ,close(
+char*c,q[512],m[256],*v[99],**u,*i[3];int f[2],p;main(){for(m[m[60]=m[62]=
+32]=m[*m=124[m]=9]=6;e(-8),gets(1+(c=q))||(exit(0),0);r(0,0))for(;*++c;);}
+r(t,o){*i=i[2]=0;for(u=v+98;m[*--c]^9;m[*c]&32?i[*c&2]=
+*u,u-v^98&&++u:3)if(!m[*c]){for(*++c=0;!m[*--c];);*--u=
+++c;}u-v^98?strcmp(*u,"cd")?*c?pipe(f),o=f[1]:1,(p=fork())?e(p),o?
+r(o,0)D o)D*f):4,wait(0):(o?dup2(*f,0)D*f)D o):*i?1 D
+0),e(open(*i,0)):5,t?dup2(t,1)D t):i[2]?9 D
+1),e(creat(i[2],438)):2,e(execvp(*u,u))):e(chdir(u[1])*2):6;}
+e(x){x<0?write(2,"?\n$ "-x/4,2),x+1||(exit(1),0):5;}
+

and in the alternate source. It has the +exit() returns void fix as well as the +gets() to fgets() fix applied to it to make it +functionally equivalent like the authors intended.

+

Alternate build:

+
make alt
+

Alternate use:

+
./tbr.alt
+

Judges’ remarks:

+

This program touches on a well known Unix utility, the 6th edition +Bourne Shell (/bin/sh), whose original source was +considered to be extremely obfuscated by many people (although Steve +Bourne might disagree). Did you know that the Bourne Shell source was a +major inspiration for the formation of the IOCCC back in 1984?

+

Authors’ remarks:

+

This program is a rudimentary shell. It does I/O redirection, pipes +and cd. It flags errors on failed chdir(), +open(), creat(), execvp(), +fork() and a few syntax errors.

+

This program is obfuscated in a few notable ways: apart from the +layout (an unformatted (but crunched) version is included for people who +want to put this through cb) it makes clever use of a +write() statement, so that the same statement can be used +to print errors and the prompt. By calling the error function with the +value -8, the pointer offset in the expression +"?\n$ "-x/4 goes from 0 to 2. Presto! A prompt. For errors +with numbers smaller than -4 (i.e., UNIX system calls) a +question mark is printed.

+

The error value of chdir() is doubled so that we don’t +exit from the parent shell on a chdir() error (since +e() exits on -1 errors only). All other system +call failures exit since they are from sub-shells.

+

Recursion is sneakily employed to avoid a second call to +fork(), and the line is parsed in a fairly bizarre fashion: +backwards. The heart of the program, that is, the part which performs +all fork()s, exec()s, open()s, +etc. is ONE C STATEMENT.

+

The meta-values array is initialized in a bizarre fashion, and the +subsequent checks for the '<' and '>' +are performed in a single statement using a mask, since you know that +'>'&2 is 0, whereas '<'&2 is 2. +Other such micro-obfuscations abound.

+

Finally, it is notable that the code was hacked for minimality. If +you look at the compressed version, you will be hard-pressed to +eliminate more than a few characters (we can’t see how to make it any +smaller!). 550 characters is pretty lean for a shell that does this +much.

+

BUGS

+

The syntax of the shell has not been fully explored, but if you try +to redirect in the same direction more than once, only one redirection +is performed. This is a “feature” of the way the line is parsed; a +pointer to the stack of arguments is assigned and an argument is stolen +every time a > or < is encountered. The +shell flags an error if no arguments are on the stack. Thus, for +example:

+
cat > foo > bar
+

cats to foo, since it was pushed last, but

+
cat > > foo bar
+

cats to bar, since bar was pushed under +foo (remember we’re parsing right-left).

+

Depending on your flavor of Unix, cd without an argument +will either produce an error or just do nothing.

+

There is just one error message, the question mark, but hey, that’s +all ed(1) does too.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1990/tbr

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1990/theorem/index.html b/1990/theorem/index.html index c8cb8f5be..e3095c591 100644 --- a/1990/theorem/index.html +++ b/1990/theorem/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,260 @@ - - + + + + + + - - -1990 theorem - - + + + +1990/theorem + + + + + -

1990 theorem

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1990/theorem

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1990/theorem/index.html

- +
+ ← tbr + ↑ 1990 ↑ + westley → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Adrian +Mariano
Location: US

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1990 theorem in bugs.md.

+

To use:

+
./theorem expression x1 x2 h y1
+

where:

+
expression - function f(x,y)  (see below)
+x1 - start of interval
+x2 - end of interval
+h - step size
+y1 - initial value  (y(x1) == y1)
+

Try:

+
./try.sh
+

Judges’ remarks:

+

The program’s source implements four functions, all from the same +source file!

+

When you compile theorem.c as is and run with +5 args, it numerically solves the equation y'=f(x,y), with +a step size of h (see above usage), over the interval +x=[x1,x2], with the initial condition of +y(x1)=y1.

+

The ‘expression’ f(x,y) is any function of +x and y with the operators:

+
+   -   *   /   ^
+

The symbol ^ is the power operator. Note that it only +supports integer powers. Also note that all expressions are evaluated +strictly left to right. (i.e., parenthesis aren’t supported).

+

Try running the program with the following args:

+
./theorem y 0 1 0.1 1
+./theorem 1/x 1 2 0.1 0
+./theorem 'x^2/y+x' 0 1 0.1 6
+

But wait, there is more! You also get, free of charge, a reversing +filter! Try:

+
./theorem -r 0 0 0 0 < theorem.c > sorter.c
+

Still not impressed? The author throws in for free, a sort program! +Try:

+
make sorter
+ls | ./sorter
+

This program is safe for home use as well. The author has included a +safety feature in case you misplace the original program source:

+
./sorter -r 0 0 0 0 < sorter.c > theorem_bkp.c
+

And finally, as a special offer to users of this entry, the author +provides a Fibonacci sequence generator! Try:

+
./sorter 0 0 0 0 < theorem.c > fibonacci.c
+make fibonacci
+./fibonacci 1 1
+./fibonacci 2 1
+

NOTE: if the two args passed to fibonacci and +theorem_bkp add to 0 it will print 0 over and over again in +an infinite loop. In this case it should not be fixed (another condition +where this occurred was fixed in 2023 as it affected usability of the +program).

+

Program available on 9 track and cartridge cassette. Neither Ginsu knife nor Swiss army +knife included! :-)

+

When this program was first shown at the 1990 Summer USENIX +conference, it received a standing ovation; a first for a contest +entry.

+

Author’s remarks:

+

Differential equations are solved via the Runge-Kutta method, which +guarantees local error proportional to h^5, and total error +across a finite interval is at most a constant times +h^4.

+

Sorting is accomplished with a standard shell sort.

+

Note that the sorting and reversing is limited to files with fewer +than 500 lines, each less than 99 characters long.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1990/theorem

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1990/westley/index.html b/1990/westley/index.html index 14f20857a..d0c4f0eb8 100644 --- a/1990/westley/index.html +++ b/1990/westley/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,228 @@ - - + + + + + + - - -1990 westley - - + + + +1990/westley + + + + + -

1990 westley

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1990/westley

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1990/westley/index.html

- +
+ ← theorem + ↑ 1990 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Brian Westley
+Location: US

+ + +

To build:

+
make all
+

To use:

+
./westley <number>
+

The number should be greater than 0.

+

Try:

+
./try.sh
+

Alternate code:

+

The alternate code is provided to show how C changed.

+

Alternate build:

+

If you have an old enough compiler try and to see how C has changed +over the years:

+
make alt
+

Alternate use:

+
./westley.alt <number>
+

Judges’ remarks:

+

If you would rather “Daisy” someone other than Westley, rename the +program as needed. :-)

+

Read each block of code as if it were a piece of correspondence. For +example, the first block of code would read:

+
charlie,
+    doubletime me, OXFACE!
+    not interested, get out
+    mainly die, charly, *die*
+        signed charlotte
+

The original source had control-L’s after each code block. To make it +easier on news readers, we converted each control-L to a blank line.

+

Author’s remarks:

+

This is a “Picking the Daisy” simulation. Now, instead of mangling a +daisy, simply run this program with the number of petals desired as the +argument.

+

This is a good counter-example to peoples’ complaints that C doesn’t +have an “English-like” syntax.

+

Lint complains about everything - null effect, xxx may be used before +set, statement not reached, return(e) and return. Lint dumps core on +some systems. My personal favorite lint complaint is

+

“warning: eroticism unused in function +main”.

+

Also obviously, (char)lotte and (char*)lie +are incompatible types…

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1990/westley

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1991/ant/index.html b/1991/ant/index.html index 90ef16043..dcd4db7c6 100644 --- a/1991/ant/index.html +++ b/1991/ant/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,303 @@ - - + + + + + + - - -1991 ant - - + + + +1991/ant + + + + + -

1991 ant

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1991/ant

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1991/ant/index.html

- +
+ first entry + ↑ 1991 ↑ + brnstnd → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Anthony C. +Howe
Location: CA

+ + +

To build:

+
make all
+

There is an alternate version that +might feel a bit more familiar to vi(m) users.

+

To use:

+
./ant some_file
+

NOTE: the file must already exist and not specifying any arg will +make the program exit without doing anything.

+

Try:

+
make hill
+./ant hill
+
make mole
+./ant mole
+

Alternate code:

+

This version changes the commands slightly so that to go to the first +column you should enter 0, to go to the last column you +should enter $, to quit you should enter q, to +go back a word you should enter b and to go forwards a word +you should enter w. Also, and perhaps most useful, rather +than having to hit ctrl-L (form-feed, \f) to get back to +command mode you can use the usual ESC (\x1b).

+

These will make it slightly less unwieldy for those familiar with +vi(m); the rest was unchanged.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use ant.alt as you would ant above with the +changes in the input keys. See the author’s remarks for the remaining +keys.

+

Judges’ remarks:

+

The author was kind enough to supply a list of references below, in +case you are still confused after read the source! :-)

+

BTW: you’ve most likely heard the joke that if you want a +pseudo-random string of characters you can put a user unfamiliar with +vi(m) in a vi(m) session (in insert mode) and ask them to exit. Well in +this case you’re likely to have this problem if you ARE a vi(m) user! +:-) … especially if you don’t read the information below. This means if +you’re reading this in vi(m) you’ll have to exit this like in normal +vi(m) and then try the same with ./ant only to fail. +:-)

+

NOTE: to enter form feed you should be able to hit +ctrl-L. This will allow you to exit insert mode rather than +ESC like in normal vi(m). See the author’s commands section for other +commands.

+

Author’s remarks:

+

Ant’s Editor vIOCCC91

+

Text files consists of lines of printable text or tab characters. A +line can be of arbitrary length and is delimited by either a newline or +the end of file. Carriage return is mapped to newline on input and +ignored on output. Tab stops are every eight columns. Non-printable +characters may have unpredictable results depending on the +implementation of curses.

+

Commands

+ +

Exit status

+ +

About this entry

+

The BUF size should be set at compile time to 32767. +This value was used because the Sozobon C compiler for the Atari ST has +16 bit ints and a limit on the size of arrays & structures of 32k. +Also the WatCom C compiler for the PC also has 16 bits ints. On machines +that have 32 bit ints (most unix boxes), a larger value for +BUF could be used.

+

It is recommend that compact memory model be used on PC class +machines. Small memory model may work too provided BUF is +not too large.

+

The character constants '\b', '\f', +'\n', '\r', '\t' are used in +order to provide more portable code, since the compiler should handle +the translation of them into the native character set. Note that +'\f' (form-feed) was used to exit insert mode because +K&R C had no escape constant for the escape-key.

+

My goals for this project were to learn and experiment with the +Buffer Gap Scheme [Fin80][net90], write a useful and portable +program, and meet the requirements of the IOCCC. I initially planned to +have a mini curses built-in like the IOCCC Tetris entry from a previous +year, however this was not as portable as using a +curses library with +TERMINFO/TERMCAP support.

+

I plan to post follow-ups such as unobfuscated versions and bugs +fixes to comp.editors. Reposts of the editor.101, gap.doc, and +editor.102 can be found in the same group every so often.

+

This entry will display a file with long lines, but has trouble +scrolling the screen with long lines. Paging up and down should work +correctly, however.

+

References:

+

[Fin80] Craig A. Finseth, “Theory and Practice of Text Editors +or
+A Cookbook For An EMACS”, TM-165, MIT Lab. for Computer
+Science

+

[KeP81] Kernighan & Plauger, “Software Tools in Pascal”,
+Addison-Wesley, 81, chapter 6

+

[Mil86] Eugene W. Myers & Webb Miller, “Row-replacement +Algorithms for Screen Editors”, TR 86-19, Dept. of Computer +Science,
+U. of Arizona

+

[MyM86] Eugene W. Myers & Webb Miller, “A simple +row-replacement
+method”, TR 86-28, Dept. of Computer Science, U. of Arizona

+

[Mil87] Webb Miller, “A Software Tools Sampler”, Prentice Hall, 87 +ISBN 0-13-822305-X, chapter 5

+

[net90] “Editor 101/102” articles from comp.editors

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1991/ant

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1991/brnstnd/index.html b/1991/brnstnd/index.html index 74efd318b..e56b76712 100644 --- a/1991/brnstnd/index.html +++ b/1991/brnstnd/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,413 @@ - - + + + + + + - - -1991 brnstnd - - + + + +1991/brnstnd + + + + + -

1991 brnstnd

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1991/brnstnd

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1991/brnstnd/index.html

- +
+ ← ant + ↑ 1991 ↑ + buzzard → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Daniel J. +Bernstein
Location: US

+ + +

To build:

+
make all
+

Try:

+
./try.sh
+
+./sorta < sorta.itailrec
+

Judges’ remarks:

+

For info on more examples, read the sorta.README.md file.

+

The author wished to win the “most useful program” award and +documented this in the source code. The judges were unmoved by this +blatant attempt to influence the contest and rejected this idea… so we +gave it the “Best of Show” instead!!

+

NOTE: One should remove the final trailing newline to obtain the +original source file. This step is not needed to compile this entry.

+

To have a chance to compile under a modern CPP, we had to replace +#D with #define.

+

Author’s remarks:

+

This is an interpreter for the programming language SORTA, a systems +and numerical programming language with features sorta from C, sorta +from FORTH, and sorta from Ada.

+

SORTA lets you manipulate files and spawn programs easily, has +bitwise operators, and gives you absolutely brilliant error messages +like ‘?’ (that’s the C bit). SORTA programs work with a stack (that’s +the FORTH bit)—actually two stacks, one for integers and one for +strings. And all SORTA operations are strongly typed, detect practically +any failure, and garbage-collect (that’s the Ada bit).

+

SORTA also contains features you might not expect from such a small +interpreter: arbitrary-length string input and concatenation, for +instance, not to mention infinite-depth tail recursion.

+

SORTA ignores its arguments (though it makes them available to the +script); it takes all commands, character by character, from its +standard input. Unrecognized commands are repeated with a ‘?’.

+

SORTA maintains an i stack for integers and an +s stack for strings. It also keeps track of +programs, one for each character. Operations are silently +ignored if the relevant stacks are too low, except as noted for +s, S, and !. If the +i stack or s stack (or the stack of buffered +macro commands) grows too high, SORTA will exit silently with exit code +2. (Compile parameter -Do=250 controls what ‘too high’ +means; you should not make o larger than 250.) I don’t +think it’s possible to crash the interpreter.

+

Here, then, is the SORTA programming language. All non-digits delimit +numeric constants. Spaces and newlines are ignored except as numeric +delimiters.

+

Basic operations

+ +

System operations

+ +

High-level language +operations

+ +

Common idioms: To drop the top of the s stack, +ld. To do a <, 1s>. To +unconditionally execute the program labeled by character x, +1=x (or any nonzero number followed by =x). To +print the top of the i stack non-destructively, +# (or #$ if you don’t want the newline). To +subtract, _+. To do mod or and or any of the other missing +operations, combine the available operations as illustrated below. To +introduce a comment, +[ this is a comment string which is promptly eliminated ]ld.

+

SORTA’s requirements: it wants fork(), +execvp(), open(), close(), +dup(), pipe(), and wait(), so it +obviously won’t even compile on a non-UNIX machine. It also assumes that +you have a size-256 character set and that the characters between +'0' and '9' are exactly the digits in order. +It does not depend on ASCII, despite the code appearance. Also +note that SORTA does not attempt to declare malloc(), so +you will get some warnings about illegal pointer combinations. Also note +that there are unreachable statements in SORTA.

+

While the program source of course depends highly on +#defines for obfuscation, I like to think that this code +has those little touches, those professionally sharpened edges that mark +true software engineering. Observe, for instance, how i and +s are the string and integer stacks respectively. It’s +these little things that make you feel at home in an otherwise utterly +useless piece of code. They’re what make an obfuscation work.

+

The character pool (I after cpp) makes it rather painful +to see the effect of commands at a glance. I can just imagine people +spending hours bouncing between the pool and the rest of the code, or +accidentally changing the pool without realizing its importance. Without +documentation and example scripts, someone would find it a challenge to +figure out what the arrays are used for, let alone that SORTA is a +scripting language.

+

Another nice feature is that the SORTA language itself encourages you +to write not merely obfuscated but plain incomprehensible scripts (like +the examples in sorta.README.md —after +working with the language for a while, I guess I can read it pretty +easily, but I also think FORTH is a beautiful language). The numbers +running around everywhere will make people think of ASCII, even though +the code is not ASCII-dependent. What’s your first thought when you see +several arrays[256]? This is pretty standard obfuscation +otherwise. I like the way that unbalanced macro braces can throw off the +reader in if(c>0){y+1]=z[c];, and I had fun covering the +alphabet with #defines, but that’s nothing special.

+

Possible future extensions to SORTA include string extraction and +matching, reading from files into strings, and encrypting the string +pool to further confuse the judges. I don’t think I can fit this into +the size limit, unfortunately.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1991/brnstnd

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1991/buzzard/index.html b/1991/buzzard/index.html index 7403b6036..bc3215b41 100644 --- a/1991/buzzard/index.html +++ b/1991/buzzard/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,256 @@ - - + + + + + + - - -1991 buzzard - - + + + +1991/buzzard + + + + + -

1991 buzzard

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1991/buzzard

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1991/buzzard/index.html

- +
+ ← brnstnd + ↑ 1991 ↑ + cdupont → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Sean Barrett
+Location: unknown

+ + +

To build:

+
make all
+

There is an alternate version which +might feel more at home for vi(m) users in navigation.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1991 buzzard in bugs.md.

+

To use:

+
./buzzard
+

Alternate code:

+

This version changes the keys f for forward, +l for left and r for right by default to +k for forward, l for right and h +for left, which is more natural for those who use vi(m). Also one can +just hit q followed by enter to quit the maze. It is +problematic to reconfigure the keys except by modifying the code +directly so the keys are not made a -D at the compiler.

+

Alternate build:

+
make alt
+

Alternate use:

+
./buzzard.alt
+

Judges’ remarks:

+

You will be A-mazed.

+

You are invited to try to cheat, … if you can figure out how! :-)

+

Author’s remarks:

+

How to play

+

When the game starts, you are at the far end of the maze from the +exit, looking down a corridor. To move forward, type f and +press return. To turn 90 degrees right, type r; and for +left, l. You can put multiple commands on one line, and the +new view will be drawn after all the moves.

+

The game ends if you get out the exit (you’ll know it when you see +it) or when you type ^D (EOF).

+

Hints on how to cheat

+

You can, of course, cheat by looking at the maze map. The question +you need to ask yourself, though, is what sequence of characters marks +the place where you can escape the maze?

+

The algorithm is quite bizarre–the primary nested loop that generates +it goes top to bottom on the display, looping forward then backward from +the current position to draw the left side and then the right side.

+

Advanced usage notes

+

The program can also be run from other files containing mazes. The +maze should be laid out graphically in the obvious format; newlines +separate physical rows in the maze; a space indicates a corridor, and +any other character is a wall. Tabs are also considered walls, so make +sure to convert tabs to spaces before using it.

+

Usage:

+
./buzzard [filename [escape-char [start-x start-yNNN
+

Filename is the name of the file containing the maze. This defaults +to buzzard.c or rather __FILE__.

+

Escape-char is the character in the maze that represents the exit. +You can put more than one exit in the maze (for example, you could make +all ’!’s in the maze be exits).

+

Start-x and start-y mark the coordinates where you begin playing. Y +coordinate is down the rows in the files, X is to the right through the +characters of each line. Both X and Y begin counting from 0. The default +is start-x = 4, start-y = 5, which is needed for the buzzard.c, but +would probably be inappropriate for other mazes.

+

BUGS:

+

You can’t change that at start you’re facing down (“south”).

+

The drawing algorithm cannot handle open spaces (two successive +side-corridors with no wall between them). In fact, it cannot handle +small dog-legs properly, although the error is subtle.

+

The exit is drawn like a normal corridor from the side view; it’s +only displayed as the exit when you are facing it.

+

Improper command line arguments are not handled nicely.

+

Mazes with openings at the edges will cause the drawing program to +reach into arbitrary parcels of memory.

+

The program assumes that tabs are set to 8 characters.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1991/buzzard

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1991/cdupont/index.html b/1991/cdupont/index.html index 8172361c3..439da1a77 100644 --- a/1991/cdupont/index.html +++ b/1991/cdupont/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,204 @@ - - + + + + + + - - -1991 cdupont - - + + + +1991/cdupont + + + + + -

1991 cdupont

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1991/cdupont

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1991/cdupont/index.html

- +
+ ← buzzard + ↑ 1991 ↑ + davidguy → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Christian +Dupont
Location: FR

+ + +

To build:

+
make all
+

To use:

+
./cdupont
+

Judges’ remarks:

+

Why is the following label necessary?

+
sorryfor_this_unused_but_very_needed_label:
+

Notice that if you C beautify (cb) or pre-process this program, it +will no longer work correctly, if at all. (go ahead, try it… :-))

+

NOTE: One should remove the final trailing newline to obtain the +original source file. This step is not needed to compile this entry.

+

Author’s remarks:

+

The source code holds the letters of the message. Each letter, +combined with another key letter, is used to compute the coordinates of +the next letter and key. Thus, the message is code. That is why I use +silly comments, most often badly spaced.

+

The space character sequence between the words is given by a simple +computation in an octal constant (given here as an hex value, of +course).

+

This way, any message can be mixed into a code, since the keys allow +you to place the meaningful letters wherever you want.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1991/cdupont

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1991/davidguy/index.html b/1991/davidguy/index.html index 9ecbf74e9..032053c97 100644 --- a/1991/davidguy/index.html +++ b/1991/davidguy/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,266 @@ - - + + + + + + - - -1991 davidguy - - + + + +1991/davidguy + + + + + -

1991 davidguy

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1991/davidguy

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1991/davidguy/index.html

- +
+ ← cdupont + ↑ 1991 ↑ + dds → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: David +Applegate
Location: US

+ + +

To build:

+
make all
+

To use:

+
./davidguy ip_address:server.screen
+

where ip_address in an IP address of an X server.

+

Try:

+
./davidguy 127.0.0.1:0.0
+

Of course, you may need to supply a more reasonable address. :-)

+

Also try:

+
cp -f davidguy guydavid
+./guydavid 127.0.0.1:0.0
+

Can you determine why this makes a difference?

+

Judges’ remarks:

+

We permitted this type of entry to win because:

+ +

Now that X11 and sockets have become ‘standard’, we plan to open up +the contest to programs that use them. Future rules will explain this +further.

+

We are pleased that this entry has helped bring new ‘life’ into the +contest.

+

Authors’ remarks:

+

The program is a fully-functional X client. It talks directly to the +X server through a socket without using Xlib, Xt or any other wussy +toolkit junk. With no arguments, it will try to run locally using the +unix-domain socket (only on BSD :-( ) or you can give it a command line +argument identifying a display host address (in dotted octet notation, +like 127.0.0.1:0.0) where the X server is running. It handles color and +monochrome displays, and performs whatever byte-swapping and +bit-reversal is needed (so that the program works even when the server +and the client have different architectures). It buffers communication +to the X server for efficiency.

+

NOTE: The original source in davidguy.c used only an IP address +argument (assumed :0.0) and assumed the color of black and white.

+

The program doesn’t require any user interaction; you can just sit +back and watch it run. All the action takes place in the root window of +the display.

+

We think the program is interesting for these reasons:

+
    +
  1. It belongs to a class of programs that programmers make the +following complaints about: they require a mountain of code to implement +even the simplest program; and they must be linked with giant libraries +of hard-to-understand functions. In contrast to these complaints (made +by wimps, in our humble opinion), our program fits in under 1536 bytes, +doesn’t need any external functions except for a few system calls, and +doesn’t need to include any header files.

  2. +
  3. It implements an extremely efficient algorithm for the +computation it performs. One cool feature of the algorithm (at least as +far as this contest is concerned) is that its obscurity is fundamentally +necessary for its efficiency. In other words, even if we took steps to +present the algorithm clearly, (we haven’t) the relation of the +computation performed to the specification of what the program was +supposed to do would still be hard to understand.

  4. +
+

Quasi-spoiler on internals:

+

The program plays Conway’s +Game of Life in the root window’s background pixmap. It starts by +setting the background to random bits, and then plays Life, with one +Life cell for each pixel of the screen. In the game of Life, a cell +survives to the next round if 2 or 3 of its 8 neighbors are also alive, +and a cell is born if exactly 3 of its neighbors are alive. Otherwise, a +cell dies of exposure if it has only 0 or 1 neighbors, and dies of +overcrowding if it has 4 or more neighbors.

+

The algorithm used to compute the next generation is based on the +observation that a cell’s state in the next generation is a boolean +function of its current state, and the states of its 8 neighbors (i.e., +a boolean function from 9 bits to 1 bit). This function can be computed +by a boolean circuit. In addition, intermediate values computed by the +circuit can be shared between neighboring cells, reducing the number of +gates per cell required. These ideas have been used before, to compute +the next generation through a series of bit blits.

+

Instead of doing this, we map values in the circuit to bits in +registers, so that the next generation can be computed efficiently +within registers, minimizing memory access. As a result, the computation +of the next generation is performed with about 1.6 instructions per life +cell, consisting of .125 memory accesses, .17 shifts, and 1.3 logic +operations. The net result is that the time to transfer the bits to the +X server, and for the X server to draw them on the screen, dominates the +time to compute the next generation.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1991/davidguy

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1991/dds/index.html b/1991/dds/index.html index 0a0cf8fa5..c5d2a16df 100644 --- a/1991/dds/index.html +++ b/1991/dds/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,262 @@ - - + + + + + + - - -1991 dds - - + + + +1991/dds + + + + + -

1991 dds

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1991/dds

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1991/dds/index.html

- +
+ ← davidguy + ↑ 1991 ↑ + fine → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Diomidis +Spinellis
Location: GR

+ + +

To build:

+
make all
+

To use:

+
./dds basic_program
+./a.out 2>/dev/null
+

Try:

+

The author suggests trying:

+
./dds LANDER.BAS
+./a.out
+

Notice that a file a.c has been generated. Can you tell +how a.c was produced? How does a.c relate to +LANDER.BAS?

+

What happens if you give the program a C program like itself? +Try:

+
./dds dds.c
+

You’ll get errors yes but what does the generated file look like? +What about other types of files?

+

Judges’ remarks:

+

This obfuscated program translates BASIC programs into obfuscated C +programs by way of an obfuscated algorithm.

+

Author’s remarks:

+

This program is a companion to the DDS-BASIC interpreter program that was +submitted to the contest in 1990. This +compiles BASIC programs into compilable C code and then compiles it. The +input format is almost identical to the input format of the DDS-BASIC +interpreter. The program needs an executable C compiler called +cc in your path in order to work.

+

Program commands:

+ +

Expressions are the same as the expressions of the C language. Many +system calls and C library calls can be used.

+

Input format:

+ +

Error checking / error +reports:

+

The compiler silently ignores many errors. Other errors may produce +errors in later phases of the compilation.

+

Can you figure out +how the compiler works?

+

Hint:

+

The compiler is NOT written in C, so this is really a meta-obfuscated +program. The C code is an interpreter for the four register, seven +instruction COGNIMP$ machine that is contained in the +s string. (COGNIMP$ is named after the +symbolic names of the seven instructions it defines (Copy, +Output, Goto, iNcrement, +If, Match and Print).

+

The $ sign is used for labels. The actual compiler is +written in COGNIMP$. Browsing through the +COGNIMP$ code we encourage you to examine the loops for +scanning the expression in the IF statement and the way a +decision tree is implemented in order to match the statements. (Of +course the s string is encoded by adding one to every +character of it just to confuse you).

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1991/dds

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1991/fine/index.html b/1991/fine/index.html index bbb5520a0..18f149b03 100644 --- a/1991/fine/index.html +++ b/1991/fine/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,262 @@ - - + + + + + + - - -1991 fine - - + + + +1991/fine + + + + + -

1991 fine

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1991/fine

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1991/fine/index.html

- +
+ ← dds + ↑ 1991 ↑ + rince → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Thomas A. +Fine
Location: US

+ + +

To build:

+
make all
+

To use:

+
echo text | ./fine
+

Try:

+
./try.sh
+

Make sure that you read the last line backwards! Credit goes to Merlyn LeRoy (Brian Westley) for +that. See his 22 August 1992 rec.puzzles +post. Some others come from his 1989 entry as well. To those who +have a harder time reading backwards it says: +Gary lent the rug, rotated from +the rug gary lent!

+

Judges’ remarks:

+

This filter, 80 chars plus a newline, fits into a single line on most +terminals (unless your terminal has a line wrap mis-feature :-)).

+

Note in 2023: fixing this entry to work with modern systems increased +the size, originally to 106 characters but it was dropped back down to +80 with clever use of the Makefile.

+

This entry is likely one of the smallest C implementations of this +filter, excluding programs that resort to command line or include file +tricks.

+

How does this program work? Which 3 bytes of C code can be changed +into 2 bytes, allowing the program to still work, but also stripping the +high bit off some input?

+

Author’s remarks:

+

The author wishes to thank J Greely for the last 6 bytes.

+

Here’s about how it does it:

+

NOTE: Bits are referred to as 76543210, high to low.

+
    +
  1. Get the character in variable a. Note the fun way we +check for EOF. (thanks J).

  2. +
  3. Reverse bit 6, and strip bit 5. Bit 6 determines (mostly) whether +or not this character is a letter. Bit 5 would determine case if we +cared. Assign this value to variable b (We need to save it, +since we need to make 2 comparisons and maybe one operation with this +value). We can’t abuse our first variable, since it saves the bits we’re +changing.

  4. +
  5. Check this value to see if it is a letter. It must be non-zero - +if it is zero, then we have either the @ (64) or the +` (96). It also must be less than 27 - this checks the +range for letters as well as implicitly checking the value of bit 6 (if +it was originally clear, it is set now, so b would be too +big).

  6. +
  7. If it is not a letter, the conditional expression inside of the +putchar() returns the original character (a). +Otherwise, it returns a really messy expression that performs the actual +rotation and fixes the fifth and sixth bits:

    +
      +
      1. +
      2. Subtract 1, to get into the range 0-25 (for the modulo +operation).
      3. +
    • +
      1. +
      2. Add 13 to the character. Steps A and B are combined.
      3. +
    • +
      1. +
      2. Take this modulo 26 to make the addition wrap around.
      3. +
    • +
      1. +
      2. Fix bits 5 and 6, based on variable a.
      3. +
    • +
      1. +
      2. Add 1 back in (we took it out in step A.) This is okay to do +after step D, because we know the addition won’t trickle up +past the fourth bit (b would have to be 31 for this to +happen).
      3. +
    • +
  8. +
+

Notice that this implementation operates only on characters with the +high bit clear. The high bit can be ignored without changing the size of +the program. Also, if you know you are only dealing with seven bit data, +the size can be reduced by one byte. These are left as exercises for the +student.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1991/fine

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1991/rince/index.html b/1991/rince/index.html index 70a46dc3c..c73d7071d 100644 --- a/1991/rince/index.html +++ b/1991/rince/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,261 @@ - - + + + + + + - - -1991 rince - - + + + +1991/rince + + + + + -

1991 rince

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1991/rince

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1991/rince/index.html

- +
+ ← fine + ↑ 1991 ↑ + westley → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: James +Bonfield
Location: GB

+ + +

To build:

+
make all
+

There are two alternate versions which +allow one to not be restricted in movements or to change the maximum +number of movements, even if that’s fewer than the original program.

+

To use:

+
./rince
+

Alternate code:

+

The first alternate version, rince.alt.c, +disables a maximum move count so that anyone with enough patience and +time can complete the puzzle, without having to worry about how many +moves they make, assuming they don’t get stuck. The second version, rince.alt2.c, allows one to reconfigure at +compilation the maximum number of moves, even if that is lowering the +count.

+

The author set the maximum number of moves to 484.

+

Alternate build:

+
make alt
+

This will build both alt versions where the first one, +rince.alt, has no restrictions in the number of movements +and the second one, rince.alt2, has a configurable maximum +number of moves allowed, defaulting to the entry’s max, 484.

+

To reconfigure the maximum number of moves to 700:

+
make clobber MAXMOVES=700 alt
+

Alternate use:

+

To run the first alt version:

+
./rince.alt
+

To run the second alt version:

+
./rince.alt2
+

Can you figure out how to make the two alternate versions equivalent +in functionality without modifying the code? That is can you make the +second alt version end up allowing any number of movements?

+

Judges’ remarks:

+

In 2023 this entry was updated to allow most ANSI C compilers to +compile the code and to fix a bug where the win or lose message was not +seen.

+

Author’s remarks:

+

This program is a simple puzzle type game. (I’ll leave you to play it +to see the rest of it .. :-) .) The general idea was to try and write +the smallest playable game, but keep the playability and enjoyment +high.

+

Instructions:

+

Key to map:

+
            |
+ ######                 | | | /\   /--\  ==|    /\ | |  Directonal keys
+ ######  Solid Wall     | ----||    \/     /\   ||----  (unlock doors of
+ ######                 |     \/  ==|     \--/  \/       the same direction)
+            |\
+            |   <<                    >>    Doors. Unlocked by
+     Blank space    |   <<   vvvvvv  ^^^^^^   >>    the above keys.
+            |   <<                    >>
+            |\
+   ___                  | o__O\   O__O   ^__^   /O__o\
+  /   \  'Crushable'    | \___/  /----\ /----\  \___/  The four sprites for
+  \___/    boulder      |  _/_\  _/  \_ _/  \_  /_\_   your character :-)
+            |\
+   ___   uncrushable    |   /\   Diamonds. They can either be found lying
+  /@@@\    boulder      |  <  >  around (if only!) or manufacture by pushing
+  \@@@/                 |   \/   two 'crushable' rocks together.
+            |
+

The general idea of the game is to collect all the diamonds. This +must be done in the minimum amount of moves. I’ve allowed a margin of 5 +moves which brings the moves allowed to 484. (alter the +value of u in the program to set the max moves +allowed).

+

There are two types of boulders. Both can be pushed around, but only +the hollow (crushable) ones can be turned into diamonds (by pushing it +onto another hollow one).

+

Of the four types of doors (and keys) only 3 have been defined. This +was done to keep the source as low as possible (as I only used 3 in the +map). To unlock a door simply push a key into the corresponding door. +Take care that it’s facing in the correct direction.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1991/rince

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1991/westley/index.html b/1991/westley/index.html index a6ff7dde0..8ee697992 100644 --- a/1991/westley/index.html +++ b/1991/westley/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,415 @@ - - + + + + + + - - -1991 westley - - + + + +1991/westley + + + + + -

1991 westley

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1991/westley

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1991/westley/index.html

- +
+ ← rince + ↑ 1991 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Brian Westley
+Location: US

+ + +

To build:

+
make all
+

There is an alternate version that is +supposed to win all the time.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1991 westley in bugs.md.

+

To use:

+

NOTE: we have provided a script to perform the below procedure which +we include for the interested. See the try section if +you just want to play.

+

Make and then run as follows:

+
./westley [move_location] | tee nextmove.c
+

where the move_location is a digit from 1 to 9 that +represents a move on a tic-tac-toe board:

+
1 2 3
+4 5 6
+7 8 9
+

If you omit move_location, then the computer moves +first. For your next move, recompile nextmove.c and play it +again:

+
make nextmove
+./nextmove move_location | tee nextmove.c
+

Try:

+

We have provided the shell script, ttt, to make +it easier to play the game:

+
make ttt
+./ttt [first_move]  # <- omit first arg to have it move first
+./ttt next_move
+

The shell script determines when the game is over, and automatically +replaces merlyn.c (copied from westley.c with an improved version after a loss). +The ttt script has two other modes:

+
./ttt quitgame  # cancel any game in progress, revert to merlyn.c
+./ttt clobber   # remove all game files, revert to original source
+

For example here is a potentially losing game:

+
./ttt 1
+./ttt 4
+./ttt 6
+

The final might look like:

+
        a(X){/*/X=-     a(X){/*/X=-
+    X   -1;F;X=-        -1;F;X=-
+        -1;F;}/*/       -1;F;}/*/
+char z[][100]={"char z[][100]={","a(X){/*/X=-","-1;F;X=-","-1;F;}/*/","1999999999  :-) ",
+"int q,i,j,k,X,O=0,H;S(x)int*x;{X+=X;O+=O;*x+1?*x+2||X++:O++;*x=1;}L(n){for(*",
+"z[i=1]=n+97;i<4;i++)M(256),s(i),M(128),s(i),M(64),N;X*=8;O*=8;}s(R){char*r=z",
+"[R];for(q&&Q;*r;)P(*r++);q&&(Q,P(44));}M(m){P(9);i-2||P(X&m?88:O&m?48:32);P(",
+"9);}y(A){for(j=8;j;)~A&w[--j]||(q=0);}e(W,Z){for(i-=i*q;i<9&&q;)y(W|(1<<i++&",
+"~Z));}R(){for(k=J[*J-48]-40;k;)e(w[k--],X|O);}main(u,v)char**v;{a(q=1);b(1);",
+"c(1);*J=--u?O?*J:*v[1]:53;X|=u<<57-*v[u];y(X);K=40+q;q?e(O,X),q&&(K='|'),e(X",
+",O),R(),O|=1<<--i:J[*J-48+(X=O=0)]--;L(q=0);for(s(i=0);q=i<12;)s(i++),i>4&&N",
+";s(q=12);P(48);P('}');P(59);N;q=0;L(1);for(i=5;i<13;)s(i++),N;L(2);}",0};
+        b(X){/*/X=-     b(X){/*/X=-
+    X   -1;F;X=-        -1;F;X=-    X
+        -1;F;}/*/       -1;F;}/*/
+int q,i,j,k,X,O=0,H;S(x)int*x;{X+=X;O+=O;*x+1?*x+2||X++:O++;*x=1;}L(n){for(*
+z[i=1]=n+97;i<4;i++)M(256),s(i),M(128),s(i),M(64),N;X*=8;O*=8;}s(R){char*r=z
+[R];for(q&&Q;*r;)P(*r++);q&&(Q,P(44));}M(m){P(9);i-2||P(X&m?88:O&m?48:32);P(
+9);}y(A){for(j=8;j;)~A&w[--j]||(q=0);}e(W,Z){for(i-=i*q;i<9&&q;)y(W|(1<<i++&
+~Z));}R(){for(k=J[*J-48]-40;k;)e(w[k--],X|O);}main(u,v)char**v;{a(q=1);b(1);
+c(1);*J=--u?O?*J:*v[1]:53;X|=u<<57-*v[u];y(X);K=40+q;q?e(O,X),q&&(K='|'),e(X
+,O),R(),O|=1<<--i:J[*J-48+(X=O=0)]--;L(q=0);for(s(i=0);q=i<12;)s(i++),i>4&&N
+;s(q=12);P(48);P('}');P(59);N;q=0;L(1);for(i=5;i<13;)s(i++),N;L(2);}
+        c(X){/*/X=-     c(X){/*/X=-
+    0   -1;F;X=-    0   -1;F;X=-    0
+        -1;F;}/*/       -1;F;}/*/
+
+ttt: I win!
+

Redirects stderr to /dev/null by default. If you need +errors or warnings use -e.

+

Alternate code:

+

This version is based on the author’s remarks. It is not supposed to +lose but it can lose if you cheat. That’s supposed to happen. Can you +win any other time?

+

Alternate build:

+
make alt
+

Alternate use:

+

Rather than use ttt try the script ttt.alt +instead.

+

Judges’ remarks:

+

Can you figure out why the board looks different than the westley.c?

+

What happens if you make a move already made?

+

Now go try and draw or better yet win (without cheating which is very +easy :-) )! Why is win better than draw? Because everyone knows how to +draw:

+
+

Professor Falken: Did you ever play tic-tac-toe?
+Jennifer Mack: Yeah. Of course.
+Falken: But you don’t any more.
+Jennifer: No.
+Falken: Why?
+Jennifer: Because it’s a boring game. It’s always a tie.
+Falken: Exactly. There’s no way to win. The game itself is pointless. +But back at the International +Obfuscated C Code Contest judges’ room they believe that you can win +tic-tac-toe, that there can be acceptable draws.

+
+

This is supposed to happen. As is written in the The Jargon +File:

+
That's not a bug, that's a feature.
+

Try not to cheat (even though it’s very easy :-) ), the computer has +not learned how to catch you doing it.

+

Author’s remarks:

+

A tic-tac-toe self-modifying program that “learns”. This C program +plays standard tic-tac-toe on itself. The code is written as a +tic-tac-toe grid; moves are carried out within the code.

+

The human is X, the computer 0 [sic, +“zero”, not letter “O”].

+

The program, when run, reproduces itself with both the player’s move +and the computer’s move added. Recompile THIS program (using the same +compile line) and repeat until the game is finished.

+

If the computer wins, the “straight face” in the upper right-hand +corner, “:-|”, will change into a happy face, “:-)”. If it is a draw, +the face does not change. If the computer loses, the board is blanked +and the face changes into a sad face, “:-(”. If this happens, the blank +board should replace the original program; the computer changes its play +and will continue to do so until it no longer loses games.

+

If you want a program that never loses, simply replace the string +"9999999999 :-| " with +"9883857753 :-| ".

+

How it works

+

The vertical “bars” of the grid are identical functions, with the +name of the function as a(), b(), or +c(). After each function is called, the global variables +X and O contain bitmasks of where all the +Xs and Os are placed. The statement:

+
X=-   <char>   -1;
+

evaluates to 1, -1, or -2 when +X is 1 and <char> is one of +"X", "0", or " ". The function +S(&X) sets the appropriate bits in (global vars) +X and O and resets the value of +&X to 1. This is how the current position +is computed.

+

The player’s move is bitwise ORed into the X mask, and +(if it is the opening move) the strategy string’s first character is set +to the player’s first move (or 5 if the computer moves +first).

+

The evaluation function y(M) checks if the mask has a +winning pattern (any of the first eight bitmasks of the +w[N] array), and sets the variable q to +0 if it does.

+

The player’s move is evaluated to see if the human has won. The +smiley is set to “:-)” or “:-(” depending on this. Also, if the human +has won, the digit in the strategy string is decremented to change the +computer’s play for the next round.

+

If the human has NOT won, the e(N,M) function evaluates +if ANY move not in mask N can produce a win in mask +M. The first evaluation e(X,O) checks if +O can make a legal winning move. If so, the computer has a +winning move and makes it. If not, the smiley is set to “:-|”, and a +non-winning move is generated.

+

A non-winning move first checks if X can win in one +move; if so, this move is selected, blocking the win. Otherwise, a move +is generated by looking down the list of “move templates”. The first +move template that generates a move that is NOT already occupied by an +X or O is returned.

+

The “move templates” are static tic-tac-toe positions that generate +possible moves by making the e() function return “winning” +moves, e.g. the template:

+
. . .
+O , O    (this is the value 40; 2^3+2^5)
+. . .    ("O"s are 1 bits, "." and "," are 0 bits)
+

…will make the e() function return a center move, as +this is the only move that produces three in a row. Notice that the +computer does not consider which cells contain Xs and +Os when making a template move, only which cells are empty +and not-empty. This makes for unusual play.

+

The templates are carefully chosen to eventually block all traps that +X can try, by just blundering in the way.

+

Also note that the winning & strategy templates are part of the +compile line, making it possible to change the rules of the game by +changing the compile line.

+

The templates are:

+
O , O
+, , ,
+O , O
+
+, . .
+. O .
+. . O
+
+. . .
+O , O
+. . .
+
+. . .
+O O ,
+. . .
+
+. . .
+O , O
+. . .
+
+. , ,
+. O .
+O O ,
+
+O , O
+, , .
+O . .
+
+, . O
+O , O
+O . ,
+
+O . ,
+O , O
+, . O
+
+O , O
+, , ,
+O , O
+

A digit of 9 means start with the first template, +8 starts at the second, etc. The templates are scanned +until a legal move is found. A template is scanned from bottom to top, +right to left (i.e. move 9 is tested first, then +8, down to move 1).

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1991/westley

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1992/adrian/index.html b/1992/adrian/index.html index 5161d6a1c..64272883a 100644 --- a/1992/adrian/index.html +++ b/1992/adrian/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,378 @@ - - + + + + + + - - -1992 adrian - - + + + +1992/adrian + + + + + -

1992 adrian

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1992/adrian

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1992/adrian/index.html

- +
+ first entry + ↑ 1992 ↑ + albert → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Adrian +Mariano
Location: US

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: known bug - please help us fix
+STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1992 +adrian in bugs.md.

+

Try:

+
./try.sh
+

For the slow minded, try:

+
./adsleep 32767
+

Judges’ remarks:

+

Once you get past the obfuscation, you have an opportunity to learn +about regular expressions and state machines.

+

NOTE: Some compilers have had trouble optimizing this entry.

+

Author’s remarks:

+

ADrian’s GREP (adgrep)

+

For those confused by the complexity of full-blown +egrep(1) style regular expressions, this program offers an +alternative. It implements an equivalent search, using a deterministic +finite automaton.

+

A deterministic finite automaton consists of a finite set of states, +along with transition rules to move from one state to another, an +initial state, and a set of accepting states. The automaton takes a +string as input and begins in the start state. It reads a character of +the string and consults the rules for the current state, moving to the +new state indicated by the appropriate rule. This process is repeated +until the string is consumed. If the current state at this point is one +of the accepting states, then the string is accepted.

+

The deterministic finite automaton is specified as a series of rules +for each state:

+
<state> chars1 <dest1> chars2 <dest2> ...
+

chars1 is a list of characters (only the first +8 are significant) which should trigger a transition to +<dest1>. <dest1> is another state +which should have a similar specification somewhere. A state is +accepting if it is specified in square brackets: [final]; +state strings are significant to only eight characters like +chars1.

+

Example 1: matches +^abc$

+
<q0> a <q1>          The first state to appear is the start state
+<q1> b <q2>
+<q2> c [q3]
+[q3]
+

Technically, a deterministic finite automaton should have a rule for +each possible input character at each state. To simplify descriptions of +the automata, if no rule is present, the string will not be accepted. +Also, the . character matches any character if it occurs +first in the character list.

+

Example 2: ^abc

+
<q0> a <q1>
+<q1> b <q2>
+<q2> c [q3]
+[q3] . [q3]
+

Example 3: abc$

+
<q0> a <q1> . <q0>
+<q1> b <q2> a <q1> . <q0>
+<q2> c [q3] a <q1> . <q0>
+[q3] . <q1>
+

Example 4: ^(abc)*$

+
[q0] a <q1>
+<q1> b <q2>
+<q2> c [q0]
+

Example 5: ^[ab][cd][ef]$

+
<q0> ab <q1>
+<q1> cd <q2>
+<q2> ef [q3]
+[q3]
+

Example 6: ^(abc|efg)$

+
<q0> a <q1> e <q3>
+<q1> b <q2>
+<q2> c [q5]
+<q3> f <q4>
+<q4> g [q5]
+[q5]
+

With the automaton specification in filename, invoke the +program by typing

+
./adrian filename
+

It will read the file and print out all the lines which the automaton +accepts. If the file cannot be opened, a system error message will be +printed. If the input contains errors, then an error message along with +the number of the offending line will be printed to stderr. The number +of rules for each state is limited to 17. If more than 17 rules are +present, you get the error too_many_rules, and the state +that was being processed is printed. Error no_destination +occurs if you specify a set of characters, but no destination state, and +error too_many_states occurs if your automaton has more +than 257 states.

+

Running:

+
./adrian from < your_mailbox
+

will perform a function similar to that of the unix from +command.

+

If no filename is specified on the command line, then +__FILE__ is used as the specification for the automaton. +(Originally this was "adgrep.c" but the file was renamed to +adrian.c by the judges and for more portability the arg was +changed to __FILE__.) In this case, the program will search +for matches to the regular expression:

+
^.[^|C][^w[Q]*(Q|[w[]c).*|^.[C|]$
+

I suggest using adrian.c as input, and storing the +output in adwc.c:

+
./adrian < adrian.c > adwc.c
+

Compiling the new file, adwc.c, yields a clone of the +unix wc command. It runs on one file, defaulting to +"adrian.c" if no file is given (again, this was changed to +be __FILE__) and displays the number of lines, words, and +bytes in the input file.

+

Another possibly interesting automaton can be created by slightly +adjusting the adrian.c file. Change the first line to +read

+
/* . echo| . */
+

and repeat the process above

+
./adrian <adrian.c > adecho.c
+

The new file now contains all lines which match

+
^.[^5|m^]*[m^]([e=p,;]|[^e=+p,;].*)$
+

Compile and run. This is an echo(1) clone. Note the +efficient algorithm employed.

+

Two other adjustments to the first line also yield useful results. By +changing it to

+
/* . head; . */
+

you can search for matches to

+
^.[^W]*W..*$
+

By some freak happenstance, lines of adrian.c which +match this regular expression form a unix head(1) command. +It prints the first ten lines of the file specified on the command line +or adrian.c if no file is specified (again this was changed +to __FILE__).

+

By setting the first line to

+
/* . basename . */
+

a clone of the unix basename(1) command can be +unearthed. The automaton will search for

+
^.[^j]*jr.*$
+

on standard input. And the program which results by running +adrian.c through this filter requires two parameters. The +first is meant to be a filename, and the second, an extension. All +leading pathname components are removed from the filename, and the +extension is removed if present. The resulting base name is printed to +stdout.

+

Lastly, by setting the first line to

+
/* . sleep . */
+

you can search for

+
^.[^(~][^s]*sl.*$
+

Filtering adrian.c through this search yields a clone of +the sleep(1) command. Invoke with a single integer +parameter, and it will pause for that many seconds.

+

If either adbasename or adsleep is invoked +with too few parameters, the program will print the error message:

+
+

Segmentation fault (core dumped)

+
+

(The exact text of the above error messages varies from machine to +machine.) The four programs which read from stdin require lines shorter +than 999 characters.

+

The other info files are adrian.grep.[1-6] which contain +the six examples that appear above, and from, which is used to emulate +the unix from command. For reasons of clarity, the name +"from" should probably not be changed if possible. I +wouldn’t want to be accused of confusing people by giving the input +files weird names.

+

If you want to change the default input filename (line 80) you must +be careful to choose a name that doesn’t match the wrong search +patterns, introducing extra lines into one of the programs (again, this +was changed to be __FILE__).

+

The program will produce at least one warning and possible several +when compiled depending on the compiler.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1992/adrian

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1992/albert/index.html b/1992/albert/index.html index dd23c6dc7..efb56ccb0 100644 --- a/1992/albert/index.html +++ b/1992/albert/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,288 @@ - - + + + + + + - - -1992 albert - - + + + +1992/albert + + + + + -

1992 albert

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1992/albert

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1992/albert/index.html

- +
+ ← adrian + ↑ 1992 ↑ + ant → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Albert van der +Horst
Location: NL

+ + +

To build:

+
make all
+

An alternate version exists that fixes +a bug.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: known bug - please help us fix
+

For more detailed information see 1992 +albert in bugs.md.

+

To use:

+
./albert number
+

Try:

+
./try.sh
+

Alternate code:

+

An alternate version of this entry, albert.alt.c, is provided. Leo Broukhis, before +he was an IOCCC judge, sent the IOCCC judges this Email message:

+
From: leo _at_ zycad -dot- com (Leo Broukhis)
+Date: Tue, 30 Jan 96 17:37:51 PST
+To: judges _at_ toad -dot- com
+Subject: IOCCC 1992 - a bug
+
+Dear Judges,
+
+albert.c (even in its fixed form) still has a bug. Although I don't
+remember the number that exposed the bug (afair, resulting in coredump)
+in albert.orig.c that has been fixed in albert.c,
+
+I've found a number exposing another bug: 10000000001 (that's 9 0's).
+Both albert and albert.orig loop without printing anything, although
+the first factor is 101 and is usually found in an instant.
+

The albert.alt.c file is the fixed file, +whereas the albert.c is the file before applying +Leo Broukhis’ fix.

+

Alternate build:

+

To compile this alternate version:

+
make alt
+

Alternate use:

+

Use albert.alt as you would albert +above.

+

Alternate try:

+
./try.alt.sh
+

Judges’ remarks:

+

We were impressed with the speed at which it was able to factor +arbitrarily large numbers consisting of factors that fit into a +long.

+

Author’s remarks:

+

The Obfuscated version of the Horst algorithm.

+

This program will factor unlimited length numbers and print the +factors in ascending order. Numbers of one digit (e.g. 8) are rejected +without notice.

+

It quits as soon as there is at most one factor left, but that factor +will not be shown. It accomplishes this efficiently, without resorting +to division or multiplication, until the candidate factor no longer fits +in a signed long.

+

The nicest way is to rename the program into e.g. 4294967297 if you +want to factor Fermat’s 4th number. Then just run it.

+

Or you may type ./albert <some-number> A nice one +is also (30 ones):

+
./albert 111111111111111111111111111111
+

Apart from the foregoing there are no special execution +instructions.

+

To customize the program into a factorizer of a fixed number, use

+
cc albert.c -o 4294967297
+

or some such.

+

There are no data files used, and it is not possible to feed input +via stdin.

+

I think this program is a nice example of algorithmic obfuscation. +Several times two similar algorithms are merged into one. Then you need +quite some tricks to get it running, such as long jumps through +recursive subroutines. I felt like a sword smith, welding the sword very +long, folding it again to the proper length, keep on hammering till it +is tight, then fold again. Always keeping it at the proper red hot +temperature, but not too hot lest the hardness fades.

+

The strict naming conventions for subroutines did not make things +much clearer after all, but it was not supposed to.

+

I would like to draw attention to the robustness of the program with +respect to error handling and the nice stopping criterion. The aesthetic +appeal of some lines is at the expense of clearness, I apologize.

+

Running the program through the C-beautifier reveals nothing, it will +only destroy some of the lay out. Running the program through lint shows +the usual remarks for a K&R program. Defeating this through casts +does not make a program cleaner in my opinion.

+

Hints

+

Here are some hints, but they may not be too helpful:

+
    +
  1. The Horst algorithm is described in the Hobby Computer Club +Newsletter, year 82, part 4, a real Dutch treat. Assembly, C and Forth +version have been around for some years.
  2. +
  3. Does fractal programming exist after all?
  4. +
  5. You remember the Toom-Cook algorithm in Knuth? It uses iteration +instead of recursion and is quite jumpy. This program shares these +disadvantages in a modified form.
  6. +
  7. The Conversion is to be found in Knuth, not so the Observation. The +Observation: “if it ends in a zero, it is divisible by ten”.
  8. +
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1992/albert

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1992/ant/index.html b/1992/ant/index.html index 633d2ebcb..c6916f64e 100644 --- a/1992/ant/index.html +++ b/1992/ant/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,210 @@ - - + + + + + + - - -1992 ant - - + + + +1992/ant + + + + + -

1992 ant

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1992/ant

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1992/ant/index.html

- +
+ ← albert + ↑ 1992 ↑ + buzzard.1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Anthony C. +Howe
Location: CA

+ + +

To build:

+
make all
+

To use:

+
./ant Makefile
+
+./ant Makefile rule
+

where Makefile is a Makefile to use and +rule is an optional rule to use.

+

Try:

+
./try.sh
+

Judges’ remarks:

+

Like much of POSIX, obfuscation has its place. Your task is to figure +out where.

+

This entry comes complete with a POSIX-like command description. +Interested POSIX balloters should lobby the IEEE for an obfuscated P1003 +subcommittee.

+

Author’s remarks:

+

See the file ant.README.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1992/ant

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1992/buzzard.1/index.html b/1992/buzzard.1/index.html index b215348c2..9d602ee60 100644 --- a/1992/buzzard.1/index.html +++ b/1992/buzzard.1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,350 @@ - - + + + + + + - - -1992 buzzard.1 - - + + + +1992/buzzard.1 + + + + + -

1992 buzzard.1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1992/buzzard.1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1992/buzzard.1/index.html

- +
+ ← ant + ↑ 1992 ↑ + buzzard.2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Sean Barrett
+Location: unknown

+ + +

To build:

+
make all
+

To use:

+
./buzzard.1 num num
+

Try:

+
./try.sh
+

Judges’ remarks:

+

To see good C Preprocessor buzzard.1, try:

+
make babble.cppcb
+cat babble.cppcb
+

Notice how many statements it takes to do anything useful?

+

Author’s remarks:

+

What you shouldn’t think about buzzard.1:

+

buzzard.1 doesn’t just do a mass of +#defines as its obfuscation.

+

What you should be glad +about:

+

I didn’t just submit the post-C-preprocessed output as an entry.

+

Cute trick warning

+

buzzard.1 contains only a numeric +printf(3), yet sometimes it prints out short strings.

+

What it does

+

buzzard.1 is a simple mathematical program. It expects +two numeric arguments.

+
./buzzard.1 0 <num>
+

will print out the factorial of <num>.

+
./buzzard.1 <num1> <num2>
+

will print out the largest common factor of num1 and +num2.

+
./buzzard.1 1 <num2>
+

will print out a factor of num2 if it’s composite, or +else it will print a string informing you that num2 is +prime.

+

If the first argument is less than 0, it prints out an error +message.

+

What it is

+

buzzard.1 is a translator from a pseudo-assembly +language into a subset of C suitable for execution on Charles Babbage’s +Analytical Engine. Or rather, the #defines in +buzzard.1 are that translator. The rest of +buzzard.1 is a buzzard.1 program. If you run +the whole mess through CPP and a beautifier, you will see that all you +have is a loop that runs until a variable is not 0, and a sequence of +assignment statements. The assignment statements are all of the form +a op= b or a = b. The Engine actually allowed +‘a = b op c’. Only +, -, /, and +* are used–no boolean or bitwise operators. The infinite +loop could have been simulated on the AE by connecting the +already-processed card stack to the input card stack.

+

How to try to understand it

+

Don’t expand the #defines! Rather, decipher +what they do. Some of them are mere obfuscation fodder, put in to +encourage you to run it through CPP.

+

What it doesn’t do +quite right as an emulator

+

Because of the definitional constraints, calls to +atoi(argv[#]) also appear inside the loop. These could be +put outside–the initial values of the “registers” on the AE–but the +macro conventions being used didn’t lend themselves to it.

+

Theoretical observations

+

The simulated comparison operations only work with a certain range of +numbers; numbers that are too large will cause the output code to fail +to simulate the input code. This means that this implementation of +buzzard.1 would not be Turing-complete, even if the AE +could process indefinitely-sized numbers. However, this is actually a +constraint that no actual computer can meet, either, so we can conclude +that if an AE, with card bins connected as suggested above, were hooked +up to a memory unit of sufficient size, it would be as Turing complete +as any existing machine (or, for those who interpret that excessively +critically, i.e. “not at all” for both, we can simply say that the AE +could simulate any existing machine–although not quickly). This would be +a good place to site some references on the AE, but I don’t have +any.

+

Definition +of the input language to buzzard.1 (OR What Exactly Do All The Macros +Do?)

+

[Don’t read this unless you’re stumped!]

+

+MACRO       FUNCTION                MNEMONIC
+
+V               begin variable declarations     Variable
+C               begin program               Code
+
+Q(b,a)          let b = a               eQuals
+A(c,a,b)        let c = a + b               Add
+S(c,a,b)        let c = a - b               Subtract
+D(c,a,b)        let c = a / b, where b is a *constant*  Divide
+U(c,a,b)        let c = a / b, where b is anything      Unknown
+M(c,a,b)        let c = a * b               Multiply
+
+O(c,a,b)        let c = a boolean-or b (a,b are 0 or 1) Or
+B(b, a)         let b = boolean value of a      Boolean
+P(b, a)         let b = 1 if a>0, else 0.       Positive
+
+l               emit next sequential label      Label
+J(x)            goto label #x               Jump
+
+Z(a,d)          if a is 0 goto d    (a is 0 or 1)   Zero
+E(a,d)          if a is 1 goto d    (a is 0 or 1)   Else
+
+H               halt                    Haly
+
+K(x)            let x = number of cmd line arguments    Kount
+G(x,y)          let x = the value if the yth argument   Get argument
+
+T               end of code; begin output section   Terminate
+X(y)            print out hexadecimal value of y    heXadecimal
+T               end of output section and program   Terminate
+

You can figure out the other macros yourself. In the sample program, +I’ve actually implemented subroutines by saving a return address in a +variable and then jumping to a routine– specifically, a routine that +converts a number into BCD, so it can be output by the hexadecimal +output statement.

+

How it +works, i.e., how to get useful programs from a op= b

+

The essential statement to be able to make interesting programs is +the conditional (given that we have loops). Since all you can do in the +given operation output set is assignment, we implement “conditional +assignment”:

+
if (x) y = z;
+

To implement this, we constrain x to be either 0 or 1, +and simply compute:

+
y = (z * x) + (y * (1-x));
+

This is more obscured by factoring out common terms and restricting +ourselves to two operand operations:

+
temp = z;                       (temp == z)
+temp -= y;                      (temp == z-y)
+temp *= x;                      (temp == (z-y)*x)
+y += temp;                      (y    == (z-y)*x + y)
+                (     == z*x - y*x + y)
+                (     == z*x + y*(1-x))
+

Next we imagine we have a pc. “I’m +supposed to execute statement pc next”, says our emulator. But suppose +we’re not currently coming up on statement pc. To handle this, we simply +make every operation conditional on the pc having the correct value:

+
if (pc == some_constant) y = z;
+

To combine this with other operations, we simply multiply by our +(pc == some_constant) flag right after the above +temp *= x.

+

To evaluate pc == some_constant requires one more trick. +We assume that numbers can only be in some limited range. Then we use +successive additions and divisions to reduce that number down to +-1, 0, or 1. You could, for +instance, do this by using mod by 2 and div by +2 to count bits, stopping after, say, 32 +iterations. The number you get is between 0..32, so another +6 iterations on it reduces it to 0..6. Three +iterations on this produces 0..2 (3 would be +7), and then two iterations on this produces 0 or 1. +Instead I use a shorter two-divide approach that assumes I’m allowed to +use numbers slightly larger than the numbers I’m operating on.

+

A similar approach is used to detect positive numbers.

+

Note that the obvious code to compute y/x will not work +correctly, because every value is computed, even if the pc is not set +correctly; if x is ever 0 when the real C code +reaches this computation the program will die. (This was discovered the +hard way.) The solution is to stick x in a temporary, and +if the current code is not about to be executed, set the temporary to +1.

+

Thanks to Bill Pugh for bringing the loop-ability of the AE to my +attention.

+

buzzard.1 was originally named ‘cb’, for obvious +reasons, and is dedicated to the memory of Charles Barrett.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1992/buzzard.1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1992/buzzard.2/index.html b/1992/buzzard.2/index.html index 14dbfd874..e7a366415 100644 --- a/1992/buzzard.2/index.html +++ b/1992/buzzard.2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,418 @@ - - + + + + + + - - -1992 buzzard.2 - - + + + +1992/buzzard.2 + + + + + -

1992 buzzard.2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1992/buzzard.2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1992/buzzard.2/index.html

- +
+ ← buzzard.1 + ↑ 1992 ↑ + gson → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Sean Barrett
+Location: unknown

+ + +

To build:

+
make all
+

There is an alternate version of this program. See Alternate code below for details.

+

To use:

+

First, you must make sure that first is made first (even +though make all should make first first :-) ):

+
make first
+

Second:

+
# get help:
+echo help | cat third help.th - | ./first
+
+# try out a demo:
+cat third demo5.th | ./first
+

Third:

+
cat third help.th - | ./first
+

NOTE: Wait until ‘Ok’ is printed and the type:

+
2 3 + . cr
+

Yes you should really type the 2 letters: cr.

+

Fourth:

+
Sorry, this is third!
+

Try:

+
./try.sh
+

Alternate code:

+

This alternate version, buzzard.2.alt.c, does not contain a fix that +the author notes in their remarks.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use buzzard.2.alt as you would buzzard.2 +above.

+

Alternate try:

+
./try.alt.sh
+

Judges’ remarks:

+

Have fun!

+

Author’s remarks:

+

What it does

+

first implements a relatively primitive stack machine. +How primitive? It supplies 13 visible primitives: 3 arithmetic, 1 +comparison, 2 memory-access, 2 character I/O, 3 primitives for defining +new words, 1 tokenizing, and 1 special stack operation. (There are also +three internal operations for the stack machine: ‘push this integer’, +‘call this code’, and ‘compile a call to this code’.)

+

It is very difficult to accomplish anything with this set of +primitives, but they do have an interesting property.

+

This–what this interesting property is, or in other words what first +is good for–is the major obfuscation; there are also minor source +obfuscations, as well as some design tricks that are effectively +obfuscations. Details on the obfuscations are below, and the interesting +property is discussed much further down.

+

How to run it

+

first expects you to first enter the names of the 13 +primitives, separated by whitespace–it doesn’t care what you name them, +but if all the names aren’t unique, you won’t be able to use some of +them. After this you may type any sequence of valid first +input. Valid first input is defined as any sequence of +whitespace-delimited tokens which consist of primitives, new words +you’ve defined, and integers (as parsed by "%d"). Invalid +input behaves unpredictably, but gives no warning messages. A sample +program, demo1.1st, is included, but it only works on ASCII +systems.

+

Do not expect to be able to do anything interesting with +first.

+

To do something interesting, you need to feed first the +file third first. In unix, you can do

+
cat third help.th - | ./first
+

to do this. Hopefully most operating systems will provide a way to do +this. It may take some time for this to complete (I seem to remember it +taking several minutes on an 8086 PC); THIRD will prompt +you when it is finished. The file third has not been +obfuscated, due to sheer kindness on the author’s part.

+

For more information on what you can do once you’ve piped third into first, type help and consult FORTH +manuals for further reference. Six sample THIRD programs are included in +the files demo[1-6].th. buzzard.2.README.md has more +information.

+

Keep in mind that you are still running first, and are +for the most part limited by first’s tokenizer (notably, +unknown words will attempt to be parsed as integers.) It is possible to +build a new parser that parses by hand, reading a single character at a +time; however, such a parser cannot easily use the existing dictionary, +and so would have to implement its own, thus requiring reimplementing +all of first and third a second time–I did not +care to tackle this project.

+

Compiling

+

first is reasonably portable. You may need to adjust the +size of the buffers on smaller machines; m[] needs to be at +least 2000 long, though.

+

I say first is portable mainly because it uses native +types. Unlike +[FORTH](https://en.wikipedia.org/wiki/Forth_(programming_language), +which traditionally allows byte and multi-byte operations, all +operations are performed on C ints. That means +first code is only as portable as the same code would be in +C. As in C, the result of dividing -1 by 2 is +machine (or rather compiler) dependent.

+

How is first obfuscated?

+

first is obfuscated in several ways. Some minor +obfuscations like &w[&m[1]][s] for +s+m[w+1] were in the original source but are no longer +because, apparently, ANSI doesn’t allow it +(gcc -ansi -pedantic doesn’t mind it, though.)

+

Other related obfuscations are still present. The top of the stack is +cached in a variable, which increases performance massively if the +compiler can figure out to keep it in a register; it also obfuscates the +code. (Unfortunately, the top of stack is a global variable and neither +gcc nor most bundled compilers seem to register allocate +it.)

+

More significant are the design obfuscations. m[0] is +the “dictionary pointer”, used when compiling words, and +m[1] is the return stack index. Both are used as integer +offsets into m. Both are kept in m, instead of +as separate pointers, because they are then accessible to +first programs, which is a crucial property of +first. Similarly the way words are stored in the dictionary +is not obvious, so it can be difficult to follow exactly what the +compiler words are doing.

+

Assuming you’ve waded through all that, you still have to penetrate +the most significant obfuscation. Traditionally, the question is whether +a reader can answer the question “what will this do when I run it”. A +reader who has deciphered first to this point may think +they know the answer to this question, but they may not know the answer +to the more important question, “what will this program do when given +the right input?” FORTH +aficionados, and especially FORTH implementers, may recognize the +similarity of the internal compiler format to many FORTH internal +representations, and, being aware that FORTH interpreters can often be +self-compiling, may be suspicious that this program can compile FORTH, +or a significant subset of it, or at least be capable of doing so if fed +the right input. Of course, the name “THIRD” should be a dead giveaway, +if the name “first” wasn’t. (These numbers were largely chosen because +they were five letters long, like “FORTH”, and would not require +truncation to five letters, which would be a dead giveaway. Besides, +THIRD represents a step backwards, in more ways than one.)

+

What exactly is first, +then?

+

first is a tiny interpreter which implements a +sufficient pseudo-subset of FORTH +to allow it to bootstrap a relatively complete version of FORTH (based +loosely on forth79), which I call THIRD. Complete relative to what, I’m +not sure.

+

I believe first is close to the smallest amount of code +possible to get this effect using forth-style primitives, and +still have some efficiency (it is possible to get by without +multiplication if you have addition, obviously). In the design file, +design, I give a justification for why each primitive in +first was included.

+

THIRD is sorta slow, because first has so few primitives +that many things that are primitives in FORTH +(like swap) take a significant amount of time in THIRD.

+

When you get the Ok. message from third, +try out some sample FORTH +code (first has no way of knowing if keyboard input is +waiting, so it can’t actually prompt you in a normal way. It only prints +'Ok.' after you define a word).

+
2 3 + . cr
+

(which adds 2 and 3, and print the result and a newline.)

+

THIRD responds:

+
5
+

Now try:

+
: test 11 1 do i . loop cr ;
+test
+

and THIRD responds

+
1 2 3 4 5 6 7 8 9 10
+

When in THIRD, you can see how much space you’re +currently using by typing:

+
here .
+

The number THIRD replies with is the number of machine words +(ints) that the dictionary (the first code) takes up, plus +the 512 ints for the return stack. If you compile the basic +THIRD system without the help word (strings take up one int +per character in the string!), you should find that you’re using around +1000 ints (plus the return stack).

+

Thus THIRD gives you a relatively complete FORTH +system in less than 700 chars of C source + about 1000 ints +of memory–and it’s portable too (you could copy over the THIRD memory +dump to another machine, in theory). If the above numbers seem to you to +be mixing apples and oranges (C source and compiled THIRD code), note +that you should in theory be able to stick the compiled THIRD code into +the C source.

+

Software Construction Company gets credit for rekindling my interest +in FORTH and thus indirectly inspiring me to write this program.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1992/buzzard.2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1992/gson/index.html b/1992/gson/index.html index bd8fafef1..90a61178c 100644 --- a/1992/gson/index.html +++ b/1992/gson/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,385 @@ - - + + + + + + - - -1992 gson - - + + + +1992/gson + + + + + -

1992 gson

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1992/gson

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1992/gson/index.html

- +
+ ← buzzard.2 + ↑ 1992 ↑ + imc → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Andreas +Gustafsson
Location: FI

+ + +

To build:

+
make all
+

NOTE: we DISABLE the optimiser because having it enabled causes some +invocations to crash in some systems.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: uses gets() - change to fgets() if possible
+

For more detailed information see 1992 +gson in bugs.md.

+

To use:

+
./ag word word2 word3 < /path/to/dictionary
+

Try:

+

Determine where your system dictionary is located. You may find it +located in one of the following places:

+
/usr/share/dict/words
+/usr/share/lib/spell/words
+/usr/ucblib/dict/words
+/dev/null           # <-- for machines with nothing to say
+

Then using the proper dictionary:

+
./ag free software foundation   < /usr/share/dict/words
+./ag obfuscated c contest   < /usr/share/dict/words
+./ag unix international     < /usr/share/dict/words
+./ag george bush        < /usr/share/dict/words
+./ag bill clinton       < /usr/share/dict/words
+./ag ross perot         < /usr/share/dict/words
+./ag paul e tsongas     < /usr/share/dict/words
+

Judges’ remarks:

+

Recently some newspapers printed amusing anagrams of one of the names +listed above. Run this program to find the anagrams they weren’t allowed +to print!

+

The author provided an obfuscated script that can be used to +construct dictionaries which has been put in as mkdict.sh. To use try:

+
cat README.md | ./mkdict.sh > words
+

Then try using the program as shown above with the file +words.

+

Author’s remarks:

+

The name of the game:

+

AG is short for either Anagram Generator or simply AnaGram. It might +also be construed to mean Alphabet Game, and by pure coincidence it +happens to be the author’s initials.

+

What it does

+

AG takes one or more words as arguments, and tries to find anagrams +of those words, i.e. words or sentences containing exactly the same +letters.

+

How to use it

+

To run AG, you need a dictionary file consisting of distinct words in +the natural language of your choice, one word on each line. If your +machine doesn’t have one already, you can make your own dictionary by +concatenating a few hundred of your favourite Usenet articles and piping +them through the following obfuscated shell script:

+
#!/bin/sh
+z=a-z];tr [A-Z\] \[$z|sed s/[\^$z[\^$z*/_/g|tr _ \\012|grep ..|sort -u
+

Using articles from alt.folklore.computers is likely to make a more +professional-looking dictionary than rec.arts.erotica.

+

AG must be run with the dictionary file as standard input.

+

Because anagrams consisting of just a few words are generally more +meaningful than those consisting of dozens of very short words, the +number of words in the anagrams is limited to 3 by default. This limit +can be changed using a numeric command line option, as in +./ag -4 international obfuscated c code contest </usr/dict/words.

+

Bugs and limitations

+ +

Obfuscatory notes

+

As you can see, AG takes advantage of the new ‘92 whitespace rules’ +to achieve a clear, readable, self-documenting layout. The identifiers +have been chosen in a way appropriate for an alphabet game, and common +sources of bugs such as goto statements and malloc/free have been +eliminated. As AG also refrains from abusing the preprocessor, it +doesn’t really have much to offer in terms of “surface obfuscation”. +Instead, it tries to achieve both its speed and its obscurity through a +careful choice of algorithms. Some of the finer points of those +algorithms are outlined in the spoiler below.

+

How it works:

+

Here follows a description of some of the data structures and +algorithms used by AG. It is by no means complete, but it may help you +get an idea about the general principles.

+
+

Internally, AG represents words and sentences as arrays of 32 4-bit +integer elements. Each element represents the number of times a letter +occurs in the word/sentence. There are 32 elements because 32 is a +convenient power of two larger than the number of letters in most +western alphabets, and the elements are 4 bits each because the same +letter is unlikely to occur more than 15 times in a practical anagram +generation problem.

+

These 32*4-bit arrays are actually stored in memory in a +“bit-transposed” format, as arrays of four long values. It +is assumed that a long is at least 32 bits. The first 4-bit +letter count is formed by the least significant (2^0) bit +in each of the four longs, the next one is formed by the +2^1 bits, etc.

+

This storage format makes it possible to add or subtract two such +vectors of 32 4-bit values in parallel by simulating a set of 32 binary +full adders in software using bitwise logical operations. E.g., all the +LSBs of the result are formed in parallel by taking the exclusive OR of +the LSBs in each summand, and 32 carry bits are formed in parallel in a +similar way using a logical AND. Thus, 32 independent 4-bit additions +can be performed by just four iterations of a loop containing some +32-bit bitwise logical operations, but no arithmetic operations other +than those implied by array indexing.

+

Subtraction works similarly, and in fact AG only implements +subtraction directly, handling addition by means of the identity +a+b = a-(0-b).

+

In addition to this 32*4-bit representation, AG also +forms a so-called “signature” that is the bitwise OR of the four +longs, which is equivalent to saying that the signature of +a word contains a logical 1 in the bit positions corresponding to +letters occurring at least once in that word.

+

The first thing AG does is to construct a lookup table of 256 +longs, one for each 8-bit character value. The entry for a +character will be zero if that character doesn’t appear in the sentence +given on the command line, or it will have a single bit set if the +character does appear in the sentence. By adding together the bit masks +for all the letters in the input sentence using the transpose addition +method described above, AG forms the 32*4 bit array +representation of the input sentence.

+

The next action performed is reading the dictionary. Those words that +contain letters not in the input sentence are immediately discarded. +Words containing the right letters but in excessive numbers are +eliminated in a separate check involving the 32*4 bit +array.

+

The remaining words, which will be referred to as “candidate words”, +are stored in 32*4-bit representation, together with their +signatures and offsets into the dictionary file so that the plain-text +version of a word can later be found for printing. This information is +kept in a local struct in the dictionary-reading function, +and memory is allocated for each candidate word simply by making another +recursive call to that function.

+

Each struct so allocated is linked into a fixed-size +hash table of 4096 entries indexed by the 12 low bits of the word’s +signature. When the dictionary-reading function encounters end-of-file, +all the candidate words have been stored in nested activation records on +the stack, accessible through the hash table.

+

Generating the anagrams is then done by traversing the hash table and +subtracting the letters of each word in the hash table from the “current +sentence”, which initially is the sentence given on the command +line.

+

The subtraction is performed in parallel on the 4-bit letter counts +as described above, and if all 32 results are zero, an anagram has been +found. If the result is negative for one or more of the letters (as +indicated by one or more 1s in a vector of 32 borrow bits +returned by the subtraction routine), the word did not match the current +sentence and is ignored. Finally, if the result contained only +non-negative letter counts, we have found a partial anagram: a word +containing some, but not all, of the letters in the current sentence. In +this case we recursively try to find an anagram of the remaining +letters. The depth of the recursion is limited to the maximum number of +words in the anagram, as specified by the user.

+

When the deepest recursion level has been reached, an optimization +can be applied: because no further recursion will be done, there is no +need to look for partial anagrams, and therefore AG only needs to check +for words that contain exactly the same letters as the current sentence. +Those words can be found simply by indexing the hash table with the +signature of the current sentence.

+

Even when not on the deepest recursion level, AG generally avoids +examining all the entries of the hash table. The idea is that we are not +interested in hash buckets whose words contain any letters not in the +current sentence; these buckets are exactly those whose index has a +logical one in a bit position where the signature of the current +sentence has a zero. Put another way, we want to loop through only those +hash bucket indices i that contain zeroes in all the bit +positions where the signature s of the current sentence +contains a zero; this can be expressed in C as +(i & ~s == 0).

+

It is possible to loop through all such numbers in an efficient way +by taking advantage of certain properties of binary arithmetic: by +forcing the bits corresponding to zeroes in s to ones, we +can make the carries generated in incrementing i propagate +straight across those bits that should remain zero. For example, the +following program prints all those 16-bit integers that contain zeroes +in all even bit positions:

+
main(){int i=0,s=0xAAAA;do{printf("%04x\t",i);}while(i=((i|~s)+1)&s);}
+

AG uses a similar method but works in the opposite direction, finding +the next lower value with zeroes in given bit positions by propagating +borrows across those bits. Some additional adjustments are made to the +hash table index when initiating a recursive search, using similar +bit-twiddling techniques.

+

Whenever an anagram has been found, it is printed by traversing a +linked list formed by structs in the activation records of +the recursive invocations of the search function, seeking to the +beginning of the word matched by that invocation, and copying the +characters of the word directly from standard input to standard +output.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1992/gson

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1992/imc/index.html b/1992/imc/index.html index 42344b8be..b04461f88 100644 --- a/1992/imc/index.html +++ b/1992/imc/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,321 @@ - - + + + + + + - - -1992 imc - - + + + +1992/imc + + + + + -

1992 imc

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1992/imc

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1992/imc/index.html

- +
+ ← gson + ↑ 1992 ↑ + kivinen → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Ian Collier
+Location: GB

+ + +

To build:

+
make all
+

To use:

+
# text mode
+./imc -text
+
+./imc
+

Try:

+

To see a number of options and configurations:

+
./try.sh
+

Judges’ remarks:

+

The program is more interesting to run on workstations that can make +use of a Sun raster file. Others can make use of the -text flag for +character oriented output.

+

Of course, the source (layout) is self-documenting! :-)

+

NOTE: The original winning source assumed that exit(3) +returned a value which cause problems for some systems where +exit(3) returns a void. The file imc.c +has been modified to avoid this problem. The original file also declared +argc to be a long which was fixed.

+

Author’s remarks:

+

Portability

+

This program depends upon the ASCII character set, and makes certain +assumptions about the architecture. It naughtily declares the first +argument to main() as a long, and passes a +pointer to long instead of char to +fwrite(3), giving a length value of 32 bytes for an array +of 8 longs. I guess that makes this program OK on most +flavours of unix, but not on PCs.

+

About the program

+

This program has several parameters; each of them has a default, so +the program runs happily without any parameters. If you supply an +incorrect parameter, an obfuscated error message results! :-) Should you +want to run the program without knowing what it does, then supplying the +single letter t as a parameter is a good move. Otherwise, +direct the output into a file. The resulting file is most useful on +SunOS, where the file(1) command will tell you what to do +with it. For best results with the t option, you may want +to change the definition of the I macro :-) Details appear +later, though the formatting of the code is a large clue.

+

All the code in this program appears between the ; and +) in for(;;). That isn’t because I want to win +the best one-liner, but merely because it makes the code so much more +impenetrable :-) In fact running a pretty printer on the code hardly +improves it at all. This program has the obligatory macros with +unmatched parentheses, and the cleverly arranged macro names and +parameters to spell out "Ian Colliers Obfuscated C Code". +If you expand macros, bear in mind that the more complex ones are best +left as macros, because they have well-defined and nontrivial (IMHO) +functions. These macros help to give the program’s parameter format its +flexibility. The parameters are sorted out in a unique way (based on an +idea by Pete Bevin) which hides very effectively their identities (and I +think that using a variable called _ adds a nice touch to +the illegibility of the code). In this section of the code, the data +types of the numbers checked against is varied, and just because you see +a , doesn’t mean it has anything to do with commas! So I +hope you will agree that this program is more than a little +obfuscated…

+

This is a Mandelbrot/Julia drawer. Normally it produces a monochrome +Sun-format raster file. The version of xloadimage we have +is able to view such files, and so is Sun’s screenload +command. [Note: the header contains eight 4-byte integers, the byte +order in which depends upon the machine. On Sun workstations they are +stored MSB first].

+

The program may be asked to produce text output instead of a raster +file. Then the characters defined in the I macro will be +used to create up to 16 different shades of grey. Quite a respectable +picture can be gained by printing a 130x110 output on a dot matrix 132 +column printer with the linefeed set to 7 points. Text output also +gives a good picture when used in an X window with small characters +having a square aspect ratio.

+

The options accepted by the program follow. Each option is a single +letter; it may be preceded with a minus sign (or any character in +[!-/]) and may be followed by other letters, so for +example:

+ +

all mean the same thing. Most options may be followed by one or two +numbers. These numbers may be separated from each other and from the +option by a space, or may be joined to each other with a comma, or may +be appended to the single-letter option, so

+ +

all mean the same (note that in -size123 all characters +following the initial s are ignored). Numbers need not be +specified, as each has a default value. In all cases except for +j, t, and s whenever it appears +before t, specifying an option without numbers has no +effect. (specifying -s -t has the effect of producing text +with the default raster size; not a good idea!).

+

Options

+

The options of this program are:

+
-centre x y  (float x,y) Centre the picture at x+iy in the complex
+             plane (default x=0 y=0)
+
+
+-factor f    (float f)   Use f pixels per unit of the plane (default
+             f=x/4 where x is the width)
+
+
+-julia  x y  (float x,y) Draw a julia set. Use x+iy as the constant
+             to add after squaring (default x=0 y=0)
+
+-limit  l    (int l)     Use l iterations maximum (default l=128)
+
+-mask   m    (int m)     Use m as a mask in deciding the colour of each
+             pixel (see below) (default m=1)
+
+-size   x y  (int x,y)   Produce an x-by-y output (default for raster
+             x=768 y=768; default for text x=63 y=23)
+
+-text                    Produce text instead of raster.
+

The colour of each point is determined by taking the bitwise AND of +the number of iterations and the mask. For a raster, the point is black +(1-bit) if the result is zero, white otherwise. For text, the result of +the operation determines the greyness of the character produced, with a +blank for zero going up to a star for the maximum value. For a +four-colour picture, for example, use a mask with two bits set (e.g. 3), +and for a 16-colour picture use a mask with four bits set (e.g. 15). For +a picture with coarse detail, use a mask which ends with several zero +bits (e.g. 8).

+

While the program is creating your picture, it displays dots on the +standard error to indicate its progress (one dot per pixel line).

+

Example pictures to try

+

Here are a couple of good pictures to draw:

+
./imc -s 512,512 -f 600000 -l 512 -m 16 -c.00805,.74274 > screen1.ras
+./imc -s512,512 -j-.523,-.535 > screen2.ras
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1992/imc

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1992/kivinen/index.html b/1992/kivinen/index.html index 0dfda5115..58657f31e 100644 --- a/1992/kivinen/index.html +++ b/1992/kivinen/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,283 @@ - - + + + + + + - - -1992 kivinen - - + + + +1992/kivinen + + + + + -

1992 kivinen

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1992/kivinen

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1992/kivinen/index.html

- +
+ ← imc + ↑ 1992 ↑ + lush → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Tero Kivinen
+Location: FI

+ + +

To build:

+

If your machine support the X Window System, Version 11:

+
make alt
+

We recommend that you try the alt version first so you can get a +better idea of what this looked like back in 1992. See original code for the original should you wish +to see what we mean.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: known bug - please help us fix
+

For more detailed information see 1992 kivinen in bugs.md.

+

To use:

+
./kivinen.alt
+
+./kivinen.alt a
+
+./kivinen.alt a b
+

See also the author’s remarks for other variations.

+

Try:

+

Also try changing the speed that the game moves. For instance if you +wish to change the usleep(3) value to 30000 +from 20000, try:

+
make clobber SLEEP=30000 alt # make it slower
+
+make clobber SLEEP=10000 alt # make it faster
+

Then use the same syntax as above and described by the author.

+

Original code:

+

As noted above, the alt version is recommended because the code goes +too fast in modern systems. If you wish to see the original you may do +so with the original code.

+

Original build:

+
make all
+

Original use:

+

Use kivinen as you would kivinen.alt.

+

Judges’ remarks:

+

The type of entertainment depends on number of arguments you have +with the program. :-)

+

NOTE: Some systems do not need (or have) +-lsocket -lresolv -lnsl. Such systems should compile using +-lX11.

+

NOTE: The original winning source kivinen.orig.c assumed that +exit(3) returned a value which cause problems for some +systems where exit(3) returns void. The file +kivinen.c avoids this problem.

+

Author’s remarks:

+

X Entertainment Kit

+

This kit includes three games from the early era of video games +designed for the X Window System Version 11 Release 5. It should work +with earlier releases, though.

+

Space Invaders

+

The classic game of shooting aliens from outer space, trying to +exterminate all life on earth. The game ends when the first line of +aliens touches the ground, or destroy you. To win the game you must +destroy all the aliens. If you evade out from the screen you lose.

+
Controls
+ +

Breakout

+

Break all the bricks with the ball, using your paddle. If you miss +the ball the game ends.

+
Controls
+ +

Dropout

+

Catch all the falling pieces, before they reach the ground. If you +miss it, game ends. To win you must catch all 30 pieces.

+
Controls
+ +

Starting a game

+

The type of the game is determined by the number of arguments given +to the program.

+ +

…and so on…

+

Scores

+

The exit value of the game is your score. The smaller the score the +better it is. The exit value of zero means you have won.

+

Features

+

The game has a cheat system, which can be found after examining the +event loop at the end of program. It is not a bug, it’s a feature!

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1992/kivinen

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1992/lush/index.html b/1992/lush/index.html index 4f4022c28..66d0d4431 100644 --- a/1992/lush/index.html +++ b/1992/lush/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,202 @@ - - + + + + + + - - -1992 lush - - + + + +1992/lush + + + + + -

1992 lush

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1992/lush

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1992/lush/index.html

- +
+ ← kivinen + ↑ 1992 ↑ + marangon → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Ed Luke
Location: +US

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: doesn't work with some compilers - please provide alternative code or fix for more compilers
+

For more detailed information see 1992 +lush in bugs.md.

+

To use:

+
./lush.sh
+

Judges’ remarks:

+

The program uses error messages issued by the C Preprocessor to +generate its message to the world. One program’s error is another +program’s data!

+

Author’s remarks:

+

This program is yet another “Hello World.” program with a twist. The +string Hello World has been encoded in the error messages the compiler +generates when compiling the source.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1992/lush

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1992/marangon/index.html b/1992/marangon/index.html index f7ab29b22..b1677a2a0 100644 --- a/1992/marangon/index.html +++ b/1992/marangon/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,206 @@ - - + + + + + + - - -1992 marangon - - + + + +1992/marangon + + + + + -

1992 marangon

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1992/marangon

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1992/marangon/index.html

- +
+ ← lush + ↑ 1992 ↑ + nathan → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Andrea +Marangoni
Location: IT

+ + +

To build:

+
make all
+

To use:

+
./marangon
+

Judges’ remarks:

+

The object is to refill the table with 5’s, by incrementing or +decrementing numbers as needed. It is the side effects that get you into +trouble. If you are not careful, you may find things “at 6’s and 7’s”. +:-)

+

NOTE: Some compilers have had trouble optimizing this entry.

+

NOTE: Some systems need to compile with -ltermcap as +well as -lcurses.

+

NOTE: The original winning source marangon.orig.c, found in the archive +directory, assumed that exit(3) returns a value which cause +problems for some systems where exit(3) returns a +void. The file marangon.c avoids +this problem.

+

Author’s remarks:

+

It starts off by creating a table with number 5 in all places. The +CPU melts the numbers and you must return them in original state. When +you increase a number, all the other eight numbers next to it decrease +and vice-versa.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1992/marangon

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1992/nathan/index.html b/1992/nathan/index.html index 7a7e73d40..01552ebbd 100644 --- a/1992/nathan/index.html +++ b/1992/nathan/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,273 @@ - - + + + + + + - - -1992 nathan - - + + + +1992/nathan + + + + + -

1992 nathan

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1992/nathan

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1992/nathan/index.html

- +
+ ← marangon + ↑ 1992 ↑ + vern → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Nathan +Sidwell
Location: GB

+ + +

To build:

+
make all
+

To use:

+
./nathan
+# enter some text
+

Try:

+

To see some other fun uses:

+
./try.sh
+

Judges’ remarks:

+

WARNING:

+

The judges make no claim as to the strength or security of this +program. It is likely to be nil, or the next best thing to it. Still, +you might consider installing it in /usr/games/nathan. +:-)

+

Note from the +judges about the winning category::

+

The ‘winning’ category is also open to question. One could say that +it is a ‘file obfuscator’. One could also say that it unintentionally +abused the intent of rule #7 (that programs should be freely +re-distributable). We suspect that the author may not have intended to +do this, but that is the way things go sometimes.

+

BTW, ‘abuse of the rules’ entries do not violate the rules. Entries +that violate the rules are disqualified. Abuse of the rules entries are +ones that tend to ‘stretch’ the limits and take the contest into +unexpected territory.

+

Historical +notes from the judges about this entry:

+

The US International Traffic in Arms Regulations controls certain +exportations going out of the United States. The U.S. Munitions List +gives the specific categories of restricted exports. Because this entry +at one time appeared to fall under this restricted category, the judges +originally were not able to distribute winners outside of the US.

+

Nathan Sidwell stated that he was willing to distribute the winning +source. To read HIS instructions of how to obtain his winning program +one was able to run:

+
make nathan
+./nathan
+

to learn how to get a copy of the code.

+

See the 1992/nathan.c file in the archive/historic/archive-1992.tar.bz2 +tarball if you’re interested in this file.

+

Personal note from chongo:

+

I think the situation showed just how ridiculous US crypto +regulations really were/are. Certain US federal officials can get away +with shipping arms to certain nations in apparent violation of US laws, +but I personally can’t re-distribute a program contest winner to the +network!

+

Author’s remarks:

+

Program use

+

This program is a hello world text encryptor/decryptor. It uses an +enigma (I think) style encryption algorithm, where the encryption key +character is modified by a value, determined from the previous +character. Non-printable characters (those with ASCII values < +' ' or > 0x7e) are passed unaltered, thus +any kind of file may be successfully processed, but if the original is +printable, the processed file will be too. The input is read from +stdin, and the output presented to stdout. The +key, a text string, is presented as a command argument. This is +optional, and if omitted, the file is self-{de,en}crypted. To specify +decryption, a - should be given before the key. (Actually +encryption and decryption proper inverse operations, so you can use +decrypt to scramble and encrypt to descramble, if you’re perverse.)

+

Portability +(A little knowledge is a dangerous thing)

+

It’s written in ANSI C, and doesn’t even assume an ASCII character +set, (it has an array of the characters to convert), so should be +portable across many platforms. It passes +gcc -ansi -pedantic -O -Wall with no warnings (You may get +assignment in conditional warnings on other platforms though). Because +I’ve heard that conditional jumps slow down fast processors, I’ve +eliminated all the ifs from the code; indeed, as its only +one statement, it should compile to one instruction and a suitably +designed CISC machine. To speed compilation, there is only one statement +in the loop, so that another scoping level does not need to be +opened.

+

Being an encryptor/decryptor, you probably want the source code to be +obfuscated, to hide the algorithm.

+

Obfuscation

+

In spite of the fact that it looks like a nice friendly hello world +program, it isn’t (as documented above). (Short lines have been padded, +as you’ll find if you look at an encrypted copy of the source.)

+

I’ve also named some of the macros from commonly used functions, just +to keep things muddy. Of course, all the variables are misnamed. The +program is kept simply (one for statement), by serious overuse of +, and ?:. These are really confusing when used +together, nested or put in argument lists (is that a comma operator, or +argument separator?).

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1992/nathan

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1992/vern/index.html b/1992/vern/index.html index b32b42754..ed7dfc16d 100644 --- a/1992/vern/index.html +++ b/1992/vern/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,311 @@ - - + + + + + + - - -1992 vern - - + + + +1992/vern + + + + + -

1992 vern

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1992/vern

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1992/vern/index.html

- +
+ ← nathan + ↑ 1992 ↑ + westley → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Vern Paxson
+Location: US

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1992 +vern in bugs.md.

+

To use:

+
./vern 3    # <-- default is 2
+

Try:

+

You might start off by giving the following input:

+
63 43
+76 55
+71 52
+67 57       # <-- this may take a while
+

Judges’ remarks:

+

The judges assume no responsibility for the obfuscated opening +suggested above. :-)

+

For a real quick game try:

+
./vern
+
+65 55
+66 46
+

NOTE: Move values must be restricted to the range 00 to 77.

+

NOTE: Because some mailers have problems with the original winning +source, a slightly modified version with shorter lines has been +provided.

+

Author’s remarks:

+

This program plays chess. You play the white pieces and the program +the black pieces. Moves are entered as a two-digit number specifying the +coordinates of the piece to be moved followed by another two-digit +number specifying the coordinates of where to move it. Rows and columns +are numbered starting with (0,0) for the upper-left-hand +corner (black’s queen’s rook) and going to (7,7) for the +lower-right-hand corner (white’s king’s rook). For example, the +PK4 opening for white is indicated as +"64 44" (without the quotes). Moves are read using +scanf() so care should be taken to not enter the wrong +number of fields.

+

If the move you enter is illegal then you are just prompted again to +move. If the move is legal then the new position is displayed and the +program starts computing its response. For every 64 board positions it +examines a “.” is printed. Once it has chosen its move it simply +displays the board updated to reflect the move.

+

Your move is prompted for using a string like +"1351 9 2 >". The first number is how many board +positions the program examined when computing its previous response. The +second number is its anticipated value for the move it just made (with +larger numbers meaning an ultimately better board position for it), and +the third number is the evaluation it assigns to the your current +position (larger numbers meaning better positions for you). A +> indicates that you are not in check; for check it is +changed to !.

+

There are a few limitations on play:

+ +

If you checkmate the computer it prints “Rats!” and exits. If your +own checkmate is imminent it prints “Har har.” but doesn’t exit so it +can rub your nose in defeat (which may be a move or two away if you’re +playing at a high “ply” - see the next paragraph). Stalemates are not +recognized per se, but when selecting its move the program assigns a +stalemate position a value of 0 so it will try for a stalemate if its +other options are worse.

+

The program takes one optional argument indicating the ply +(lookahead) it should use. The default is 2, which is enough to keep it +from making flaming blunders. The higher the ply, the better the play, +and the longer you have to wait. For example, at a ply of 2, a response +to the PK4 opening takes about 1.8 CPU seconds on a SPARC +ELC when compiled -O with Sun cc. A ply of 3 +takes 13 CPU seconds (and results in a different response to +PK4) and a ply of 4 takes a little under 4 CPU minutes (and +for PK4 comes up with the same response as a ply of 3). A +ply of 3 is in general good enough to avoid not only flaming blunders +but also immediately stupid moves altogether. A ply of 4 will find all +mate-in-two’s.

+

Obfuscation

+

This program is obfuscated in a number of ways. First, it abuses the +contest rule regarding ‘;’, ‘{’, and ‘}’ in the source not counting +against the non-whitespace character limit if followed by whitespace. As +can be seen from the build file, certain combinations of these +characters followed by a particular whitespace character are expanded at +build time into much-needed text. Without this hack the program wouldn’t +pass the character limit. A nice side effect is that the initial source +is gloriously difficult to peruse. In particular, the Makefile does:

+
sed <vern.c 's/{ /(/g;s/} /)/g;s/;       /#define /' | \
+    sed 's/}      /=/g;s/{        /i/g' >vern.tmp.c
+

and compiles vern.tmp.c.

+

Second, the rather ho-hum step has been taking of naming each +variable with a one or two letter identifier to render it meaningless +(and save space). This tactic is rather effective in a complex +program.

+

Third, the board is represented not as an array of pieces but rather +as an array of function pointers (with a separate array representing +whether a piece is white or black). This obfuscates the program’s +central data structure. There is one function per type of piece; when +called they return 1 if the current move is illegal for that piece and 0 +if it is legal. The functions also as a side effect set a global +indicating the type of the piece (though the type can also be determined +by comparing the function pointer with the function itself).

+

Fourth, there are no independent routines for generating potential +moves. Instead, the program generates its moves by brute force: for +every piece it controls on the board, it attempts to move it to every +square on the board. Those moves that are legal it then explores to see +their effects (using alpha-beta +search). This tactic somewhat obfuscates the algorithm used by the +program.

+

Finally, there are three key constants that occur throughout the +program: 64, 8, and 3 +(lg 8). Rather than making these available at compile-time, +which provides a hint as to what the program is up to, they are computed +probabilistically at run-time. An instance of the “Inspection +Paradox” is used which happens to produce a value that on average is +close to .64. 10000 instances of this value +are computed, added up, and then divided by 100. Sometimes +the value produced will be 63 or 65 instead of +64 (but I’ve never observed any other values), so the +result is then rounded to the nearest multiple of 4, and +then the other constants are derived from it.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1992/vern

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1992/westley/index.html b/1992/westley/index.html index ea0524d7b..cfe10c50e 100644 --- a/1992/westley/index.html +++ b/1992/westley/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,332 @@ - - + + + + + + - - -1992 westley - - + + + +1992/westley + + + + + -

1992 westley

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1992/westley

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1992/westley/index.html

- +
+ ← vern + ↑ 1992 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Brian Westley
+Location: US

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+STATUS: known bug - please help us fix
+

For more detailed information see 1992 westley in bugs.md.

+

To use:

+

If lost:

+
./whereami lat long
+
+# or, if you don't have curses installed:
+./westley lat long
+

Where lat and long correspond to your +latitude and longitude.

+

NOTE: you MUST have a terminal that is at least 80 +columns for this to show properly. The whereami and +whereami.alt code checks this but it is not prohibitive if +it cannot be compiled and linked (it uses curses); instead one should +just use the westley and westley.alt programs +directly.

+

Try:

+
./whereami 47 -122  # NOTE: - means west of meridian
+./whereami 47 122
+
+# or if you don't have curses installed:
+./westley 47 -122
+./westley 47 122
+

Alternate code:

+

The author provided a version for the US which we added. To +build:

+

Alternate build:

+
make alt
+

Alternate use:

+
./whereami.alt lat long
+
+# or if you don't have curses installed:
+./westley.alt lat long
+

NOTE: this alternative version also needs a terminal with at least 80 +columns.

+

Judges’ remarks:

+

To find the approximate place where this entry was judged, type:

+
./whereami 37 -122  # NOTE: - means west of meridian
+
+# or if you don't have curses installed:
+./westley 37 -122   # NOTE: - means west of meridian
+

Author’s remarks:

+

Run the program with your latitude & longitude as integer +arguments; it will produce a map made up of '!' with the +given position marked with either a '"' (if the position is +over a '!') or a # (if the position is over a +space). Southern latitudes and western longitudes are entered as +negative numbers. For example, to find San Francisco, run with +./whereami 38 -122. The resolution of the map is five +degrees horizontally, ten degrees vertically. The map is a Mercator +projection with equal spacing of the latitudes, so the areas near the +poles are very distorted. Latitudes near the poles and Antarctica are +not shown.

+

The program requires the ASCII character set, putchar(), +atoi(), and a display that auto-wraps at 80 characters(!). +If your display does not work this way, you will have to massage the +output; for example, you can redirect it to a file and edit it with vi, +which will do auto-wrap for you.

+

Lint complains that main() returns a random value and +I’m not checking the value that putchar() returns. +Scandalous!

+

If you run it with fewer than 2 arguments, it will likely give you an +exception, as it will access arguments that don’t exist and characters +before a string constant.

+

How it works:

+

The map is printed as one long string of ' ' and +'!' characters, with the auto-wrap used to stack up slices +of 80. The map data is a string; the first character is how many +!s are printed ('A'=1, 'B'=2, +etc), the second character is how many ' 's, the third is +how many !s, etc. ASCII characters less than +'A' print no characters but still change the polarity, so +any map of ' 's and '!'s is possible. This is +done in the putchar() argument as 33^l&1, +where l is the character position+4; if +l is odd, ' ' is printed, if l is +even, '!' is printed.

+

The position of latitude & longitude is changed into a single +character position within the one long string via the first expression +d = latitude/10*80 - longitude/5 - offset. The latitude is +divided by ten because the vertical resolution is ten degrees, then +multiplied by 80 because of the 80 character wrap (i.e. each ten degrees +moves the position up or down one entire row). The longitude is divided +by five and added, because five degrees of change moves the location one +character. The signs are opposite because latitude is decreasing and +longitude is increasing as you go from upper left to lower right. The +offset is where the origin (latitude=0, longitude=0) is found.

+

The position counting down to zero changes the putchar() +from printing ('!' or ' ') to printing +('"' or '#').

+

The "H E L L O, W O R L D!" string inside the data +string prints the line of blanks past Tierra del +Fuego and the last blank line. It’s just for show, really.

+

Since the resolution is coarse, a few coastal cities are shown to be +just off the map; this is an unavoidable artifact. The map is reasonably +accurate.

+

Here are some cities +you might like to try:

+ +

For a domestic (US) version with higher resolution, try:

+
main(l,a,n,d)char**a;{for(d=atoi(a[1])/2*80-atoi(a[2])-2043;
+n="bnaBCOCXdBBHGYdAP[A M E R I C A].AqandkmavX|ELC}BOCd"
+[l++-3];)for(;n-->64;)putchar(!d+++33^l&1);}
+

The code will test the 80-column wrap and document itself if it is +joined together as one 160-character line and listed. You should +see:

+
main(l,a,n,d)...
+[A M E R I C A]...
+

…going down the left edge if your terminal auto-wraps at 80 +characters.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1992/westley

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1993/ant/index.html b/1993/ant/index.html index d959af0a0..30e919a5e 100644 --- a/1993/ant/index.html +++ b/1993/ant/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,225 @@ - - + + + + + + - - -1993 ant - - + + + +1993/ant + + + + + -

1993 ant

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1993/ant

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1993/ant/index.html

- +
+ first entry + ↑ 1993 ↑ + cmills → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Anthony C. +Howe
Location: CA

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: missing file - please provide it
+

For more detailed information see 1993 +ant in bugs.md.

+

To use:

+
./ant 'ERE' [file ...]
+

Try:

+
./try.sh
+

Judges’ remarks:

+

See the author’s POSIX P1003.2-like documentation file ant.txt for more information.

+

This program demonstrates that POSIX doesn’t guarantee readability. +:-)

+

Author’s remarks:

+

Some of the features of my entry are:

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1993/ant

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1993/cmills/index.html b/1993/cmills/index.html index 8be5815b1..b638ae6ff 100644 --- a/1993/cmills/index.html +++ b/1993/cmills/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,251 @@ - - + + + + + + - - -1993 cmills - - + + + +1993/cmills + + + + + -

1993 cmills

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1993/cmills

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1993/cmills/index.html

- +
+ ← ant + ↑ 1993 ↑ + dgibson → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Christopher +Mills
Location: US

+ + +

To build:

+

We recommend you try the alt version first so you can get a better +idea of what this entry was like back in 1993. See the original code section below to run the +original.

+
make alt
+

NOTE: this entry requires the X11/Xlib.h header file and +the X11 library to compile. If you’re under macOS and do not know how to +install and use X11 programs see FAQ 3.7 - How +do I compile and use on macOS, an IOCCC winner that requires +X11?.

+

To configure how many microseconds to sleep before updates try:

+
make clobber SLEEP=200 alt
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: known bug - please help us fix
+

For more detailed information see 1993 +cmills in bugs.md.

+

To use:

+
DISPLAY="your_X_server_display"
+export DISPLAY
+./cmills.alt [speed]    # must be run on an X11 server
+

where:

+

speed is update speed from 1 to 9 (default is 9).

+

NOTE: in most cases DISPLAY should already be set.

+

Original code:

+

We recommend the version that uses usleep(3) to more +easily see what is going on but you can use the original without any +delays if you wish.

+

Original build:

+
make all
+

Original use:

+

Use cmills as you would cmills.alt +above.

+

Judges’ remarks:

+

From the San Jose Mercury News (May 15, 1993 page 20A “West Hackers +trounce East in computer quiz game”):

+
"Since 1984, a contest has been held on Usenet for the most
+unreadable, creative, bizarre but working C program", Gates
+said. "What is the name of this contest"
+
+"Windows," shot back Gassee, naming Microsoft's premier product
+- a product over which Apple sued Microsoft five years ago. Not
+the right answer - it's "The Obfuscated C Contest [sic]" - but
+it brought down the house of Apple partisans...
+

[The expression on Bill Gates’ face was a sight to behold, as +reported to us by several who were there].

+

You must set $DISPLAY in your environment or the program +will dump core. This is not a bug as the author documented it as a +feature. :-)

+

The optional argument is integer which controls the speed of the +program. By default the speed is 9. You may want to try 1.

+

You will have to kill the program (i.e., ^C) to stop it.

+

WARNING: Slow servers or servers with long request queues will +continue to ‘run’ for a while after you have killed the program.

+

This program makes your windows about as useful as their windows. +:-)

+

Author’s remarks:

+

The program uses a single backing pixmap (which is the size of the +screen) for all of its subwindows (with a little bit of trickery to move +the offset around). This is much better (and faster) than the obvious +implementation which would require a full-screen pixmap and a separate +backing pixmap for each subwindow.

+

The chance that a window breaks is based on it’s kinetic energy, +which in turn is based on it’s area and speed. How silly!

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1993/cmills

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1993/dgibson/index.html b/1993/dgibson/index.html index c740d251d..732b40102 100644 --- a/1993/dgibson/index.html +++ b/1993/dgibson/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,254 @@ - - + + + + + + - - -1993 dgibson - - + + + +1993/dgibson + + + + + -

1993 dgibson

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1993/dgibson

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1993/dgibson/index.html

- +
+ ← cmills + ↑ 1993 ↑ + ejb → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: David Gibson
+Location: unknown

+ + +

To build:

+
make all
+

To use:

+
./dgibson.sh [datafile]
+

where:

+

datafile is the initial pattern (default: dgibson.data1)

+

Try:

+
./try.sh
+

Judges’ remarks:

+

We have provided the shell script dgibson.sh +to make it easier to run this entry. Run this shell script several times +to see what happens.

+

There are a number of data files available:

+ +

For dgibson.data5 you will need a large +screen, lots of virtual memory and lots of time! The try.sh script will run dgibson.sh on all the data files.

+

Good luck trying to use a debugger on this entry! Life is not always +pretty.

+

Author’s remarks:

+

This program plays the Game of +Life.

+

Life is a cellular automaton invented by J. H. Conway, in which each +of a rectangular grid of cells can be alive or dead, and cells with more +than 3 or less than 2 (out of 8) live neighbours die, and empty cells +with exactly 3 neighbours give birth.

+

Some notes

+ +

Further features: the current generation number is preserved, and the +grid automatically resizes itself as the object gets too big or too +small.

+

When writing this program, my goal was to make each cell in the life +grid expand to the code which calculates the fate of that cell. In +addition, the resulting program is a single expression, which makes it +necessary to recurse main() in two “directions” +simultaneously.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1993/dgibson

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1993/ejb/index.html b/1993/ejb/index.html index f1d8a4e5e..3e101a6db 100644 --- a/1993/ejb/index.html +++ b/1993/ejb/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,258 @@ - - + + + + + + - - -1993 ejb - - + + + +1993/ejb + + + + + -

1993 ejb

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1993/ejb

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1993/ejb/index.html

- +
+ ← dgibson + ↑ 1993 ↑ + jonth → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: E. Jay +Berkenbilt
Location: unknown

+ + +

To build:

+
make all
+

To use:

+
./ejb level
+

where:

+
level   a value from -128 to 127
+

Try:

+
./try.sh
+

Judges’ remarks:

+

A negative argument plays the patience puzzle. An argument greater +than 0 plays the Tower of Hanoi puzzle. In either case the absolute +value of the argument specifies the size of the respective puzzle. Refer +to the files hanoi.md and patience.md for more information on these +puzzles.

+

Of course, you need a different kind of “patience” if you give the +argument 127 to this program and want to see it finish!

+

We note that this also works under macOS just fine.

+

Author’s remarks:

+

What this program does

+

Output +solution to Towers of Hanoi for five rings:

+
./ejb 5
+

The format of the output for the Towers of Hanoi case is simply a +text description of how to solve the puzzle.

+

Output +solution to the Patience puzzle for six rings:

+
./ejb -6
+

For the patience puzzle, the output is a sequence binary codes +representing successive states of the puzzle. The rightmost digit +represents the first ring. A 1 means the ring is on the +U; a 0 means it is off the U. The +program prints the word "Invalid" in response to illegal +command line parameters.

+

Motivation

+

Most people who have written software for other people have been +asked to count lines of code. Naturally, this brings up the +controversial question of exactly what defines a line of code. This +program serves to show that counting semicolons will not always provide +a meaningful measure of code size. This is especially true in this +program where the number of semicolons itself is ambiguous. Does it have +two or three? In addition, the only C keyword this program uses besides +type names and qualifiers is return, and the only function +defined in the code is main(). The level of complexity of +the program without multiple semicolons, statements, and functions is +achieved by abusing C operators, especially the comma operator. +Considerable use of ||, &&, and +?: helps too. In addition, main() is called +recursively. The NULL pointer that terminates argv is used +to pass additional information into main(). Even though the +algorithms used by this code are simple, this program is still hard to +follow even when indented properly. (It is pretty hard to indent this +code reasonably, however.)

+

Although this program has only been tested on UNIX systems it will +probably run on just about any machine with an ANSI C compiler. It does +not use the C preprocessor at all. The only functions it uses are +atoi(), malloc(), memset(), +printf(), and puts(). It does, however, +require that the architecture it runs on have bytes that are at least +eight bits long and pointers that are at least four bytes long. In +addition, it requires an ANSI compiler since it uses +signed char and ANSI-style function declarations.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1993/ejb

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1993/jonth/index.html b/1993/jonth/index.html index aa64512b3..4fd94c3f4 100644 --- a/1993/jonth/index.html +++ b/1993/jonth/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,205 @@ - - + + + + + + - - -1993 jonth - - + + + +1993/jonth + + + + + -

1993 jonth

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1993/jonth

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1993/jonth/index.html

- +
+ ← ejb + ↑ 1993 ↑ + leo → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jon Thingvold
+Location: NO

+ + +

To build:

+

NOTE: this entry requires X11/Xlib.h header file and the +X11 library to compile. macOS users running Mountain Lion and later will +need to download and install XQuartz in order to compile and run +this entry.

+
make all
+

To use:

+
./jonth         # must be run on an X11 server
+

Judges’ remarks:

+

Use h and l to shift objects left or right. +Use k to rotate and press SPACE to drop.

+

This program’s output may be even more obfuscated when played on +inverse video. :-)

+

Author’s remarks:

+

This is jonth (jon's t(h)etris) for the X +Window System.

+

This program is also an example of data abstraction. The X array is +after initialization hidden by the well defined macros t, +u and F.

+

This program is highly portable as it runs on a “Notebook” size +SPARC. This program will not work on machines where +sizeof(int)!=sizeof(void *).

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1993/jonth

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1993/leo/index.html b/1993/leo/index.html index dd3f07c8d..9c63dc3ab 100644 --- a/1993/leo/index.html +++ b/1993/leo/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,253 @@ - - + + + + + + - - -1993 leo - - + + + +1993/leo + + + + + -

1993 leo

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1993/leo

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1993/leo/index.html

- +
+ ← jonth + ↑ 1993 ↑ + lmfjyh → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Leonid A. +Broukhis
Location: US

+ + +

To build:

+
make all
+

To use:

+

To have the computer guess:

+
./leo [colors]
+

To guess the computer’s number:

+
./mind [colors]
+

where:

+

[colors] is the number of possible colors (1 to 15) (default: 6)

+

Judges’ remarks:

+

By default, the number of colors is 6. You may specify a value of +between 1 and 15 colors. See the author’s notes for instructions of how +to play.

+

We look forward to more entries from the newer members of the +International Internet community.

+

Author’s remarks:

+

This program plays +[Mastermind](https://en.wikipedia.org/wiki/Mastermind_(board_game), if +you call it by a name ending by ‘d’, otherwise it solves +Mastermind. Call it without parameters to use 6 digits (colors), or +indicate the number of possible digits (you cannot change the number of +positions so easily).

+

The number in parentheses is the number of possible combinations, +based on previous questions and answers. If you solve the puzzle, “(1)” +indicates that your previous moves are enough to give correct answer. If +the program acts as solver and terminates prematurely, it means that +you’re mistaken in your answers to its question(s). Question marks +indicate the number of digits you have to enter (either 4 when you guess +or 2 when computer guesses).

+

Note that the program uses the same code for both player and solver, +and the only place where it makes a difference is the interactive part. +Many obfuscations have been made to achieve this. An expression giving +(bulls * 16 + cows) from two numbers is, however, quite +straightforward :-) , as well as the arithmetic of binary coded +colors-base numbers is.

+

Limitations: +maximum number of digits (colors) is 14 (1..F).

+

Suggestions: Use terminal (or emulator) with non-destructive +backspaces. Do “disable scrolling” on cmdtool or similar emulators.

+

Bugs

+

Please don’t type ^D at the prompt!!

+
EXAMPLE: Suppose we think of +1234
+
$ ./leo
+(1296): 6433
+?? 12       # one 3 is a bull, another is a cow, and 4 is a cow
+(160): 5363
+?? 02       # both 3's are cows
+(21): 4231
+?? 22       # 2 and 3 are bulls, 4 and 1 are cows
+(2): 4132
+?? 13       # 3 is a bull; 1, 2 and 4 are cows
+(1): 1234
+?? 40       # you may enter everything there
+
EXAMPLE: Guess the +computer’s number
+
$ ./mind
+(1296): ???? 1122   # my strategy isn't the best, just as example
+00
+(256): ???? 3344
+20
+(18): ???? 5566
+02
+(6): ???? 3654
+11
+(2): ???? 3355
+00
+(1): ???? 6444
+40         # we have guessed the number
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1993/leo

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1993/lmfjyh/index.html b/1993/lmfjyh/index.html index e1f1ae76c..dffb8697c 100644 --- a/1993/lmfjyh/index.html +++ b/1993/lmfjyh/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,336 @@ - - + + + + + + - - -1993 lmfjyh - - + + + +1993/lmfjyh + + + + + -

1993 lmfjyh

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1993/lmfjyh

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1993/lmfjyh/index.html

- +
+ ← leo + ↑ 1993 ↑ + plummer → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jyrki +Holopainen
Location: FI

+ + +

To build:

+

If you have gcc < 2.3.3 you can build this entry like:

+
make all
+

This will create a file called +";main(){puts("Hello World!");}char*C=".c which would print +Hello World! when compiled.

+

For an explanation of why and how this works see the author’s +remarks. The gist of the entry itself, however, is the file name +itself is the code.

+

NOTE: we delete the temporary file whether or not the compilation +succeeds because it is an unsafe filename and not doing so would cause +problems for anyone running make.

+

This entry will not compile with gcc < 2.3.3 as it relies on a bug +which was fixed in gcc 2.3.3 which was fixed a very long time ago now. +There is an alternate version for those +of us with gcc >= 2.3.3. See Alternate +code section below for more details.

+

However, there is an another version that will be compiled in the +extremely likely case this fails. This should happen automatically. See +Alternate code below for more details on +it.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1993 +lmfjyh in bugs.md.

+

To use:

+

If you have gcc < 2.3.3 (i.e. the entry can compile):

+
./lmfjyh
+

Alternate code:

+

This version does what the code did but in a way that will work with +modern compilers. We’d like to say there’s something special about it +but there isn’t. Nonetheless it will be compiled in case the original +entry fails to compile (which will happen unless you have gcc < +2.3.3.

+

Alternate build:

+

Should you wish to build this version manually:

+
make alt
+

Alternate use:

+

Use lmfjyh.alt as you would lmfjyh above. +Note that other code could also be done with the bug that the entry +abuses but that would have to be manually programmed for this version; +see the author’s remarks for more details.

+

Judges’ remarks:

+

There’s more than one way to get around disk quotas. :-)

+

Author’s remarks:

+

“Practical and efficient method of compressing source code”.

+

Introduction

+

I will shortly present a totally new compression method. It may be +used to compress any types of files, but it works best with C-source +code.

+

As an example, I have taken a simple “Hello world!” program that +should be familiar to all C-programmers.

+

Listing 1: A simple +“Hello World” program

+
main()
+{
+  puts("Hello World!");
+}
+

Packing method

+

Normally a file name is used only to identify the file, but this new +revolutionary method introduces a totally new concept: THE FILE +NAME IS THE PROGRAM. There is no need to waste +valuable disk space to store source code. The program is embedded in the +file name, only a minor portion of it is inside the file.

+

Listing 2: Compressed “Hello +world”

+
char*_=__FILE__;
+

Listing 3: Code +embedded in the file name

+
";main(){puts("Hello World!");}char*C=".c
+

The sample program in listing 1 is 36 bytes long. By using the new +compression method, the example program may be squeezed to sixteen +bytes. In the example the compression ratio is 2:1. It is evident that +the longer the program is, the better the compression ratio is. The +maximum compression ratio in a UNIX environment is 254:16 which equals +approximately to 16:1. By using the method a one megabyte of source code +file can be compressed to 64 kilobytes.

+

One might easily think that the program could be compressed to a +single byte by writing a one character long preprocessor directive in +the source file and defining the actual source code in the command line, +e.g. cc hello.c -DX='main(){puts ...'. With this method +nothing is gained, since the compiling commands must be stored in a +file, and that takes even more space than writing the code in a source +file as presented in listing 1.

+

Packing files in a UNIX +environment

+

In a UNIX environment it is possible to write almost any program by +including the code in file names. Since / is used to +separate path components and cannot therefore exist in a file name, all +features of the C language cannot be used.

+

In C, the / is used as a division operator and it may +also be a part of a comment start and end identifier. This, however, is +not a dangerous limitation, since practice has shown that comments are +almost totally unnecessary. A real programmer can more easily understand +pure source code, and misleading comments are disastrous. The division +operation may be replaced with pow(x, -1) and +multiplication when using real numbers or with div() +function when using integers.

+

Large programs must be separated into small modules. This enforces +people to write better programs, since monolithic programming style +cannot be used. Program development will also be faster, no extra code +needs be recompiled after changes have been made.

+

Usage with currently +available tools

+

I have tested how well this new method works with currently available +programming tools.

+

Any ANSI conforming C-compiler that runs under a REAL operating +system should be able to compile the code (there might be problems with +some older UNIX variants).

+

Compilers

+

These worked:

+ +

These failed miserably:

+ +

Other tools

+

Debuggers: (tested at SunOS +4.1.2)

+ +

Lints

+

None of the lints tested environments were able to parse the +file.

+

Conclusions

+

The method can be used to compress any type of file and the +compression ratios are even better when compressing files other than C +source. For example plain text files may be compressed with INFINITE +compression ratio. It is trivial task to compress a 100 kilobytes long +text file in about 400 files whose lengths are zero bytes. The drawback +is that the files must be unpacked before they can be used, so a large +amount of temporary disk space is needed, while C source is totally +usable in the compressed form.

+

Evidently, there is a long way to go before this new programming +technique may be widely used, since currently there are only few tools +supporting it. The advantages over the traditional methods are, however, +so great that there is no doubt that this method will be new +standard.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1993/lmfjyh

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1993/plummer/.winner.json b/1993/plummer/.winner.json index ca06514c5..61cca767f 100644 --- a/1993/plummer/.winner.json +++ b/1993/plummer/.winner.json @@ -49,6 +49,22 @@ "display_via_github" : true, "winners_text" : "original source" }, + { + "file_path" : "try.alt.sh", + "inventory_order" : 100, + "OK_to_edit" : true, + "display_as" : "shellscript", + "display_via_github" : true, + "winners_text" : "how to run alternative code" + }, + { + "file_path" : "try.sh", + "inventory_order" : 100, + "OK_to_edit" : true, + "display_as" : "shellscript", + "display_via_github" : true, + "winners_text" : "how to run" + }, { "file_path" : "1993_plummer.tar.bz2", "inventory_order" : 300, diff --git a/1993/plummer/index.html b/1993/plummer/index.html index d6edeb406..ad655c59a 100644 --- a/1993/plummer/index.html +++ b/1993/plummer/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,312 @@ - - + + + + + + - - -1993 plummer - - + + + +1993/plummer + + + + + -

1993 plummer

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1993/plummer

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1993/plummer/index.html

- +
+ ← lmfjyh + ↑ 1993 ↑ + rince → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Mark Plummer
+Location: unknown

+ + +

To build:

+
make alt
+

We recommend that you try the alternate version first to get a better +idea of what this entry looked like back in 1993. The alternate version +sleeps (via usleep(3)) in between writes, defaulting at +1000 microseconds (but reconfigurable). If you wish to see the original +entry then see original code below.

+

If you wish to speed the entry up, say to 500 microseconds between +writes, try:

+
make clobber SLEEP=500 alt
+

Alternatively if you wish to slow it down, say to 1500 microseconds +between writes, try:

+
make clobber SLEEP=1500 alt
+

To use:

+
./plummer.alt number arg
+

where:

+ +

Wait until you’re bored enough to send intr/ctrl-c to exit or until +the Vogons build +that hyperspace +bypass.

+

Try:

+
./try.alt.sh
+
+./try.alt.sh 21701
+
+SLEEP=500 ./try.alt.sh
+
+SLEEP=900 ./try.alt.sh 789789789789789
+
+./try.alt.sh 789789789
+
+SLEEP=400 ./try.alt.sh 42424242424242
+
+SLEEP=1000 ./try.alt.sh xyzzyzzyx
+
+SLEEP=1200 ./try.alt.sh xyzzyzzyx 5555
+

Original code:

+

This version, the original, does not sleep in between writes, and is +thus much faster (depending on the SLEEP parameter +specified in the build of alt, of course).

+

Original build:

+
make all
+

Original use:

+

Use plummer as you would plummer.alt +above.

+

Original try:

+
./try.sh
+
+./try.sh 21701
+
+./try.sh 789789789789789
+
+./try.sh 789789789
+
+./try.sh 42424242424242
+
+./try.sh xyzzyzzyx
+
+./try.sh xyzzyzzyx 5555
+

Judges’ remarks:

+

For extra credit: What happens when ‘number’ contains non-numeric +characters, and why?

+

Author’s remarks:

+

This program prints out all numbers up to a given number of digits on +a single line. When the largest number is reached, the program starts +again with 0. It takes two arguments: the first argument specifies the +number to start counting from and uses leading 0s to +indicate the number of digits, the second argument can be anything but +must be present.

+

Variable names are single characters chosen for their similarity to +other characters (O for 0 (zero), +l for 1 (one), S for +5 (five) in some fonts, and _ for … well +nothing really, but it is easy to miss). To prevent the need for +strlen(), the fact that argv is laid out sequentially is +exploited +(i.e. argv[i + 1] == argv[i] + strlen(argv[i]) + 1). This +is not portable (by the books), but it seems to work everywhere I try +(actually, for VMS, that only holds for i > 1). Also, I +depend on the fact that a carriage return causes the line just written +to be overwritten. lint (and most compilers) complain that +there is no control path leading to a return from main(). +At 125 characters, it still fits on a single line (for those of us who +don’t mind ruining our eyes with 132 column screens).

+

Spoiler:

+

The first statement points the base of l (the argument +vector) to be the first argument by incrementing it. It then assigns +O to point to the character before the first character of +the second argument which also happens to be the NUL termination of the +first argument. *O gets a \r assigned to it. +Finally 0 is assigned to the first character of the second +argument which has the effect of NUL terminating the first argument +after the carriage return had removed its NUL termination. I really +tried to make the last part of that statement part of the original +expression, but the best I could do was attach it with a comma (against +the advice of K&R). The for loop runs the next for loop continuously +(actually until the machine crashes or the user gets tired of seeing the +counting). The next for loop is the meat of the program. In the +initialization statement, the string pointed to by l (the +first argument containing the digits used for counting followed by a +\r) is printed, and _ is started at the least +significant digit in the string. In the test portion, _ is +ensured not to be past the beginning of the string (the most significant +digit), and the digit pointed to by _ is incremented and +checked to be sure that it is greater than 9 +(written here as (S+*O+S)*S). If the test fails, either the +string has been incremented or each digit in the string has been reset +to 0. If the test succeeded, the iteration statement +assigns 0 (written here as (S+*O)*S (which has +the added bonus of having the code be a cry for help)) to +*_ and decrements _ to point to the next more +significant digit to be incremented; it is done only when a carry +situation results (*_ has been incremented past +9).

+

The inspiration for this program came from actual code which dealt +with scanning for a unique temporary filename by appending a +successively larger number to the end of a string.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1993/plummer

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1993/rince/index.html b/1993/rince/index.html index d5b91d7cf..4515d5b2a 100644 --- a/1993/rince/index.html +++ b/1993/rince/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,354 @@ - - + + + + + + - - -1993 rince - - + + + +1993/rince + + + + + -

1993 rince

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1993/rince

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1993/rince/index.html

- +
+ ← plummer + ↑ 1993 ↑ + schnitzi → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: James +Bonfield
Location: GB

+ + +

To build:

+
make all
+

NOTE: there are two alternate versions of this program, both allowing +one to slow down the game and the second one with movements more +familiar to vi users. See the Alternate +code section below.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1993 +rince in bugs.md.

+

To use:

+
./rince [cabbage]
+

where:

+

[cabbage] is a CABBAGE description file (default: +rince.c)

+

Alternate code:

+

Some people may want to slow down the game by increasing the value 17 +in the lines:

+
struct timeval v= {0,1<<17} ;
+

and

+
refresh(),c=select(k,&y,0,0,(v.tv_usec=1<<17,&v))?getch():0;
+

to another value like 18 or 19 which you can do with the alternate +code.

+

In the case of rince.alt2.c the movement +keys for the default game are slightly different and will feel more +familiar to vi users: h for left, l for right +(that was not changed) and k for fire (that was also not +changed).

+

Alternate build:

+
make SLEEP=18 clobber alt
+

Replace 18 with whatever number you wish.

+

Alternate use:

+

Use rince.alt or rince.alt2 as you would +rince above.

+

Judges’ remarks:

+

The author has provided several CABBAGE files for your amusement:

+ +

For a brief design description, see design.md.

+

WARNING for SunOS 4.1.x:

+

If you are running SunOS 4.1.x (assuming you can find an ANSI +compiler in the first place), this program may be used to log out very +quickly. Unfortunately, you can’t do anything else with it.

+

Additional notes

+

Some people report that rince dumps core on their +system.

+

On some systems that use gcc, the curses.h used by gcc +(typically /usr/local/include/curses.h if not +/usr/include/curses.h) is not compatible with the curses +library (typically /lib/libcurses.a for static libraries) +used. It has been suggested that the following gcc command may help:

+
gcc -fno-builtin -I/usr/include -o rince rince.c -lcurses -ltermcap
+

Author’s remarks:

+

This is a Cellular Automata Based, Beautifully Abysmal Game +Environment (or CABBAGE for short). To execute the program simply type +./rince gamefile, where gamefile is a game +description file. A few are supplied for your enjoyment. Alternatively, +with no arguments it will default to using it’s own datafile (the source +code in fact). This happens to be a game of Space Invaders. +To prevent people from firing too often a very simple method is +employed; you must move after firing to be able to fire again.

+

Keys

+ +

This is a new breed of generic games. For instance:

+

Game play : Whatever you define Keys : Whatever you define Score : If +you can figure out how to update it! Levels : Ahh well… it’s not +totally generic.

+

The proper definition for usage would be: +./rince [data_filename]

+

Portability

+

I have compiled in on the following systems:

+
System              OS              Compiler (and flags)
+DECstation 5000/240 Ultrix 4.2A     c89 -std
+SPARCstation 1+     SunOS 4.1       gcc -ansi -pedantic
+SPARCstation 10/31  Solaris 2.1     gcc -ansi -pedantic     (*)
+DECAlpha 3000/500   OSF/1 V1.2      c89 -std
+SGI Indigo (R4000)  IRIX 4.0.5F     cc -ansi
+Alliant FX2800      Conentrix 3.0.0 fxc
+

* I never said it worked! The guidelines state that you dislike +programs that won’t compile under both BSD or SysV +Unix. This compiles, and indeed runs on all the others +(both BSD and SysV) correctly.

+

Alas, on Solaris it compiles, but mysteriously stops displaying +output after a while until you quit with control-c, when it all catches +up again. I think the problem may lie in either select(2), +or curses, (or perhaps conflict of the two).

+

The use of select(2) no doubt makes it less portable to +STRICT SysV machines. However I have tested this on several so-called +SysV machines, and all of them support select(2). In fact, +the select(2) they support appears to be more portable +between them than their poll() call.

+

Obfuscation

+

I have tried to use as many different obfuscation techniques, +including some of which (such as sizeof confusion) I have +not seen in any winners (hmmm - perhaps there’s a reason for that…) so +far. Also, very poor structure (yes, I use goto’s) has led +to apparently having an fgets() as the last line of main. +Note that I have still tried to aim at least some efficiency (provided +it makes things slightly more obfuscated of course). One such thing is +the way I dynamically allocate a 2-dimensional array using only ONE +malloc(). Hence this program could be used as a tutorial +for all those people who consistently ask this question in the C +newsgroups.

+

Also, the program does require a volatile type (especially when +optimising) to perform correctly. This is the first time I have ever +truly needed this when not accessing memory external to this process +:-)

+

Of course, all the usual obfuscation lurks within, such as combining +multiple for loops into single ones; warped and twisted logic; plus a +plethora of other minor oddities. It’s up to you to discover some of +them of course… Sometimes I have sacrificed length for obfuscation. It +is all too easy to change the arguments in main() to one +character identifiers, but in my opinion they add to obfuscation in this +case by being longer.

+

lint complains about lots of things. Firstly the use of +curses immediately makes lint complain. The Alpha’s +lint gave me some positive encouragement! +precedence confusion possible: parenthesize! :-) :-) +main() does not return correctly, because, basically, it +doesn’t return.

+

Bugs

+

Very little error checking is performed. I do check for not being +able to open the requested filename and return 1 upon failure. However, +badly formatted data files will cause major problems. No other checking +(such as insufficient memory) is performed.

+

There is no ‘end of game’ checking method. Hence games like Sokoban +rely on the user to decide when they have had enough. Also, there is no +quit mechanism other than control-c.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1993/rince

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1993/schnitzi/index.html b/1993/schnitzi/index.html index eba39d00e..aebab7eb2 100644 --- a/1993/schnitzi/index.html +++ b/1993/schnitzi/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,273 @@ - - + + + + + + - - -1993 schnitzi - - + + + +1993/schnitzi + + + + + -

1993 schnitzi

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1993/schnitzi

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1993/schnitzi/index.html

- +
+ ← rince + ↑ 1993 ↑ + vanb → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Mark +Schnitzius
Location: unknown

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1993 schnitzi in bugs.md.

+

To use:

+
./schnitzi file
+

where

+

file is a file containing some text.

+

Certain input will cause the program to fail as described in the +bugs.md file.

+

Try:

+
./schnitzi schnitzi.info
+# ask some questions suggested by the author, noted below
+

We also suggest you ask the program the following questions:

+
Who is Mark Schnitzus?
+
+Who was Jack the Ripper ?
+

Notice how it still manages to answer the first question despite +there being an intentional spelling error there.

+

Try feeding the program source to the program and ask both:

+
What is cat ?
+What is cat?
+

What happens if you ask it other questions with and without a space +before the ??

+

Judges’ remarks:

+

After this program prints the contents of ‘file’, ask it some +questions related to the text.

+

The author suggests the following questions when using schnitzi.info:

+ +

We suggest you try using the body (minus the header and signature +line) of a Usenet article. You might want to try something from +alt.flame. :-)

+

NOTE: If you have certain ' in the question this entry +might fail.

+

Author’s remarks:

+

I wanted to write a program that would read in a text file in natural +language (such as English) and answer questions about that text file. I +thought this might be a complicated task, and I was right – it took me +over 800 bytes. Of course, it doesn’t always work, but that’s AI for +you.

+

This program accepts the name of a text file as the first parameter. +For example, to run it on the supplied data file called ‘schnitzi.info’ +you would type ./schnitzi schnitzi.info. It echoes the +file, then gives you a prompt where you may type in questions about that +text. The more words you use which are actually present in the text +file, the better results you get. You’ll need to hit ctrl-c +to break out of the program. Just hitting return at the +prompt will reprint the paragraph.

+

If you’re curious as to how it works, I guess you could feed in the +source as the input file and ask “How does this work?” at the prompt, +but I’m not guaranteeing any results…

+

Compilation notes

+ +

Obfuscation

+ +

The text for the info file, by the way, consists largely of headlines +from the Weekly World News.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1993/schnitzi

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1993/vanb/index.html b/1993/vanb/index.html index f5737872c..9a5c62700 100644 --- a/1993/vanb/index.html +++ b/1993/vanb/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,344 @@ - - + + + + + + - - -1993 vanb - - + + + +1993/vanb + + + + + -

1993 vanb

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1993/vanb

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1993/vanb/index.html

- +
+ ← schnitzi + ↑ 1993 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: David Van +Brackle
Location: unknown

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1993 +vanb in bugs.md.

+

To use:

+
./vanb 'exp'
+

where exp is an octal expression. See below for how it +can also have hexadecimal and decimal numbers.

+

Try:

+
./try.sh
+

What happens if you use something other than valid digits?

+

Judges’ remarks:

+

The octal expression may contain:

+
unary operators:    +, -
+binary operators    +, -, *, /, %
+hex numbers:        x or X followed by hex digits
+decimal numbers:    d or D followed by decimal digits
+octal numbers:      octal digits
+grouping:       ()
+

No spaces are allowed in the expression. To avoid shell expansion, +one should surround the expression in single quotes.

+

It is a good thing that this program consists of only one expression, +otherwise it might become hard to understand. :-)

+

Author’s remarks:

+

The program does no error checking - erroneous expressions will +produce spurious results. Note that unary - is an operator. +Thus, decimal -46 would be entered as -d46 and +not d-46.

+

What Makes This Program +Special:

+
    +
  1. Of course, the fact that the program takes input and produces +output in octal, rather than a more useful system like decimal, makes it +“special”.

  2. +
  3. The entire program consists of a single expression, returned from +main().

  4. +
  5. There are no global or local variables other than the parameters +to main().

  6. +
  7. All of the constants in the program are expressed in octal - +including the printf(3) string.

  8. +
  9. The variables are given names which cause visual confusion with +the octal constants.

  10. +
  11. The program is formatted like a Roman numeral 8. The significance +of 8 is obvious. I chose Roman numerals because it is a numbering system +even more arcane than octal. It’s not very ‘deceptive’, but it’s +difficult to deceptively format a program which has no explicit control +structures (other than ?:s).

  12. +
  13. Many simple tasks are done many times. I tried to do these +differently each time, to make the program harder to +understand.

  14. +
+

How It Works:

+

It’s a recursive descent parser, calling main() for all +of its recursion. O2 is a state variable, telling +main() what grammar non-terminal to parse. +**O7 is the next character. O3 is an +intermediate result. Whenever you see a construct like:

+
!(expression with O2)?
+

it’s decrementing and testing O2 to see what state it’s +in. Comparisons involving **O7 and octal constants are +looking for certain characters.

+

Here’s the grammar ('e' denotes the empty string) :

+
<E>  ::=  <T><E'>
+<E'> ::=  +<T><E'> | -<T><E'> | e
+<T>  ::=  <F><T'>
+<T'> ::=  *<F><T'> | /<F><T'> | %<F><T'> | e
+<F>  ::=  +<F> | -<F> | (<E><C> | d<D> | D<D> |  x<X> | X<X> | <O>
+<C>  ::=  )
+<D>  ::=  [0-9]<D> | e
+<X>  ::=  [0-9]<X> | [A-F]<X> | [a-f]<X> | e
+<O>  ::=  [0-7]<O> | e
+

Here’s how the grammar nonterminals map to octal state numbers:

+
<E>  is  012
+<E'> is  011
+<T>  is  010
+<T'> is   07
+<F>  is   06
+<C>  is  013
+<D>  is   04
+<X>  is   05
+<O>  is   03
+

Here’s a version of the program before it got formatted into the +VIII, augmented with comments showing where each state begins. +N1 and N2 are notes:

+
#define O5 main
+O5(O2,O7,O3)char**O7;
+{
+     return
+/* N1 */ !(O2+=~01+01) ?\
+          00:
+/* N2 */ !(O2-=02>01) ?\
+          printf("\045\157\012",O5(012,O7+01,00)):
+/* O  */ !(O2-=02>>01) ?\
+          (**O7<=067 && **O7>057 ? O5(03,O7,*(*O7)++-060+010*O3):O3):
+/* D  */ !(O2-=-O3-~O3) ?\
+          (072>**O7 && 060<=**O7 ? O5(04,O7,012*O3-060+*(*O7)++):O3):
+/* X  */ !(O2-=!O3+!!O3) ?\
+          (**O7>057 && **O7<=071 ? O5(05,O7,*(*O7)+++O3*020-060):
+          **O7<=0106 && 0101<=**O7 ? O5(05,O7,020*O3+*(*O7)++-067):
+          0140<**O7 && **O7<0147 ? O5(05,O7,-0127+*(*O7)+++020*O3):O3):
+/* F  */ !(O2-=02-01) ?\
+          (**O7==050 ? 050**++*O7,O5(013,O7,O5(012,O7,00)):
+          **O7<056 && 054<**O7 ? 055**++*O7,-O5(06,O7,00):
+          054>**O7 && 052<**O7 ? 050**(*O7)++,O5(06,O7,00):
+          !(**O7^0170)||!(0130^**O7) ? *++*O7,O5(05,O7,00):
+          **O7==0144||**O7==0104 ? ++*O7,O5(04,O7,00):O5(03,O7,00)):
+/* T' */ !--O2 ?\
+          (**O7==052 ? O5(07,O7,O3*(*++*O7,O5(06,O7,00))):
+          !(045-**O7) ? O5(07,O7,O3%(03+(*O7)++,O5(06,O7,00))):
+          !(**O7^057) ? O5(07,O7,O3/(03-*++*O7,O5(06,O7,00))):O3):
+/* T  */ !(O2+=01-02) ?\
+          O5(07,O7,O5(06,O7,00)):
+/* E' */ !(O2+=-02/02) ?\
+          (!(**O7-053)?O5(011,O7,O3+(++*O7,O5(010,O7,00))):
+          !(055^**O7) ? O5(011,O7,O3-(03+*(*O7)++,O5(010,O7,00))):O3):
+/* E  */ !(O2-=0563&0215) ?\
+          O5(011,O7,O5(010,O7,00)):
+/* C  */ (++*O7,O3);
+}
+

Note N1: It should never enter this state, unless the +user invokes the program with no parameters, in which case it just +returns 0.

+

Note N2: Since the program is properly invoked with 1 +parameter, this is the first state it will go into. This state just +invokes printf, and sends the parser to state 012 (which is +<E>).

+

The E and T states work like this:

+
int e(){ return eprime( t() ); }
+

The E' and T' states work like this:

+
int eprime( int intermediate )
+{
+    if( ch == '+' )
+    {
+    ch = nextchar();
+    return eprime( intermediate + t() );
+    }
+    else return intermediate;
+}
+

The D, X and O states work +like this (they assume that they’re initially called with +0):

+
int octal( int intermediate )
+{
+    if( ch>='0' && ch<='7' )
+    {
+    intermediate = intermediate * 8 + ch - '0';
+    ch = nextchar();
+    return octal( intermediate );
+    }
+    else return intermediate;
+}
+

F and C work similarly.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1993/vanb

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1994/dodsond1/index.html b/1994/dodsond1/index.html index 50ab30804..8c8d1664e 100644 --- a/1994/dodsond1/index.html +++ b/1994/dodsond1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,199 @@ - - + + + + + + - - -1994 dodsond1 - - + + + +1994/dodsond1 + + + + + -

1994 dodsond1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1994/dodsond1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1994/dodsond1/index.html

- +
+ first entry + ↑ 1994 ↑ + dodsond2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Don Dodson
+Location: US

+ + +

To build:

+
make all
+

To use:

+
./dodsond1
+

Try:

+

At the prompt, try entering E3.

+

Judges’ remarks:

+

The program plays the game that the layout of the source implies. The +source, on the other hand, implies a language along the lines of Lisp. +:-)

+

Author’s remarks:

+

For each turn, the board is displayed and the player is prompted for +a move. Enter your move as an upper-case character followed by a +number.

+

The program uses a single function for 4 different purposes – to +determine if a valid move exists, to verify that a move is valid, to +make a move, and to determine the value of a move.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1994/dodsond1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1994/dodsond2/index.html b/1994/dodsond2/index.html index a07b79bf9..83258d386 100644 --- a/1994/dodsond2/index.html +++ b/1994/dodsond2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,256 @@ - - + + + + + + - - -1994 dodsond2 - - + + + +1994/dodsond2 + + + + + -

1994 dodsond2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1994/dodsond2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1994/dodsond2/index.html

- +
+ ← dodsond1 + ↑ 1994 ↑ + horton → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Don Dodson
+Location: US

+ + +

To build:

+
make all
+

There is an alternate version that allows you to cheat, giving you +configurable amount of arrows at the start of the game. See the Alternate code section below.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1994 dodsond2 in bugs.md.

+

To use:

+
./dodsond2
+

Alternate code:

+

This version allows you to choose how many arrows to start with, +instead of the default 0. If one tries specifying a value < 0 it will +set it to 0.

+

Fun fact: this version helped uncover and fix a bug that prevented +the entry from working in some cases.

+

Alternate build:

+
make alt
+

The default number of arrows in this version is 3 but if you want to +change it, say to 5, try:

+
make clobber ARROWS=5 alt
+

Alternate use:

+
./dodsond2.alt
+

Judges’ remarks:

+

Each year people find new ways to squeeze more and more out of the +contest rules. Next year, entries that use compression utilities to get +around the size limit will find themselves squeezed out of the +contest!

+

A historical note:

+

The original source code was submitted as a GZIP compressed file that +the file(1) command reports as:

+
dodsond2.gz: gzip compressed data, last modified: Mon Aug 29 21:54:39 1994, max compression, from Unix, original size modulo 2^32 2652
+

The dodsond2.gz file was submitted as +source in an effort to get around the 1994 version of Rule 2:

+
2) Your entry must be <= 3217 bytes in length.  The number of characters
+   excluding whitespace (tab, space, newline), and excluding any ; { or }
+   followed by either whitespace or end of file, must be <= 1536.
+

Indeed, when dodsond2.gz is uncompressed, +it is identical to the dodsond2.c file you find +today.

+

The IOCCC rules and guidelines were modified in an effort to address +this fun “abuse of the rules” style hack.

+

It is worth noting that without this compression “abuse of the +rules” style hack, the dodsond2.c is +further obfuscated.

+

Author’s remarks:

+

Go searching for the Wumpus in the Caverns of Doom! But be careful… +There are pits and bats waiting to seal your fate, as well as a stealthy +robber lurking in the shadows. Move through the rooms by typing the +number of the adjacent room you wish to visit. You can feel a breeze if +there is a pit in an adjacent room. A rustling sound will tell you that +bats are nearby. The scent of the evil Wumpus can be detected from 2 +rooms away.

+

To win, you must find one or more arrows, determine where the Wumpus +is, and shoot him, all without falling into a pit or becoming the next +meal for the Wumpus. To shoot an arrow, type s. Then give a +list of the rooms you want to shoot into. The rooms must be connected in +the order you list them, or else the arrow may bounce back and hit you. +An arrow can go through as many as four rooms. But beware that shooting +an arrow and missing the Wumpus may awaken him.

+

There is a robber who waits in an unknown room. If you enter that +room carrying an arrow, he will steal that arrow from you and move to a +new room. If he steals all the arrows in the Caverns, you may catch him +and recover all of them. Doing this gives you a bonus on your score.

+

You can quit at any time by typing q. Typing +i will tell you how many arrows you are carrying. +l prints the description of the current room again.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1994/dodsond2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1994/horton/.winner.json b/1994/horton/.winner.json index dd78d6e67..6ab324b75 100644 --- a/1994/horton/.winner.json +++ b/1994/horton/.winner.json @@ -57,6 +57,30 @@ "display_via_github" : true, "winners_text" : "gtface source code" }, + { + "file_path" : "try.alt.sh", + "inventory_order" : 100, + "OK_to_edit" : true, + "display_as" : "shellscript", + "display_via_github" : true, + "winners_text" : "how to run alternative code" + }, + { + "file_path" : "try.sh", + "inventory_order" : 100, + "OK_to_edit" : true, + "display_as" : "shellscript", + "display_via_github" : true, + "winners_text" : "how to run" + }, + { + "file_path" : "login_sept92-pp28-31.pdf", + "inventory_order" : 125, + "OK_to_edit" : true, + "display_as" : "pdf", + "display_via_github" : false, + "winners_text" : "login article on graphics for dumb terminals" + }, { "file_path" : "gtface.data", "inventory_order" : 150, diff --git a/1994/horton/index.html b/1994/horton/index.html index 3fe3afd34..b6634e3aa 100644 --- a/1994/horton/index.html +++ b/1994/horton/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,271 @@ - - + + + + + + - - -1994 horton - - + + + +1994/horton + + + + + -

1994 horton

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1994/horton

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1994/horton/index.html

- +
+ ← dodsond2 + ↑ 1994 ↑ + imc → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Mary Ann +Horton
Location: US

+ + +

To build:

+
make all
+

To use:

+
./horton A B C D
+

A, B, C and D are +numeric arguments.

+

Try:

+
./try.sh
+

Alternate code:

+

This confuses cb greatly. See horton.alt.c +for an unobfuscated/enhanced version.

+

Alternate build:

+
make alt
+

Alternate use:

+
./horton.alt A B C D
+

Where A, B, C and D are numbers like with horton.

+

Alternate try:

+
./try.alt.sh
+

Judges’ remarks:

+

Try to figure out how this program prints, for a given slope, the +right character. And for extra credit, try to figure out which character +is at the bottom of this hint file. :-)

+

You might be interested in the author’s article that they cite +towards the end of their remarks, included as PDF files for your +convenience, the full newsletter and a PDF file of just the pages +cited.

+

Author’s remarks:

+

Run it with any 4 numeric arguments, +e.g. ./horton 3 2 1 0. Play with the numbers to get a +pleasing result, or use it for your high school algebra class.

+

SPOILER:

+

As should be obvious from 20 feet away, the program is a cubic +plotter. It plots against certain artists, splattering their cubes with +graphs of their cubic equations. Those dastardly arguments are mere +coefficients, cogs in the wheels of the grand plot to overthrow the +cubics!

+

Oh, by the way, it uses a self-contained graphtab and frame buffer. +It’s easily modified to graph any 96x160 bitmap on a dumb +terminal.

+

See the gtface program for another example. +Try:

+
make gtface
+./gtface < gtface.data
+

For more information, see my article

+

Using GraphTab; USENIX ;login: +Sept/Oct 1992, pages 28-31.

+

+              MMMM,M,MM"MM,,,
+           ,,MMMMMMMMM"""""""",
+          ,MMMMM"""            ",
+         ,MMM"                   "
+         MMM                      M
+         MM
+         MM" "                     M
+          M " , ,,,,,     ,,,,,,,,,MM
+          "MMMM"M,MMMMM MMMM M M"MMM,
+         ,M"MMMM"MM"MMM""M""MMMM""M"M
+          , MM M M,M M"  "M",, M "M "
+          M ,M,"    ,M    "M, ,,,", M
+           M , M"MMM",,M,M,,""" , ,
+          ",," , " "MMMMMMMM "   , "
+           ,M , ""M,MMMMMMMM,M " ,,
+           ,MM, MMMMMMMMMMMMMM,", M,
+            M,M,MM"M"M" """M"MM,M M
+           ,MMMMMM M,MMMMM"M MM""M
+          M MMMMMM,M M"M"" M MMMM", ,
+           "M"MMMMMMMMMM"M ,MMMMM M  ,,
+         "" MMMMMMM,M,MM,M,,,MMM"M    ,
+       ," , "MMMMMMM"MM"M,,,,MMMMM ,   ,,
+       M  ," MMMMMM"MM""M ,MMMMM,M,    M
+      ,      MMMM,MMMM"M"M"M,MM,M,",    "
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1994/horton

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1994/imc/.winner.json b/1994/imc/.winner.json index b9b706a4a..42ec2a9b3 100644 --- a/1994/imc/.winner.json +++ b/1994/imc/.winner.json @@ -41,6 +41,14 @@ "display_via_github" : true, "winners_text" : "original source" }, + { + "file_path" : "try.sh", + "inventory_order" : 100, + "OK_to_edit" : true, + "display_as" : "shellscript", + "display_via_github" : true, + "winners_text" : "how to run" + }, { "file_path" : "1994_imc.tar.bz2", "inventory_order" : 300, diff --git a/1994/imc/index.html b/1994/imc/index.html index 803539308..5f6f7c7ca 100644 --- a/1994/imc/index.html +++ b/1994/imc/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,238 @@ - - + + + + + + - - -1994 imc - - + + + +1994/imc + + + + + -

1994 imc

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1994/imc

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1994/imc/index.html

- +
+ ← horton + ↑ 1994 ↑ + ldb → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Ian Collier
+Location: GB

+ + +

To build:

+
make all
+

To use:

+
./imc [NUMBER]
+

where [NUMBER] is an optional number. Default is 5.

+

Try:

+
./try.sh
+

Judges’ remarks:

+

This entry’s algorithm is as magic as its output!

+

Author’s remarks:

+

This program may be compiled with an ANSI or K&R compiler. A few +harmless warnings are displayed only if gcc -Wall is +used.

+

This entry is really a set of library functions, but an example +main() function has been added so that the library can be +tested. If the program appears too large, consider that functions +o() and s() can each be separated from the +rest of the program (except for the short functions p() and +r(), which they require) and used alone. However, the main +part of the program is the function e, which does require +all the other functions (apart from main()).

+

The program should be supplied with an integer parameter. If no +parameter or an invalid parameter is given, then 5 is assumed. The +maximum parameter is determined only by the amount of CPU time, virtual +memory and display (or file) space available.

+

SPOILER:

+

OK, so you have probably seen magic square printers before. But what +about one that deals with even sizes as well as odd ones, or one that +prints out a different one each time (or attempts to, at any rate)?

+

I have formatted the important functions o(), +s() and e() to show how useful the word +for is, and (in function e()) how useful the +words if and else are. In fact, hardly +anything happens that isn’t in one of these instructions. I did this in +order to simplify the code - the algorithms used to make the random +squares are quite complex without being shrouded in obfuscated code! :-) +Incidentally, I was surprised to find out how useful the exclusive-or +operator was while writing function s().

+

Here are the descriptions of the functions in the library:

+
o(n,a,q,d): makes a magic square of order n when n is odd and at least 3.
+s(n,a,q,d): makes a magic square of order n when n equals 4.
+e(n,a,q,d): makes a magic square of order n when n is even and at least 6.
+

In the above, a (of type int *) points to +an area of memory in which the magic square will be stored and +q (also of type int *) points to an area of +memory of length at least n*sizeof(int) bytes which can be +used as a work space. Both a and q must be +allocated by the caller. The integer parameter d, usually +zero, indicates the length of a gap which will be left between adjacent +rows of the magic square.

+

The square which is returned will (or should) be a permutation of the +numbers 1 to n*n in which all rows and columns and the two +diagonals add up to n*(n*n+1)/2.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1994/imc

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1994/ldb/.winner.json b/1994/ldb/.winner.json index 59d03b362..e7075e8fd 100644 --- a/1994/ldb/.winner.json +++ b/1994/ldb/.winner.json @@ -41,6 +41,14 @@ "display_via_github" : true, "winners_text" : "original source" }, + { + "file_path" : "try.sh", + "inventory_order" : 100, + "OK_to_edit" : true, + "display_as" : "shellscript", + "display_via_github" : true, + "winners_text" : "how to run" + }, { "file_path" : "1994_ldb.tar.bz2", "inventory_order" : 300, diff --git a/1994/ldb/index.html b/1994/ldb/index.html index 2084f18c7..fe4c19304 100644 --- a/1994/ldb/index.html +++ b/1994/ldb/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,207 @@ - - + + + + + + - - -1994 ldb - - + + + +1994/ldb + + + + + -

1994 ldb

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1994/ldb

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1994/ldb/index.html

- +
+ ← imc + ↑ 1994 ↑ + schnitzi → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Laurion +Burchall
Location: unknown

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1994 +ldb in bugs.md.

+

To use:

+
./ldb < file
+
+some_command | ./ldb
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Trigraphs are natural obfuscators. Most C-beautifiers become +C-uglifiers because they don’t handle them correctly.

+

Can you figure out how it prints a given random line (or if the line +is longer than 231 characters, part of that line) from stdin?

+

Author’s remarks:

+

All input lines must be under 232 characters long. The compiling +platform should be ASCII based.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1994/ldb

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1994/schnitzi/.winner.json b/1994/schnitzi/.winner.json index 97441065a..5421e93bb 100644 --- a/1994/schnitzi/.winner.json +++ b/1994/schnitzi/.winner.json @@ -57,6 +57,30 @@ "display_via_github" : true, "winners_text" : "original source" }, + { + "file_path" : "try.alt.sh", + "inventory_order" : 100, + "OK_to_edit" : true, + "display_as" : "shellscript", + "display_via_github" : true, + "winners_text" : "how to run alternative code" + }, + { + "file_path" : "try.sh", + "inventory_order" : 100, + "OK_to_edit" : true, + "display_as" : "shellscript", + "display_via_github" : true, + "winners_text" : "how to run" + }, + { + "file_path" : "try.txt", + "inventory_order" : 100, + "OK_to_edit" : true, + "display_as" : "text", + "display_via_github" : true, + "winners_text" : "input data for try.sh" + }, { "file_path" : "1994_schnitzi.tar.bz2", "inventory_order" : 300, diff --git a/1994/schnitzi/index.html b/1994/schnitzi/index.html index f0f934603..3484116e2 100644 --- a/1994/schnitzi/index.html +++ b/1994/schnitzi/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,274 @@ - - + + + + + + - - -1994 schnitzi - - + + + +1994/schnitzi + + + + + -

1994 schnitzi

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1994/schnitzi

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1994/schnitzi/index.html

- +
+ ← ldb + ↑ 1994 ↑ + shapiro → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Mark +Schnitzius
Location: unknown

+ + +

To build:

+
make all
+

There are two alternate versions, one that has an increased buffer +size and one that uses fgets(); neither are completely +functional. See below section bugs and (mis)features for details and the +alternate code section for how to use.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: uses gets() - change to fgets() if possible
+

For more detailed information see 1994 schnitzi in bugs.md.

+

To use:

+
./schnitzi < textfile
+

Try:

+
./try.sh
+

Alternate code:

+

The first version, schnitzi.alt.c, uses +fgets(3) but when fed its own code it will generate code +that still uses gets(3). What’s more is it will not +compile. Other functionality works fine.

+

The second version, schnitzi.alt2.c, has an increased +buffer size but when fed its own source code it will generate code that +can compile but with the original buffer size. This is due to a comment +which is explained in more detail in 1994/schnitzi in bugs.md.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use schnitzi.alt and schnitzi.alt2 as you +would schnitzi above except that feeding the source code to +it will not work right.

+

Alternate try:

+
./try.alt.sh
+

Judges’ remarks:

+

Try:

+
./schnitzi < schnitzi.c
+

Compare the output of the program with its source. Sure the output is +different, but there is more than meets the diff’s eye. Can +you find out why?

+

You might also wish to redirect the output to another file, compile +it and compare how it works to the original code.

+

Author’s remarks:

+

SPOILER:

+

This is a program which takes any text file as input and ‘flips’ the +input file along a diagonal running from the top left corner down to the +bottom right. In other words, the first row in the file ends up written +down the first column of the result, the second row is written down the +second column, etc. The program is run by redirecting a file into the +executable on the command line; for instance, for the file ‘info’, the +program would be run as follows:

+
./schnitzi < info
+

The program generates interesting results when its source file is +used as input:

+
./schnitzi < schnitzi.c
+

The result of this command is a program which does the exact same +thing – in other words, both the program and the “flipped” version of +itself work identically (you’ll need to redirect the output of the above +command into a separate file and compile it). You might notice some +differences in the flipped version, though. First off, a secret message +becomes visible that was not visible in the original program. Also, much +of the code shows up in different places in the flipped program than it +appeared in the first program. My first version of this program was +perfectly symmetrical along the diagonal, but I later found out there +were interesting ways to break the symmetry. The best way to see this is +to load both the original and flipped versions of the program into an +editor and switch back and forth between them rapidly.

+

C tokens longer than a character (such as main()) proved +difficult to use in both the original and flipped versions (after +flipping, they show up as a string of single letters on successive +lines). However, I found that it was possible to get around this through +a few well-placed comments. An earlier version of this program used +nearly every single-character token in the “shared” area; however, it +proved to be too large for contest guidelines (although the code itself +is only about 300 characters, the extra whitespace needed to pad it put +it over the limit – it nearly filled a 79 by 79 area, adding up to over +4000 total characters).

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1994/schnitzi

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1994/shapiro/index.html b/1994/shapiro/index.html index 192e187a1..24e85f0ed 100644 --- a/1994/shapiro/index.html +++ b/1994/shapiro/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,252 @@ - - + + + + + + - - -1994 shapiro - - + + + +1994/shapiro + + + + + -

1994 shapiro

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1994/shapiro

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1994/shapiro/index.html

- +
+ ← schnitzi + ↑ 1994 ↑ + smr → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Andrew T. +Shapiro
Location: unknown

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: missing file - please provide it
+STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1994 shapiro in bugs.md.

+

To use:

+
./shapiro &
+

Now find the clock in the same terminal window (or console if at the +console).

+

Try:

+
./shapiro
+^Z
+bg
+ps x
+fg
+^C
+
+./shapiro_t1
+

Notice what you see in the output of ps! Observe too +what happens after you bring it back to the foreground.

+

Judges’ remarks:

+

This entry has many different levels of obfuscation, and yet the +source file is self documenting. :-)

+

From time to time, run ps(1) and look at the new +processes.

+

See shapiro.md for more information in the +internals of this program. The file shapiro.alt.c contains a non-obfuscated version +of this program. Note that this alt file is currently missing. See bugs.md for details.

+

Author’s remarks:

+

The basic theme (pun) of this program is:

+
+

“This time (everything) is not where it should be.” ~~~~

+
+

My entry (shapiro.c) is mostly comments, +formatted in the shape of a clock. If you strip out the comments and +look at the code you will quickly realize that the comments were the +important part and that the code does very little (see pun above). It +writes (to stdout) another C program (shapiro_t2.c). This is the first level of +obfuscation.

+

The second program (shapiro_t2.c (use +make everything first) prints a clock in the upper right +hand corner of your VTxxx/ANSI display.

+

Most of the surface obfuscation in the second program (shapiro_t2.c) was an attempt to make it as small +as possible. You should be able to see around this with +cb(1) and some more intelligent variable names. Once you +get past this you will realize that the third level of obfuscation is a +six member client/server hierarchy. (See the shapiro.md file for a detailed description of the +algorithm.)

+

lint complains about: precedence confusion, +K may be used before set, main() returns +random value to invocation environment, value type used inconsistently, +value type declared inconsistently, function argument (number) used +inconsistently, function returns value which is always ignored, function +returns value which is sometimes ignored. All of which are harmless +(famous last words).

+

This may or may not work on non ASCII systems (I could not find one +to test it on.)

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1994/shapiro

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1994/smr/.winner.json b/1994/smr/.winner.json index daf9e15fd..672e83a75 100644 --- a/1994/smr/.winner.json +++ b/1994/smr/.winner.json @@ -41,6 +41,14 @@ "display_via_github" : true, "winners_text" : "original source" }, + { + "file_path" : "try.sh", + "inventory_order" : 100, + "OK_to_edit" : true, + "display_as" : "shellscript", + "display_via_github" : true, + "winners_text" : "how to run" + }, { "file_path" : "1994_smr.tar.bz2", "inventory_order" : 300, diff --git a/1994/smr/index.html b/1994/smr/index.html index 35efe83b4..f5a83b027 100644 --- a/1994/smr/index.html +++ b/1994/smr/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,210 @@ - - + + + + + + - - -1994 smr - - + + + +1994/smr + + + + + -

1994 smr

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1994/smr

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1994/smr/index.html

- +
+ ← shapiro + ↑ 1994 ↑ + tvr → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Szymon +Rusinkiewicz
Location: US

+ + +

To build:

+
make all
+

To use:

+
./smr
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Nearly every year, one or more people would submit what they claimed +was the world’s smallest self reproducing program. While the sizes of +these submissions varied, a quick glance would reveal that they were too +big, until this entry came along.

+

While strictly speaking, smr.c is not a valid C +program, it is not an invalid C program either! Some C compilers will +compile an empty file into a program that does nothing. But even if your +compiler can’t, the build instructions supplied with this entry will +produce an executable file. On most systems, the stdout +from the executable will exactly match the original source.

+

In the future, the contest rules will specify a minimum size that is +one character larger than this entry, forever eliminating this sort of +program from the contest. After all, how many variations can one make on +this entry? :-)

+

Author’s remarks:

+

The world’s smallest self-replicating program. Guaranteed. Produces a +listing of itself on stdout.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1994/smr

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1994/tvr/.winner.json b/1994/tvr/.winner.json index 4c9e04fee..dff61bcdb 100644 --- a/1994/tvr/.winner.json +++ b/1994/tvr/.winner.json @@ -49,6 +49,38 @@ "display_via_github" : true, "winners_text" : "original source" }, + { + "file_path" : "try.alt.bw.sh", + "inventory_order" : 100, + "OK_to_edit" : true, + "display_as" : "shellscript", + "display_via_github" : true, + "winners_text" : "demonstrate alt code in black and white mode" + }, + { + "file_path" : "try.alt.color.sh", + "inventory_order" : 100, + "OK_to_edit" : true, + "display_as" : "shellscript", + "display_via_github" : true, + "winners_text" : "demonstrate alt code in colour mode" + }, + { + "file_path" : "try.bw.sh", + "inventory_order" : 100, + "OK_to_edit" : true, + "display_as" : "shellscript", + "display_via_github" : true, + "winners_text" : "demonstrate code in black and white mode" + }, + { + "file_path" : "try.color.sh", + "inventory_order" : 100, + "OK_to_edit" : true, + "display_as" : "shellscript", + "display_via_github" : true, + "winners_text" : "demonstrate alt code in colour mode" + }, { "file_path" : "tvr.bw", "inventory_order" : 150, diff --git a/1994/tvr/index.html b/1994/tvr/index.html index 2c341e28e..d7924badf 100644 --- a/1994/tvr/index.html +++ b/1994/tvr/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,377 @@ - - + + + + + + - - -1994 tvr - - + + + +1994/tvr + + + + + -

1994 tvr

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1994/tvr

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1994/tvr/index.html

- +
+ ← smr + ↑ 1994 ↑ + weisberg → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Teemu +Rantanen
Location: FI

+ + +

To build:

+
make all
+

The author provided a spoiler version as alt code. See Alternate code below.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: known bug - please help us fix
+

For more detailed information see 1994 +tvr in bugs.md.

+

To use:

+
./tvr mode screensize/2 < colormapfile
+

Mode may be a value from 0 to 12.

+

Try:

+
./try.color.sh          # for colour displays
+./try.bw.sh         # for Black & White displays
+

Alternate code:

+

The author provided us a spoiler version that might be of interest to +some.

+

Alternate build:

+
make alt
+

Alternate use:

+
./tvr.alt altmode screensize/2 < colormapfile
+

where altmode 1 - 4 correspond +to mode 0 - 3 in the original entry and +altmode 0 calculates Mandelbrot/Julian sets correctly.

+

Alternate try:

+
./try.alt.color.sh          # for colour displays
+./try.alt.bw.sh         # for Black & White displays
+

Judges’ remarks:

+

This entry requires the use of X11. It will form two windows +(hopefully your window manager will ask you where to place these in your +display) which you should place side by side. Move the cursor around in +one of the two windows and watch what happens.

+

The fractally minded may be able to detect that mode 0 does not +calculate Mandelbrot/Julian sets correctly. Can you find the bug? Better +still, can you fix it without breaking something else?

+

Author’s remarks:

+

Interactive Fractals +for X Window System

+

This program contains four pairs of fractals/effects and three +methods of animating them. There are two windows for a pair of fractals, +one of which contains static fractal (e.g. Mandelbrot set) +and the other an animating one (e.g. Julia set) which is +derived from the same formula as the static one. Only one pair of +fractals can be displayed in one process.

+

To animate the fractal, you must move your mouse on the static +fractal window and the animated fractal will be calculated based on +mouse coordinates. If you are on one of the two non-stable modes (more +about them later) you can stabilize the picture by pressing a mouse +button. Pressing it does nothing on stable mode.

+

The three modes are:

+ +

On Mandelbrot/Julia mode the stable mode calculates normal Julia set +according to the Mandelbrot coordinates (mouse position). On non-stable +modes the picture slowly transforms to the same picture as on the stable +mode but transformation can take some time. Usually, and especially if +changes are relatively small between mouse movements or frame rate is +high, the non-stable mode makes much more interesting effects IMHO. The +difference between the two non-stable modes is that the first tries to +stabilize the picture. It doesn’t stabilize much, but it helps in some +cases quite a lot. One notable case where help can be seen is when you +first move your mouse to non-black areas of the Mandelbrot set, then +back to near the center. In some cases ‘attractor searcher’ can be seen +as noise.

+

The first of the fractal pairs is Mandelbrot/Julia set as mentioned +before. The second is a variation of that. The third makes nice +3D-look-a-like effects and the fourth is a variation of that with more +nice effects.

+

Usage:

+
./tvr mode screensize/2 < colormapfile
+

The first parameter is the operating-mode of the program. There are 4 +fractal pairs and 3 display modes, making total of 12 modes. +screensize is half of the actual +screenlength/width. I.e. if you use 128 as a second +parameter, you will get two 256x256 windows.

+

The program needs reasonable values for both of these parameters to +operate. A good first try could be 0 128 or +8 128. The colormap has to be redirected into +the programs standard input via the colormapfile parameter +as shown above.

+

Note that you will need approximately +(second_parameter^2)*64 bytes of free main memory or the +machine will swap heavily (memory references are quite random and may +confuse paging algorithms easily). This means that for 512x512 windows +you will need 4M of memory.

+

colormapfile

+

This is the file from which program reads colors for screen +colormap. The first line of the file must be a number +between 3..254. This informs the program how many colors +there are to be expected. This is also the maximum number of iterations +used on picture calculations. Lines after that are X11 color names. The +program expects to find, and will use, the number of colors reported on +the first line.

+

There are two colormapfiles to start with. One with +colors and another with only black and white. If you have enough colors +on your display you can use the one with colors (even on +grayscale). The other is meant mainly for a one bit plane +display (on which the picture looks terrible compared to a 8 bit plane +display).

+

Compilation

+

You should compile this entry with an optimizing compiler with the +highest level of optimization possible. You will also need an ANSI +compatible compiler (gcc -ansi -pedantic will do fine).

+

This entry has been tested on wide variety of machines including:

+
Machine         OS
+-------         --
+Decstation 5000/240 Ultrix 4.3A
+DECAlpha 3000/300   OSF/1 v1.3 and v2.0
+IBM RS6000      AIX v3
+SPARCStation IPX    SunOS 4.1.3
+i486            Linux v1.1.8  (binarysize 3576 bytes
+                      using `gcc -O6 -s -N` ;)
+HP 9000/730     HP-UX
+

Also, many of the X server and X library versions have been tested +and the program should be highly portable. The program may slow down +considerably on machines where table references are slow as the program +makes extensive use of them. Also, due to the huge amount of data sent +to the X server, considerable slowdown can be noticed if the X server is +slow or especially if the connection between the X server and the client +is slow. (Don’t try this on 9600 bps modem line. I did ;) )

+

Obfuscation

+

Obfuscation is done on different levels. Almost none of it is made at +the macro level, so cpping the code won’t give you much. +Perhaps most notable is the algorithmic obfuscation. Simple formula has +been turned into something completely different. Also it may be a +surprise to find out which piece of the code calculates non-stable +fractals and how it does that. Many obfuscations were left out of the +program because speed of animation was one of the key issues. Well, +obfuscated or not, some of the effects are very nice ;)

+

Memory refreshment

+

Mandelbrot set is calculated from the formula

+

+                 2
+              Z   = Z  + Z
+               n+1   n    0
+

and the Julia set is calculated from the formula

+

+                 2
+              Z   = Z  + C
+               n+1   n
+
+

where C is the same throughout the picture. Both +calculation are finished when |Z| >= 2.0. For the other +fractals, the basic methods are the same but the formula is different +(look at the source ;) )

+

Note that Mandelbrot and Julia on this program aren’t exactly +correct. Find out why ;)

+

Bugs

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1994/tvr

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1994/weisberg/.winner.json b/1994/weisberg/.winner.json index 3899c7d6c..df7ef1fd2 100644 --- a/1994/weisberg/.winner.json +++ b/1994/weisberg/.winner.json @@ -41,6 +41,22 @@ "display_via_github" : true, "winners_text" : "original source" }, + { + "file_path" : "primes.sh", + "inventory_order" : 100, + "OK_to_edit" : true, + "display_as" : "shellscript", + "display_via_github" : true, + "winners_text" : "feed primes to the program" + }, + { + "file_path" : "try.sh", + "inventory_order" : 100, + "OK_to_edit" : true, + "display_as" : "shellscript", + "display_via_github" : true, + "winners_text" : "how to run" + }, { "file_path" : "1994_weisberg.tar.bz2", "inventory_order" : 300, diff --git a/1994/weisberg/index.html b/1994/weisberg/index.html index 165e65f08..5a866bba3 100644 --- a/1994/weisberg/index.html +++ b/1994/weisberg/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,242 @@ - - + + + + + + - - -1994 weisberg - - + + + +1994/weisberg + + + + + -

1994 weisberg

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1994/weisberg

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1994/weisberg/index.html

- +
+ ← tvr + ↑ 1994 ↑ + westley → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jeff Weisberg
+Location: unknown

+ + +

To build:

+
make all
+

There is an alternate version that uses more memory. See alternate code below for more details.

+

To use:

+
./weisberg
+

Try:

+
./try.sh
+

If you have primes(1) installed you might also wish to +try:

+
./primes.sh number
+

where number is a positive number, defaulting to 15. The +try.sh script will also do this.

+

Alternate code:

+

If you liked what you saw from the above program, and happen to have +some 512 Megabytes of virtual memory lying around with to do something +with you might try this version.

+

Alternate build:

+
make alt
+

Alternate use:

+
./weisberg.alt
+

Lesser systems will find this alternative version a good way to +create a core file. :-)

+

Judges’ remarks:

+

This entry confuses some C-preprocessors and some C-beautifiers. We +found one cpp that processed this source differently when it was read on +stdin instead of via cc -E.

+

Author’s remarks:

+

Description

+

The following short program implements the “Yet Another” algorithm +for generating prime numbers. It will generate all primes up to +33554432, displaying them to the standard output as it churns along. As +33554432 is rather large on most machines, this code may take quite some +time to run to completion, so as an added feature, it will cease +execution upon reception of a signal (any will do equally well), as well +as in the event of a system shutdown or reboot.

+

Bugs

+

The alternative version (weisberg.alt.c) +has never actually run to completion. After running for close to a week +it had reached somewhere around 250e6, when it became necessary to test +the reboot feature (which worked remarkably well). As there are quite a +lot of primes to be found before reaching INT_MAX, the +output produced can be quite overwhelming so it’s recommended to pipe +the output through your favorite pager (more or +less), and not output to a paper output device (unless you +have LOTS of paper).

+

Technical

+

The original “Yet Another Prime Program” algorithm used here was +developed as a Computer Architecture course micro-programming exercise, +and was designed to take full advantage of the UR300 micro-architecture +to achieve blindingly fast speed. It was ported to C specifically for +the IOCCC. In the conversion/obfuscation step some of (much of) the +blazing speed was lost, but as a bonus, the understandability of the +code was reduced to zero.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1994/weisberg

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1994/westley/index.html b/1994/westley/index.html index 0ea0843ba..c04055dfe 100644 --- a/1994/westley/index.html +++ b/1994/westley/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,262 @@ - - + + + + + + - - -1994 westley - - + + + +1994/westley + + + + + -

1994 westley

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1994/westley

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1994/westley/index.html

- +
+ ← weisberg + ↑ 1994 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Brian Westley
+Location: US

+ + +

To build:

+
make all
+

NOTE: the purpose of this entry is to escape the dungeon via the +compiler line where you get messages as compiler +errors. Depending on the compiler line you will get different +error messages and one compiler line will make you win the game!

+

NOTE: your terminal should be set to 80 columns, 8 character tabs, +and wraparound.

+

To use:

+

There is no running as such. See below.

+

Try:

+

But for something more interesting try compiling it with different cc +arguments. For example:

+
cc -Describe -Door westley.c
+cc -Describe -Drain westley.c
+

Judges’ remarks:

+

Not all compiler errors are bad.

+

For spoilers see the end of the notes from the author below.

+

To use:

+
./try.sh
+

Author’s remarks:

+

This program, in accordance with the rules, compiles into a legal C +program without human intervention. However, it simply compiles into +main(){}, which does nothing and exits, so you don’t need +to actually compile the program.

+

This program is a simple adventure game which uses only C +preprocessor error messages (for missing #include files) as +output. To begin, try to compile the program with no options:

+
cc westley.c
+

This will fail, producing an error message for a missing +#include file as the opening description. Your terminal +should be set for 80 columns, 8 character tabs, and wraparound, as there +is no way to reliably output newlines. You should see something like +this (text massaged to change wraparound to separate lines):

+
    westley.c
+    westley.c(87) : fatal error C1024: cannot open include file '
+
+     You are in a debris-filled
+      dungeon; a door bars the
+      way, and sludge trickles into
+      a floor drain
+
+     '
+

Your compiler error message will vary, but the important part is the +missing include file name, which functions as the game text.

+

To “do” things, all words must start with -D. For +example, to look at the door, do:

+
cc -Describe -Door prog.c
+

…and you will get another error message telling you about the door. +(note: some compilers will stop after the first missing include file, +while others will continue to try compiling; the latter will repeat the +opening message each time, as if you are playing an adventure game with +“verbose” turned on).

+

The goal of the game is to escape the dungeon.

+

Here is a walk-through for the game, including a few dead-ends:

+

SPOILER

+
cc -Describe -Door westley.c
+cc -Describe -Drain westley.c
+cc -Describe -Dwarf westley.c
+cc -Describe -Debris westley.c # or -Dungeon
+cc -Describe -Desk westley.c
+cc -Describe -Dime westley.c
+cc -Describe -Directory westley.c
+cc -Dial -DUNgeon0614 westley.c
+cc -Drink -Daiquiri westley.c
+cc -Drop -Daiquiri westley.c
+cc -Drop -Dwarf -Daiquiri westley.c # or -Drop -Down -Daiquiri
+cc -Describe -Document westley.c
+cc -Depress -Dotted -Dog westley.c
+cc -Depress -Dalmatian westley.c # also accepts "Dalmation" [sic]
+cc -Deposit -Dime westley.c
+cc -Drop -Donut westley.c
+cc -Drop -Donut -Down -Drain westley.c # or -Drop -Dwarf -Donut
+# (at this point, you win!)
+

Note that the game has no real state information; you can type these +commands in any order, at any time. Also note that word order is +unimportant.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1994/westley

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1995/cdua/index.html b/1995/cdua/index.html index c542d1bc4..bda4f9cdc 100644 --- a/1995/cdua/index.html +++ b/1995/cdua/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,236 @@ - - + + + + + + - - -1995 cdua - - + + + +1995/cdua + + + + + -

1995 cdua

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1995/cdua

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1995/cdua/index.html

- +
+ first entry + ↑ 1995 ↑ + dodsond1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Carlos Duarte
+Location: unknown

+ + +

To build:

+

We recommend that you try the alternate version first so you can see +what this entry looked like back in 1995 (with a configurable speed). +See the original code section below for the +original entry.

+
make alt
+

The alternate version uses usleep(3) with +SLEEP (defined in the Makefile, default 3000) +microseconds to make it easier to see the maze being solved in real +time. You can redefine SLEEP at compile time to reconfigure +it in case it’s going too slow, too fast :-) or you’re doing some +strange experiment like making it 100000 (which is actually fun :-) +).

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1995 +cdua in bugs.md.

+

To use:

+
./cdua.alt
+

Try:

+
make SLEEP=1500 clobber alt
+
+./cdua.alt # press enter and watch it go much faster!
+

You might also like to try:

+
make SLEEP=65000 clobber alt
+
+./cdua.alt # press enter and watch it go much slower!
+

Do you see anything strange in this version when SLEEP +is a high value like 65000? What happens if you use +100000? Is this strange output still there? Why?

+

Original code:

+

With modern systems this was hard to see it solve it in real time +because it goes so quickly which is why we recommend the alternate +version first: you can actually see it being solved in real time rather +than have it go by in a flash.

+

If you wish to use the original version, for instance if you wish to +see how fast your computer is :-) or use both to see the difference, you +can do so.

+

Original build:

+
make all
+

Original use:

+
./cdua
+

Judges’ remarks:

+

This could be used as the basis of an a-maze-ing screen +exerciser.

+

Author’s remarks:

+

A program that generates a maze, and then solves it, all this being +seen by the user. Some highlights of obfuscation are: 3 step function in +one - main(), several recursive calls with conditional +actions, and just one (big and ugly) statement to solve the maze.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1995/cdua

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1995/dodsond1/index.html b/1995/dodsond1/index.html index 76cb556f8..cb776c10a 100644 --- a/1995/dodsond1/index.html +++ b/1995/dodsond1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,213 @@ - - + + + + + + - - -1995 dodsond1 - - + + + +1995/dodsond1 + + + + + -

1995 dodsond1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1995/dodsond1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1995/dodsond1/index.html

- +
+ ← cdua + ↑ 1995 ↑ + dodsond2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Don Dodson
+Location: US

+ + +

To build:

+
make all
+

To use:

+
./dodsond1 < text_file
+

Try:

+
./dodsond1 < README.md
+

Judges’ remarks:

+

You might consider giving the following input:

+
... a male (who) gets very, very frustrated sitting in a chair all
+the time because males are biologically driven to go out and hunt
+giraffes.
+    -- Adjunct Professor Newt Gingrich, Reinhardt College, 1/7/95
+

… which can be done like:

+
./try.sh
+

Author’s remarks:

+

Istha ogrampra akesta Englishwa extta aswa inputwa andwa anslatestra +itwa intowa Igpa Atinla.

+

The obfuscation is on several levels.

+

Most obviously, the shape of the program.

+

Underneath that, the variable names are in pig Latin, as are the +names of the standard C functions, such as putchar(). Even +main is written as ainma.

+

The program construction is also very obfuscated, with all of the +code being inside the ()’s of one of the 6 +orfa loops.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1995/dodsond1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1995/dodsond2/index.html b/1995/dodsond2/index.html index 0cc9e8ff6..7d49e8666 100644 --- a/1995/dodsond2/index.html +++ b/1995/dodsond2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,199 @@ - - + + + + + + - - -1995 dodsond2 - - + + + +1995/dodsond2 + + + + + -

1995 dodsond2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1995/dodsond2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1995/dodsond2/index.html

- +
+ ← dodsond1 + ↑ 1995 ↑ + esde → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Don Dodson
+Location: US

+ + +

To build:

+
make all
+

To use:

+
./dodsond2
+

Judges’ remarks:

+

An amazing entry!

+

The official chef enjoyed solving the maze, which she did on the +first attempt.

+

Author’s remarks:

+

Interactive 3D Maze

+

Step into a randomly generated 3D maze and try to get out alive! Use +the vi movement keys (hjkl) to move on a level, and +u or d to move (u)p or (d)own from a position +with a U or D on the map. To simulate the +feeling of being in an unknown labyrinth, areas which you have not +visited cannot be seen.

+

Reach the north-west left corner of level 1 to exit.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1995/dodsond2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1995/esde/index.html b/1995/esde/index.html index 1f4ba88eb..ee0432cc3 100644 --- a/1995/esde/index.html +++ b/1995/esde/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,235 @@ - - + + + + + + - - -1995 esde - - + + + +1995/esde + + + + + -

1995 esde

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1995/esde

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1995/esde/index.html

- +
+ ← dodsond2 + ↑ 1995 ↑ + garry → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Sebastian +Deorowicz
Location: PL

+ + +

To build:

+
make all
+

To use:

+
./esde data-file word
+

where data-file contains lines of < 255 chars in length.

+

Try:

+
./try.sh
+

Judges’ remarks:

+

When reading the source be careful to distinguish between variable +names and library functions.

+

If you still don’t know what it does, try https://en.wikipedia.org/wiki/Soundex.

+

Author’s remarks:

+

what this program does

+

This program searches in the file words which have the same Soundex +code of the given word, and print out lines with those words.

+

The Soundex code is used to find similar sounding words.

+

Soundex code begins with the first letter of the word followed by a +three-digit code. This is the algorithm:

+
    +
  1. Every letter in the word beyond the first letter is replaced by a +digit.
  2. +
  3. Replace all pairs of the same code by single code +(e.g. R011235 -> R01235).
  4. +
  5. Remove all zeroes (e.g. R01235 -> +R1235).
  6. +
  7. If length of code is > 4, get only first 4 characters +(e.g. R1235 -> R123).
  8. +
  9. If length of code is < 4, add zeros (e.g. T12 -> +T120).
  10. +
+

These are the codes:

+
0  =  A, E, H, I, O, U, W, Y
+1  =  B, P, F, V
+2  =  C, S, G, J, K, Q, X, Z
+3  =  D, T
+4  =  L
+5  =  M, N
+6  =  R
+

information about an info +file:

+

An info file should be a text file consisting of lines of text (max. +256 bytes in each line).

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1995/esde

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1995/garry/index.html b/1995/garry/index.html index 4e6412e5c..17cf9e114 100644 --- a/1995/garry/index.html +++ b/1995/garry/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,242 @@ - - + + + + + + - - -1995 garry - - + + + +1995/garry + + + + + -

1995 garry

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1995/garry

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1995/garry/index.html

- +
+ ← esde + ↑ 1995 ↑ + heathbar → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Garry +Glendown
Location: DE

+ + +

To build:

+
make all
+

To use:

+
./garry <input_file >output_file
+

Try:

+
./try.sh
+

Alternate code:

+

While it may not have been the intention of the author, the judges +noted that the C pre-processed version (with the #includes +left intact) looked very much like a rat “dropping core”. See garry.alt.c and judge for yourself!

+

Alternate build:

+
make alt
+

Alternate use:

+
./garry.alt <input_file >output_file
+

Alternate try:

+
./try.alt.sh
+

Judges’ remarks:

+

The author was kind enough to provide a less obfuscated version of +the source called garry.fmt.c.

+

Author’s remarks:

+

This program is a file filter, designed to do environment-expansion +and incorporating the ability to create binary from escaped data in the +environment variables.

+

The calling syntax is pretty simple, just use it with +stdio-redirection or inside pipelines, e.g.:

+
./garry <file_to_convert >converted_file
+

or

+
cat all_my_files/* | ./garry | lp
+

The syntax of the conversion of the input file is as follows: To +include the value of an environment variable in the output file, place +the name of the variable between $-signs in the input, +e.g.:

+
My Home-Directory is: $HOME$
+I'm using the path: $PATH$
+

Unknown Env-variables or malformed expressions are ignored and kept +intact.

+

Additionally, the filter replaces escaped octal values in the +environment variables by their binary representation, e.g.:

+
$ TEST="\110\145\154\154\157"
+$ export TEST
+$ echo '$TEST$' | ./garry
+Hello
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1995/garry

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1995/heathbar/index.html b/1995/heathbar/index.html index 68fee812f..4b8fdc64c 100644 --- a/1995/heathbar/index.html +++ b/1995/heathbar/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,225 @@ - - + + + + + + - - -1995 heathbar - - + + + +1995/heathbar + + + + + -

1995 heathbar

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1995/heathbar

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1995/heathbar/index.html

- +
+ ← garry + ↑ 1995 ↑ + leo → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Authors:

Name: Heather Downs
+Location: unknown +

Name: Selene +Makarios
Location: unknown

+ + +

To build:

+
make all
+

To use:

+
./heathbar num num
+

where num is a non-negative number.

+

Try:

+
./heathbar 4253 2281
+

Judges’ remarks:

+

The main reason we liked this entry was mainly because the main +effect of the source was self documenting! :-)

+

Author’s remarks:

+

Run this program with two non-negative integer arguments +(e.g. ./heathbar 1234 999).

+

My goal was to create the fastest possible C program. To that end, I +made three critical observations:

+
    +
  1. If there’s one thing computers are good at, it’s math.
  2. +
  3. Simple operations take less time than complicated ones.
  4. +
  5. Every C program seems to contain the word main.
  6. +
+

Based on #1, I knew that the Fastest Program had to be one that +performed addition. From #2, I reasoned that it ought to directly +manipulate the bits, rather than wasting time dealing with bloated, +high-level, fuzzy-logic, artificial-intelligence, neural-net, +client-server, object-oriented abstractions like the C language “+” +operator. And it was obvious from #3 that the program should resemble, +as closely as possible, a long sequence of the familiar word +main repeated over and over, so the computer would be +comfortable running the program and wouldn’t get distracted dealing with +unfamiliar variable names.

+

Also, I’ve looked at some past winning entries of your contest, and +if you don’t mind a little constructive criticism, some of them are +kind-of hard to figure out. I didn’t want my program to fall into the +same trap, so I went out of my way to write self-documenting code. +Anyone who so much as glances at my program will immediately see that it +adds two 16-bit unsigned integers by streaming their bits through a +simulated cascade of hardware adders. I hope my diligent effort to write +especially clear code gets me extra points!

+

P.S. What does “obfuscated” mean?

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1995/heathbar

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1995/leo/index.html b/1995/leo/index.html index fa887620a..a7670216d 100644 --- a/1995/leo/index.html +++ b/1995/leo/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,361 @@ - - + + + + + + - - -1995 leo - - + + + +1995/leo + + + + + -

1995 leo

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1995/leo

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1995/leo/index.html

- +
+ ← heathbar + ↑ 1995 ↑ + makarios → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Leonid A. +Broukhis
Location: US

+ + +

To build:

+
make all
+

To use:

+
./leo [ deep ] [ right ] [ Variable ] [ cycle [ freq ] ]
+

See the author’s information below on these details.

+

Try:

+
./leo 1 | cat - /dev/tty | gs -
+
+./leo 37 80 | cat - /dev/tty | gs -
+

If you don’t have gs or an equivalent postscript viewer, try:

+
echo "" | ./leo 1 > foo.ps
+

and send foo.ps to your local postscript printer or open it in an +appropriate application (e.g. GIMP).

+

Judges’ remarks:

+

Press return after each image is drawn.

+

The variable names are element-ary. If you find this confusing, +remember that it is nu-clear. :-)

+

Some Ghostscripts/Postscript programs cleared the screen right after +the image is drawn, so we added element 106 which acts as an input +buffer.

+

To qualify for a category specially for yourself in the Geek code, +find out all the secret switches that the author doesn’t divulge ! (All +switches are single characters on the command line - anything that’s not +a number is a candidate.)

+

Author’s remarks:

+

The usage is:

+
./leo [ deep ] [ right ] [ Variable ] [ cycle [ freq ] ]
+

where the first three are literal words, cycle is a +positive integer (0 is ignored), and freq is an integer +(default = 0) that’s supposed to be in the range 0..100 +(bigger values are allowed, however). Invalid parameters and options +usually stop the command line parsing (not always but why?). The actual +position of the word options does not matter, so +./leo right Variable 1 70 is equivalent to +./leo 0 0 0 1 Variable 70 right, etc.

+

If Variable is used, cycle is almost +ignored (see below) but has to be present if you want to enter +freq (and you usually do).

+

Some options to try (besides the obvious):

+
./leo 1 | cat - /dev/tty | gs -
+

This draws the basic pattern I invented in high school:

+

You take a big sheet of “arithmetic” paper and draw a line of length +1 (between 2 crossings) at the center of the sheet:

+
                |
+

This makes 2 open ends (I think the notion of an “open end” doesn’t +require explanations) in step 1. Now, until there are open ends in step +N, repeat: for each open end pretend it points north and draw 2 lines +going northwest and northeast from it to the nearest crossings. This +needs to be done “simultaneously” for all ends that are open at that +moment.

+

Step 2:

+
                               \./
+                                |
+                               / \
+

Step 3:

+
                            __|   |__
+                               \./
+                                |
+                            __ / \ __
+                              |   |
+
+

Step 4:

+
                                .
+                             \./ \./
+                           \__|   |__/
+                           /   \./   \
+                                |
+                           \__./ \.__/
+                           /  |   |  \
+                             / \./ \
+

Step 5:

+
              ._|   .   |_.
+            __|  \./ \./  |__
+               \__|   |__/
+            __./   \./   \.__
+            __I     |     I__
+               \__./ \.__/
+            __./  |   |  \.__
+              |_./ \./ \._|
+                |       |
+
+

The lines marked by I show the places where +“simultaneity” is significant.

+

Note that so far all the drawings represent valid structural formulas +of some organic substances.

+

step 1: ethane step 2: 2,3-dimethylbutane step 3: +(2,5-dimethyl;3,4-isopropyl)-hexane step 4 and 5: I don’t know. Do +you?

+

Step 6:

+
               \./     \./                 \./     \./
+              ._|   .   |_.               ._|   .   |_.
+           \__|  \./ \./  |__/         \__|  \./ \./  |__/
+           /   \__|   |__/   \         /   \__|   |__/   \
+           \__./   \./   \.__/         \__./   \./   \.__/
+           X__|     |     |__X   or    <__|     |     |__>
+           /   \__./ \.__/   \         /   \__./ \.__/   \
+           \__./  |   |  \.__/         \__./  |   |  \.__/
+           /  |_./ \./ \._|            /  |_./ \./ \._|
+                |       |                   |       |
+               / \     / \                 / \     / \
+
+

depending on the desired “hairiness”. The original (paper-based) +algorithm was “hairy”, but it didn’t look as good on the screen.

+

The program cannot handle non-hairy mode 100% correctly - step 6 +happens to be

+
                                      |__
+        ...__/                  ...__/
+        ...  \                  ...  \.
+        ...__/                  ...__/|__
+        ...__Y  and step 7:     ...__Y
+        ...  \                  ...  \
+        ...__/                  ...__/
+             \                       \.__
+                                      |
+
+

and so on: the horizontal symmetry has been lost. That’s why the +opening for step 1 is not a single line but a cross:

+
                                \./
+                                / \
+

To watch it repeatedly (as a screen saver), use:

+
./leo 2 | cat - /dev/tty | gs -
+

The command line:

+
./leo Variable 1 | cat - /dev/tty | gs -
+

draws the same as above. Try:

+
./leo Variable 1 1 | cat - /dev/tty | gs -
+

What happened to the picture? Increase freq and watch +the changes.

+

If cycle is more than 1, the program loops, allowing the +user to enjoy randomly changing patterns (the delay is 3 seconds), but +there is a secret switch to suppress looping: useful if you want to pipe +the output to a printer.

+

uudecode the spoiler below if you really want to +know.

+
begin 664 spoiler1
+M*%1H92!C;VQO;B J:7,J('1H92!S96-R970@<W=I=&-H("T@=&AE('-P86-E
+=(&)E9F]R92!I="!I<R!N;W0@82!M:7-T86ME*0II
+
+end
+

If Variable is used, the actual value of +cycle doesn’t matter, as far as it is > 1. To figure out +what difference cycle makes when Variable is +not used, try

+
./leo Variable 37 80 | cat - /dev/tty | gs -
+

and other values of cycle; smaller values usually +require smaller values of freq for the patterns to be +non-trivial.

+

The options deep and right make the +patterns to be drawn in different manners. Try all the examples above +with deep and with right. What is the +difference between them?

+

…There is a little flaw in the implementation of the algorithm, and +sometimes the patterns are not symmetrical when they ought to be (the +program needs to be slightly changed to expose the flaw, otherwise it is +hardly noticeable, if ever).

+

A quick and dirty fix (turned on by another secret switch) makes the +patterns symmetrical, but a little too HAIRY.

+

There is one more secret switch (it shall also remain nameless), and +I don’t even want to explain what it does. You’ve been warned!

+
        *               *               *
+

Special thanks:

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1995/leo

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1995/makarios/index.html b/1995/makarios/index.html index 9c1eb20d4..b8a833275 100644 --- a/1995/makarios/index.html +++ b/1995/makarios/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,197 @@ - - + + + + + + - - -1995 makarios - - + + + +1995/makarios + + + + + -

1995 makarios

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1995/makarios

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1995/makarios/index.html

- +
+ ← leo + ↑ 1995 ↑ + savastio → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Authors:

Name: Heather Downs
+Location: unknown +

Name: Selene +Makarios
Location: unknown

+ + +

To build:

+
make all
+

To use:

+
./makarios
+

Judges’ remarks:

+

The judges were impressed that such a small program could do so much! +Can you figure out how it does it?

+

Author’s remarks:

+

This program takes no arguments. It emits the base 8 representation +of prime palindromes (palindromic in base 8, of course).

+
^_^
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1995/makarios

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1995/savastio/index.html b/1995/savastio/index.html index 7c67c0fa1..bdbd46993 100644 --- a/1995/savastio/index.html +++ b/1995/savastio/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,215 @@ - - + + + + + + - - -1995 savastio - - + + + +1995/savastio + + + + + -

1995 savastio

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1995/savastio

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1995/savastio/index.html

- +
+ ← makarios + ↑ 1995 ↑ + schnitzi → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Michael +Savastio
Location: unknown

+ + +

To build:

+
make all
+

To use:

+
./savastio
+# enter a number such as 100
+

Try:

+
echo 42 | ./savastio
+

Judges’ remarks:

+

I know an l when I see a 1.

+

Author’s remarks:

+

This program is an infinite-precision factorial calculator. It will +compute the factorial of any number entered to an infinite degree of +precision (or the limits of your machine’s memory, whichever comes +first). I’d suggest you start with small numbers the first few times you +run it and gradually work your way up in order to get a feel for the +computation time your machine will require.

+

Aside from having an artistic code layout and confusing variable +names, the algorithm itself takes advantage of some cute C-isms. Try to +figure out how it prints the prompt “Enter number:”.

+

Numbers are represented internally by a linked list of +blocks each containing 1000 buckets of 4-digit integers. To further +confuse matters, the buckets are arranged backwards in the block. For +example, the number 8347108947139478934713847134 is represented as:

+
7134 1384 9347 3947 9471 7108 834
+

Platform limitations

+

Long integers must be at least 4 bytes.

+

Features

+

In order to prevent the user from wasting too much time computing +useless factorials, the maximum factorial that can be computed is +429539! This limit was selected through extensive research in time +management studies and the factorial arts.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1995/savastio

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1995/schnitzi/index.html b/1995/schnitzi/index.html index 558fca329..23d4a2c17 100644 --- a/1995/schnitzi/index.html +++ b/1995/schnitzi/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,201 @@ - - + + + + + + - - -1995 schnitzi - - + + + +1995/schnitzi + + + + + -

1995 schnitzi

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1995/schnitzi

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1995/schnitzi/index.html

- +
+ ← savastio + ↑ 1995 ↑ + spinellis → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Mark +Schnitzius
Location: unknown

+ + +

To build:

+
make all
+

To use:

+
./schnitzi num
+

Try:

+
./schnitzi 24
+./schnitzi 18
+./schnitzi 30
+

WARNING: the author warns to not use too high a number! If you wish +to ignore the warning it is an exercise to determine how high is too +high. :-)

+

Judges’ remarks:

+

Sometimes a core dump is a feature, not a bug!

+

This is one of the better one-liners we have seen in a while. Take +some time to figure out what it does before you run it!

+

Author’s remarks:

+

Beware, running this program with too high of a number amounts to +doing a fork bomb on your machine!

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1995/schnitzi

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1995/spinellis/index.html b/1995/spinellis/index.html index 94ca6ba23..bf12f2a8c 100644 --- a/1995/spinellis/index.html +++ b/1995/spinellis/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,199 @@ - - + + + + + + - - -1995 spinellis - - + + + +1995/spinellis + + + + + -

1995 spinellis

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1995/spinellis

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1995/spinellis/index.html

- +
+ ← schnitzi + ↑ 1995 ↑ + vanschnitz → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Diomidis +Spinellis
Location: GR

+ + +

To build:

+
make all
+

To use:

+
./spinellis < spinellis.c
+

Judges’ remarks:

+

While the code does not abuse the rules, its output surely does!

+

P.S. Does the source have any spelling errors?

+

Author’s remarks:

+

96% of the program lines (631 out of the 658) are comment text +rendering the program readable and understandable. With the exception of +the two include file names (needed for a warning-free compile) the +program passes the standard Unix spell checker without any errors. +Checking for spelling errors is considered very important for programs +that are so heavily commented. This program is exactly 3217 characters +long through judicious use of white space. Rule abuse? Would I +ever abuse the rules?

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1995/spinellis

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1995/vanschnitz/index.html b/1995/vanschnitz/index.html index 870042a33..7e0a11e0c 100644 --- a/1995/vanschnitz/index.html +++ b/1995/vanschnitz/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,344 @@ - - + + + + + + - - -1995 vanschnitz - - + + + +1995/vanschnitz + + + + + -

1995 vanschnitz

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1995/vanschnitz

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1995/vanschnitz/index.html

- +
+ ← spinellis + ↑ 1995 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Authors:

Name: David Van +Brackle
Location: unknown

Name: Mark +Schnitzius
Location: unknown

+ + +

To build:

+
make all
+

The authors provided a spoiler version, originally uuencoded but +uudecoded by us in 2023. See Alternate +code below.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: missing file - please provide it
+

For more detailed information see 1995 vanschnitz in bugs.md.

+

To use:

+
./vanschnitz
+

Try:

+
make clobber all LEVEL=6
+./vanschnitz
+

Alternate code:

+

The authors provided a spoiler version of the program. Originally +uuencoded we have decoded it for the wider audience in vanschnitz.alt.c. The uuencoded +blob is still available in their remarks below. They encourage you to +first try and figure out the program without the spoiler.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use vanschnitz.alt as you would vanschnitz +above.

+

Judges’ remarks:

+

Back in 1995, values of LEVEL>8 caused some compilers +(and in one case a system) to crash during compilation. In 2023 with +modern systems this is not really a problem.

+

Back in 1995 we also suggested that for a bad/slow time to try +LEVEL=15 but this is not a big deal in 2023 either.

+

Authors’ remarks:

+

A classic problem in computer science is known as the Towers of +Hanoi. It involves a set of different-sized disks mounted on one of +three pegs. The object is to move the pile of disks to one of the other +pegs. You may only move one disk at a time, and there is an additional +constraint that a disk may never be placed on top of a smaller disk.

+

Our program solves the Towers of Hanoi problem. Well, that’s not +exactly true; actually, it’s the compiler that solves the problem. The +resulting program just prints out the correct solution.

+

How do you trick a compiler into actually solving the problem? First, +you must tell it how many disks you wish to solve it for. This is done +by defining the symbol n on the compile line. For instance, +to cause the compiler to solve the Towers of Hanoi problem with four +disks, you would compile the program like this:

+
gcc hanoi.c -o hanoi -Dn=4
+

A default value of 5 will be used for n if +you do not define it on the command line. The value of n +cannot be greater than fifteen (the compiler we used to test has a limit +on the #include depth). The compiler then solves the +problem using binary arithmetic based on whether particular symbols are +defined or not.

+

To loop, the program #includes itself. This is, of +course, expensive; one compile we did with n=14 took about +fifty minutes to compile on our system (compiling with n=15 +caused our system to crash).

+

The resulting program that the compiler generates simply prints out +the answer. Did I say “simply”? Actually, the whole resulting program +consists of a single printf(3) statement, consisting of a +massive string constant of length 35*(2^n-1), followed by +3*(2^n-1) integers which get formatted into the string. For +our n=14 run, this adds up to a string constant of length +573405, followed by 49149 integers delimited by commas. (Generating the +string constant depends on the ANSI C feature in which adjacent +character strings are concatenated; a version that does not use this +feature has been included for people who can only run K&R). A good +way to see the resulting program (on a Unix system) is to do the +command

+
gcc hanoi.c -E -Dn=5 | grep -v \# | grep -v ^\$
+

For an odd number of disks, the program will provide a solution +wherein the disks end up on peg 2; for an even number of disks, they +will end on peg 3. This should provide some hint as to what sort of +algorithm is used.

+

We have included a spoiler version of the +program, with meaningful symbol names and comments, but we encourage you +to try to decipher the program without it…

+
begin 444 spoiler.c
+M(VEF;F1E9B`@24Y)5$E!3$E:140*"B\J"B`J("!)9B!N(&ES;B=T(&1E9FEN
+M960L(&UA:V4@:70@-0H@*B\*(VEF;F1E9B`@;@HC9&5F:6YE("!N(#`U"B-E
+M;F1I9@H*+RH*("H@4V]M92!U<V5F=6P@=F%R:6%B;&5S"B`J+PHC9&5F:6YE
+M("!42$E37T9)3$4@7U]&24Q%7U\@"B-D969I;F4@($9/4DU!5%]35%))3D<@
+M(DUO=F4@9&ES:R`E9"!F<F]M('!E9R`E9"!T;R!P96<@)61<;B(*(V1E9FEN
+M92`@24Y)5$E!3$E:140*"B\J"B`J(%1R86YS;&%T92!N(&EN=&\@8FET<PH@
+M*B\*(VEF("`@("`@;B8P,0HC9&5F:6YE("!B:70P"B-E;F1I9@HC:68@("`@
+M("!N)C`R"B-D969I;F4@(&)I=#$*(V5N9&EF"B-I9B`@("`@(&XF,#0*(V1E
+M9FEN92`@8FET,@HC96YD:68*(VEF("`@("`@;CX^,PHC9&5F:6YE("!B:70S
+M"B-E;F1I9@H*+RH*("H@2&5R92=S('1H92!P<F]G<F%M(0H@*B\*;6%I;B@I
+M>PIP<FEN=&8H"B-I;F-L=61E(%1(25-?1DE,10HC9&5F:6YE("!.3U=?1$]?
+M5$A%7TY534)%4E,*(VEN8VQU9&4@5$A)4U]&24Q%"BD[?0H*(V5L<V4*"B\J
+M"B`J($-H96-K('1O('-E92!I9B!T:&4@;G5M8F5R(&ES('IE<F\@*&)O='1O
+M;2!O9B!R96-U<G-I;VXI"B`J+PHC:69D968@("!B:70P"B-D969I;F4@($Y?
+M25-?3D]47UI%4D\*(V5N9&EF"B-I9F1E9B`@(&)I=#$*(V1E9FEN92`@3E])
+M4U].3U1?6D523PHC96YD:68*(VEF9&5F("`@8FET,@HC9&5F:6YE("!.7TE3
+M7TY/5%]:15)/"B-E;F1I9@HC:69D968@("!B:70S"B-D969I;F4@($Y?25-?
+M3D]47UI%4D\*(V5N9&EF"@HC:69D968@("!.7TE37TY/5%]:15)/"B-U;F1E
+M9B`@($Y?25-?3D]47UI%4D\*"B\J"B`J($1E8W)E;65N="!N"B`J+PHC:69N
+M9&5F("!B:70P"B-D969I;F4@(&)I=#`*(VEF;F1E9B`@8FET,0HC9&5F:6YE
+M("!B:70Q"B-I9FYD968@(&)I=#(*(V1E9FEN92`@8FET,@HC:69N9&5F("!B
+M:70S"B-D969I;F4@(&)I=#,*(V5L<V4*(W5N9&5F("`@8FET,PHC96YD:68*
+M(V5L<V4*(W5N9&5F("`@8FET,@HC96YD:68*(V5L<V4*(W5N9&5F("`@8FET
+M,0HC96YD:68*(V5L<V4*(W5N9&5F("`@8FET,`HC96YD:68*"B\J"B`J("!(
+M97)E)W,@<F5C=7)S:6]N"B`J+PHC:6YC;'5D92!42$E37T9)3$4*"B\J"B`J
+M("!.;W1E.B!/9&0@;G5M8F5R960@9&ES:W,@86QW87ES(&-Y8VQE(&9R;VT@
+M,2`]/B`R(#T^(#,@/3X@,2`]/B`R(#T^(#,*("H@($5V96X@;G5M8F5R960@
+M9&ES:W,@86QW87ES(&-Y8VQE(&9R;VT@,2`]/B`S(#T^(#(@/3X@,2`]/B`S
+M(#T^(#(*("HO"@HO*@H@*B!#:&5C:R!T;R!S964@:68@;B!I<R!Z97)O+B!)
+M9B!S;RP@=V4G<F4@;6]V:6YG(&1I<VL@,2X*("H@26X@9V5N97)A;"P@9F]R
+M(&%N>2!N('=E)W)E(&UO=FEN9R!D:7-K(&XK,2X@5&AA="!M96%N<R!T:&%T
+M"B`J('=H96X@;B!I<R!O9&0L('=E)W)E(&UO=FEN9R!A;B!E=F5N(&1I<VLL
+M(&%N9"!V:6-E('9E<G-A+@H@*B\*(VEF;F1E9B`@8FET,`HC:69N9&5F("!B
+M:70Q"B-I9FYD968@(&)I=#(*(VEF;F1E9B`@8FET,PHC9&5F:6YE("!.7TE3
+M7UI%4D\*(V5N9&EF"B-E;F1I9@HC96YD:68*(V5N9&EF"@HC:69D968@("!.
+M7TE37UI%4D\*(W5N9&5F("`@3E])4U]:15)/"@HC:69N9&5F("!.3U=?1$]?
+M5$A%7TY534)%4E,*1D]234%47U-44DE.1PHC96QS90H*+RH*("H@($EF(&1I
+M<VL@,2!I<R!O;B!P96<@,BP@;6]V92!I="`R(#T^(#,*("HO"B-I9F1E9B`@
+M($1)4TM?3TY%7TE37T].7U!%1U]45T\*+#$L,BPS"B-U;F1E9B`@($1)4TM?
+M3TY%7TE37T].7U!%1U]45T\*(V1E9FEN92`@1$E32U]/3D5?25-?3TY?4$5'
+M7U1(4D5%"B-E;'-E"@HO*@H@*B`@268@9&ES:R`Q(&ES(&]N('!E9R`S+"!M
+M;W9E(&ET(#,@/3X@,0H@*B\*(VEF9&5F("`@1$E32U]/3D5?25-?3TY?4$5'
+M7U1(4D5%"BPQ+#,L,0HC=6YD968@("!$25-+7T].15])4U]/3E]014=?5$A2
+M144*(V5L<V4*"B\J"B`J("!$:7-K(#$@;75S="!B92!O;B!P96<@,2X@36]V
+M92!I="`Q(#T^(#(*("HO"BPQ+#$L,@HC9&5F:6YE("!$25-+7T].15])4U]/
+M3E]014=?5%=/"B-E;F1I9@HC96YD:68*(V5N9&EF"B-E;'-E"@HO*@H@*B`@
+M2&5R92P@=V4@:&%N9&QE(&1I<VMS(#XQ+B!296UE;6)E<B!T:&%T(&]D9',@
+M8WEC;&4@,2`]/B`R(#T^(#,@/3X@,2P*("H@(&%N9"!E=F5N<R!C>6-L92`Q
+M(#T^(#(@/3X@,R`]/B`Q+B!#;VUB:6YE('1H:7,@=VET:"!T:&4@:VYO=VQE
+M9&=E"B`J("!O9B!W:&5R92!D:7-K(#$@:7,L(&%N9"!W92!C86X@9&5T97)M
+M:6YE(&AO=R!T;R!M;W9E(&%N>2!D:7-K+@H@*B\*(VEF;F1E9B`@3D]77T1/
+M7U1(15].54U"15)3"D9/4DU!5%]35%))3D<*(V5L<V4*"B\J"B`J("!0<FEN
+M="!T:&4@9&ES:R!N=6UB97(N(%)E;65M8F5R+"!D:7-K(&YU;6)E<B`](&XK
+M,0H@*B\*+#$*(VEF9&5F("`@8FET,`HK,0HC96YD:68*(VEF9&5F("`@8FET
+M,0HK,@HC96YD:68*(VEF9&5F("`@8FET,@HK-`HC96YD:68*(VEF9&5F("`@
+M8FET,PHK.`HC96YD:68*"B\J"B`J("!$:7-K(#$@;VX@<&5G(#(@"B`J+PHC
+M:69D968@("!$25-+7T].15])4U]/3E]014=?5%=/"B-I9F1E9B`@(&)I=#`*
+M+#$L,R`@("`O*B!%=F5N.B`Q(#T^(#,@("AN(&ES(&]D9"P@<V\@=&AE(&1I
+M<VL@:7,@979E;BD@*B\*(V5L<V4*+#,L,2`@("`O*B`@3V1D.B`S(#T^(#$@
+M("HO"B-E;F1I9@HC96QS90H*+RH*("H@($1I<VL@,2!O;B!P96<@,R`*("HO
+M"B-I9F1E9B`@($1)4TM?3TY%7TE37T].7U!%1U]42%)%10HC:69D968@("!B
+M:70P"BPR+#$@("`@+RH@179E;CH@,B`]/B`Q("HO"B-E;'-E"BPQ+#(@("`@
+M+RH@($]D9#H@,2`]/B`R("HO"B-E;F1I9@HC96QS90H*+RH*("H@($1I<VL@
+M,2!O;B!P96<@,2`*("HO"B-I9F1E9B`@(&)I=#`*+#,L,B`@("`O*B!%=F5N
+M.B`S(#T^(#(@*B\*(V5L<V4*+#(L,R`@("`O*B`@3V1D.B`R(#T^(#,@*B\*
+M(V5N9&EF"B-E;F1I9@HC96YD:68*(V5N9&EF"B-E;F1I9@H*+RH*("H@($UO
+M<F4@<F5C=7)S:6]N"B`J+PHC:6YC;'5D92!42$E37T9)3$4*"B\J"B`J("!)
+M;F-R96UE;G0@;@H@*B\*(VEF9&5F("`@8FET,`HC=6YD968@("!B:70P"B-I
+M9F1E9B`@(&)I=#$*(W5N9&5F("`@8FET,0HC:69D968@("!B:70R"B-U;F1E
+M9B`@(&)I=#(*(VEF9&5F("`@8FET,PHC=6YD968@("!B:70S"B-E;'-E"B-D
+M969I;F4@(&)I=#,*(V5N9&EF"B-E;'-E"B-D969I;F4@(&)I=#(*(V5N9&EF
+M"B-E;'-E"B-D969I;F4@(&)I=#$*(V5N9&EF"B-E;'-E"B-D969I;F4@(&)I
+M=#`*(V5N9&EF"@HC96YD:68@("\J("-I9F1E9B!.7TE37TY/5%]:15)/("HO
+M"@HC96YD:68@("\J("-E;'-E(&]F("-I9FYD968@24Y)5$E!3$E:140@*B\*
+`
+end
+
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1995/vanschnitz

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1996/august/index.html b/1996/august/index.html index 48a8b56ff..ea654ba62 100644 --- a/1996/august/index.html +++ b/1996/august/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,377 @@ - - + + + + + + - - -1996 august - - + + + +1996/august + + + + + -

1996 august

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1996/august

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1996/august/index.html

- +
+ first entry + ↑ 1996 ↑ + dalbec → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Lennart +Augustsson
Location: SE

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: doesn't work with some compilers - please provide alternative code or fix for more compilers
+

For more detailed information see 1996 +august in bugs.md.

+

To use:

+
cat august.c test.oc | ./august > test.oo
+./august < test.oo
+

NOTE: some compilers will compile this code into infinite loops! If +the above cat line (or one of the ones later in the try section) does +not execute in a very short amount of time, then you may need to fix +your compiler or use gcc.

+

The above should print a ! followed by a newline.

+

Try:

+
./try.sh
+

Judges’ remarks:

+

This entry can feed on itself. If you C pre-process the source, you +compile the interpreter:

+
make august.oc
+

We can now compile the interpreter as follows:

+
cat august.c august.oc | ./august > august.oo
+

and use the compiled interpreter to execute some previously compiled +code:

+
cat august.oo test.oo | ./august
+

And we can have the compiled interpreter interpret itself which in +turn compiles the test program:

+
cat august.oo august.oo fac.oo | ./august
+

And if you have lots of spare time, you can recurse one level +deeper:

+
cat august.oo august.oo august.oo fac.oo | ./august
+

We (the judges) recommend that you spend some time studying this +entry as it surely will make the ‘best of the IOCCC’ list. It was very +well received by those who attended the IOCCC BOF.

+

Author’s remarks:

+

This program is a bytecode interpreter. This fact is not particularly +obfuscated; any experienced C programmer can see that in about a +minute.

+

The interpreter reads the bytecode from the standard input. What +remains of the standard input after this is left as standard input for +the interpreted program.

+

Having an interpreter but no code isn’t any fun. But within a comment +in the beginning of the interpreter is a sequence of bytes that is code +that the interpreter understands. It is in fact the code for a compiler +that compiles from OC (Obfuscated C, a subset of C) into the byte code +that the interpreter understands.

+

The language the compiler understands is a subset of C (the grammar +is below) with the functions getchar(3) and +putchar(3) available. The subset has the types +int, char, and pointers to those (it has +function pointers too, but not with the proper syntax). Arrays can only +be global. There is a rather limited set of operators, and control +constructs.

+

The compiler has absolutely no error checking, so things can go +wrong. But this is what seasoned C programmers are used to.

+

Assume that the interpreter has been compiled (source in august.c and binary in august) and that we have this +in a file named test.oc:

+
main() { putchar('!'); putchar('\n'); exit(0); }
+

We can then compile by

+
cat august.c test.oc | ./august > test.oo
+

And run the compiled program by

+
./august < test.oo
+

Or even simpler:

+
cat august.c test.oc | ./august | ./august
+

A larger example is included fac.oc.

+

The compiler for OC is naturally written in OC (where did you think +the byte code came from?). It is in the file parse.oc.

+

Hmm… So now we have an interpreter written in OC and a compiler for +OC, can we compile the interpreter? Yes, we can! The OC compiler does +not have a preprocessor (hey, what do you expect from a program that is +this small), so we need to use an external one. To pre-process august.c use the command from the Makefile, but add +the -E flag and change 60000 to 40000, i.e.:

+
cc -E -DZ=40000 .... august.c > august.oc
+

If august.oc contain some junk line starting with a +# (most likely it does) then remove it like:

+
sed -i'' '/^#/d' august.oc
+

OK, we can now compile the interpreter:

+
cat august.c august.oc | ./august > august.oo
+

And we can run it:

+
cat august.oo test.oo | ./august
+

Here we have the interpreter interpreting another interpreter that +runs the program. Did you think that was too fast? Just throw in another +level of interpretation:

+
cat august.oo august.oo test.oo | ./august
+

And another…

+
cat august.oo august.oo august.oo test.oo | ./august
+
+

Fitting the byte code for the compiler into the initial comment was a +challenge. I had to strip the compiler/interpreter of a lot of +functionality to bring down their sizes. The initial version had a full +set of binary operators as well as prefix &. Given a +handful more bytes it would be easy to put them back.

+

Anyway, the bytecode from the compiler is first optimized in an +external optimizer (not supplied here); this brings down the size of it +by about 30%. The remaining code is then LZ-compressed (roughly) with a +sliding window of 255 bytes. The most common occurring bytes are then +encoded using " \n\t;{}" to avoid having them counted as +significant. About 200 bytes of the interpreter handles the unpacking of +the byte code (this is a lot, but it pays off).

+

Despite all this work I still had to put a lot of code in the +compilation command. This disturbs me. It is possible to compress the +code further with a better entropy coder (e.g. an arithmetic coder), but +decompression then takes up too much code. Maybe this would be a way to +fit it all into the 1536 bytes, but I don’t have time to try it.

+
+

Execution starts at main(). Nothing can be used before +it is defined. getchar() and putchar() are +predefined functions.

+

Below is a description of the OC grammar.

+

OC grammar

+

Terminals are in quotes, () is used for bracketing.

+
program:    decl*
+
+decl:       vardecl
+        fundecl
+
+vardecl:    type NAME ;
+        type NAME "[" INT "]" ;
+
+fundecl:    type NAME "(" args ")" "{" body "}"
+
+args:       /*empty*/
+        ( arg "," )* arg
+
+arg:        type NAME
+
+body:       vardecl* stmt*
+
+stmt:       ifstmt
+        whilestmt
+        dowhilestmt
+        "return" expr ";"
+        expr ";"
+        "{" stmt* "}"
+        ";"
+
+ifstmt:     "if" "(" expr ")" stmt
+        "if" "(" expr ")" stmt "else" stmt
+
+whilestmt:  "while" "(" expr ")" stmt
+
+dowhilestmt:    "do" stmt "while" "(" expr ")" ";"
+
+expr:       expr binop expr
+        unop expr
+        expr "[" expr "]"
+        "(" expr ")"
+        expr "(" exprs ")"
+        NAME
+        INT
+        CHAR
+        STRING
+
+exprs:      /*empty*/
+        (expr ",")* expr
+
+binop:      "+" | "-" | "*" | "/" | "%" |
+        "=" |
+        "<" | "==" | "!="
+
+unop:       "!" | "-" | "*"
+
+type:       "int" stars
+        "char" stars
+
+stars:      "*"*
+
+
+

Well, that is enough ranting for now.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1996/august

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1996/dalbec/index.html b/1996/dalbec/index.html index 36d37d361..6a52ae223 100644 --- a/1996/dalbec/index.html +++ b/1996/dalbec/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,227 @@ - - + + + + + + - - -1996 dalbec - - + + + +1996/dalbec + + + + + -

1996 dalbec

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1996/dalbec

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1996/dalbec/index.html

- +
+ ← august + ↑ 1996 ↑ + eldby → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: John Dalbec
+Location: US

+ + +

To build:

+
make all
+

To use:

+
./dalbec
+

Try:

+
./dalbec 3 | head -n 29
+

Why does the output end with 121?

+

Judges’ remarks:

+

The output is mis-leading … why does it also print 2047?

+

For a hint see https://web.archive.org/web/20000510191341/https://www.utm.edu/research/primes/prove2.html.

+

… and then try to understand the source! :-)

+

We (the judges) recommend that you take the time needed to understand +how this program works. The source is small enough to make the effort +reasonable, and complex enough to make it interesting.

+

Author’s remarks:

+

This program assumes that your terminal wraps lines automatically. If +this is not the case, you may need to change the space in the “printf” +format string to a newline character.

+

An extra feature of this program is that it allows you (in most +cases) to estimate the stack space available to programs on your system. +Simply allow the program to run to completion. The stack space is +roughly proportional to the last number printed.

+

(On SunOS/cc, the proportionality constant is about 48 bytes.)

+

On completion, the program produces a core file that may be used to +refine this estimate. (Or you could try typing limit if +you’re running csh.) In rare cases the stack space may +exceed 24*INT_MAX bytes, in which case the program will +produce an inaccurate estimate.

+

This program is obfuscated by:

+
    +
  1. The use of easily-confused variable names.

  2. +
  3. Using the implicit !=0 in conditional +expressions.

  4. +
  5. Substituting expressions such as !a for +0 where a!=0 and !a for +1 where a==0.

  6. +
  7. The fact that main() is a single expression and so +beautifies poorly.

  8. +
  9. The fact that main() is used:

    +
      +
    • to compute powers in modular arithmetic.
    • +
    • to recursively call itself in the main loop.
    • +
  10. +
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1996/dalbec

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1996/eldby/index.html b/1996/eldby/index.html index 25414a3e4..0d2056ebe 100644 --- a/1996/eldby/index.html +++ b/1996/eldby/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,218 @@ - - + + + + + + - - -1996 eldby - - + + + +1996/eldby + + + + + -

1996 eldby

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1996/eldby

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1996/eldby/index.html

- +
+ ← dalbec + ↑ 1996 ↑ + gandalf → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Thor Eldby
+Location: unknown

+ + +

To build:

+
make alt
+

We recommend that you use the alt version to see what the entry +looked like back in 1996. For the original version see the original code section.

+

To use:

+
./eldby.alt
+

To quit send intr (typically ctrl-c).

+

NOTE: to reset the sanity of your terminal after this program ends +try reset.

+

Try:

+

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 +35000 but you can easily change it. To do so try:

+
make SLEEP=20000 clobber alt
+./eldby.alt
+

Original code:

+

This version is the original which has no sleep time in between +updates.

+

Original build:

+
make all
+

Original use:

+

Use ./eldby as you would ./eldby.alt +above.

+

Judges’ remarks:

+

We were impressed by the author’s ability to render spheres in 3D in +a very small chunk of code.

+

Author’s remarks:

+

This program shows flying spheres. The program eats CPU on lesser +equipped systems. The program will run until termination. Terminal must +be VT100 or better with 80 columns and 24 rows or more.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1996/eldby

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1996/gandalf/index.html b/1996/gandalf/index.html index 76c767ee5..ea40fe335 100644 --- a/1996/gandalf/index.html +++ b/1996/gandalf/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,207 @@ - - + + + + + + - - -1996 gandalf - - + + + +1996/gandalf + + + + + -

1996 gandalf

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1996/gandalf

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1996/gandalf/index.html

- +
+ ← eldby + ↑ 1996 ↑ + huffman → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Dean Swift
+Location: unknown

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: missing or dead link - please provide them
+

For more detailed information see 1996 gandalf in bugs.md.

+

To use:

+
./gandalf
+

Try:

+
./try.sh
+

As the script asks, care to guess why these execute differently? Only +the compiler knows … ok maybe other things like the author, the judges +and perhaps you too?

+

BTW: it is perilous to ‘try’ the patience of Gandalf. Go +ahead, ‘try’ it! :-)

+

Judges’ remarks:

+

For misleading C pre-processor output, try:

+
cc -E gandalf.c
+

Author’s remarks:

+

The program requires an ASCII system.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1996/gandalf

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1996/huffman/index.html b/1996/huffman/index.html index 8991036d3..2fa9bf6e8 100644 --- a/1996/huffman/index.html +++ b/1996/huffman/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,215 @@ - - + + + + + + - - -1996 huffman - - + + + +1996/huffman + + + + + -

1996 huffman

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1996/huffman

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1996/huffman/index.html

- +
+ ← gandalf + ↑ 1996 ↑ + jonth → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Ken Huffman
+Location: US

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: uses gets() - change to fgets() if possible
+

For more detailed information see 1996 huffman in bugs.md.

+

To use:

+
echo 'Huffman Decoding' | ./huffman
+

Try:

+
./try.sh
+

Judges’ remarks:

+

If you are still confused and want to read a spoiler, check out the +source and it will be clear as mud!

+

And for a misleading hint, consider who won! :-)

+

And if you really can’t see what is going on, here is an extra +spoiler:

+
./huffman < huffman.c 2>/dev/null
+

This entry was very well received at the IOCCC BOF.

+

Author’s remarks:

+

This filter program is really not obfuscated code. It compiles +cleanly with an ANSI C compiler and comes with user documentation that +even a blind person could read.

+

The program is a bidirectional filter with the output of the program +suitable for its input. The output of this program, when used as input, +undoes the original program filtering.

+

This program accepts any alphanumeric text that has lines less than +100 characters. The user is encouraged to use the program’s source as +input to the executable.

+

This program is best appreciated on a tactile monitor.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1996/huffman

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1996/jonth/index.html b/1996/jonth/index.html index f8b10c3f4..23b51c68d 100644 --- a/1996/jonth/index.html +++ b/1996/jonth/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,221 @@ - - + + + + + + - - -1996 jonth - - + + + +1996/jonth + + + + + -

1996 jonth

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1996/jonth

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1996/jonth/index.html

- +
+ ← huffman + ↑ 1996 ↑ + rcm → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jon Thingvold
+Location: NO

+ + +

To build:

+
make all
+

NOTE: this entry requires X11/Xlib.h header file and the +X11 library to compile. macOS users running Mountain Lion and later will +need to download and install XQuartz in order to compile and run +this entry.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+STATUS: missing or dead link - please provide them
+

For more detailed information see 1996 +jonth in bugs.md.

+

To use:

+
./jonth :0 :0
+

NOTE: the two boards will be on top of each other so you will have to +drag one off the other so that you can properly play.

+

NOTE: if there is no X service open this will crash. If this is the +case you might try:

+
./jonth
+

These are supposed to happen. As is written in the The Jargon +File:

+
That's not a bug, that's a feature.
+

Try:

+
./jonth host1:0 host2:0
+

Judges’ remarks:

+

For extra credit, figure out how you can cheat by taking over a +square already occupied by an opponent.

+

Author’s remarks:

+

This is multi-user tic-tac-toe for X Windows. You may give one or two +X displays as arguments to this game.

+

Known bugs:

+

Sometimes on Solaris, X gets confused and this program core dumps. +The solution: give two display arguments +(./jonth host:0 host:0).

+

If one (or both) windows look like a copy of the window(s) below, try +xrefresh(1) command.

+

Have a nice(1) day.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1996/jonth

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1996/rcm/index.html b/1996/rcm/index.html index 4fa292076..218a6a3f0 100644 --- a/1996/rcm/index.html +++ b/1996/rcm/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,230 @@ - - + + + + + + - - -1996 rcm - - + + + +1996/rcm + + + + + -

1996 rcm

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1996/rcm

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1996/rcm/index.html

- +
+ ← jonth + ↑ 1996 ↑ + schweikh1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Ron McFarland
+Location: US

+ + +

To build:

+
make all
+

To use:

+
./rcm < rfc1951.gz
+

Try:

+

For more information try:

+
./rcm < rfc1952.gz
+

Judges’ remarks:

+

For a good no-op try:

+
gzip -c < rcm.c | ./rcm
+

Author’s remarks:

+

Except for some silly requirements regarding input validation, CRC +checking, and similar unimportant fluff, this program is a fully +compliant RFC1951/RFC1952 (GNU Gzip) file +uncompressor. Feed it a gzip compressed file on standard +input, and it will write the fully uncompressed original file to +standard output.

+

ObJustifications for this +entry:

+

The Design Trade-off +Argument:

+

“The 184 characters worth of defines in the build file have been +carefully offset by 184 redundant and unnecessary ‘{’, +‘}’, and ‘;’ characters in the source +file.”

+

The Design Review Argument:

+

“Using only 216 characters out of a maximum of 256, the build file +meets and actually exceeds specification.”

+

The Program Metrics Argument:

+

“The program source is less than 3,100 characters in length and +uncompresses the file emacs-19.34b.tar.gz +in about 130 seconds on my HP 9000/735. The now obsolete source file +`inflate.c’ from the GNU gzip source tree is 31,613 characters in length +and uncompresses the emacs distribution file in slightly under 25 +seconds. Thus:

+
3100 / 130 = 23.85       -vs-      31613 / 25 = 1264.52
+

which represents a better than 530% improvement in the ratio of +source file size to execution time.”

+

The Whining Programmer’s +Argument:

+

“The inflate algorithm requires that over 400 characters worth of +constants and tables be defined. Which means the program itself had to +be squeezed down to about 1,100 IOCCC countable bytes.”

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1996/rcm

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1996/schweikh1/index.html b/1996/schweikh1/index.html index 89f824c6f..7acf5012b 100644 --- a/1996/schweikh1/index.html +++ b/1996/schweikh1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,274 @@ - - + + + + + + - - -1996 schweikh1 - - + + + +1996/schweikh1 + + + + + -

1996 schweikh1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1996/schweikh1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1996/schweikh1/index.html

- +
+ ← rcm + ↑ 1996 ↑ + schweikh2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jens +Schweikhardt
Location: DE

+ + +

To build:

+
make all
+

To use:

+
./schweikh1
+

Try:

+

To find the day that Easter falls on in the current year:

+
./schweikh1 |grep $(date +%Y)
+

Judges’ remarks:

+

Look at the source. There is something very odd going on here. Where +does the real code come from if everything is a C pre-processor +statement?

+

Clearly this is either the Best Use or the Worst Abuse of the C +Preprocessor that the judges have seen this year!

+

Author’s remarks:

+

What this program does

+

This program is an implementation of an algorithm that calculates the +date of the Sunday following the first full moon after the spring +equinox. (Also known as “Easter”, defined this way by the Nicaean +Concilium in 325 Anno Domini.) The algorithm is attributed to the famous +mathematician Carl Friedrich +Gauss [“Meyers Handbuch ueber das Weltall” ‘Handbook About Space’, +Meyer, 5th Edition, 1973, p149] and is suitable for anni domini within +the Gregorian +Calendar, that is, from ad 1582 to ad 2199:

+
Let J be the year.
+If J is from 1582 to 1699, let M be 22, let N be 2
+If J is from 1700 to 1799, let M be 23, let N be 3
+If J is from 1800 to 1899, let M be 23, let N be 4
+If J is from 1900 to 2099, let M be 24, let N be 5
+If J is from 2100 to 2199, let M be 24, let N be 6
+Let a be the modulus of J divided by 19
+Let b be the modulus of J divided by 4
+Let c be the modulus of J divided by 7
+Let d be the modulus of (19a + M) divided by 30
+Let e be the modulus of (2b + 4c + 6d + N) divided by 7
+
+

The interesting Sunday is either:

+
March 22 + d + e   or
+April d + e - 9    (only one of them is a valid date)
+

with the following exceptions:

+
April 26 must always be changed to April 19
+April 25 must be changed to April 18 if d is 28 and a is greater than 10
+

Example:

+
J = 1962, M = 24, N = 5
+a = J % 19 == 5
+b = J %  4 == 2
+c = J %  7 == 2
+d = 119 % 30 == 29
+e = 191 % 7 == 2
+

March 53 is invalid, so the result is April 22 1962.

+

Why I think this is +obfuscated

+

Apart from the calculation of the Easter date, the definition +and calculation of which are obfuscations in their own right, +obfuscation lurks in many places. Look at those macro identifiers. What +can be more obvious than a program that explicitly mentions the +grammatical constructs it is composed of? If you look at K&RII A.9.3 +you will find that a compound statement consists of an opening brace +followed by a declaration list followed by a semicolon followed by a +statement list followed by another semicolon and a closing brace. Nobody +can learn that by heart so I gently remind the reader by defining a +macro that expresses this clearly (line 25). This goes up to the +definition of a translation unit. Unfortunately, due to the IOCCC’s size +restrictions, I had to abbreviate some syntactic elements. +ae actually reads “assignment expression”. I had to stop at +some arbitrary point, so don’t waste your time trying to find out how +preprocessing tokens form type qualifier lists, cast expressions or +direct abstract declarators. Assuming the reader knows about these easy +to remember language elements is justified in my opinion.

+

The moral:

+

Try to be as precise as can be and no one will comprehend what you +mean.

+

The formula:

+
comprehension = 1/(2**precision)
+

The interpretation:

+

“Say nothing and everybody will understand.”

+

The -I/usr/include in the build file is needed by gcc on +Solaris because gcc’s “fixed” header in +gcc-lib/sparc-sun-solaris2.5/2.7.2/include/errno.h is +broken (sort of) because it has two identical extern +declarations of errno. This leads to an error due to the redefinition of +main. The -I option makes sure the working +/usr/include/errno.h is found first, which shouldn’t cause any problems +on other systems.

+

Usage:

+

The program is run without arguments. It prints all dates in +order.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1996/schweikh1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1996/schweikh2/index.html b/1996/schweikh2/index.html index 8b9c2813c..2fb940fdd 100644 --- a/1996/schweikh2/index.html +++ b/1996/schweikh2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,301 @@ - - + + + + + + - - -1996 schweikh2 - - + + + +1996/schweikh2 + + + + + -

1996 schweikh2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1996/schweikh2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1996/schweikh2/index.html

- +
+ ← schweikh1 + ↑ 1996 ↑ + schweikh3 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jens +Schweikhardt
Location: DE

+ + +

To build:

+
make all
+

To use:

+
./schweikh2
+

The program accepts up to 4 parameters:

+
    +
  1. The number of operators in the expression [default: 9]

  2. +
  3. The value of the first operand [default: 1]

  4. +
  5. The (possibly negative) increment to the next operand [default: +1]

  6. +
  7. The goal value or 0/0 [default: 42]

  8. +
+

Try:

+
./try.sh
+

What happens if you pass only three parameters like the below?

+
./schweikh2 15 1 0
+

The author also suggests:

+
while :; do grep -v '#' schweikh2.c; done
+

(and we do too) which works with sh, bash, +ksh and zsh as well. Press ctrl-c to stop it. +Observe how the try.sh script does this a number of +times.

+

Judges’ remarks:

+

The original program, with only slight obfuscations, may be found in +hunni.c. The perl script, hunni.pl, obfuscates it appropriately. Try:

+
less hunni.c
+
+perl ./hunni.pl < hunni.c
+

This entry was another crowd pleaser at the IOCCC BOF.

+

Author’s remarks:

+

Note: the source must be viewed with tabstop 8. To appreciate the +beauty have your eyes half closed.

+

Why I think this program +is obfuscated:

+

C is a free format language. It is therefore a question of style how +variables, operators, declarations, functions and syntactic elements +like braces and parentheses are grouped together. As a rule of thumb, I +put spaces around operators, after opening braces and before closing +braces. I have generalized this rule by putting whitespace after +any non-white space character (with the exception of +preprocessor directives). There are no recognizable keywords anymore. +There are no recognizable string literals any more. The +main() function is invisible. All operators longer than one +character are gone. They have been replaced by macro calls with quite a +number of arguments. The keys are the token pasting and stringizing +macros e and O. The “arcane rules of token +pasting” [K&R2] are used up to three levels: +H(O,r)R(O,r) (!) which is needed to make one 8-character +token from 8 characters (unsigned). BTW, C has no 9 or more +character reserved words, so a fourth level is only required if you +intend to generate object names from 9 or more components. The final +round even swaps the tokens, so all keywords must be spelled backwards +(sort of, can you spot printf in the P +macro?).

+

Try to indent the source. The unbalanced parentheses confuse Solaris’ +indent to the max (although the result does compile):

+

Looking at the indented source is even less fun, because the +nice diamond pattern has been replaced by something that looks like, +uhm, modem noise.

+

Lint the source. It’s clean. How obfuscated…

+

What’s the exit status? The program exits with J - 1 +where J is the return value from several non-void functions +(needed to shut up lint). The last assignment is +J = printf ("%c", 10); so the exit status is 0 unless the +last printf failed, which is even a useful status. +A further obfuscation is the use of 10 instead of +'\n'. '\n' can not be constructed by token +pasting, AFAIK. That’s why schweikh2 is likely to produce +occasional garbage on non-ASCII execution character set systems.

+

What this program does

+

The program is an expression evaluator for a limited class of +expressions. Known operators are + - +* /; operands are real numbers (integers or +fractions). The operands are restricted in that they must differ by a +constant value, for example 1 + 2 * 3 / 4 - 5. For any +combination of operators the expression is evaluated and compared to a +goal value. If they compare equal the expression is printed. If the goal +value is specified as 0/0 all expressions and results are +printed. For any fraction, the numerator and denominator are divided by +their greatest common divisor.

+

The program accepts up to 4 parameters:

+
    +
  1. The number of operators in the expression [default: 9].
  2. +
  3. The value of the first operand [1].
  4. +
  5. The (possibly negative) increment to the next operand [1].
  6. +
  7. The goal value or 0/0 [42].
  8. +
+

On ANSI/ISO C conformant systems (where long is at least +32 bits) overflow will occur in the default case (first operand 1, +increment 1) only for more than 11 operators. Because a bit mask is used +that needs twice the number of operands in bits (plus a sentinel value) +on those systems the first parameter must not exceed 15.

+

If long is at least 64 bits overflow will occur for more +than 19 operators but you will probably wait quite some time for every +of the 4^19 = 274,877,906,944 combinations to be evaluated… +While I’m at it, on a 50 MHz SPARC, 4^11 expressions are +evaluated in about 3 cpu minutes (gcc -O3).

+

Sample arguments:

+
./schweikh2 6
+./schweikh2 7 0
+./schweikh2 7 7 0
+./schweikh2 8 9 -1 -67/21
+./schweikh2 8 2 2/5 -98/25
+./schweikh2 2 1/0 1 1/0
+

Miscellaneous

+

The diamond pattern can be continued without a break. For a nice +printout try this on your Bourne compatible shell:

+
while :; do grep -v '#' schweikh2.c; done
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1996/schweikh2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1996/schweikh3/index.html b/1996/schweikh3/index.html index 55103e85c..ab8b47796 100644 --- a/1996/schweikh3/index.html +++ b/1996/schweikh3/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,308 @@ - - + + + + + + - - -1996 schweikh3 - - + + + +1996/schweikh3 + + + + + -

1996 schweikh3

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1996/schweikh3

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1996/schweikh3/index.html

- +
+ ← schweikh2 + ↑ 1996 ↑ + westley → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jens +Schweikhardt
Location: DE

+ + +

To build:

+
make all
+

To use:

+

WARNING: DO NOT RUN this program without reading this text +down to the end! It may render your system unusable for a +limited amount of time or force you to reboot using the Big Red Button! +This is NOT a joke. You have been warned.

+
./schweikh3
+

Judges’ remarks:

+

The source fails to compile on compilers that recognize the inline +keyword by default. For gcc, you may need to use -ansi.

+

See the file schweikh3.info for example +output from various systems.

+

But still it is a useful utility. To use try:

+
./schweikh3
+

and thanks for the virtual memories! :-)

+

NOTE: On some systems such as SunOS, one may need to compile +with:

+
    ${CC} ${CFLAGS} \
+      -I. -D_POSIX_SOURCE '-Ddifftime(a,b)=(double)(b-a)' \
+      schweikh3.c -o schweikh3
+

Author’s remarks:

+

Why I think my entry is +obfuscated

+

There are some layout obfuscations that hinder readability, like some +(but not all) one character tokens in column 1. #includes, +#defines and declarations of data and functions appear +intermixed. iso646.h is even included in the middle of an +expression, how disgusting. Besides, requiring iso646.h +will render the program uncompilable on many systems that have not yet +incorporated Amendment One to The Standard. If you, dear reader, suffer +from this disease, just read iso646.h.

+

There are no +if' statements. They have been replaced byswitch () case +1:orswitch () case +0:etc. At least oneswitchhas a declaration after the opening brace, booh! Identifiers are named after random programming languages, BASIC (asBasic`), +COBOL, F77, awk etc.

+

You have to select maximum ANSI C conformance of your compiler. The +source fails to compile under a C++ compiler due to the `new’ identifier +which is a C++ reserved word:

+
$ g++ schweikh3.c
+schweikh3.c:9: parse error before `new'
+schweikh3.c:16: parse error before `new'
+schweikh3.c:46: parse error before `void'
+schweikh3.c:65: parse error before `Lisp'
+schweikh3.c:68: parse error before `;'
+[...]
+schweikh3.c:91: confused by earlier errors, bailing out
+

The source fails to compile on compilers that recognize the inline +keyword by default, e.g. gcc:

+
$ gcc schweikh3.c
+schweikh3.c:46: parse error before `void'
+schweikh3.c: In function `main':
+schweikh3.c:91: parse error before `inline'
+schweikh3.c: At top level:
+schweikh3.c:97: parse error before `void'
+

The -ansi option to gcc fixes this.

+

The source fails to compile on obsolete systems with obsolete memory +models due to the identifier far (to be honest: this is +untested :-) ).

+

Does your indent cope with backslash/newline pairs in between +keywords like in re\turn where the re\ is at +the end of a line? ? Solaris’ indent inserts spaces and thereby renders +the source uncompilable…

+

The indented source will exhibit different semantics when indenting +changes the number of lines (due to using the __LINE__ +macro in an expression).

+

And what about sizeof __TIME__? This one’s for the +philosophers and physicists among us programmers. What is it? +sizeof (char *)? – no. strlen ("hh:mm:ss")? – +no. It’s the same as sizeof __DATE__ - sizeof "no" :-)

+

The program is POSIX conformant and lints without warning under +Solaris’ Sunpro lint. Allocated memory is correctly freed on all +possible execution paths.

+

What this program does

+

This program tests your operating system’s allocation honesty. It +forks a child that will allocate as much memory as possible with byte +granularity and then write to every 1024th byte, at the same time +writing a status report on stdout. This way each page of +the allocated virtual memory will eventually be referenced. Without any +arguments, malloc(3) will be used to allocate memory. If +the first arg starts with c, calloc(3) will be +used instead.

+

I distinguish three different behaviours:

+
    +
  1. OS without memory overcommit: malloc(3) does not lie +– you can use all memory the OS granted to you.

  2. +
  3. OS with memory overcommit: malloc(3) lies – any +program may get killed at random when the OS can not acquire a free +page.

  4. +
  5. OS with pseudo memory overcommit: malloc(3) lies – +The OS puts processes to sleep for which it can not acquire a free page. +Because other processes are also affected this way, the system slows +down and quickly becomes totally unusable (also known as “thrashing”). +Because more and more processes wait for memory returned by other +exiting processes the system eventually enters a deadlock situation and +effectively halts.

  6. +
+

I had the pleasure and pain to find all three behaviours on the +platforms I use regularly.

+

The file schweikh3.info has output for +Solaris, FreeBSD and Linux. The Linux case is interesting in that the +behaviour changes when calloc(3) is used instead of +malloc(3). For FreeBSD, the last two lines are not messages +stemming from my program but issued by the syslog daemon.

+

Implementation remarks

+

How can we distinguish the three different OS types from the table +above?

+

Obviously, type (1), no overcommit, is easy.

+

For type (2), random kill, we need to fork a child that can be killed +and whose exit status the parent collects and decodes. Here’s where +POSIX enters the scene.

+

Type (3), thrashing, was the hardest part. The first attempt was to +measure the elapsed processor time it takes to write a single byte +(using clock()). If a certain threshold is reached I assume +the system is thrashing. When thrashing, however, the process does not +consume processor time in a noticeable amount any longer and I lose. So +I switched to measuring wall clock time using time(3). On +the one system that I observe thrashing (Linux) this works (although the +value returned by time(3) seems to ‘hang’ sometimes when +the OS thrashes. Exceeding a threshold of 5 seconds may be detected only +after half a minute or so.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1996/schweikh3

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1996/westley/index.html b/1996/westley/index.html index 1f10620fa..c814ea0f0 100644 --- a/1996/westley/index.html +++ b/1996/westley/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,271 @@ - - + + + + + + - - -1996 westley - - + + + +1996/westley + + + + + -

1996 westley

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1996/westley

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1996/westley/index.html

- +
+ ← schweikh3 + ↑ 1996 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Brian Westley
+Location: US

+ + +

To build:

+
make all
+

There is another version which is the original entry. See alternate version for details as to how to +use and why it was made the alt version.

+

To use:

+
./clock1.sh
+./clock2.sh
+./clock3.sh
+

Try:

+
./try.sh
+

Alternate code:

+

The original version had a display problem in modern systems which +somewhat affected the usability of the program. This alternate code, the +original, is provided, to show the differences.

+

Alternate build:

+
make alt
+

Alternate try:

+
./try.alt.sh
+

Judges’ remarks:

+

Time and time again, Brian Westley seems to come up with a winner! We +are amazed at how much is being done with only one relatively short +line. We think you will as well if you take the time to understand +it.

+

Author’s remarks:

+

This 1-line program allows various analog ASCII clocks to print out +the time; the ASCII clock is built from the command line arguments, so +many different types of clocks can be generated. Three different scripts +are supplied to print out a grandfather clock, a mantle clock that runs +backwards, and a linear-style clock. (they are clock1.sh, clock2.sh, and +clock3.sh)

+

The program makes the following (possibly non-portable) +assumptions:

+
    +
  1. Command line strings can be written to.

  2. +
  3. argv[0] can be written to as if it were a +long *.

  4. +
  5. The first three elements of the struct * returned by +localtime(3) are seconds, minutes, hours, and all are +ints.

  6. +
  7. My sample scripts assume ASCII, though this is not inherent in +the code, just my sample scripts.

  8. +
+

These assumptions are pretty reasonable. 2) can be eliminated but +makes the code larger.

+

The code is simple; the arguments passed are:

+
./westley minute_map hour_map hand_symbol clock_image
+

The program merely takes the minute (0-59) and the hour (0-23) +values, looks up the offsets in minute_map and +hour_map and writes the hand_symbol for each +into the clock_image string. This string is then +printed.

+

The for() loop starts by calling time() +with argv[0], so the time value (a long) is +written into the program name. The for() control value is +argc, which starts at 5, but the +/=2 statement is executed before the test, so the +for() loop is executed twice, with h=2, then +h=1 (for hour & minute).

+

The statement of the for() loop takes the hour or minute +field of the struct returned by localtime(3) by casting it +to an int * and dereferencing element [h]. It +is slightly smaller to use the trick h[(int*)localtime(*m)] +instead of ((int*)localtime(*m))[h].

+

This value is in turn indexed into the hour_map or +minute_map parameter to determine where the ‘hand’ symbol +should be written into the clock_image.

+

Note that the hands move in a quantum fashion; 3:59 looks deceptively +like 2:59, since the hour hand will be at the 3 position. It won’t move +until both hands click over at 4:00.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1996/westley

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1998/banks/index.html b/1998/banks/index.html index cc1cae707..4a53e5c6c 100644 --- a/1998/banks/index.html +++ b/1998/banks/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,416 @@ - - + + + + + + - - -1998 banks - - + + + +1998/banks + + + + + -

1998 banks

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1998/banks

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1998/banks/index.html

- +
+ first entry + ↑ 1998 ↑ + bas1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Carl Banks
+Location: US

+ + +

To build:

+
make all
+

You may redefine all the keys and the time step with predefined +macros. The author provided the following able:

+
Control         Description         Default Key
+-------  -------------------------  -----------
+ IT         Increase throttle      XK_Page_Up
+ DT         Decrease throttle      XK_Page_Down
+ FD         Move stick forward     XK_Up
+ BK         Move stick back        XK_Down
+ LT         Move stick left        XK_Left
+ RT         Move stick right       XK_Right
+ CS         Center stick           XK_Enter
+

There is another macro, dt, which is the time step. See +some important points on this in the author’s comments in the Alternate Build Instructions +section.

+

If however you wish to change the above controls, see the header file +keysym.h for the definitions of other characters +that you might wish to use. The name of the macro in the header file is +what you need to set the macros to, depending on what controls you wish +to redefine. For instance, to set the throttle up and down to +u and d:

+
make clobber IT=XK_u DT=XK_d all
+

because in the header file you can see that XK_u +corresponds to u and XK_d corresponds to +d:

+
#define XK_d                             0x0064  /* U+0064 LATIN SMALL LETTER D */
+#define XK_u                             0x0075  /* U+0075 LATIN SMALL LETTER U */
+

Note that the keysym.h file is not complete +from X11; it’s just the more likely candidates (and some that are +probably unlikely :-) ).

+

The upper case letters would be XK_U and +XK_D and you can search the header file for ‘LATIN CAPITAL +D’, for example.

+

For those who do not have a Page Up or Page Down key, see alternate code below. The difference from the +alt build and the original entry is that the page up and page down keys +are defined to a default but they are hard coded as doing otherwise +would necessarily complicate the build instructions. Since you can use +the original entry to redefine these this is not a problem and is purely +a convenience .. if only for those who are okay with the preselected +alternative keys.

+

To use:

+
cat horizon.sc pittsburgh.sc | ./banks
+

See the author’s remarks in scenery for more +details on the scenery files.

+

Try:

+

For a fun time after running the above command, hold down the up +arrow and left arrow for about 10 seconds and see what happens. Or, if +you wish to really use it in a non-silly way, see the author’s remarks +for the real controls. Perhaps you can regain control?

+

Alternate code:

+

If you do not have access to a page up or page down key, for instance +you’re using a Mac, you can use the alt code (though it actually uses +the same code) that will redefine the keys to increase throttle and +decrease throttle. This same method can be used with the original code +but this sets up predefined keys in place of Page Up and Page Down.

+

The keys were somewhat arbitrarily selected but it was decided to +make them both on the left side of a QWERTY keyboard as one might have a +harder time using the arrows at the same time as typing on the right +side.

+

Alternate build:

+

As the Makefile allows you to configure the keys to use you may +redefine the keys but with the alt build you cannot, as described +earlier, redefine the page up and page down replacement keys. If you +want to do that you should use the original entry as described in the to +build section above.

+

In the alt build it is f and d respectively +as these are letters on the left side of the keyboard which is easier to +use if one is using the right side for movement. These are hard coded, +as noted.

+

To use the default settings for the alternate build:

+
make alt
+

You may change the other keys as described in the build instructions, +above, but this alt code can be seen as an alternative for those who +don’t have or don’t want to use page up and page down.

+

Alternate use:

+

Use banks.alt as you would banks but for +use the different keys as configured at compilation.

+

Judges’ remarks:

+

What can we say? It’s a flight sim done in 1536 bytes of real code. +This one is a real marvel. When people say the size limits are too +tight, well, we can just point them at this one. This program really +pushes the envelope!

+

The provided Makefile should work; you will need an X-ish system, and +a select(2) system call. More on building in the author +remarks.

+

Carl Banks linked to (on his old website) an interesting article +about this entry, a flight simulator in just 1536 bytes, which can be +found at https://web.archive.org/web/20040201120708/http://www.idg.co.nz/magazine/pcworld/oct99/code.htm.

+

Author’s remarks:

+

You have just stepped out of the real world and into the virtual. You +are now sitting in the cockpit of a Piper Cherokee airplane, heading +north, flying 1000 feet above ground level.

+

Use the keyboard to fly the airplane. The arrow keys represent the +control stick. Press the Up Arrow key to push the stick forward. Press +the left arrow key to move the stick left, and so on. Press Enter to +re-center the stick. Use Page Up and Page Down to increase and decrease +the throttle, respectively. (The rudder is automatically coordinated +with the turn rate, so rudder pedals are not represented.)

+

On your display, you will see on the bottom left corner three +instruments. The first is the airspeed indicator; it tells you how fast +you’re going in knots. The second is the heading indicator, or compass. +0 is north, 90 is east, 180 is south, 270 is west. The third instrument +is the altimeter, which measures your height above ground level in +feet.

+

Features

+ +

Scenery

+

Each of the *.sc files is a scenery file. The simulator +program reads in the scenery from standard input on startup. You may +input more than one scenery file, as long as there are less than 1000 +total lines of input.

+

Here is a brief description of the scenery files:

+ +

A few examples of how to input scenery:

+
cat horizon.sc pittsburgh.sc | ./banks
+cat mountains.sc bb.sc | ./banks
+cat mountains.sc river.sc pyramids.sc | ./banks
+

You can simulate flying through a cloud bank as well:

+
./banks < /dev/null
+

You will usually want at least a horizon, though.

+

The format of scenery files is simple, by the way. They’re just a +list of 3D coordinates, and the simulator simply draws line segments +from point to point as listed in the scenery file. 0 0 0 is +used to end a series of consecutive line segments. Note that in the +coordinate system used, the third coordinate represents +altitude in a negative sense: negative numbers are +positive altitudes.

+

I’m sure you’ll be making your own scenery files very soon!!!

+

Alternate Build Instructions

+

Several options must be passed to the compiler to make the build +work. The provided Makefile has the appropriate +options set to default values. Use this section if you want to compile +with different options.

+

To map a key to a control, you must pass an option to the compiler in +the format -Dcontrol=key or if you use the Makefile you can +do make control=key.

+

The possible controls you can map are described in the table +below:

+
Control         Description         Default Key
+-------  -------------------------  -----------
+ IT         Increase throttle      XK_Page_Up
+ DT         Decrease throttle      XK_Page_Down
+ FD         Move stick forward     XK_Up
+ BK         Move stick back        XK_Down
+ LT         Move stick left        XK_Left
+ RT         Move stick right       XK_Right
+ CS         Center stick           XK_Enter
+

Values for the possible keys can be found in the X Windows header +file <X11/keysym.h>. This file is most likely a +cross-reference to another header, +<X11/keysymdef.h>.

+

For example, to map Center Stick to the space-bar, the compile option +would be -DCS=XK_space or +make CS=XK_space.

+

To set the time step size, you must pass the following option to the +compiler: -Ddt=duration, where dt is literal, +and where duration is the time in seconds you want the time +step to be. Alternatively, if you use the provided Makefile, you may +just do make dt=time.

+

Two things to keep in mind when selecting a time step. Time steps +that are too large (more than about 0.03) will cause +numerical stability problems and should be avoided. Setting the time +step to be smaller than your clock resolution will slow down the +simulator, because the system pauses for more time than the simulator +expects.

+

The best advice is to set time step size to your system timer +resolution. Try a longer period if you’re getting too much flicker.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1998/banks

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1998/bas1/index.html b/1998/bas1/index.html index fd81c161c..275012250 100644 --- a/1998/bas1/index.html +++ b/1998/bas1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,235 @@ - - + + + + + + - - -1998 bas1 - - + + + +1998/bas1 + + + + + -

1998 bas1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1998/bas1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1998/bas1/index.html

- +
+ ← banks + ↑ 1998 ↑ + bas2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Bas de Bakker
+Location: NL

+ + +

To build:

+
make all
+

To use:

+

If lpr on your system can print PostScript:

+
./bemazing | gunzip | lpr
+

else, while in X Window System,

+
./bemazing | gunzip | gv -
+

or:

+
./bemazing | gunzip | gs -sDEVICE=pgmraw -sOutputFile='|xv -' -
+

Judges’ remarks:

+

The output is supposed to be a 3D maze, but it is somewhat more than +that. If you’ve seen any of the Maurits Escher’s +works, you’ll know what +we’re talking about.

+

When trying to run the program with command line arguments, be +generous.

+

Author’s remarks:

+

BEMAZING

+

“You’re in a twisty little maze of beams, all different.”

+

Bemazing is “amazing” taken one step (letter) further. +Bemazing creates a 3D maze of beams. Try to go from the +entrance (the unfinished beam in one corner) to the exit (the unfinished +beam in the opposite corner) or vice versa.

+

For maximum portability, Bemazing is not tied to any +window system, but creates postscript output. The picture it makes will +fit on either A4 or letter size paper.

+

In addition, because postscript is rather verbose, +Bemazing creates the postscript in gzip(1) +format, in order to save precious bits on your hard disk for the latest +version of GNU Emacs +(after all, you wouldn’t want to use an editor without a +psychoanalyze-pinhead function, now would you). Again for maximum +portability, Bemazing will take special care that the +binary output will not contain any newline or return characters that may +get weird treatment on systems that do not use the One True Line +Separator.

+

NOTES

+

Be sure to view the source with something that can display characters +\240-\377. Use LESSCHARSET=latin1, +M-x standard-display-european in GNU Emacs +etc. The source does not use characters in the range +\200-\237 (we are not an unnamed word processor that tends +to create HTML containing these control characters).

+

Because this is not the obfuscated postscript contest, the postscript +does not contain any for, if or other control +structures. All the logic is in the C code. There are only a few +straightforward defs, because otherwise the output would +become much larger.

+

Try running Bemazing with command line arguments and see +what happens. (But note that the program only guarantees that there +actually is a route from entrance to exit if you run it without command +line arguments.)

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1998/bas1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1998/bas2/index.html b/1998/bas2/index.html index f57200205..78a9e1ba0 100644 --- a/1998/bas2/index.html +++ b/1998/bas2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,216 @@ - - + + + + + + - - -1998 bas2 - - + + + +1998/bas2 + + + + + -

1998 bas2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1998/bas2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1998/bas2/index.html

- +
+ ← bas1 + ↑ 1998 ↑ + chaos → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Bas de Bakker
+Location: NL

+ + +

To build:

+
make all
+

To use:

+
./bas2 < file
+echo text | ./bas2
+

Try:

+
./try.sh
+
+./try.sh "foo bar" "baz" "IOCCC 1998/bas2" README.md
+

Judges’ remarks:

+

Questions to ponder:

+

Can you determine the relationship between the input and the +resulting numeric output?

+

The program was not designed to process files with a certain octet +value, what value is that?

+

Hint and Extra Credit:

+

This entry points out a minor flaw in the IOCCC rules that has been +around since 1992. It processes a certain octet value in a way that +differs from a strict reading of one of the official IOCCC rules. What +is the rule and what is the octet value?

+

Author’s remarks:

+

The main obfuscation is the way characters are recognized, which is +done by matching the bit patterns. Minor obfuscations are:

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1998/bas2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1998/chaos/index.html b/1998/chaos/index.html index 207802cdd..f2df77c6c 100644 --- a/1998/chaos/index.html +++ b/1998/chaos/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,243 @@ - - + + + + + + - - -1998 chaos - - + + + +1998/chaos + + + + + -

1998 chaos

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1998/chaos

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1998/chaos/index.html

- +
+ ← bas2 + ↑ 1998 ↑ + df → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Alan De Smet
+Location: US

+ + +

To build:

+
make chaos
+

NOTE: Some systems do not implement halfdelay() in their +libcurses. You might try compiling with -lncurses if you +have that library. Or you can build this entry without the +halfdelay() call by:

+
make chaos_nohalf
+

To use:

+
./chaos
+

Judge’s Comments:

+

This is the author’s first IOCCC entry. We thought the entry was a +nice example of a compact collection of obfuscations.

+

Can you figure out why, in some cases, it wants to read itself?

+

Author’s remarks:

+

Usage

+

The executable takes a single argument for the data file to use. If +no argument is given, it will find a data file by itself, don’t worry +about it…

+

Summary

+

This is a simple ncurses 3D object viewer. The keys y, +u, i, h, j, and +k rotate. a and z zoom in and +out. q quits. Given about 3 seconds of no input, it will +start rotating until interrupted by user input.

+

Features (aka Bugs):

+

Memory malloc(3)ed is never freed. This shouldn’t be a +big deal, since only one block is ever allocated, and the OS should +recover it.

+

My local flavor of lint doesn’t seem to like the fact that I never +return from main(). Feh, what does it know? +Otherwise, ignoring lint’s over protectiveness (“Of course I’m not using +all of the functions defined in curses.h!”), it’s lint +clean.

+

If the compiler happens to generate the byte sequence “AlWuzEre” in +the executable by chance, the program may be unable to locate the +embedded string. As a result, running the program without an external +data file may act in undefined ways.

+

If the compiler doesn’t store char * P’s data in a nice +contiguous stream, it would be bad. As above, it would break running the +program without an external data file.

+

If the incoming data is corrupt, the results are undefined. (Although +dumping core is a popular result.)

+

When a point passes behind the camera, it is still plotted. The +object will “bounce” off the camera, but the result (some points in +front, some reflected from the rear) looks really odd. And it sometimes +hangs. So just don’t fly through objects. You’ll be happier.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1998/chaos

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1998/df/index.html b/1998/df/index.html index 0568168f0..9710ae3a8 100644 --- a/1998/df/index.html +++ b/1998/df/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,303 @@ - - + + + + + + - - -1998 df - - + + + +1998/df + + + + + -

1998 df

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1998/df

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1998/df/index.html

- +
+ ← chaos + ↑ 1998 ↑ + dlowe → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Daniel +Fischer
Location: unknown

+ + +

To build:

+
make all
+

To use:

+
./df
+

Judges’ remarks;

+

Everyone talks about how data hiding can produce clearer code; I am +pleased to offer this charming refutation.

+

The program is a simple game. A bit of observation reveals that the +game has some data - but where? It’s unclear which of the contents of +the program are used.

+

Curiously, the program only works if its source is in the directory +it’s run in. More curiously, the program would fail if the program’s +name’s second letter wasn’t r (the source has been changed +for your convenience and this restriction no longer exist).

+

Modern design has come a long way since the unreadable, +tightly-coupled systems we used to have.

+

Extra credit questions:

+ +

Author’s remarks:

+

This program lets you guess English words. It displays an underscore +for each letter in the word; guessing a letter that actually is in the +word replaces the corresponding underscores with the letter itself. You +can guess a letter simply by typing it in. If your C implementation +requires it, you may have to hit Return before it is recognized. In this +case, you can also type multiple guesses on the same line (completely +solve it by entering abcdefghijklmnopqrstuvwxyz). Execution +stops when all underscores have been replaced.

+

The program offers a number of different words to guess, +time() is used to pick one at random. All words are eight +characters long.

+

The source should compile with any ANSI C compiler (I used +CodeWarrior w/ ANSI strict). Using non-ANSI compilers that implement the +ANSI features it uses will not work (unless they defined +__STDC__ 1 which they shouldn’t). Due to space +restrictions, I did not use any trigraph sequences. It does not require +any special -D defines.

+

The source passes lint without any complaint (if invoked with +>/dev/null). (My lclint is unable to recover from some +parts of it.)

+

Actually, the code not only is compliant with the ANSI +specifications, but uses a near minimum subset of them. C keywords that +were not used have been re(de)fined to avoid unnecessary introduction of +new, unknown character patterns. The source also includes all ANSI +headers it needs (after most of the functions have been used), and the +declaration of main() follows the guidelines (but the +return type has a different meaning and the arguments are either misused +or unused). There also may be some compiler warnings. These are not +bugs, but features. The more warnings, the better the compiler. There +wouldn’t be any if I had been allowed to use some extra space for +prototypes etc.

+

Multiple defines are used (but not all of them define), and +#define y define is used with #y but the code +doesn’t assume #y to expand to #define. I have +also included comments in the code, and vital code in the comments. And +of course there is code that doesn’t do anything but will crash the +program if it is removed (just like those comments I mentioned above). +Additionally, since you said you’d be preprocessing entries ignoring +#includes I figured I should use some more of them instead +of other obfuscation methods. Did I mention that preprocessed or +beautified sources will crash or hang your system? The program will also +crash on non-ASCII machines.

+

The executable needs its source file present in the current directory +or, depending on your system, in your path. The name of the source file +is not hard-coded, __FILE__ is used instead.

+

In the original version which was sent in to the contest, there were +some restrictions on the file name:

+ +

Valid names would have been pr4.c, pr.c, +prog.c, brownie.c etc. My first private +version would only run when compiled on a Friday. I decided it would be +better this way… These restrictions have been removed for your +convenience.

+

The following lines describe how this program works; if you don’t +want to know it at this time, please skip them. If this entry would by +some mistake win the contest, please do not rot13 this - I hate rot13 +spoilers since it is somewhat complicated on a Mac to reverse them. +Anyone out there should have enough discipline and rot13 shouldn’t be +required, really. After all, we are not children anymore :-)

+
+

This paragraph is not part of the author’s remarks, but is a helpful +gift from the judges; if you read too fast to stop yourself, this should +give you enough time to stop, which you really need to do RIGHT NOW if +you don’t want to read the spoilers, which really do spoil everything, +we mean it.

+
+

The source file needs to be present because the words are read from +it. The wordlist is encoded within the source using a 24 entry sliding +dictionary where lowercase letters are offsets into the dictionary, +uppercase letters are new letters not yet in the dictionary, and all +other characters are ignored. The words are spread over six lines in the +source; decoding starts on a line after a tab and a whitespace have been +found, and stops on a newline. The grin after the “Demonic Smiley” +actually is one encoded letter while the string is completely ignored; +and the cut in “cut here” is required while +here is not.

+

“For extra credit”, explain why the words are sorted alphabetically +(because I extracted them from a dictionary :-) )

+

The file name had to fulfill the restrictions mentioned above because +__FILE__+1 was used as a second parameter to +fopen(). (It essentially was +fopen(__FILE__,__FILE__+1) ). This was an extra joke that +doesn’t exist in the released version.

+

You probably discovered that the while(FILE) in +main() is not a while loop but the statement that opens the +file and initializes the dictionary. Similarly, int and +signed have been redefined (to save space, of course).

+

The main function (the guessing part) is between the last +#else..#endif, but still is declared before +main(). The 5[O]() in main() +calls this function. Similarly, most indexing operations have been +changed to this form and I tried to write each such operation +different.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1998/df

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1998/dlowe/index.html b/1998/dlowe/index.html index 244db064f..f09e64c87 100644 --- a/1998/dlowe/index.html +++ b/1998/dlowe/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,293 @@ - - + + + + + + - - -1998 dlowe - - + + + +1998/dlowe + + + + + -

1998 dlowe

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1998/dlowe

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1998/dlowe/index.html

- +
+ ← df + ↑ 1998 ↑ + dloweneil → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: J. David Lowe
+Location: US

+ + +

To build:

+
make all
+

There is an alternate version available. See Alternate code below for more details.

+

To use:

+
./dlowe < anyfile > pootfile
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: missing or dead link - please provide them
+

For more detailed information see 1998 +dlowe in bugs.md.

+

Try:

+
./dlowe < README.md
+./dlowe < README.md > README.poot.md
+

Why is there different output?

+

Also try:

+
./try.sh
+

Alternate code:

+

The original entry was just a text based pootifier. This alternate +version is that program.

+

Alternate build:

+
make alt
+

Alternate use:

+
./dlowe.alt < anyfile > pootfile
+

What’s the difference between this and dlowe?

+

Alternate try:

+
./try.alt.sh
+

Judges’ remarks:

+

Why could this this entry be considered a utility? Well because it is +able to convert content-free web pages into useful web pages.

+

To see why, try using an online version, modified for use as a CGI +program: https://web.archive.org/web/20001025182142/http://pootpoot.com/poot/pootify?URL=http://www.microsoft.com

+

We are sure that you will find that new web page to make a much more +consistent level of quality. :-)

+

Historical remarks:

+

A CGI script such as:

+
#!/bin/sh
+# pootify - a sample CGI pootifier
+#
+POOT="/usr/local/bin/dlowe"
+LYNX="/usr/local/bin/lynx"
+ECHO="/usr/bin/echo"
+EXPR="/usr/bin/expr"
+${ECHO} "Content-type: text/html"
+${ECHO}
+if [ -z "${QUERY_STRING}" ]; then
+    ${ECHO} "QUERY_STRING not found"
+else
+    URL=`${EXPR} "$QUERY_STRING" : '[Uu][Rr][Ll]=\(.*\)'`
+    if [ -z "${URL}" ]; then
+    ${ECHO} "No URL given in QUERY_STRING"
+    elif [ X`${EXPR} "${URL}" : '[Ff][Ii][Ll][Ee]:'` != X0 ]; then
+    ${ECHO} "file: based URLs are not allowed"
+    else
+    ${LYNX} -restrictions=all -source "${URL}" | ${POOT}
+    fi
+fi
+

can be used to pootify web pages. This has been added as pootify.cgi.sh which forbids +file:// based URLs and which uses lynx(1) with +the option referred to above. This will not, of course, render it as +html but rather show the modified html. Nevertheless, this has +NOT been tested as a CGI script with a webserver to +display a pootified web page.

+

The pootify.sh script has also been added +which is a modification to the above script which can be used to render +html files locally with the added bonus that one can use +file:// URLs. If one wants a CGI script they should use the +above one instead. You can use the script pootify.sh, however, to download and generate html +files that you can look at locally in a browser or pipe through +less(1). For instance:

+
./pootify.sh URL=https://microsoft.com | less
+
+./pootify.sh -r URL=https://microsoft.com > ms.html
+

where the first one would show the text as rendered but without +links, images etc. and the second one would write the html to +ms.html so that you could open it in a browser.

+

For an old example of it working as a CGI script see:

+
https://web.archive.org/web/20040326083431/http://www.pootpoot.com/poot/pootify/?URL=http%3A%2F%2Fwww.ioccc.org
+

Author’s remarks:

+

This program is a text filter, it reads stdin and +outputs the “corrected” text to stdout.

+

It is obfuscated in that the code is painful to look at and its +purpose and mode of operation are not terribly obvious. More +importantly, it is a tool for further obfuscation, in that it can take +any text and render it unintelligible.

+

Suggested uses: add to your MANROFFSEQ environment +variable for man page enjoyment; use it to turn the GPL into the +PPL; see what happens when you run perl4 +programs after they’ve been run through it; “encrypt” sensitive (but +unnecessary) documents…

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1998/dlowe

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1998/dloweneil/index.html b/1998/dloweneil/index.html index 792ee1454..8822cfdb6 100644 --- a/1998/dloweneil/index.html +++ b/1998/dloweneil/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,311 @@ - - + + + + + + - - -1998 dloweneil - - + + + +1998/dloweneil + + + + + -

1998 dloweneil

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1998/dloweneil

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1998/dloweneil/index.html

- +
+ ← dlowe + ↑ 1998 ↑ + dorssel → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Authors:

Name: J. David Lowe
+Location: US +

Name: Neil +Mix
Location: unknown

+ + +

To build:

+
make all
+

There is an alternate version available that has a key configuration +that will be more familiar to vi(m) users and also allows one to quit. +See alternate code below.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: missing or dead link - please provide them
+

For more detailed information see 1998 dloweneil in bugs.md.

+

To use:

+

+./pootris [X size of board] [Y size of board]
+

Pressing a moves the current letter position +counterclockwise around the border of the playing field.

+

Pressing s moves the current letter one position +clockwise around the border of the playing field.

+

Pressing d drops the current letter onto the board.

+

Alternate code:

+

This version has it so that where in addition to a +moving you anticlockwise/counterclockwise h does as well; +and in addition to s moving clockwise l does +as well. Instead of using d to drop the letter you can do +j or space. Finally to quit this version you can press +q.

+

Alternate build:

+
make alt
+

Alternate use:

+
./pootris.alt [X size of board] [Y size of board]
+

Judges’ remarks:

+

Read the authors’ remarks below to find out how to play. We believe +that your experience may mirror one of our experiences:

+
Originally, I didn't appreciate the game.  Then I actually read the
+description of the controls.  I started playing.  I struggled.
+I spelled my first "poot".  I was hooked ...
+

Author’s remarks:

+

Usage

+
./pootris [X size of board] [Y size of board]
+

Synopsis

+

The object of this game is to spell POOT as much as +possible. There is no time pressure. You’re given one letter at a time +(sort of randomly chosen from the set ‘P’, ‘O’, and ‘T’) and you get to +move it freely around the border of the playing board, and decide when +and where to drop it into the board. Sound easy? Of course, there’s a +catch…

+

Controls

+

Only three controls:

+

a: moves the current letter one position +counterclockwise around the border of the playing field.

+

s: moves the current letter one position clockwise +around the border of the playing field.

+

d: drops the current letter onto the board.

+

To quit, send a fatal signal to the process.

+

Rules of motion

+

The different letters move in different directions once dropped onto +the board:

+

P moves diagonally, at a 45 degree angle and in a +clockwise direction around the board once dropped.

+

O moves in a straight line perpendicular to the border +from which it is dropped.

+

T moves diagonally, at a 45 degree angle and in a +counterclockwise direction around the board once dropped.

+

The letters bounce off the top and sides of the board. They bounce in +a ‘natural’ way, with the exception that Os will fall +straight down if they hit a side wall.

+

The letters stop when they hit another letter or the bottom of the +board.

+

Rules of spelling

+ +

Rules of scoring

+ +

Some of the obfuscations

+ +

Some +things I wish I could have fit into this, but didn’t have the +space:

+ +

Good Luck!

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1998/dloweneil

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1998/dorssel/index.html b/1998/dorssel/index.html index 773f0eb81..ac1ef7ba4 100644 --- a/1998/dorssel/index.html +++ b/1998/dorssel/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,272 @@ - - + + + + + + - - -1998 dorssel - - + + + +1998/dorssel + + + + + -

1998 dorssel

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1998/dorssel

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1998/dorssel/index.html

- +
+ ← dloweneil + ↑ 1998 ↑ + fanf → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Frans van +Dorsselaer
Location: unknown

+ + +

To build:

+
make all
+

To use:

+
./dorssel
+# input some text
+
+echo text | ./dorssel
+

Try:

+
./try.sh
+

Also try:

+
./dorssel < dorssel.md
+

Judges’ remarks:

+

How does the program decide which way to convert?

+

What obsolescent feature are we talking about? (No, it’s not a C +language feature.)

+

The author suggests that you try to answer the following +questions:

+ +

Extra credit:

+

Try doing what the last part of the last command in try.sh suggests. As in, do the following:

+
echo ". -..- . .-. -.-. .. ... .
+-.-. .... .- -. --. .  - .... .  .--. .-. --- --. .-. .- --  ... ---  .. -  -.. --- . ...  -. --- -  ... .... --- ..- -" | ./dorssel
+

and make the necessary adjustments.

+

You might also want to read the dorssel.md +file.

+

Author’s remarks:

+

Usage

+

This program converts ASCII to Morse code, and vice +versa.

+

The program reads in lines from standard input and writes its result +to standard output. The direction of conversion is determined on a per +line basis. Each line must consist of a maximum of 952 characters +followed by a new line character and they must not contain any NUL +characters. Otherwise, some characters may be lost in the +conversion.

+ +

Notes

+

The program assumes both source and execution character sets to be +ASCII. As far as I can tell, the program is conforming and does not +invoke undefined behavior.

+

Hints

+

Try:

+
./dorssel < dorssel.c | ./dorssel
+

to see what variables, numbers, and functions are used. (Does a +better job than most C beautifiers).

+ +
./dorssel < dorssel.c | ./dorssel | ./dorssel | ./dorssel
+

is the same as

+
./dorssel < dorssel.c | ./dorssel
+ +
./dorssel < dorssel.md
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1998/dorssel

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1998/fanf/index.html b/1998/fanf/index.html index 502873f06..d6eac676d 100644 --- a/1998/fanf/index.html +++ b/1998/fanf/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,499 @@ - - + + + + + + - - -1998 fanf - - + + + +1998/fanf + + + + + -

1998 fanf

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1998/fanf

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1998/fanf/index.html

- +
+ ← dorssel + ↑ 1998 ↑ + schnitzi → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Tony Finch
+Location: GB

+ + +

To build:

+
make all
+

NOTE: this may take a while. Some systems may have problems building +this entry because of the system resources it requires.

+

To use:

+
./fanf
+

Try:

+

Enter an expression on standard input. To try some we have +selected:

+
./try.sh
+

Judges’ remarks:

+

Historical aside:

+

At a time the code in fanf.c was that of fanf.orig.c but to get this to compile in modern +systems it had to be translated to what you now see. The intermediate +steps can still be performed but they might be different from the past. +This should be kept in mind as you read the below remarks.

+

This program translates lambda expressions into combinator +expressions. But you do not need to know Lambda Calculus to be impressed +by this program!

+

See the file fanf.lambda for more examples +of lambda calculus source.

+

Notice how large the code grows from the fanf.c +into the final fanftmp2.c C program. Take a look at that +final C program again, can you begin to understand what it is doing?

+

Look at the first stage of the C pre-processing which was done +like:

+
cc fanf.c -E > fanftmp1.c
+

Skip to the bottom of fanftmp1.c (after all of the C +pre-processor header stuff … look for a line of the form: +# 38 "fanf.c" near the bottom) and look at the resulting +code. This code, when C pre-processed will expand into over 342 times +the original code (ignoring #include headers) to produce +fanftmp2.c. That program in turn, when compiled translates +a single lambda expression on standard input into combinator expressions +on standard output.

+

Extra credit question:

+

What do you have to do to make this program work with an old non-ANSI +C preprocessor?

+

Author’s remarks:

+

My program is a demonstration of some practical applications of +theoretical computer science. The application it implements is a program +for translating lambda expressions into combinator expressions.

+

What the program does

+

The syntax of lambda expressions recognised by the program is as +follows: The basic atoms are variables which are single characters other +than backslash or parentheses, e.g. a or b or +@. Variables are combined by function application which is +written as e.g. (f a) which is the function f +applied to the argument a. Application groups to the left, +so (f a b c) is equivalent to (((f a) b) c). +Functions are created from lambda terms which are written in the form +\a(expr) which is the function taking argument +a and having value expr. Lambda is spelt +\ because ASCII isn’t good enough. Lambda binds tightly, so +\a\bcd is equivalent to ((\a(\b(c))) d). +Whitespace is ignored.

+

For example, the identity function, called I, is written +\x(x). A simple expression is (I a) which is +equivalent to (\x(x) a), which has the value +a. Another function called K is defined as +\x\y(x) and it evaluates as follows:

+
        K p q
+    ->  \x\y(x) p q
+    ->  \y(p) q
+    ->  p
+

Another function of interest is S, defined as +\f\g\x((f x) (g x)). My program demonstrates the fact that +any lambda expression can be translated into an equivalent “combinator +expression” which involves only S, K, +I (the combinators), and application, with no variables or +lambda abstractions. In fact, even I is unnecessary, since +it is equivalent to S K K:

+
        I z
+    ->  \a(a) z
+    ->  z
+
+        S K K z
+    ->  \f\g\x((f x) (g x)) K K z
+    ->  (K z) (K z)
+    ->  \x\y(x) z (K z)
+    ->  z
+

The algorithm for translating lambda expressions into combinator +expressions works as follows. There are three forms of lambda expression +to consider: variables, applications, and abstractions.

+
trans v     -> v                (variable)
+trans a b   -> (trans a) (trans  b )    (application)
+trans \ab   -> abs a (trans b)      (abstraction)
+

There are a further three cases to consider for the body of lambda +expressions, where we need to do the magic that transforms away the +variables.

+
abs a f x   -> S (abs a f) (abs a x)
+abs a b     -> K b         (b != a)
+abs a a     -> I
+

E.g. suppose we had combinator expressions for + and +3 and we wanted to see what the combinator expression for +doubling 3 looked like:

+
    trans \x(+ x x) 3
+->  (trans \x(+ x x)) (trans 3)
+->  (abs x (trans + x x)) 3
+->  (abs x + x x) 3
+->  S (abs x + x) (abs x x) 3
+->  S (S (abs x +) (abs x x)) I 3
+->  S (S (K +) I) I 3
+->  S (S (K +) I) I 3
+

We can then check that this evaluates to the expected result:

+
    S (S (K +) I) I 3
+->  S (K +) I 3 (I 3)
+->  K + 3 (I 3) (I 3)
+->  + (I 3) (I 3)
+->  + 3 3
+

It is possible to perform a slightly more compact translation with a +couple of simple optimisations. For example, note that +K (a b) is the same as S (K a) (K b), +because

+
    K (a b) x
+->  a b
+

and

+
    S (K a) (K b) x
+->  K a x (K b x)
+->  a b
+

Also, S (K a) I is the same as just a +because

+
    S (K a) I x
+->  K a x (I x)
+->  a x
+

The program simply reads a lambda expression from the standard input, +translates it into a combinator expression using the transformation and +optimisations described above, and prints out the result.

+

Why this is a practical +application

+

Combinator expressions are easier to evaluate than lambda expressions +because there are no problems with variables. For example, if I naively +evaluated the expression \x\y(x y) y I might get +\y(y y) which is not the same as the correct result because +the first y in the body should refer to a global +y rather than the local one. David Turner was the first +person to realise that because of this fact, SK combinators provide a +simple way to implement non-strict functional programming languages, +either in software or directly in hardware.

+

My program demonstrates this by being based on a combinator +evaluation engine which is used to implement a language called +OFL (pronounced like “offal” and short for “Obfuscated +Functional Language”). I then used OFL to implement all the +high-level functionality described above. This contributes a lot to the +obfuscation because even small amounts of OFL are quite +unpalatable, and large expressions are completely incomprehensible.

+

It is fairly well known that the lambda calculus (and hence SK +combinators) can compute anything, but mere computation is no use if you +cannot communicate with the world. This is why OFL includes +a few concessions to reality: a combinator E for +representing characters and testing them for equality, two I/O +combinators, G and P, for reading and writing +characters respectively, and a combinator J for +representing false. I also implemented the Y +combinator directly rather than in terms of the primitive combinators, +since it only required five characters to do so +(viz. Y W q Q g). However this code is not enabled because +the definition of Y in terms of other combinators is more +cute.

+

The E combinator comes in a large number of forms, one +for each character and one for end of file. It is written +E(c) for the variant of E corresponding to the +character c. An expression of the form E(c) x +is evaluated by first evaluating x. If x +doesn’t evaluate to some form of E, then evaluation of the +expression terminates. If x evaluates to E(c), +then the expression evaluates to K. If x +evaluates to E(d) (where d is a different +character to c), then the expression evaluates to +J.

+

K and J are used to represent +true and false respectively; they correspond +exactly to the standard lambda calculus representations of +true and false, viz. \t\f(t) and +\t\f(f) respectively. In this way a conditional expression +can just be written cond then else, which is even more +terse than C cond ? then : else. An expression that +compares a character with a, say, can be written in the +rather obfuscated form E('a') char then else.

+

The P combinator, like the E combinator, +starts off by evaluating its first argument and checking that it is some +form of E. It then writes that character on +stdout, and finally it calls its second argument as a +function with the argument I, i.e.

+
P x f  ->  f I
+

with a side-effect.

+

The G combinator just reads a character from +stdin then calls its argument as a function with the +appropriate E combinator as an argument, i.e.

+
G f  ->  f E(c)
+

with a side-effect.

+

One of the problems with non-strict languages is that it is hard to +predict in advance in which order side-effects will occur. In my program +I used a monadic I/O structure like that used by the programming +language Haskell; this allows one to write programs that manipulate +external state in a manner remarkably similar to imperative programming +languages like C. An examination of my program should provide an +illustration of how well this technique works in practice. (In +particular, I used the CPS form of the I/O monad from page 6 of +“Imperative Functional Programming”.)

+

The Y combinator is used for implementing recursive +functions. It has the evaluation rule

+
Y f  ->  f (Y f)
+

so that it can be used to call a function with itself as an argument. +For example, if I had the appropriate arithmetic operators defined, I +could write a factorial function in the lambda calculus like this:

+
Y \f\n((= n 0) 1 (* n (f (- n 1))))
+

OFL provides a facility for naming expressions so that +they can be used more than once without writing them in full. A +definition must be written on one line in the form +l name b expression where l is short for “let” +and b is short for “be”. Names must be more than one +character long. A complete OFL program starts off by +defining the primitives it will use with likes of the form +p (S) etc., then goes on to define the names it will use, +and finishes off with the main expression followed by a single +e short for “end”. OFL expressions must use +the minimum number of brackets needed to be unambiguous, except that the +whole expression must be surrounded by brackets.

+

OFL has a standard library which adds another five +combinators to the basic eight. These combinators provide greater scope +for optimisation when translating an expression from the lambda calculus +to combinators, and therefore more compact programs. Their evaluation +rules are:

+
B    f g x   ->      f    (g x)
+C    f g x   ->     (f x)  g
+BB c f g x   ->   c (f    (g x))
+CC c f g x   ->   c (f x)  g
+SS c f g x   ->   c (f x) (g x)
+

I used them to help fit my program into the required space; +unfortunately I couldn’t fit the version that fully optimises the lambda +expressions it reads into the required space. The complete optimisation +rules including the ones it doesn’t use are:

+
S  (K p)       I      ->       p
+S  (K p)    (K r)     ->   K ( p   r )
+S  (K p)    (B r s)   ->   BB  p   r s
+S  (K p)       r      ->   B   p   r
+S  (B p q)  (K r)     ->   CC  p q r
+S     p     (K r)     ->   C   p   r
+S  (B p q)     r      ->   SS  p q r
+S     p        r      ->   S   p   r
+

The implementation of +OFL

+

Although OFL has completely different syntax and +semantics to C, all you need to compile OFL programs is a C +compiler and a header file (which in my entry to the competition has +been included in-line). The header file implements a two-pass optimising +compiler which produces a representation of the program that is then +interpreted.

+

The first pass of the compiler is implemented via the C preprocessor. +It implements one optimisation, namely function in-lining. +Unfortunately, this optimisation always increases object code size and +execution time. The opposite optimisation, common sub-expression +elimination (which would offer improvements in code size and execution +time), has not been implemented. The output of this pass is a C program +that may be compiled by a normal C compiler.

+

The second pass is performed by the initialisation phase of the C +program. It builds a data structure representing the abstract syntax +tree of the program.

+

The program is then executed by an interpreter. This operates by +performing manipulations on the AST that correspond to the evaluation +rules of the combinators that I described above.

+

The first 54 lines of the program are mostly the interpreter; the +next 8 lines are pass one of the compiler; the next nine declare the +OFL primitives; the next five define the OFL +standard library; and the rest implement the application described in +the first part of this document. This part of the program is transformed +into the second pass of the compiler by the first pass of the +compiler.

+

The first pass of the compiler relies on some magic macros that +expand in a mutually-overlapping and almost recursive way in order to +perpetrate a complete change of syntax. Interestingly enough, if I +hadn’t used the same identifier for more than one thing in various +places in the program this transformation would work with old-style cpp +as well and ANSI cpp. It expands the program from about 2.2KB to about +740KB. The resulting code does some tricky stuff to build a data +structure of the same form as the code itself.

+

The interpreter is written in fairly straightforward C, although it +is highly compressed. The C itself is written in a fairly functional +style, in that every function consists of a single expression. In the +tradition of functional programming languages it assumes that memory is +infinite and so never frees anything. It also assumes that the C +compiler implements the tail recursion optimisation, which is probably +not true.

+

References

+

I used these references in the course of writing this program and +they explain some of the ideas behind it in more detail. Arthur Norman +(one of the authors of the first paper) did a lot to enthuse me about +this topic.

+

Clarke, T. J. W., et al., 1980. SKIM - the S, K, I Reduction Machine. +Proceedings of the 1980 ACM LISP Conference, pp. 128-135.

+

Curry, H. B. and Feys, R., 1958. Combinatory Logic, Vol. 1. +North-Holland.

+

Gordon, M. J. C., 1988. Programming Language Theory and its +Implementation. Prentice-Hall.

+

Peterson, J, et al., 1997. Report on the Programming Language +Haskell, version 1.4.

+

Peyton Jones, S. L., 1987. The implementation of Functional +Programming Languages, Chapters 2, 11, 12, 16. Prentice-Hall.

+

Peyton Jones, S. L., and Wadler, P., 1992. Imperative Functional +Programming. Proceedings of the ACM Symposium on the Principles of +Programming Languages 1993, pp. 71-84.

+

Turner, D. A., 1979. A new implementation technique for applicative +languages. Software- Practice and Experience. Vol. 9, pp. 31-49.

+

Turner, D. A., 1979. Another algorithm for bracket abstraction. +Journal of Symbolic Logic. Vol. 44, no. 2, pp. 67-270.

+

Wadler, P., 1990. Comprehending Monads. Proceedings of the ACM +conference on Lisp and Functional Programming, 1990.

+

Wadler, P., 1995. How to Declare an Imperative. Proceedings of the +ACM International Logic Programming Symposium, 1995.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +1998/fanf

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1998/schnitzi/index.html b/1998/schnitzi/index.html index 4e4f8b347..53ba80d9c 100644 --- a/1998/schnitzi/index.html +++ b/1998/schnitzi/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,270 @@ - - + + + + + + - - -1998 schnitzi - - + + + +1998/schnitzi + + + + + -

1998 schnitzi

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1998/schnitzi

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1998/schnitzi/index.html

- +
+ ← fanf + ↑ 1998 ↑ + schweikh1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Mark +Schnitzius
Location: unknown

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 1998 schnitzi in bugs.md.

+

To use:

+
./schnitzi n > sort.c
+make sort
+./sort
+# enter three numbers, space separated
+
+echo x y z | ./sort
+

where n and x, y and +z are numbers.

+

Try:

+
./try.sh
+

What happens if at the command line you don’t specify n +numbers that the program expects? For instance try:

+
./schnitzi 5 > sort.c
+make sort
+
+# try running the next command four or five times:
+echo 2 5 3 1 | ./sort
+

Why does this happen?

+

Judges’ remarks:

+

This is a beautiful program. How can a program with no conditional +(except for the fixes for modern systems) behavior at all have output +which depends on anything?

+

For hints on deciphering this, see below past the Author’s remarks; +they’re a nice summary, but they leave the mystery intact.

+

BTW: the author notes an incredible lipogram story called Gadsby +which has no letter E in the story. He did not note this but it has over +50000 (50 thousand) (!!) words without the letter E which is one of the +most common letters!

+

Author’s remarks:

+

In literary circles, there is a poetic form called a “lipogram”, +which is a poem in which a specific letter has been distinctly avoided. +This principle can be applied in other ways. For instance, in this +paragraph, the vowel which immediately follows t in the +alphabet is nowhere to be seen. There is even an entire novel (E. V. +Wright’s “Gadsby”) in which no word contains the letter +e.

+

The IOCCC has been no stranger to this concept. Several winning +entries from years past have accomplished interesting feats while +completely avoiding the use of certain C constructs thought to be +essential (e.g. 1988/robison.c). +If you have to ask why they would do it this way, then this contest just +isn’t for you.

+

In continuing with this fine tradition, this program suggests to the +ANSI committee some new practical simplifications for the C language. +For instance, it appears that CONDITIONAL BRANCHING isn’t really +necessary. So, we can do away with while, +do...while, for, +if/else, switch, ?:, +or anything else that might cause any kind of non-deterministic jump in +the code. There’s too much uncertainty in the world anyway.

+

Function parameters and return types just confuse people anyway, so +get rid of them. Same with local variables. In fact, all you really need +are assignment statements, and maybe one printf(3) and one +goto.

+

This style of programming is also ideal for systems with limited +memory capacity, since the function call stack never goes beyond a depth +of one.

+

So what does it do? Give it an integer +(1 < n < 27) on the command line, such as

+
./schnitzi 5
+

The output will itself be a lipographic program, one which expects +input of (in this case) five numbers and prints them out sorted. It +sorts them, however, using only if/else statements, without +arrays or looping. To see the resulting program run, redirect the output +from schnitzi into another file, like this

+
./schnitzi 4 > sort.c
+

and then compile it.

+

Spoilers And Hints:

+

The big key to this program is figuring out what the names of the +functions ought to be; a bit of research may allow you to guess at a few +crucial ones.

+

The only function ever called is O, but O +is just set to point to other functions all the time. Or, almost all the +time.

+

So how does h get set, and what to?

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1998/schnitzi

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1998/schweikh1/index.html b/1998/schweikh1/index.html index 0e02e03c2..852e392e7 100644 --- a/1998/schweikh1/index.html +++ b/1998/schweikh1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,410 @@ - - + + + + + + - - -1998 schweikh1 - - + + + +1998/schweikh1 + + + + + -

1998 schweikh1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1998/schweikh1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1998/schweikh1/index.html

- +
+ ← schnitzi + ↑ 1998 ↑ + schweikh2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jens +Schweikhardt
Location: DE

+ + +

To build:

+
make all
+

There is an alternate version of this entry that will work with +macOS. See the Alternate code section +below. We recommend you look at it even if you don’t have a Mac, unless +you want to figure it out yourself, as it includes some interesting +details about the entry.

+

To use:

+
./schweikh1
+

Alternate code:

+

As noted above this entry will not work as it stands for macOS and +there are some important notes as well as a description of how the fixed +version works (the details of which are relevant to the original entry +that no longer works as well as the fixed version but are described in +the context of the macOS adjustments). For details of what had to +change, see macos.md. Unless you wish to figure +it out yourself, we recommend that you read this even if you don’t have +a Mac as it has some interesting details about the entry.

+

Alternate build:

+
make alt
+

Alternate build:

+

Use schweikh1.alt as you would schweikh1 +above.

+

Alternate try:

+

Bonus exercise: modify the code to provide a different compiler.

+

Judges’ remarks:

+

What does it do? It seems to print a list of system headers, perhaps +with words after them. Curiously, if you look at the list of words +defined in a given standard header, they are never printed directly +after that header’s name. Aha! It’s a conformance test for the standard +headers.

+

This code is a wonder; it’s a wonder that it compiles. I wonder +whether or not it should. The innovative realization that you can use +special characters, such as '\n', in #file +directives alone merits some recognition.

+

I’ve included most of the author’s remarks; they’re fairly thorough. +Do not read them if you want to figure this out yourself. “Amendment +One” refers to “NA1”, the add-on to C89 which added some fairly crufty +internationalization support.

+

Historical note:

+

Some non-gcc compilers that were not fully ANSI standard did not +compile this entry correctly. Using cc by default was not helpful most +of the time on this entry, because the program had a hardcoded gcc +invocation anyway. Anyone who uses egcs and has no plain gcc will need +to frob the source anyway and can be expected to do the right thing with +${CC}. This limitation was removed in 2023 but in the past +one should have used gcc.

+

Author’s remarks:

+

Important! This program, if it compiles at all, is mis-compiled by +many compilers due to compiler bugs. It could be the “least likely to +compile and execute” in conjunction with preprocessor abuse. When run, +it is likely to uncover bugs in your system headers.

+

The program is run without arguments. If your compiler is buggy, the +most likely result is no output and/or an exit status of 1.

+

If Amendment One headers are missing you will see something like:

+
<iso646.h>:
+gcc: /usr/include/iso646.h: No such file or directory
+gcc: No input files specified
+<wctype.h>:
+gcc: /usr/include/wctype.h: No such file or directory
+gcc: No input files specified
+<wchar.h>:
+gcc: /usr/include/wchar.h: No such file or directory
+gcc: No input files specified
+

Bug your vendor for an upgrade.

+

The format of the info file is straightforward and described in the +file itself. Just load it in your favorite editor.

+

Requirements

+

gcc (the GNU C compiler) must be available at runtime. +It is assumed that your C implementation keeps headers as files in the +/usr/include directory. The info file +must be readable and reside in the current working directory. The +current working directory must be writable in order to create a +temporary file (which is removed upon program termination). In case you +don’t have gcc at runtime, not all is lost if your compiler or +preprocessor can produce a list of defined macros in the format output +by gcc -dM, i.e. lines of the form +#define MACRO value.

+

Edit the source at line 55 in this case.

+

Background

+

ISO C has a very strict idea of visibility of identifiers. All +possible macros are explicitly enumerated. In a compliant implementation +no other macros can be defined, because you could write strictly +conforming programs that may fail to compile due to syntax errors: +supposing that <stdio.h> defines +PIPE_BUF, then the conforming

+
#include <assert.h>
+#include <stdio.h>    /*  <- or where the bogus macro is defined */
+#include <string.h>
+#define STR(x) #x
+#define XSTR(x) STR(x)
+int main (void)
+{
+   int PIPE_BUF = 0;
+   assert (strcmp ("PIPE_BUF", XSTR (PIPE_BUF)) == 0);
+   return 0;
+}
+

is expected to compile and meet the assertion. If it does not, your +compiler compiles some other language than ISO C.

+

Why I think my program is +obfuscated

+

Not only is the program’s purpose a thorough standard conformance +test, the source itself is a beast and has uncovered bugs in many C +compilers.

+
    +
  1. The token sequence after #include can consist of +pp-tokens and “are processed just as in normal text.” [ISO 6.8.2] The +result must resemble one of the canonical forms, "foo.h" or +<bar.h>. This lets us write things like
  2. +
+
#define HEADER "foo.h"
+#include HEADER
+

I could not find a compiler rejecting this. However, if we’re +torturing the preprocessor a little more, by using token pasting, at +least one compiler falls over.

+
#define H(x) <st##x##.h>
+#include H(dio)              /* expands to <stdio.h> */
+

is rejected by tcc version 4.1.2, the TenDRA compiler: +"t.c", line 3: Error:\ [ISO 6.8.3.3]: Invalid result for '##' operator in macro 'H'.

+

To be honest, I don’t know if the rules for pp-tokens and token +pasting don’t forbid what I do (and thus tcc is correct in rejecting +it). In this case, all other compilers I tried are buggy, or the +Standard itself :-)

+
    +
  1. The #line directive allows to set a line number, and +optionally a file name, i.e. modify __LINE__ and +__FILE__. Strange things happen if the file name contains a +NUL byte – which the Standard allows: in #line num "file" +the "file" is an s-char-sequence per ISO 6.8.4. ISO 6.1.4 +defines string literals as s-char-sequences, which may include octal +escape sequences. Let’s look at
  2. +
+
#include <stdio.h>
+#line 42 "foo\0bar"
+int main (void) {
+   printf ("%s %d\n", __FILE__, (int)sizeof __FILE__);
+   return 0;
+}
+

This is supposed to output 'foo 8'. Here’s what happens +in RL:

+
foo 4        gcc 2.7.2.1, lcc
+foo\0bar 9   tcc 4.1.2, Sunsoft cc turn "\0" into "\\0", ugh!
+

(I have written a bug report for gcc. Newer versions and egcs are +ok.)

+
    +
  1. The %: and %:%: digraphs test for +conformance to Amendment One.

    +

    Ask your local guru if C allows the same case label in the same +switch statement to appear more than once. Ask him/her to think real +hard. The answer will be “no”. The true guru will cite a constraint in +ISO 6.6.4.2. Then make fun of the guru’s answer by waving +case __LINE__: under his/her nose. Easy money from a bet! +Make sure your guru has no chance to use Standardese weasel words as an +escape: can I have

  2. +
+
  case <some_token>:
+  case <some_token>:
+
in the same switch? (Note that you need the [invisible] newline. You
+can generously allow the additional constraint that no `#undef`s or
+`#define`s are allowed between the two cases.)
+

Lots of integer constants and string literals come into the source +via __LINE__ and __FILE__ which are redefined +at various places. Sometimes the __FILE__ contains +\0 bytes; different strings or characters are then accessed +with offsets, say 10+__FILE__ or +__LINE__+__FILE__ or 2[__FILE__]. One integral +constant in octal. This makes the source and header input depend on +ASCII.

+

A few old obfuscations, like one character identifiers, not too many +macros, a goto O, “needless” assignments to satisfy lint +with its “function value ignored” warnings. My lint has nothing to +complain about.

+

There’s more whitespace in the Standard than just space, tab and +newline. In particular, there are vertical tab and form-feed that can be +used in certain places (outside of preprocessing directives, i.e. they +are not allowed from just after the # up to the final +newline. See 6.8 for details.) On many implementations these appear as +^L and ^K. My source starts with an extremely +uncommon 32bit word consisting of ^L, ^K, +% and :. I have grepped old winning entries +for ^K, none of them contains one, so this is something new – after 14 +years of IOCCC. Be sure to have enough paper in your printer when you +make a hard copy of the source…

+

While I’m at it, the rules state that only space, tab and newline are +ignored for the count (plus ‘{’, ‘}’, +‘;’ followed by whitespace). The mkentry.c program, however, uses +isspace(3) which returns nonzero for \v and +\f and other characters as well. I could have used a lot +more ^K and ^L probably undetected by your +counter but decided to err on the side of safety. I use a perl script to +compute the character count according to the rules. The advantages of an +independent clean room approach…

+
#!/usr/bin/perl -w
+ = "\0";
+ = <>;
+s/[;{}][ \t\n]/\n/g;
+s/[ \t\n]+//g;
+print length (),"\n";
+

To use, try:

+
perl ./charcount.pl schweikh1.c
+

I have tried, as suggested in the guidelines, to let the code look +like ordinary C code. Apart from a few long lines I think I left the +indentation like I would in RL. You should however not try to use +indent on the source. The code is extremely fragile because +of the myriads of __LINE__ macros – indenting is a sure way +to break the program. Don’t even think of maintaining that beast; I’ve +had my share of core dumps during development :-) A test suite was used +after every minor change to find out if the program still does what it +should.

+

From the goals: “To stress C compilers with unusual code.” That +describes exactly my modest attempts…

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1998/schweikh1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1998/schweikh2/index.html b/1998/schweikh2/index.html index 66cd0b221..1f299d2cd 100644 --- a/1998/schweikh2/index.html +++ b/1998/schweikh2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,359 @@ - - + + + + + + - - -1998 schweikh2 - - + + + +1998/schweikh2 + + + + + -

1998 schweikh2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1998/schweikh2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1998/schweikh2/index.html

- +
+ ← schweikh1 + ↑ 1998 ↑ + schweikh3 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jens +Schweikhardt
Location: DE

+ + +

To build:

+
make all
+

To use:

+
./yarng
+

or

+
./yarng integer_number
+

Try:

+
./yarng 5
+
+./yarng
+# watch what it does
+

What is the difference there?

+

Judges’ remarks:

+

Run the program with a small argument, like 5 or 10, several times. +Are the results different? Why?

+

Historical remarks:

+

At the time of judging, some non-gcc compilers that were not fully +ANSI standard did not compile this entry correctly. Also at that time, +some gcc and egcs implementations ran into a problem when building the +entry. Doing:

+
make schweikh2
+

often produced an error of the form:

+
gcc -ansi schweikh2.alt.c -o schweikh2.alt
+as: Error: cca00NzV.s, line 58: Missing " at end of string
+     "
+as: Error: cca00NzV.s, line 58: malformed statement
+*** Error code 1 (bu21)
+

because the line:

+
#line 10 ONE(O(1,1,2,6,0,6))
+

turned into the line:

+
# 9 "01\012"
+

(note, though, how that line is on line 11) which caused gcc to give +to the assembler the following two lines:

+
.stabs "schweikh2.c
+",132,0,0,Ltext1
+

and the lone " after the #.file line +resulted in an assembly syntax error.

+

In some cases one had to compile using gcc -g:

+
make schweikh2 CFLAGS=-g
+

to trigger this error.

+

With the proper text beyond the \012, it was even +possible to have all kinds of fun adding inline assembly via +#line directives. :-)

+

For extra fun and credit:

+

If your compiler had this bug, you could transform the line in the C +program to inject assembly instructions in such a way that the program +would compile.

+

If you were able to do that, you could have tried adding assembly +instructions so that it will compile, execute and do something +interesting (or uninteresting, for that matter :-) ).

+

If you succeeded in doing that (especially on FreeBSD, Linux or +SunOS/Solaris), you could have emailed the author for a free pat on the +back (and maybe you still can :-) ).

+

Because of this bug, the code was changed to be instead:

+
#line 10 "01\015"
+

However in 2023 it was observed that it is gcc (at least +some versions?) that has a problem with the compilation of the +modified program, giving an internal compiler error:

+
:10:16: warning: type defaults to 'int' in declaration of 'zero' [-Wimplicit-int]
+: In function 'main':
+:12:1: warning: missing terminating " character
+:12:19: internal compiler error: invalid built-in macro "__FILE__"
+

so the line:

+
#line 10 "01\015"
+

was changed to:

+
#line 10 ONE(O(1,1,2,6,0,6))
+

and now it works with both clang and gcc.

+

Author’s remarks:

+

What this program does

+

My entry is a yarng, which stands for, you guessed it, +yet another random number generator, and is pronounced ‘yawn’ due to its +incredible speed. Seriously, it exploits the randomness of quantum +mechanical events that build up the hardware as well as some other +non-deterministic factors. Here’s how it works:

+
    +
  1. an alarm is scheduled to be delivered in a second
  2. +
  3. an infinite loop is entered that just increments a counter
  4. +
  5. on delivery of the alarm signal, the counter’s LSB is printed.
  6. +
  7. while some other counter is not zero, go to step (1)
  8. +
  9. exit
  10. +
+

The yarng therefore produces output at a rate of 1 baud. +The number of bits may be specified by an argument and defaults either +to UINT_MAX (least likely) or UINT_MAX+1 (most +likely). Extra credit: why the different values? How long would you need +for an empirical test?

+

For example:

+
$ ./yarng 32
+10111001010101110110010101001111
+$ ./yarng 5
+10011
+

Why I think this is +obfuscated

+ +

Where does the randomness +come from?

+

Each bit obviously depends on the number of times the loop body is +executed between two calls of the signal handler. But what determines +this number?

+ +

How about the randomness of the yarng? To measure these +properties I counted the number of bit sequences and compared them to +what I would expect from a generator with uniform distribution (all +sequences equally likely to occur).

+

It is interesting to note that yarng’s maximum +deviations are less than or equal to rand(3)’s. Randomness +however tends to degrade under high load averages on my system (Linux). +This could be avoided by allowing the process one second of execution +time instead of wall clock time (using the SIGVTALRM sent +by the virtual timer instead of SIGALRM).

+

I’m not surprised. Yarng in the end depends on +fluctuations of the electrical field and the heat distribution in the +oscillators, the implementation and state of the scheduling algorithm, +the system load, number and temporal distribution of asynchronous events +and last but not least the phase of the moon. God does play +dice. Type yarng and watch Him roll.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1998/schweikh2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1998/schweikh3/index.html b/1998/schweikh3/index.html index 0b81fd3c8..cba89e75d 100644 --- a/1998/schweikh3/index.html +++ b/1998/schweikh3/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,360 @@ - - + + + + + + - - -1998 schweikh3 - - + + + +1998/schweikh3 + + + + + -

1998 schweikh3

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1998/schweikh3

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1998/schweikh3/index.html

- +
+ ← schweikh2 + ↑ 1998 ↑ + tomtorfs → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jens +Schweikhardt
Location: DE

+ + +

To build:

+
make all
+

The author stated:

+
In the remote event that the input has more than `8192` files with
+the same size (on systems where `sizeof (char *) == 4`, or `4096` when
+`sizeof (char *) == 8`), increase the manifest constant 32767 on line
+31.
+

An alternate version allows one to fix this; see alternate code below.

+

To use:

+

If dir is the directory (or a directory tree) where you +keep all your favorite pictures off the Internet or from +alt.binaries.pictures.*, do

+
find dir -type f -print | ./samefile
+

Maybe you will not need to buy another 10 GB disk to store them. +:-)

+

Try:

+

If you’re in this winning entry’s directory:

+
./try.sh
+

Notice that the tool finds some files that are duplicates.

+

Alternate code:

+

If you run into the problem that the author described (above) you can +redefine the size as described; this was done with the SZ +macro defined in the Makefile which if (in the code) is unset will be +set to the default, 32767.

+

Alternate build:

+

If you wish to change the size to say, 55555:

+
make clobber SIZE=55555 alt
+

or whatever you wish to redefine it to.

+

Judges’ remarks:

+

This program is not as smart as to detect identity of JPEG files with +the same picture but with different compression levels. On the other +hand compression can make a thing look/sound/feel different so these +probably aren’t duplicates anyway. :-)

+

Some time after this entry won, the Internet Systems Consortium (ISC) +added the samefile utility to its treasure of software gems! See the +author’s page about the tool as well at http://www.schweikhardt.net/samefile.

+

Author’s remarks:

+

The source is expected to conform to IEEE Std 1003.1-1990 (“POSIX”). +Thank God the IEEE does not standardize a coding style…

+

What this program does

+

This is best explained in the man page. The troff source for this man +page can be found in the file samefile.1. To +render try:

+
`man ./samefile.1
+

Otherwise:

+

SAMEFILE(1) User Manuals +SAMEFILE(1)

+

NAME

+

samefile - find identical files

+

SYNOPSIS

+
./samefile
+

DESCRIPTION

+

samefile reads a list of file names (one file name per +line) from stdin. For each file name pair with identical +contents, a line consisting of six tab separated fields is output: The +size in bytes, two file names, the character = if the two +files are on the same device, X otherwise, and the link +counts of the two files. The output is sorted in reverse order by +size.

+

samefile uses two stages to give optimum +performance.

+

In the first stage, all non-plain files are silently ignored +(directories, devices, FIFOs, sockets, symbolic links) as well as files +for which stat(2) or open(2) fails. The result +of the first stage (the file names) is written into a binary tree with +one node for every file size. Each node is in turn a linked list of file +names along with inode and device information. It is also at this first +stage where checks for hard links are done. For any inode only one +filename will be added to the binary tree.

+

In the second stage all files having the same size are compared +against each other. The rules of mathematical logic are applied to +reduce work and output noise: if files A, B, +and C have the same size and samefile finds that +A = B and A = C then it will not compare +B against C (and will not output a line for +B and C) but only for A = B and +A = C. The algorithm will detect equality across +arbitrarily long chains. Note however, that because only the first +filename per inode gets into the first stage, the output for a group of +identical files with different inode numbers is also minimized. Suppose +you have six identical files of size 100 in an inode group consisting of +the three inodes with numbers 10, 20 and 30:

+
$ ls -i   # output edited for readability:
+  10 file1     20 file4     30 file6
+  10 file2     20 file5
+  10 file3
+$ ls | ./samefile
+100     file1   file4   =       3       2
+100     file1   file6   =       3       1
+

The sum of the sizes in the first column is the amount of disk space +you could gain by making all 6 files links to only one file or remove +all but one of the files. To be precise, disk space is allocated in +blocks - you will probably gain two blocks here, rather than 200 bytes. +Note that it is not enough to just remove file4 and +file6 (you would gain only 100 bytes because +file5 still exists.)

+

LIMITATIONS

+

samefile was written with no limits in mind. The number +of input lines is unlimited. The size of the actual files is only +limited by available virtual memory needed to compare one pair of files. +The only hard limit is the constraint that there should not be more than +about 8192 files having the same size. Experience has shown +that there are rarely more than a couple dozen files of the same +size.

+

EXAMPLES

+

For everybody:

+

What are the duplicates under my home directory?

+
find $HOME | ./samefile
+

For the sysadmin folks:

+

Report all duplicate files under /usr larger than 16k:

+
find /usr -size +16384c -a -type f | ./samefile
+

For the ftp and WWW admins: How much space is wasted below our site’s +/pub directory?

+
find /pub -type f | samefile | awk '{sum += $1} END {print sum}'
+

EXIT STATUS

+

If samefile runs out of memory the exit status is 1, +zero otherwise.

+

SEE ALSO

+

find(1), ln(1), rm(1)

+

Why I think it is obfuscated

+ +

Are you an algorithms guru? If so you should know why the output +appears sorted without any use of qsort(3) or +system("sort").

+

Rewrite (hah!) the program to use memory mapping of files instead of +read(2). Does this affect performance noticeably?

+

It’s easy to write a script that takes samefile’s output +and hard links (or symlinks) identical files. Writing such a script is +left as an exercise for the deobfuscator.

+

When you run samefile on some directory tree, try to +estimate how much you think it will find. Is the actual result anywhere +near your estimate? How many copies of the GPL COPYING file +are there on your filesystems? :-)

+

In the remote event that the input has more than 8192 +files with the same size (on systems where +sizeof (char *) == 4, or 4096 when +sizeof (char *) == 8), increase the manifest constant 32767 +on line 31.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1998/schweikh3

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/1998/tomtorfs/index.html b/1998/tomtorfs/index.html index 852714ded..36b94f621 100644 --- a/1998/tomtorfs/index.html +++ b/1998/tomtorfs/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,268 @@ - - + + + + + + - - -1998 tomtorfs - - + + + +1998/tomtorfs + + + + + -

1998 tomtorfs

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

1998/tomtorfs

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/1998/tomtorfs/index.html

- +
+ ← schweikh3 + ↑ 1998 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Tom Torfs
+Location: unknown

+ + +

To build:

+
make all
+

To use:

+
./tomtorfs filename bitwidth polynom reflected init xor
+

where:

+
filename  : file to calculate the CRC of
+bitwidth  : width of the CRC in bits (decimal)
+polynom   : polynomial used for the CRC (hexadecimal)
+reflected : 0 if the CRC is not reflected, 1 if it is
+init      : initial value for the CRC (hexadecimal)
+xor       : value to xor the final CRC with (hexadecimal)
+

Try:

+
./try.sh
+

Judges’ remarks:

+

If you don’t believe the program is correct, try and compare the +output of the program with the value of CRCs computed by PKZIP or any +other archiver that uses the CRC-32 algorithm.

+

Author’s remarks:

+
Usage:
+./tomtorfs filename bitwidth polynom reflected init xor
+
+filename  : file to calculate the CRC of
+bitwidth  : width of the CRC in bits (decimal)
+polynom   : polynomial used for the CRC (hexadecimal)
+reflected : 0 if the CRC is not reflected, 1 if it is
+init      : initial value for the CRC (hexadecimal)
+xor       : value to xor the final CRC with (hexadecimal)
+

Examples

+

CRC-16:

+
./tomtorfs filename 16 1021 0 FFFF 0000
+

CRC-32:

+
./tomtorfs filename 32 04C11DB7 1 FFFFFFFF FFFFFFFF
+

XMODEM:

+
./tomtorfs filename 16 8408 1 0000 0000
+

ARC:

+
./tomtorfs filename 16 8005 1 0000 0000
+

Portability notes

+

The program assumes CHAR_BIT==8. Results are undefined +if bitwidth > sizeof(unsigned long) * 8. It is also +assumed that EOF is -1 and 1 is a +valid exit value to indicate failure (replace them with EOF +resp. EXIT_FAILURE if the assumptions are false). Otherwise +ANSI/ISO C.

+

No special build options required.

+

Special notes

+

Count the number of non-whitespace characters in the source file to +find out what dark force drove me to write this ;-).

+

Spoiler

+

First of all, if you run a C beautifier on the program (thereby of +course losing the nice code shape I worked so hard on ;-) ) the code +will become a bit more readable.

+

The variable names are not very descriptive. They have the following +meanings:

+
a = argc
+A = argv
+
+b = array of unsigned long variables
+    b[0] = bit-width of the CRC (argv[2])
+    b[1] = CRC polynomial (argv[3])
+    b[2] = nonzero if CRC is reflected (argv[4])
+    b[3] = initial value of CRC (argv[5])
+    b[4] = value final CRC is XORed with (argv[6])
+    b[5] = CRC value
+    b[6] = byte from file
+    b[7] = counter
+
+B = FILE * through which the file argv[1] is opened
+
+C = typedef for unsigned long
+

The first for loop simply reads the command-line +arguments in the b[] array. The third parameter to +strtoul(3) causes all arguments to be in base-16 (hex) +except the first one, which will be in base-10 (decimal).

+

The rest of the program “simply” calculates the CRC in +b[5] and then prints it to stdout. The bit +reflection loops may appear a bit tricky at first, but if you have a +good look at them they should become obvious also.

+

Acknowledgments:

+

Ross N. Williams, whose CRC guide was very useful to me for writing +this. You can find it in crc.txt.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 1998/tomtorfs

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2000/anderson/index.html b/2000/anderson/index.html index e1adbf55e..ad14131af 100644 --- a/2000/anderson/index.html +++ b/2000/anderson/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,251 @@ - - + + + + + + - - -2000 anderson - - + + + +2000/anderson + + + + + -

2000 anderson

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2000/anderson

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2000/anderson/index.html

- +
+ first entry + ↑ 2000 ↑ + bellard → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Glyn Anderson
+Location: unknown

+ + +

To build:

+
make
+

To use:

+
echo something | ./anderson
+

Try:

+
./try.sh
+

Judges’ remarks:

+

This small program might be a nice addition to a digital personal +organizer; just in case you are stranded on a desert island and need to +signal your distress to passing ships.

+

The obfuscation in this program is truly masterful. The program is +very cleverly obscured without the use of a single #define! +Reformatting this program by hand :-) is the easiest way to understand +what is going on.

+

Note about +#defines not being used:

+

In 2023 due to annoying warnings triggered at different times, +sometimes interspersed with the output of the program (this happens in +macOS), many entries were changed to use fgets(3) instead. +However to make the entries more like the original we redefined +gets to use fgets. Unfortunately it’s not +possible to do it through -Dfoo compiler options so there +is a #define in the code now.

+

Author’s remarks:

+

This program is a simple filter that translates ASCII text into +semaphore code. It reads from standard input and converts all +alphanumeric characters to their corresponding semaphore codes. +Consecutive whitespace is translated as a single ‘break’ code. Newlines +also cause the next code to be output on a new line. All other +characters are ignored. The codes themselves are written to standard +output as a depiction of a person holding two flags, using only ASCII +characters (semaphore smileys, if you will). For example, given the +input “Hello, world!”, the output will be:

+
          <>       <>       <>    <>                  <>     <>
+  _()       ()/      ()/      ()/     _\)       ()       (/_     _\)
+[] /^      |^^      /^^      /^^    [] ^^      |^^|      ^^ [] [] ^^
+  <>[      [][     <>][     <>][       ][      [][]      ][       ][
+
+
+          <>    []
+  _()_      ()/     |()       ()
+[] ^^ []   /^^       ^^|     |^^|
+   ][     <>][       ][]     [][]
+
+

The program is obfuscated without the use of the preprocessor or any +special compilation parameters. In fact, the program doesn’t even bother +using any keywords, save the single char at the beginning. +This program was crafted using only operator precedence rules, +short-circuit evaluation and recursion. Each function contains a single, +non-empty statement. (I did have to add a couple of empty statements to +format the code properly.) There is a single string constant which +encodes the flag positions and other data needed for drawing the +semaphore codes.

+

The preprocessor will provide no help in de-obfuscating this code, +and a C beautifier won’t get you very far either. You just have to +crunch through it.

+

An ANSI C compiler will generate several warnings when it compiles +this program, as none of the functions declare their return type, nor do +they return anything. This was necessary to keep the program free of +keywords. It’s valid in K&R C, and compiles in ANSI C. There are +also warnings about conversion from int to +char and the resulting loss of data. Again, if it’s OK with +K&R, it’s OK with me.

+

This program is a great teaching tool for learning the semaphore +code; and if you don’t have any flags handy you can just use two copies +of the source file.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2000/anderson

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2000/bellard/index.html b/2000/bellard/index.html index d862fcf29..98e175315 100644 --- a/2000/bellard/index.html +++ b/2000/bellard/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,203 @@ - - + + + + + + - - -2000 bellard - - + + + +2000/bellard + + + + + -

2000 bellard

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2000/bellard

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2000/bellard/index.html

- +
+ ← anderson + ↑ 2000 ↑ + bmeyer → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Fabrice +Bellard
Location: FR

+ + +

To build:

+
make
+

To use:

+
./bellard
+

Judges’ remarks:

+

This code is a nice compact example of a Modular Fast Fourier +Transform. While its output is very specific, the internal FFT has a +wide variety of uses.

+

Can you modify this code to produce primes such as +23523*2^70000-1, 48594^65536+1 or +6917!-1?

+

NOTE: as bigger primes are found as time goes by this program no +longer prints the biggest prime once noted by the author below.

+

Author’s comments:

+

This program prints the biggest known prime number +(2^6972593-1) in base 10. It requires a few minutes. It +uses a Modular Fast Fourier Transform to compute this number in a +reasonable amount of time (the usual method would take ages !).

+

The program uses >= 64 bit long long type. It should +run on any system with a gcc compiler.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2000/bellard

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2000/bmeyer/index.html b/2000/bmeyer/index.html index ae93a08b3..3b372976e 100644 --- a/2000/bmeyer/index.html +++ b/2000/bmeyer/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,464 @@ - - + + + + + + - - -2000 bmeyer - - + + + +2000/bmeyer + + + + + -

2000 bmeyer

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2000/bmeyer

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2000/bmeyer/index.html

- +
+ ← bellard + ↑ 2000 ↑ + briddlebane → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Bernd Meyer
+Location: AU

+ + +

To build:

+
make
+

To use:

+
./bmeyer
+

Try:

+

In a video window (white text on black background):

+
./try.sh
+

The script will suggest you compare the output of the program with +images, prompting you to press any key to continue so that you may do +so.

+

Judges’ remarks:

+

Don’t even think of supplying different compression factors (the +dashed argument) for compression and decompression! You’ve been +warned.

+

The author recommended on linux/x86, glibc 2.0, libc4/5:

+
bmeyer: bmeyer.c
+    CC -DY="__setfpucw(0x127f)" -O6 $? -o $@ -lm
+

However many compilers use -O3 as the maximum level for +-O optimization.

+

And on linux/x86, glibc 2.1:

+
bmeyer: bmeyer.c
+    gcc -DY='int x=0x127f; __asm__ ("fldcw %0" : : "m" (*&x))'  $? -o $@ -lm
+

Compile with the maximum possible optimization on your system. If +your system has 80-bit internal representation of floating point values +(x86, some Motorola processors) and you want the compressed format to be +portable across platforms, you need to set your FPU to use 64 bit mode. +Read the author’s remarks below for more details.

+

If you cannot work out how to get into 64 bit mode, you can try using +-ffloat-store if you compile with GCC (this may have a +performance penalty). The resulting binary will have a good chance to +produce portable files, but due to the resulting double-rounding (first +internally set to 80 bit, then to 64 bit on writing the value to +memory), there is a small but very real chance any given file produced +might not be portable.

+

The Makefile defaults to -O3 and +no asm() call.

+

Author’s remarks:

+

This program is called GLICBAWLS

+

Function

+

GLICBAWLS stands for “Grey Level Image Compression By +Adaptive Weighted Least Squares”.

+

And that’s exactly what this program does — feed it a .PGM file +(either raw [i.e. P5] or ASCII [i.e. P2]) on stdin, and it will output a +compressed version to stdout. Feed it a compressed file on stdin, and it +will decompress it to stdout — as either raw or ASCII .PGM, depending on +what format it was compressed from. For example:

+
./glicbawls < michael.pgm > michael.glic
+

and then

+
./glicbawls < michael.glic > michael.decoded.pgm
+

As it turns out, glicbawls compresses greyscale images +(or, more precisely, “natural” greyscale images) better than any other +program I am aware of (with the exception of the not-yet-published +program developed for my PhD thesis). Of course, this might take some +time, so a progress indicator is provided. To make things more +interesting, instead of a boring bar or percentage display, an ASCII +rendition of the image being compressed/decompressed is output to +stderr (assuming white text on black background). If you +have trouble recognizing the image, try squinting at it ;-).

+

If you still have trouble, simply use a terminal or xterm with more +than 80 columns, and tell glicbawls about it by giving the +number of columns as an argument. For example

+
./glicbawls 260 <lavabus.pgm >lavabus.glic
+

will allow glicbawls to use up to 260 columns, which +makes things much more recognizable.

+

Still running out of space? Need to compress those images just a tad +more? And maybe you can handle some loss due to the compression? If so, +you can use glicbawls’ “near lossless” compression mode. In +that mode, the decoded pixel values are allowed to differ from the +originals, but there is an upper limit on the magnitude of the +difference. For example, if a maximum error of 2 is allowed, an original +pixel value of 37 could be decoded as 35, 36, 37, 38 or 39. In order to +use this mode, simply give the maximum allowed error as an argument, +with a dash (-) before it. For example:

+
./glicbawls -2 < graph.pgm > graph.2.glic
+

will compress in a way that allows decompression with a maximum error +of two. You can combine both types of arguments, i.e.:

+
./glicbawls -3 180 < graph.pgm >graph.3.glic
+

will compress with a maximum error of 3, using a 180 column terminal +for the progress display, and:

+
./glicbawls -3 180 < graph.3.glic > graph.3maxerr.pgm
+

will decompress the result on such a terminal.

+

But wait, there is more — you can also feed glicbawls +.PPM files (i.e. colour images), raw or ASCII, your choice. +glicbawls will compress and decompress them just fine. +However, it only does “reasonably well” on them; It beats PNG easily, +but there are certainly programs out there that can compress colour +images considerably better. And don’t even think about using it +for so-called “artistic” images (i.e. anything that wasn’t scanned from +a photo or camera)….

+

WARNING

+

glicball is rather CPU and FPU intensive. Don’t run it +on anything slow. Things start to be usable around 300+MHz, with 600+ +being highly desirable.

+

Compile Instructions

+

Unlike most compression program, glicbawls makes heavy +use of floating point maths — and not all FPUs are created equal. Most +importantly, the x86 and 68k FPUs use 80 bit floating point formats +internally, while most other processors use IEEE 64 bit formats by +default. If not taken care of, this means that a glicbawls +file compressed on one CPU cannot generally be decompressed on +another.

+

Fortunately, just about all current FPUs can be put into IEEE 64 bit +mode (or at least something close enough for glicbawls). +Unfortunately, there is no standard way of doing so. For this reason, +the build file contains three compile lines; one for machines +that already use 64 bit mode by default (most RISC processors), one for +linux/x86 machines using libc4, libc5 or glibc2.0, and one for linux/x86 +machines using glibc2.1 (glibc2.1 no longer exports the +__setfpucw() function, necessitating the use of gcc inline +assembly. *Grumble*).

+

So, if you are building on a machine that does not, by default, use +IEEE 64 bit floating point doubles, you’ll have to define Y +to be a command that switches it into that mode. If you fail to do so, +your glicbawls executable will still be able to decompress +its own compressed files, but you may be unable to exchange files with +glicbawls on other machines.

+

Obfuscation

+

Most of the obfuscation of this program was driven by the desperate +struggle to fit all of glicbawls’ features into code that +fits the IOCCC’s size limits. All identifiers’ names are +single-character, which was only possible by ruthless exploitation of +scope. There is a function M() that handles nearly all +input from stdin, handles all output to +stdout, and also recursively calculates one of the +mathematical expressions needed for error modelling. There is a function +that calculates (A^(-1)*b)*x with A being a +matrix and b and x being vectors, and does so +in a very efficient way — but one would be hard pressed to find it. +There is an arithmetic coder that is even less recognizable. A lot of +loop variables don’t get initialized, but instead the code is arranged +in such a way that they just happen to have the right value when control +flow reaches the loops. Lots of functions use the same two global +scratch variables. Variables change their meaning all the time, and the +differences between compressing and decompressing are handled in rather +subtle ways all over the program. The string that holds the ASCII values +for displaying the progress image doubles as a description on how to +find a pixel’s causal neighbours. And then there are a few +#defines that really are just in there to save a few +characters, but as an added “benefit” make the source ever more +unreadable.

+

In short — running it through the preprocessor and the pretty-printer +will give you something that looks slightly less like line noise and +slightly more like a C program, but unless you are a true wizard, it is +unlikely to gain you any insights into what is actually going on….1

+

Bugs, Assumptions and TODO

+

glicbawls assumes that characters are 8 bit wide, and +that the character set used is ASCII. If one of these isn’t true, all +hell will break loose.

+

The .PGM headers are not checked very thoroughly — +glicbawls will happily try to encode lots of files that it +shouldn’t touch. The old adage of “garbage in, garbage out” holds in +that case. Furthermore, even if glicbawls detects an +incorrect input, it fails to provide a meaningful error message, and +instead simply aborts.

+

When decompressing a near-lossless encoded image, the maximum allowed +error is required as a command line parameter. This should really be +saved in the compressed file!

+

glicbawls relies on the decimal representation of all +integers having less than 255 digits. While ANSI C does not guarantee +this, it seems rather unlikely that anyone in the foreseeable future +would use images with 10^255 rows, columns or different +levels of grey. Also, it is assumed that any integer used can be cast to +a double and back without loss of precision. This limits +the number of rows, columns and grey levels to 9 quintillion, which +should also be sufficient for the next few years.

+

There is a theoretical chance that you might get a division by zero +error. You have a MUCH better chance of getting hit by lightning the +very second you realize that you just won a few million in a lottery. +But if it happens to you, don’t say I didn’t warn you! Instead, go out +and buy a lightning rod and a lottery ticket ;-)

+

At one point, a pointer to int is used as the target of +a "%1[#]" conversion in a scanf(3), which +makes gcc rather unhappy, but shouldn’t really cause anyone any trouble. +The same goes for a couple of assignments which are used as truth +values.

+

Algorithm

+

An exhaustive explanation of the algorithm used would go beyond the +scope of an info file, and would also be quite difficult in pure ASCII, +so the following is just a rough outline, and contains some +compression-speak…

+

The image is handled in scanline ordering. +For each pixel, an expected value is calculated by creating a least +squares predictor of order 12 based on all of the previously +encoded/decoded pixels. However, the contribution of each pixel is +weighted according to its Manhattan-distance +from the current pixel, D. That weight used is +pow(0.8,D). 2 3 4

+

In a similar way, the prediction errors for all previous +pixels are combined — a weighted average (with weight +pow(0.7,D)) of the squares of all previous prediction +errors is taken, and the square root of the (appropriately scaled) +result is called sigma.

+

The predicted value and sigma are then used as the parameters of a Student +or t-distribution (which is similar to a normal +distribution, but has more weight in the tails), providing a probability +distribution for the current pixel.

+

Next, the possible interval of values for the current pixel is +halved, and through integration of the probability distribution, a +probability is calculated for the pixel value being in the lower half. +During encoding, the actual value is examined, and the result encoded +using an arithmetic coder. During decoding, the arithmetic decoder +provides the information which half the actual value is in. In both +cases, the interval borders are adjusted accordingly, the arithmetic +coder/decoder updated, and the interval halving repeated until the +precise value has been en/decoded5.

+

Photo Credit:

+

Lavabus was taken by the judge, Landon Curt +Noll. Michael was provided by the author. Lenna is a 1972 Playboy centerfold (doesn’t show +very much).

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+
+
+
    +
  1. Yes, this could be seen as a challenge….↩︎

  2. +
  3. Actually, the weight is pow(0.8,D)/s, where +s is the sigma used for encoding/decoding the particular +previous pixel. Dividing by s is a rather arbitrary action +justified only by the improvement in results. Mathematically, I can only +justify dividing by s^2, or not dividing at all….↩︎

  4. +
  5. Obviously, these least squares predictors are not +calculated from scratch for each pixel. Some clever reuse of earlier +results allows O(1) calculation, rather than the +O(previous_rows*columns) this description would suggest.↩︎

  6. +
  7. As anyone who has ever tried local least squares knows +from bitter experience, there is a lot of numerical instability +associated with them. So glicbawls adds a bias towards an +averaging predictor to the equation system the least squares predictor +is calculated from. The weight that is given to this bias is constantly +adjusted throughout coding/decoding, thus justifying the ‘a’ in +glicbawls.↩︎

  8. +
  9. In the case of near-lossless coding, the interval is not +necessarily halved, but rather split at a convenient point (the +split points are chosen in such a way as to minimise the expected number +of bits needed for coding). Also, the iteration ends as soon as the +interval is small enough to guarantee decoding within the requested +maximum error.↩︎

  10. +
+
+ + +

Inventory for +2000/bmeyer

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2000/briddlebane/index.html b/2000/briddlebane/index.html index 2e6208637..28f91e03b 100644 --- a/2000/briddlebane/index.html +++ b/2000/briddlebane/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,217 @@ - - + + + + + + - - -2000 briddlebane - - + + + +2000/briddlebane + + + + + -

2000 briddlebane

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2000/briddlebane

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2000/briddlebane/index.html

- +
+ ← bmeyer + ↑ 2000 ↑ + dhyang → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Authors:

Name: Lord Zarbon
+Location: unknown +

Name: Moxen N. +Briddlebane
Location: unknown

+ + +

To build:

+
make
+

To use:

+
./briddlebane
+

Try:

+

For some fun every time you log in try running this from your +.bashrc or equivalent file!

+

Judges’ remarks:

+

One could argue that this program was a “diseased dumpster of tripe” +but I suspect that would only result in the judges being heckled as a +“scum-encrusted congress of obscurity” (but only if it was in the early +evening of Dec 22, 2000).

+

Can you find out how it stores the insult strings? Can you then take +an insult and figure out when it will be uttered?

+

Author’s remarks:

+

This program was broadcast from deep within the Zarbonic Cluster and +received at 9:03pm on March 21st, 2000 by Moxen N. Briddlebane. The +original author, as designated by other components of the transmission, +refers to himself simply as “Lord Zarbon”, though offers no information +in relation to the significance of that post. The sole purpose of this +program appears to be to degrade and humiliate the people of this planet +by calling them names. It takes no input, it only produces a single line +of slanderous output.

+

The program appears to be rather confused, internally. It is unclear +whether or not “Lord Zarbon” truly understands the mechanics of +programming. What is particularly disturbing is the curious method of +insult-encoding employed by this program. Furthermore, it is ambiguous +how said data is arranged and why it is necessary to resort to +trigonometric functions to handle it. One of the real mysteries involves +the numbers 114 and 2, which are, according to +Lord Zarbon, very deliberate.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2000/briddlebane

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2000/dhyang/index.html b/2000/dhyang/index.html index f2f7d113d..f70d48422 100644 --- a/2000/dhyang/index.html +++ b/2000/dhyang/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,221 @@ - - + + + + + + - - -2000 dhyang - - + + + +2000/dhyang + + + + + -

2000 dhyang

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2000/dhyang

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2000/dhyang/index.html

- +
+ ← briddlebane + ↑ 2000 ↑ + dlowe → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Don Yang
Location: +US

+ + +

To build:

+
make
+

To use:

+
./dhyang
+

Try:

+
./try.sh
+

Judges’ remarks:

+

A beautiful combination of solving several different problems, but +mostly, the single most impressive layout we’ve ever seen. Many programs +have one interesting layout; this one has four.

+

It may be informative to run the code through a “beautifier”, to +study it, but the layout itself is where most of the interest lies.

+

Author’s remarks:

+

This one is dedicated to Saitou Hajime fans ^_^x

+

Instead of making one self reproducing program, what I made was a +program that generates a set of mutually reproducing programs, all of +them with cool layout!

+

For your enjoyment:

+
    +
  1. Compile dhyang.c.
  2. +
  3. Run ./dhyang and redirect output to another +.c file.
  4. +
  5. Compile that file.
  6. +
  7. Repeat steps 2 and 3 until eventually the output cycles.
  8. +
+

To interpret the output: the dhyang.c is an +image of Saitou Hajime, which eventually generates three sources files +that are images of “aku soku zan” (sin swift slay), Saitou’s motto +;)

+

For best viewing, set tab spaces to 8 characters, and set your +terminal fonts to as close to square as possible. I hate to do this but +you know, size…

+

dhyang.c and all its output compiles with gcc +if your OS uses ASCII character set. No file is included and all +functions assume default int return type (a source of +compile warnings).

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2000/dhyang

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2000/dlowe/index.html b/2000/dlowe/index.html index eba2efd45..4f6fc3912 100644 --- a/2000/dlowe/index.html +++ b/2000/dlowe/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,401 @@ - - + + + + + + - - -2000 dlowe - - + + + +2000/dlowe + + + + + -

2000 dlowe

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2000/dlowe

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2000/dlowe/index.html

- +
+ ← dhyang + ↑ 2000 ↑ + jarijyrki → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: J. David Lowe
+Location: US

+ + +

To build:

+
make
+

The following bit of perl may help determine the values you need:

+
perl -MConfig -e 'print "$Config{archlibexp}/CORE\n"'
+

… just in case the Makefile does not figure this out for you.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: doesn't work with some platforms - please help us fix
+STATUS: known bug - please help us fix
+

For more detailed information see 2000 +dlowe in bugs.md.

+

To use:

+
./dlowe [file ...]
+

Try:

+
echo "13 14 15 16 17 + - * / p" | ./dlowe
+

Judges’ remarks:

+

When this entry was submitted the rules of the IOCCC did not prohibit +the use of embedded language interpreters. The judges considered +disqualifying this entry because of the use of perl, but on the other +hand it qualifies as the Worst Abuse of the Rules. As a previous winner* +David Lowe continues to inflict the highest quality “poot” on the +Judges.

+

The program also contains an undocumented command for Chad and Chongo +(Landon). The judges’ remarks contain a clue to the hidden command +:-).

+ +

Author’s remarks:

+

Usage

+
./dlowe [file ...]
+

Synopsis

+

This is a Reverse +Polish calculator, loosely based on the dc(1) unix +calculator.

+

Syntax

+

This program understands the following dc(1) +commands:

+
p   prints the top stack value without altering the stack.
+P   prints the top stack value, removing it from the stack, and
+    doesn't print a trailing newline.
+f   prints the contents of the stack, one number per line,
+    without modifying it.
+c   clears the stack.
+d   pushes a copy of the top stack value onto the stack.
+r   reverses the order of the top two stack values.
+

And the following arithmetic operators are supported:

+
   +   Pops 2 values and pushes their sum.
+   -   Pops 2 values and pushes the result of subtracting the first
+       from the second.
+   *   Pops 2 values and pushes their product.
+   /   Pops 2 values and pushes the result of dividing the second
+       by the first.
+   ^   Pops 2 values and pushes the result of raising the second
+       to the power of the first.
+   %   Pops 2 values and pushes the remainder of the division that
+       / would do.
+

The precision and range are double, like it or not, except that the +modulus operator actually returns (p1 - (p2 * (p1 / p2))), +but with the innermost division calculated at integer precision. This is +usually what you expect +(e.g. echo "12 8 % p" | ./dlowe == 4)

+

Commands are read from stdin or from a list of files +named on the command line. Unlike dc(1), multiple commands +on the same line must be space separated. Commands are only executed +when a newline or EOF is encountered.

+

Diagnostics:

+
"stack empty"       Not enough on the stack for the requested command
+"divide by zero"    Attempt to divide by zero
+"unimplemented"     Invalid input
+Floating point exception (core dumped) (or something to that effect)
+             Bug in Perl_sv_upgrade causes this in some cases when
+                 the results of an operation are really huge (> 10^308)
+                 This bug appears to be fixed in perl5.6.0
+
+

Examples:

+
$ echo '12 13 14 15 16 + + + + f' | ./dlowe
+70
+$ echo '12 13 14 15 16 17 + - * / p' | ./dlowe
+-0.0515873015873016
+$ echo '+' | ./dlowe
+stack empty
+$ echo '999999999999999 1 + p' | ./dlowe
+1e+15
+$ echo '99999999999999 1 + p' | ./dlowe
+100000000000000
+$ echo '12.5 9 % 10 * 15 + f' | ./dlowe
+50
+$ echo '7 P 6 d P P 8 p' | ./dlowe | tr 876 tpo
+poot
+

Code Concept:

+

We all know that Perl and other VHLLs (very high level languages) are +particularly well-suited for (among other things) string handling, I/O, +and powerful built-in data types, and (relatively) poorly suited for +number crunching and other processor-intensive tasks - areas where C is +strongest. This program takes this knowledge to its extreme conclusion, +using each language for its strengths. Thus, it uses Perl to read and +parse input, for output, and for the easy-to-use list primitive, and +uses C for mathematical operations. Since the rules of this contest +state that the program must be generated by an ANSI C compiler, of +course, the outer Perl layer is wrapped with a thin layer of C.

+

In case that wasn’t clear, in a nutshell: this program is C, calling +embedded Perl (contained in a C string), which in turn calls back to C, +which performs math on Perl data types and calls Perl functions for +error reporting.

+

Requirements:

+

Unfortunately, Perl is an evolving beast - that includes the +embedding API and the XS API. The code was developed under +Perl 5.005_03, successfully tested against +Perl 5.6.0, Perl 5.005_02 and +Perl 5.004_04, and according to the version delta +documentation, should work as-is with Perl 5.002 and later +(which has been around since February 1996). To clarify - it’s not the +Perl code itself that may be non-portable, it’s the C code for embedding +Perl and for calling C from Perl.

+

It is also important that Perl be installed cleanly and correctly. +You may have problems linking if, for example, you have multiple +overlapping versions of Perl installed (which might not be a problem for +scripts, but causes problems with embedding the interpreter). More +commonly, you may get non-fatal warnings from the linker, caused by +slight mis-configurations of Perl on your system.

+

Some compilers also complain that “third argument of +main() is deprecated” or something to that effect. But in +Perl prior to 5.6.0, the header file “proto.h” actually had +a prototype for main(), so applications which embed Perl +must use the three argument form of main().

+

Aside: history…

+

Larry Wall wrote the original Perl in 1986-87, the same two +successive years he won the IOCCC. I hope this program helps you to +realize that this was no fluke - that Perl and Obfuscation are as +inseparable as, say, camels and humps.

+

Obfuscated?

+ +

. The first IOCCC entry with an “easter egg”?…

+

Aside: on unobfuscated Perl

+

My original intent was to write obfuscated C and crystal-clear Perl, +to highlight my bending of the rules. Unfortunately, Perl really doesn’t +lend itself to crystal-clear code…

+

Bending the rules?

+

Well, the rules never state that you can’t embed another programming +language, but on the other hand, knowing Perl probably isn’t high on the +list of qualifications for judges… Oh dear, I guess your C beautifier +won’t help too much, either ;)

+

If you don’t change the rules, it’ll be embedded Ada next year!

+

Auto defend

+

A. Isn’t this the obfuscated C contest? What’s this Perl +$#_&&$_?

+

D. Hey, this program is 100% C, and does not exec an +external Perl interpreter. It simply links against the Perl language +library. The “Perl code” is just a C string constant.

+

A. Perl isn’t portable enough, or ubiquitous enough.

+

D. I’d argue that it is more portable than X. According to the Perl +folks, it runs on the following platforms: Acorn, AIX, Amiga, AS/400, +BeOS, Concurrent, Debian, DEC OSF/1, Digital UNIX, EPOC, FreeBSD, +Guardian, HP-UX, IRIX, LinuxPPC, LynxOS, MacOS, MachTen, Minix, MPE/iX, +MS-DOS, MVS, NetBSD, Netware, NextStep, OpenBSD, OpenLinux, ODT, +OpenVMS, OS/2, OS390, OSR, PowerMAX, Psion, QNX, Redhat, Reliant UNIX, +RISCOS, SCO, SGI, SINIX, Slackware, Solaris, Sun, SuSE, Tandem, Tru64, +UNIX, U/WIN, Unixware, VMS, Win31, Win32, Windows 3.1, and Windows +95/98/NT/2K. Granted, embeddable Perl isn’t quite so portable, but +still…

+

Also, Perl 5 is bundled with the following OS distributions: AIX +4.3.3+, FreeBSD 3.0+, IRIX 6.4+, every Linux distribution, NetBSD, +OpenBSD, and DEC Tru64 5.0+, again according to the Perl people.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2000/dlowe

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2000/jarijyrki/index.html b/2000/jarijyrki/index.html index 54f0f172c..556319364 100644 --- a/2000/jarijyrki/index.html +++ b/2000/jarijyrki/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,471 @@ - - + + + + + + - - -2000 jarijyrki - - + + + +2000/jarijyrki + + + + + -

2000 jarijyrki

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2000/jarijyrki

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2000/jarijyrki/index.html

- +
+ ← dlowe + ↑ 2000 ↑ + natori → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Authors:

Name: Jari Arkko
+Location: SE +

Name: Jyrki +Holopainen
Location: FI

+ + +

To build:

+
make
+

You will need X11 header files and libraries installed to build this +program.

+

To use:

+
./jarijyrki < infile.info > outfile.info
+

You will need a system capable of displaying the results of X Window +programs.

+

Try:

+
./jarijyrki < finance.sheet > myedits.info
+

Then click on cell C3 and type in the following:

+
C5 C6 C7 @
+

Click on cell D4 and type in the following:

+
C5 C6 C7 !
+

Hit ESC.

+

Now try running:

+
./jarijyrki < myedits.info
+

And observe that it matches what you had in the previous run!

+

NOTE: changing the dimension parameters (see the authors’ remarks) +renders existing spreadsheet files unusable.

+

Judges’ remarks:

+

This entry is one of those that makes you wonder why some commercial +software needs tens to hundreds of megabytesgigabytes +to install! This entry does not simply do the basics, it includes +graphing features. All this program needs now is a flight simulator!

+

Author’s remarks:

+

1. OVERVIEW

+

This program is an X-Windows based spreadsheet program. The main +functions it supports are:

+ +

2. USAGE INSTRUCTIONS

+

2.1. Quick Guide

+
Starting
+
./jarijyrki < finance.sheet > myedits.info
+
Stopping
+

Use the ESC key.

+
Movement
+

Click the mouse or use the arrow keys.

+
Editing
+

The currently selected cell is always in the edit state. Press any +key to add a character at the end of the formula; press backspace to +delete the last one.

+
Formulas
+
123.45
+A1 A2 +
+B1 B2 -
+C1 C2 *
+D1 D2 /
+
Pie charts
+
A1 A2 A3 ...
+

Finish the formula with @ to create the pie chart.

+
Histograms
+
A1 A2 A3 ...
+

Finish the formula with ! to create the histogram.

+

2.2. Starting and Loading +Spreadsheets

+

To start the spreadsheet program with an existing spreadsheet, for +instance finance.sheet, use the following +command line:

+
./jarijyrki < finance.sheet
+

The file finance.sheet has been provided +as an example. This file contains a set of financial numbers and two +graphical entities - a pie chart and a histogram - based on them. We +recommend starting the use of the program from this file, as a way to +study and learn the formula language supported by the program.

+

To start the program with an empty sheet, use

+
./jarijyrki < /dev/null
+

Alternatively, /dev/zero could be used but that may not +exist on all systems.

+

2.3. Exiting and Saving +Spreadsheets

+

Normally the user obviously wants to edit the spreadsheet. After the +spreadsheet program finishes, it outputs the edited spreadsheet to the +standard output. Hence, when the spreadsheet window has come up, you’ve +made your changes, and you press the ESC key the program finishes. To +save the results in a file, the following typical command line would be +used:

+
./jarijyrki < finance.sheet > myedits.info
+

2.4. Visual Overview

+

On top of the window the Formula Area shows the formula (or text) of +the currently selected cell. The program starts with A1 as +being the current cell. Below the Formula Area is the Column Letters +Area: A, B, and so on. Correspondingly, on the +left side of the window is the Row Numbers Area: 1, +2, and so on. The rest of the window is dedicated to the +actual spreadsheet cells.

+

The example spreadsheet, finance.sheet, +provided with this program contains two sets of numbers in the visible +area of the spreadsheet. The top set of numbers forms the +product-by-product turnover breakdown of an imaginary company. Below it +is the yearly development of the company profits. On the top right +corner is a pie chart showing the turnover breakdown in graphical form, +and on the bottom right corner is a histogram showing the yearly +development. If you scroll the window you can see additional data from +the spreadsheet.

+

2.5. Movement and Scrolling

+

Use arrow keys to move left, right, up, and down among the cells. You +may also click the mouse on a cell to cause it to be activated as the +current one.

+

Note that it is not possible to move around the formula; the formula +can only be edited from its end by adding or removing characters.

+

Going beyond the borders of the window results in scrolling the +current view. It is not possible to go up from the first row or left +from the first column; but it is possible to wrap back to start from the +last row and last column.

+

2.6. Formulas

+

The spreadsheet formulas operate on a stack. Operands of an operation +(e.g. plus) are first pushed to the stack and then the operation is +performed. If a formula on a cell produces exactly one result +then that is shown in the cell. Otherwise, the formula is interpreted as +a string and shown as it is.

+

An example of a simple formula, simply specifying a number is

+
123.50
+

Another simple formula refers to a cell:

+
A1
+

This particular example formula referred to the first cell of the +first row in the spreadsheet. Arithmetic operations require both +arguments:

+
A1 A2 +
+B1 B2 *
+C1 C2 -
+D1 D2 /
+

More complex formulae can be constructed by combining these simple +ones:

+
A1 A2 + 2 *
+

This example calculates the sum of the cells A1 and +A2, and then multiplies the result by two.

+

The currently selected cell is always in a state where it can be +edited. Press any key to add a character at the end of the formula; +press backspace to delete the last character. Any resulting +recalculations are immediately visible. (Note how much nicer this +feature is as you get used to it, compared to the behaviour of certain +commercial spreadsheet programs.)

+

2.7. Graphical Formulas

+

The program supports two types of graphical representations of the +data in the cells: pie charts and histograms. The pie chart can consist +of any number of slices, and is constructed by putting the pie amounts +in stack and using the @ operator. The program +automatically computes the relative size of the slices.

+
A1 A2 A3 A4 @
+

This example would draw a pie chart of four cells, A1 to +A4. The pie formula is shown above the pie for +reference.

+

The histograms are drawn in a similar manner, by using the +! operator:

+
A1 A2 A3 A3 !
+

2.8. Errors in Formulas

+

The program detects recursive reference attempts, references cells +not containing a numerical value, attempts to define formulas with zero, +two, or more results remaining on the stack, and syntax errors of +formulas. Note that typically as the user types in a formula, it toggles +between valid and invalid forms dynamically as all single character +changes are immediately taken in account. This is not dangerous, just +complete the formula and view the results.

+

Errors are signalled by showing the formula on a cell instead of the +numerical value supposedly returned by it.

+

Division by zero results in an IEEE Inf number.

+

2.9. Compilation +Parameters and Configuration

+

This section explains the meaning and rationale for the compile time +parameters:

+
+
-DC=XK_Up
+-DL=XK_Down
+-DO=XK_Left
+-DV=XK_Right
+-DR=XK_Escape
+-D_=XK_BackSpace
+

These definitions can be used to change the user interface of the +program with respect to special keys. The first four define the movement +operations and the latter two define the program termination and +character deletion keys. Typical modifications to these parameters +include changing character deletion to the key the user is most familiar +with, which could also be XK_Delete. XK_Escape +might be better in some cases as one of the function keys. Likewise for +the arrow keys.

+
-DU=40
+

This parameter defines the maximum dimensions of the stored and +handled spreadsheet (but see section 4.4 for a warning about changing +this without thinking about the consequences!).

+
-DT=98
+

This parameter defines the maximum length of a formula in one cell. +Note the warning in section 4.4.

+
-Dz="(T+1)*U*U"
+

Defines the number of bytes in a spreadsheet file. The number is +automatically adjusted when the spreadsheet size parameters are changed. +Note the warning in section 4.4.

+
-DQ=80
+-DS=20
+

These two parameters define the visual dimensions of a cell. Changing +these may be necessary on your system if the default font sizes differ +from those in the systems we’ve tested the program with. S +also defines the size of the left (x1) and top margins +(x2).

+
-DN=10
+

This is the x-indentation of text inside a cell. Changing this may be +necessary to suit other font sizes and different X environments.

+
-DB=5
+

This is the y-indentation of text inside a cell. Changing this may be +necessary to suit other font sizes and different X environments.

+
-DG=23
+

This parameter is the number of cell rows visible at one time.

+
-Dp=7
+

This parameter is one smaller than the number of cells columns +visible at one time.

+
-DM="((p+1)*Q)+S"
+-DH="(G*S)+S+S"
+

These parameters are the window x and y sizes of the spreadsheet +program window. With these definitions, they are automatically +reflecting the at-one-time-visible cell row/column amounts. Hence, we +recommend changing the G and p parameters if +you want to change the window size in normal cases. Experimentation with +M and H can be used to get other types of +effect such as adding a margin also at the bottom of the window.

+

3. IMPLEMENTATION

+

It’s better to just read the code. But note the use of stack in the +implementation of @ and ! operators, and note +the use of *#i in one of the macros (can you see why?). +Extreme compression has been the key in writing this program. With +compression comes the use of ASCII code numbers instead of character +constants and so on. (This particular obfuscation is not really a +desirable one as it is not completely portable. But it certainly was a +necessary one.)

+

What does i(=) do or does it do anything? Why?

+

4. WARNINGS AND CAVEATS

+

4.1. X11 Paths in Compilation

+

The given Makefile may have to be edited to insert correct library +and include file path names.

+

4.2. Font Sizes

+

We’ve tested the program with a limited amount of X servers. It is +possible that other systems use default font sizes or other parameters +that cause the visual looks to be different or perhaps even unusable; if +this happens, changing compile-time parameters explained in section 2.8 +might help.

+

4.3. Screen Sizes

+

The size of the window as it comes up - a parameter as defined in +compile-time - has been set suitable for a small laptop screen. Larger +screens may benefit from setting these parameters higher. Smaller +screens require changing the parameters so that all of the window +becomes visible.

+

4.4. Spreadsheet Dimension +Changes

+

The size of the read, manipulated, and stored spreadsheets is defined +by a compile time parameter. However, changing this parameter is not +entirely trivial. The following constraints apply:

+ +

4.5. ASCII Reliance

+

The software relies on running on ASCII-based code system. Why? +Because 32 is shorter than ' '.

+

4.6. Command Line Single +Character Defines

+

The use of single character (e.g. G or p) +for a -D option might break certain systems, if those +characters are used in the included X header files in certain kinds of +places. If this happens, you may move the offending character to a new +name by exchanging it on the command line and in the program with +another character. Note that there are no free characters in +the program currently.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2000/jarijyrki

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2000/natori/index.html b/2000/natori/index.html index 90e0ab51b..d9c9a8f0b 100644 --- a/2000/natori/index.html +++ b/2000/natori/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,228 @@ - - + + + + + + - - -2000 natori - - + + + +2000/natori + + + + + -

2000 natori

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2000/natori

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2000/natori/index.html

- +
+ ← jarijyrki + ↑ 2000 ↑ + primenum → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: NATORI Shin
+Location: JP

+ + +

To build:

+
make
+

An alt version exists for those in the southern hemisphere (or those +who want to see what it would be in the southern hemisphere). See alternate version below.

+

To use:

+
./natori
+

Try:

+
./try.sh
+

Also try modifying the code so that it will show another Moon phase +based on input or else just by the code itself. Bonus points if you can +make it show all~

+

Alternate code:

+

The author noted that those in the southern hemisphere might want to +change acos(l/2) into acos(-l/2) which we have +done in the alternate version.

+

Alternate build:

+

To run the alternate code that supports the southern hemisphere:

+
make alt
+

Alternate use:

+
./natori.alt
+

What happens if you run it in the northern hemisphere? Are there any +differences?

+

Can you identify any Moon phases that result in the same output of +both versions? Or are there any?

+

Judges’ remarks:

+

Here is a nice compact program that changes with the phase of the +Moon. Can you figure out how it does it?

+

The ANSI-C committee, among their multiple misdeeds, broke perfectly +fun C programs by making it intractable for them to declare their own +non-traditional prototype for main(). We have had to uglify +this program in order to prevent C compilers from failing to compile it +due to (the now changed) unusual arg types of the main() +function.

+

Author’s remarks:

+

This program outputs a rough image of the moon in its current phase. +The main obfuscation of this entry is its complicated double recursion +(without any loop or conditional statement).

+

People living in the southern hemisphere may want to change +acos(l/2) into acos(-l/2).

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2000/natori

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2000/primenum/index.html b/2000/primenum/index.html index a642ea497..cbeebb189 100644 --- a/2000/primenum/index.html +++ b/2000/primenum/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,256 @@ - - + + + + + + - - -2000 primenum - - + + + +2000/primenum + + + + + -

2000 primenum

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2000/primenum

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2000/primenum/index.html

- +
+ ← natori + ↑ 2000 ↑ + rince → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Raymond +Cheong
Location: US

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2000 primenum in bugs.md.

+

To use:

+
echo n | ./primenum n
+

NOTE: n is an integer.

+

Try:

+
./try.sh
+

Judges’ remarks:

+

Don’t read the author remarks until you’re ready for the spoiler. +Just stop and read the program; it won’t take long. Once you’ve figured +out what it does, run it. It may surprise you.

+

This entry won, not because the obfuscation is impenetrable, but +because it successfully fooled half of the judges, including me.

+

Author’s remarks:

+

Description

+

For 15 years, IOCCC winners have obfuscated programs using esoteric, +difficult-to-interpret, confusing algorithms. This entry finally bucks +that trend and obfuscates in the most “obvious” way possible: by +painstakingly describing the algorithm in clear pseudocode. Even novice +programmers will recognize that the program should find and print prime +numbers up to a given number (as specified on the command line).

+

But novice programmers especially know that mistakes are often made +in translating pseudocode to real code, often resulting in programs with +unexpected and confusing output. Clearly, the program contains several +syntax “mistakes” (e.g. LessThanOrEqualTo) and blatant +“errors” (e.g. Zero). This program clearly requires +“debugging.”

+

As a result of these “bugs”, the program does not calculate primes at +all. Instead, the program reads input from stdin and +returns garbled text on stdout. Fortunately, you can +recover the original message simply by running the program a second +time. Try:

+
./primenum n < textfile | ./primenum n > textfile2
+diff textfile textfile2
+

where n is the same number (modulo 64). So, the prime number +generator is actually a simple text encoder/decoder! Of course, don’t +forget that argument, otherwise the “bugs” in the program will cause it +to crash!

+

Features

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2000/primenum

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2000/rince/README.md b/2000/rince/README.md index 0c0ee3d29..928e3fa05 100644 --- a/2000/rince/README.md +++ b/2000/rince/README.md @@ -86,7 +86,7 @@ Julian day number (given as a fractional component). E.g.: ``` A Julian day is defined to be the number of days since January 1st in the year -`-4712 (4713BC)`, starting at 12 noon GMT.[^1] To aid conversion from our time +`-4712 (4713BC)`, starting at 12 noon GMT.[^1][^2] To aid conversion from our time (GMT) to Julian day there is a supplementary program named: [dmy2jd.c](dmy2jd.c). Run it with `day_float month year` as arguments. See below for an example. @@ -368,7 +368,6 @@ Jean Meeus. Published by Willmann-Bell Inc. [^2]: Astronomical algorithms (1st ed): pages 285-299. Jean Meeus. Published by Willmann-Bell Inc. - ## Copyright and CC BY-SA 4.0 License: This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved. diff --git a/2000/rince/index.html b/2000/rince/index.html index bed3e77cb..a0138ca07 100644 --- a/2000/rince/index.html +++ b/2000/rince/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,479 @@ - - + + + + + + - - -2000 rince - - + + + +2000/rince + + + + + -

2000 rince

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2000/rince

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2000/rince/index.html

- +
+ ← primenum + ↑ 2000 ↑ + robison → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: James +Bonfield
Location: GB

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2000 +rince in bugs.md.

+

To use:

+
./rince number number2
+

If DISPLAY is not set the program will very likely crash +or do something different.

+

This is supposed to happen. As is written in the The Jargon +File:

+
That's not a bug, that's a feature.
+

Try:

+
./try.sh
+

This will run the program several times with different parameters to +show different types of things. See the author’s remarks for more +details.

+

Judges’ remarks:

+

This program may have you going around in circles :-) Try running it +first before reading the author’s remarks below.

+

The judges verified the correctness of output for recent dates +through visual observation.

+

Author’s remarks:

+

How to use it

+

The simplest way to run it is with no arguments. Just type:

+
./rince
+

You will need to have access to X windows, although it doesn’t +require desperately high resolution and there are no known limitations +on colour depth.

+

The display will change slowly over time, although it may take 10 +minutes or more to be visible. For those that cannot wait that long the +program has a built in time machine. Indeed the program knows the speed +of light, which is used to ensure that we see the “live” pictures. +Simply specify the fraction of a day to skip forward for each screen +refresh. I suggest:

+
./rince 0.01
+

To display the output (still guessing?) for a given date, specify two +arguments. The first argument is as before and the second argument is a +Julian day number (given as a fractional component). E.g.:

+
./rince 0 2441193.6
+./rince 0.01 2441193.6
+

A Julian day is defined to be the number of days since January 1st in +the year -4712 (4713BC), starting at 12 noon GMT.12 To aid conversion from +our time (GMT) to Julian day there is a supplementary program named: dmy2jd.c. Run it with +day_float month year as arguments. See below for an +example.

+

What it does

+

This program plots the positions of the four Galilean moons +of Jupiter, as seen +from Earth. It doesn’t +correct for your location on Earth, but I assure you that the parallax is +minimal!

+

The moons are labelled with Roman numerals from I to +IV, I being the closest to the planet and +IV being the furthest. They are:

+
I     Io
+II    Europa
+III   Ganymede
+IV    Callisto
+

Amazingly, all it takes is a pair of binoculars to see the Galilean +moons, so the results can be experimentally checked. (Note that at +present, the best views of Jupiter are over the autumn/winter.)

+

The positions of the moons should be correct for binoculars, but +possibly not if you have a telescope or if you are in the southern +hemisphere. In that case I suggest that to get the correct image you +look at the screen from inside the monitor whilst standing on your head. +In case of confusion, please consult the following chart (*):

+
           N
+           ^
+           |
+     E <---+---> W
+           |
+           v
+           S
+

(*) Not to scale.

+

History

+

Galileo discovered the moons in January 1610. https://web.archive.org/web/20001204212000/http://www-isds.jpl.nasa.gov/cwo/cwo_54ga/html/cd/galileo.htm +states the following:

+
By early 1610, Galileo had further improved his telescope by
+double its power, so it now enlarged objects a thousand
+times. He began looking at the stars and couldn't believe how
+many more he could now see! The number seemed infinite. He was
+beginning to realize the fixed stars weren't a flat distant
+wall on a globe, but a three-dimensional expanse bigger than
+anyone had ever thought!
+
+Then, on January 7, about an hour after sunset, Jupiter rose
+in the east, and Galileo happened to turn his powerful scope
+on its bright disk. It wasn't the first time he had looked at
+Jupiter, but before it was with one of his lesser-powered
+telescopes. This time, though, he noticed three small but
+bright stars near the planet, two to one side and one to the
+other. He wondered at how bright the small stars were and how
+they were arranged in what seemed like a straight line. The
+next night he decided to look at Jupiter again, and to his
+surprise, the stars had moved. But not in such a way as he
+would expect. If Jupiter was moving as it normally should, the
+stars would be east of Jupiter. But all three were to the
+west! The next night was cloudy, but on January 10, Galileo
+was able to observe the planet again. One of the stars was
+gone, and the other two were now on the east side. As the
+stars moved around Jupiter on each succeeding night, and were
+finally joined by a fourth star, it dawned on Galileo that
+what he had found were moons orbiting Jupiter!  Almost at once
+he realized that this was proof that not all objects orbited
+the Earth. Here were four bodies that were orbiting
+Jupiter. One argument against the sun-centered theory was, if
+the Earth orbited the sun, wouldn't the moon get left behind?
+Here he could see for himself that somehow, a planet could
+orbit the sun, and not leave a moon behind!
+

Thus we can plot Galileo’s discoveries using the following three +plots:

+
./rince 0 $(./dmy2jd  7.8 1 1610)
+./rince 0 $(./dmy2jd  8.8 1 1610)
+./rince 0 $(./dmy2jd 10.8 1 1610)
+

However we can go one better by seeing what Galileo would have seen +if it wasn’t cloudy on the 9th. Try:

+
./rince 0 $(./dmy2jd 9.85 1 1610)
+

to see what he was missing out on. I wonder what he’d have made of +that!

+

Galileo discovered the fourth moon a few days later.

+

I’ve tried typing these dates into two Java based Jovian moon +plotters, but both I tried had problems dealing with dates earlier than +1900. More professional software, such as the SkyMap gets these +values correct and this compares well with the above description and +with this IOCCC entry.

+

The year 4713BC was chosen by Joseph +Justus Scaliger in the 16th Century, so clearly this program has a +long history :-) A more complete description of the origins of Julian +Days can be found at https://web.archive.org/web/20001206152200/http://aa.usno.navy.mil/AA/faq/docs/millennium.html.

+

Assumptions

+

This program assumes:

+
    +
  1. The ASCII character set is used.

  2. +
  3. That an enormous comet hasn’t changed the course of Jupiter (or +Earth!).

  4. +
  5. That the date has not been specified as the gap between the Julian and Gregorian +calendar.

  6. +
  7. That the DISPLAY environment variable is set and the +X display can opened. If this is not the case the program will +crash.

  8. +
  9. There is a year 2000BC problem :-)

    +

    More specifically, the plots for dates that far back are too +inaccurate to be of realistic use. Comparisons against SkyMap Pro show that +there is a good similarity (but not much more) up to about +500BC.

  10. +
  11. The code definitely is not portable - it will produce incorrect +results if run from the surface of Mars.

  12. +
+

Obfuscations

+

In addition to the normal obfuscations, I feel that the code contains +some less common tricks. Taken through the standard rounds listed in the +guidelines, the code attempts to pass +these as follows:

+
    +
  1. Look at the original source

    +

    With luck, pure casual inspection should not reveal much except that +the program contains the X Windows logo (a big clue) and contains a +date. This date may give a clue to a few people that this is an +astronomical program.

    +

    Unfortunately I was stretched for space which meant that the large +string constant could not be split up using a “partA” “partB” method +which clearly limits the code layout. However the space saved by using a +single long string constant is more than outweighed by the ability to +further obfuscate.

  2. +
  3. convert ANSI trigraphs to ASCII

    +

    These are not used.

  4. +
  5. C pre-process the source ignoring #include +lines

  6. +
  7. C pre-process the source ignoring #define and +#include lines

    +

    This does a good job of expanding out the code, but it does not +clarify things greatly. The use of #defines has been +restricted primarily to a space-saving mechanism.

    +

    Additionally, the use of typedefs means that the types +used are still obscured unless further replacement edits are +made.

  8. +
  9. Run it through a C beautifier.

    +

    GNU indent(1) seems to do a reasonable job, provided +that the #defines are expanded first. This doesn’t lay the +algorithm particularly bare though as most of the obfuscations are not +simple code layouts.

  10. +
  11. Examine the algorithm.

    +

    The algorithm operates on two levels. The main visible level is by +taking a large string and breaking this down into a series of opcodes +(which I have termed J-code). These are then executed.

    +

    To get to the real method of how it works, you need to decode the +opcode string (which deliberately contains as many ;, +{ and } symbols as possible), which will give +you a Reverse +Polish notation chunk of mathematics.

    +

    Sensible people amongst you will simply refer to the referenced book +:-)

  12. +
  13. Lint it.

    +

    I no longer have lint, although I do have access to Purify. I’m happy +to say that purify does not detect any memory errors or memory +leaks.

    +

    See below for compilation warnings.

  14. +
  15. Compile it.

    +

    I’m sorry to say that there are several warnings issued by the +compiler.

    +

    Firstly, the return type for X() is not specified, so it +defaults to int. Horror of all horrors - this function does +not return an integer type (it doesn’t contain any specific +returns). The return value from X() is not +accessed. The same problem occurs in main() - it does not +return. However main() never exits unless there is a +serious error.

    +

    The 6th argument of XDrawText (which should be +XTextItem) is passed as a compatible structure, but without +casting. This is to reduce code space. A more elegant solution is to +remove the struct {...} Z completely and use +XTextItem f={i-127+r/3*2,r%3+r/3+1,0,E} at the start of +XDrawText block. Although this is accepted by several +compilers, it is not strict ANSI due to the non-constant initialisers. A +pity.

    +

    Note that I make use of usleep(). This is a POSIX call +(it is BSD), but it’s supported on many systems. It may be implemented +using select() or poll() if required, or as a +final solution you can change the usleep(10000) to +sleep(1). To compile on systems which do not have +usleep(), but do have select(), the following +may suffice as an additional compiler argument:

    +
    -Dusleep={time_t v[2]={0,10000};select(0,0,0,0,v);}
    +

    gcc complains about “unreachable code at beginning of +switch statement”, although removing some of this code will prevent the +algorithm from working.

    +

    gcc also suggests that I should be using extra +parenthesis, but I’m taking this as good comment :-)

  16. +
+

In addition to the above, the program has the following useful(?) +obfuscations:

+
    +
  1. The algorithm requires many floating point numbers (about 50). +These are encoded as ASCII.

  2. +
  3. The J-code algorithm has opcodes designed to be space saving. +They are all one byte, but many are also considered as whitespace by the +rules. This algorithm forms part of the same string that the floating +point constants are embedded within. What does the ; +command do in J-code?

  4. +
  5. The J-code language is both stack based and variable based. This +“uncleanliness” is not ideal from a computer science angle, but when has +cleanliness been considered as good in IOCCC? :-)

  6. +
  7. Association of unconnected data by implied function usage. E.g. +use of strlen() and sizeof() simply to return +useful numerical values, using irrelevant arguments.

  8. +
  9. As we already have a dependency on ASCII this has been abused +further. Specifically some integer constants are specified as ASCII and +some ASCII constants are integers. This hides the true meaning for the +values.

  10. +
  11. Red herrings: there are a couple of pieces of code whose +appearance is just there to mislead the infirm of mind. I’ve only tried +to include such examples in places where at first glance the code +appears to be executed.

  12. +
+

References

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+
+
+
    +
  1. Astronomical algorithms (1st ed): page 59 Jean Meeus. +Published by Willmann-Bell Inc.↩︎

  2. +
  3. Astronomical algorithms (1st ed): pages 285-299. Jean +Meeus. Published by Willmann-Bell Inc.↩︎

  4. +
+
+ + +

Inventory for +2000/rince

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2000/robison/index.html b/2000/robison/index.html index f564a37be..187255b65 100644 --- a/2000/robison/index.html +++ b/2000/robison/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,317 @@ - - + + + + + + - - -2000 robison - - + + + +2000/robison + + + + + -

2000 robison

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2000/robison

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2000/robison/index.html

- +
+ ← rince + ↑ 2000 ↑ + schneiderwent → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Arch D. +Robison
Location: US

+ + +

To build:

+
make
+

To use:

+
./robison
+

Judges’ remarks:

+

The program plays almost always reasonably, but does not always +detect illegal moves. Try “9 1” as your first move, then “13 2”. Also it +tends to think for quite a while in the beginning of a game. It is also +smart enough to give up by making a losing move at the end of a game +when its position is hopeless.

+

Unfortunately, due to the contest rules, we’re unable to grant the +author a patent he applied for. :-)

+

Author’s remarks:

+

TITLE OF INVENTION

+

Highly Compressed Program for Playing Hygienic Checkers

+

FIELD OF INVENTION

+

The present invention generally relates to checkers.

+

BACKGROUND OF THE INVENTION

+

Within the field of Checkers, the problem +of finding a hygienic opponent is difficult, as good opponents are +peculiar to the tavern habitat of cracker-barrels, pot-belly stoves, +tobacco, and spittoons.

+

BRIEF SUMMARY OF THE +INVENTION

+

The present invention plays Checkers without +spitting.

+

BRIEF +DESCRIPTION OF SEVERAL VIEWS OF THE INVENTION

+

FIG. 1 shows a numbering of positions.

+

FIG. 2 shows a numbering of directions.

+

FIG. 3 shows a sample board.

+

FIG. 4 shows a method in accordance with the present invention.

+

DETAILED DESCRIPTION OF +THE INVENTION

+

Operator plays Black (x); the program plays White +(o). Said Black goes first. On operator’s turn, said +program requests a position and direction. FIG. 1 shows the numbering of +the squares. FIG. 2 shows the numbering of directions. As per standard +rules, if one or more jumps are possible, one of the jumps must be taken +in preference to other moves. Said operator enters the numbers for the +position and direction. If after jumping over a piece, another jump is +possible, and said piece did not become a king after said jump, standard +rules require that another jump be taken. In said case, said program +requests a direction only in which to continue jumping from the present +position. Kings are denoted by upper case. FIG. 3 shows a sample board. +There is a black king (X) on square 30 and a red king +(O) on square 2. The numbers on the right are the numbers +of the rightmost square in each row.

+

A player loses if they cannot make a legal move. Said loss is +trivially true if player loses all of his/her pieces. The present +invention announces said loser.

+

FIG. 4 shows a C program in accordance with the present invention. +Control flow is straightforward: control enters routine +main(), executes a plurality of statements, and exits via a +return statement. FIG. 4 presumes that type +int is 32 bits and short is +16 bits, which are essential to the preferred embodiment of +the invention. FIG. 4 also presumes that the host computer uses ASCII +encoding for characters. It should be obvious that practitioners skilled +in the art of C programming can remove said limitations.

+

The disclosure here describes a particular embodiment of the present +invention, and other embodiments within the spirit of this disclosure +are possible, as well as consumption of spirits while playing.

+

CLAIMS

+

I claim, by letters patently absurd:

+
    +
  1. A method for playing checkers on a computer-based system, where +said method’s source code fits into 1536 countable bytes of source code, +where a byte is countable if

    +
      +
    • it is not whitespace and
    • +
    • it is not a ‘{’, ‘}’, or ‘;’ +immediately followed by whitespace.
    • +
  2. +
  3. The method of claim 1, further comprising a method of alpha-beta +pruning that exploits the zero-sum nature of the game to unify alpha and +beta cuts.

  4. +
  5. The method of claim 1, further comprising the step of formatting +the source code with short lines, in order to impress the manager with +high productivity, when measured in lines of code.

  6. +
  7. The method of claim 3, further comprising the step for telling +the skeptical manager that this is the well-known technique of “linear +programming”.

  8. +
  9. The method of claim 1, where ~- and -~ +replace the obvious arithmetic operations.

  10. +
  11. The method of claim 1, further comprising a method where

    +
      +
    • strings are encrypted in a manner suitable as C strings, and
    • +
    • 7-bit ASCII characters with uniform distribution are maximally +packed subject to the restriction that each byte is not countable
    • +
  12. +
  13. A method for a computer-based system that uses a single shared +code sequence to either sum a plurality of bits in an N-bit word or +reverses them, in lg(N) time, depending upon a parameter.

  14. +
+

DRAWINGS

+

FIG 1.

+
    +--+--+--+--+--+--+--+--+
+    |32|  |31|  |30|  |29|  |
+    +--+--+--+--+--+--+--+--+
+    |  |28|  |27|  |26|  |25|
+    +--+--+--+--+--+--+--+--+
+    |24|  |23|  |22|  |21|  |
+    +--+--+--+--+--+--+--+--+
+    |  |20|  |19|  |18|  |17|
+    +--+--+--+--+--+--+--+--+
+    |16|  |15|  |14|  |13|  |
+    +--+--+--+--+--+--+--+--+
+    |  |12|  |11|  |10|  | 9|
+    +--+--+--+--+--+--+--+--+
+    | 8|  | 7|  | 6|  | 5|  |
+    +--+--+--+--+--+--+--+--+
+    |  | 4|  | 3|  | 2|  | 1|
+    +--+--+--+--+--+--+--+--+
+

FIG. 2.

+
    1   0
+     \ /
+      .
+     / \
+    3   2
+

FIG. 3.

+
    o o X .  29
+     o . . . 25
+    o . . o  21
+     . o . o 17
+    x . . .  13
+     . . x .  9
+    x x . .   5
+     x x O x  1
+

FIG. 4

+

[See attached listing.]

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2000/robison

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2000/schneiderwent/index.html b/2000/schneiderwent/index.html index 1bc2fade2..68e6edaa5 100644 --- a/2000/schneiderwent/index.html +++ b/2000/schneiderwent/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,243 @@ - - + + + + + + - - -2000 schneiderwent - - + + + +2000/schneiderwent + + + + + -

2000 schneiderwent

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2000/schneiderwent

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2000/schneiderwent/index.html

- +
+ ← robison + ↑ 2000 ↑ + thadgavin → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Craig +Schneiderwent
Location: US

+ + +

To build:

+
make
+

To use:

+
./schneiderwent
+

Try:

+
./schneiderwent schneiderwent.data
+./schneiderwent
+

What’s the difference?

+

Judges’ remarks:

+

Very nice play by the rules and portable text obfuscation. This far +surpasses old tricks like adding or subtracting 1 from every character +in a C string.

+

Translating the messages into your language of preference while +keeping the program portable between different encodings (Chinese, +Japanese, Russian - anyone?) may be an entertaining task.

+

Author’s remarks:

+

This entry displays the current time to the console, for example:

+
+

it’s just after ten ’til 6 in the evening

+
+

FWIW, none of the compilers with which this entry was tested issued +any warnings or errors in compiling the source for this entry. No doubt +lint will complain about the goto statements.

+

The schneiderwent.data file consists +of the values used by multiple table lookups. This is simply good +program design, separating these values from the source code allows +changing the behavior of the application without recompiling.

+

Having learned COBOL at an early age, the pthreads of my +thought processes tend to be translated into code in a verbose manner. +Some of the #defines in this entry’s code are to mitigate +this personal deficiency.

+

Obfuscation

+

Obfuscation in this entry consists of:

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2000/schneiderwent

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2000/thadgavin/index.html b/2000/thadgavin/index.html index aabe37e16..3fd0291d3 100644 --- a/2000/thadgavin/index.html +++ b/2000/thadgavin/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,274 @@ - - + + + + + + - - -2000 thadgavin - - + + + +2000/thadgavin + + + + + -

2000 thadgavin

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2000/thadgavin

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2000/thadgavin/index.html

- +
+ ← schneiderwent + ↑ 2000 ↑ + tomx → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Authors:

Name: Gavin +Buttimore
Location: unknown

Name: Thaddaeus +Frogley
Location: GB

+ + +

To build:

+
make alt
+

NOTE: if you don’t have curses or SDL1 installed both modes will fail +to compile. In that case see the FAQ 3.8 - How do +I compile an IOCCC winner that requires SDL1 or SDL2? and FAQ 3.9 - How do I compile an IOCCC winner that +requires (n)curses? for more information.

+

We recommend that you use the alternate code so you can see what this +entry looked like back in 2000 (with a configurable speed). See the original code section for the original +entry.

+

To use:

+
./thadgavin.alt
+

You can press ‘q’ at any time to exit.

+

Try:

+

If you have SDL1 installed:

+
./thadgavin_sdl
+

Whereas the curses version has an early exit the SDL version does +not. You will have to kill it yourself.

+

You might also wish to reconfigure the speed at which the programs +run. The code calls usleep(3) with two default values, one +for SDL and one for curses. The curses and SDL macros are defined in the +Makefile in a way that makes it easy to redefine the values: +SLEEP is how long the program sleeps (in microseconds) +between output with curses and SDL_SLEEP is how long it +sleeps (also in microseconds) for the SDL version.

+

To change the SDL one to something like 15000 you can +do:

+
make SDL_SLEEP=15000 clobber alt
+

and to change the curses one to 40:

+
make SLEEP=40 clobber alt
+

Then use the program(s) in the same way.

+

The different macros is because the curses version is already much +slower and so it’s better to not tie the two values together. You may of +course redefine both in the same command.

+

Original code:

+

WARNING: if you are sensitive to rapid movement or if you want to see +better what is going on then please use the alternate code as described +above. If you wish to see the original entry see below.

+

NOTE: in curses mode you might want to type reset after +execution of this program if your terminal is messed up after exiting +the program (send intr, typically ctrl-c) as the program does not call +endwin(). Using reset will clear the screen. +The alt code, as noted above, allows one to quit early so this is not a +problem there.

+

Original build:

+
make all
+

Original use:

+
./thadgavin
+

Original try:

+

If you have SDL1 installed:

+
./thadgavin_sdl
+

Judges’ remarks:

+

This entry is a nice play by the rules. It can use curses, if the SDL +graphic library is not present, and is quite good at that, but the +colors used in graphic mode (16 bit depth) are unfortunately less than +dazzling. We could not test this entry in DOS mode.

+

Authors’ remarks:

+

To use under DOS:

+

Compile using DJGPP as follows:

+
gcc thadgavin.c -o thadgavin.exe -Wall -lm -O6 -mpentium -fomit-frame-pointer -ffast-math
+

To +use under Windows, X-Windows or macOS using the Simple DirectMedia +Layer:

+
gcc -O6 -lpthread -g -o thadgavin thadgavin.c -lSDL -DSDL -lm
+

To use curses:

+
gcc -O6 -lpthread -g -o thadgavin thadgavin.c -lncurses -lm
+

Warnings

+

In gcc you might get the following warning:

+
thadgavin.c.c:46: warning: passing arg 2 of `SDL_SetColors' from incompatible pointer type
+

In Microsoft Visual Studio you may get warnings as follows:

+
thadgavin.c(46) : warning C4133: 'function' : incompatible types - from 'unsigned
+char *' to 'struct SDL_Color *'
+thadgavin.c(63) : warning C4026: function declared with formal parameter list
+thadgavin.c(77) : warning C4244: '=' : conversion from 'double ' to 'unsigned
+char ', possible loss of data
+
+

But don’t worry, this is completely normal.

+ +

At least 3 minutes taken 3 times a day when tired.

+

Do not exceed 3 times recommended dose. May cause sickness, +dizziness, nausea.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2000/thadgavin

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2000/tomx/index.html b/2000/tomx/index.html index 0b0456a32..f7d6a480c 100644 --- a/2000/tomx/index.html +++ b/2000/tomx/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,281 @@ - - + + + + + + - - -2000 tomx - - + + + +2000/tomx + + + + + -

2000 tomx

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2000/tomx

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2000/tomx/index.html

- +
+ ← thadgavin + ↑ 2000 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Thomas P John
+Location: NL

+ + +

To build:

+
make
+

There is an alternate version that compiles mkentry.c. See alternate +code.

+

To use:

+
./tomx
+

Try:

+
./try.sh
+

Alternate code:

+

This alternate code is based on the author’s remarks with a slight +fix so that it will do what it once did, compile and run mkentry.c. You can use it in a similar way as tomx.c, both executing the source file and using it as +a Makefile and running the code ends up running +mkentry.

+

Alternate build:

+
make alt
+

Alternate try:

+
./try.alt.sh
+

Judges’ remarks:

+

Polyglots have come and gone, but this was the first one we’d seen +where one language used another to perform its tasks. An +interesting approach. Admittedly, it’s not all that obfuscated - but +there’s more to it than you might think, since you have to make sure +that your changes don’t change the shell code or the Makefile.

+

Author’s remarks:

+

Summary

+

This program works as a C source file, a Makefile and also as a shell +(/bin/sh) script. But unlike some other multi-language +programs, this one is NOT meant to print Hello, world in +all 3 cases (At least in the true sense ;-)). The C, Makefile and shell +code build upon each other to create a C program (?) which when executed +as a shell script will compile itself through the C compiler using a +Makefile! - Pretty useful, Eh?

+

Probably, this is the first entry ever to fully satisfy Rule #1 +(“Your entry must be a complete program”) in the strictest sense;-)

+

Top 5 +reasons (IMHO) why this code is an entry for IOCCC

+
    +
  1. A glance at the source itself will tell you that most of the +Obfuscation is NOT in the C code per se, but in the comments to the C +code. (But sadly, I could not find an “International Obfuscated C +COMMENT contest”. So I HAD to send this entry here to the IOCCC +itself).

  2. +
  3. Of the 3 languages in the source, the least obfuscated is C (But +again, there was NO obfuscated make/shscript contest) (Does this hint +for a rule in IOCCC-2001 that the major obfuscation should be in C and +not elsewhere???. Mmmmm…).

  4. +
  5. Extending Argument #2… Obfuscation done in the C code (comments?) +creates obfuscated code for the other 2 languages. This opens new +possibilities to be explored in depth in future +IOCCCs.

  6. +
  7. LOOKS like a Makefile, WORKS like a shell script and COMPILES +like a C program.

  8. +
  9. Does something useful (See Notes #1 and #2 below).

  10. +
+

Notes

+
    +
  1. The program could have been something other than the simple “Hello, +world” program that it is. It is possible to do +#include "prog2.c" in the place of the main(), +leaving the complexities of the C file elsewhere and making this source +still acceptable to make and sh. The following +modification to the last few lines will compile the IOCCC’s famous mkentry.c.
  2. +
+
.PHONY: /* true clean */
+#undef   true
+#include "mkentry.c"
+

Ain’t that useful?

+
    +
  1. By extending this program’s idea, It is possible to do some very +interesting things like generating C code on execution by adding +additional code in make/sh (open up a loop????). This opens the +possibilities of generating & compiling some (obfuscated?) C code. +(Maybe should try this if this program fails at IOCCC 2000)

  2. +
  3. Changing the %:%.c dependency to a +$(PROG):$(PROG).c form can compile this program with some +other makes (I got it to work in Windows using nmake and +Gnuwin32’s sh ;-) )

  4. +
  5. Interesting things to do: try ./tomx.c clean. This +will do the same as make clean :-)). Also: +./tomx.c all

  6. +
  7. Be careful about the tabs in the source code. Removing them or +converting tabs to spaces can be disastrous.

  8. +
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2000/tomx

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2001/anonymous/index.html b/2001/anonymous/index.html index 4eb665a70..c3a07c658 100644 --- a/2001/anonymous/index.html +++ b/2001/anonymous/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,376 @@ - - + + + + + + - - -2001 anonymous - - + + + +2001/anonymous + + + + + -

2001 anonymous

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2001/anonymous

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2001/anonymous/index.html

- +
+ first entry + ↑ 2001 ↑ + bellard → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Anonymous +2001
Location: GB

+ + +

To build:

+
make
+

The programs that this program is supposed to act on, anonymous.ten.c and anonymous.bed.c, compiled with +make, MUST be compiled as 32-bit ELF binaries. In the case +that this fails these programs will be compiled as 64-bit binaries as +alternate code, anonymous.ten.alt and +anonymous.bed.alt, ELF or otherwise. However trying to use +the entry on these files will fail. See Alternate code below for information on how +to compile these programs as 64-bit binaries (or whatever your system +will compile them as).

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2001 anonymous in bugs.md.

+

To use:

+
./anonymous x86_program
+

Try:

+
./try.sh
+
+./anonymous anonymous.bed # if able to compile as a 32-bit (-m32) ELF binary
+

NOTE: if the 32-bit version cannot be compiled the script will at +least compile anonymous.ten as a 64-bit +program (or whatever your system is set to) and run it directly.

+

What happens if the x86 program has already been modified by this +program? The judges’ remarks below might give you a hint!

+

What happens if you try it on another file like anonymous.c? Can you recompile it okay? What if +you run it on anonymous itself? Can you run the program +successfully after it without recompiling?

+

Alternate code:

+

In the case you you wish to manually compile the extra programs as +64-bit code you may do so. Using the entry on these binaries will very +likely crash the program or do something terribly wrong like +slaughtering all the elves of Imladris! :-) so +please don’t do that :-(

+

Alternate build:

+
make alt
+

Alternate use:

+
./anonymous.ten.alt
+
+./anonymous.bed.alt
+

A 2023 note about +the warning from the author:

+

The author suggested that this might somewhat destroy the +binaries this touches but after the fix of 2023 this was not observed +(yet?). It does indeed modify the files (though not all files are +modified: can you figure out why that is?) but using them after did not +result in any problems. It could be that it’s no longer known exactly +what is supposed to happen and possibly that the modification might not +be entirely correct for that reason though it does appear to be +correct.

+

It appears that the corruption happens only if the modification fails +in the middle of doing so so that might be why it hasn’t been +observed.

+

Judges’ remarks:

+

Is emulation the sincerest form of flattery? This small program does +quite a lot of bit twiddling.

+

Author’s remarks:

+

This program is an optimizing dynamic binary translator, allowing you +to run x86 programs on any machine (x86 or otherwise).

+

I have included a simple 10 +Green Bottles program (try +make anonymous.ten), meant to be compiled as a 32-bit ELF +binary.

+

The program anonymous.ten, and its source (dull) are +included as data files.

+

Warning

+

Note that the translator screws around with the binary you run on it +and might corrupt the binary to some extent and in so doing +might leave any program you run on it unusable.

+

The build script should give an example command to compile the +program.

+

Features

+

Basic Block +Cache: +Rather than translating each instruction individually the dynamic binary +translator generates a translation for an entire basic block of subject +code. Having translated a block once, the target code generated will be +stored for the duration that the program is running, so as a program +runs its performance will improve, as it hits cached blocks. This can be +clearly observed in the example program, anonymous.ten which must be compiled as a +32-bit ELF binary.

+

Target Library Linking:

+

The program runs dynamically +linked ELF +binaries, and when the subject program attempts to make a call to a +standard library, +the translator attempts to make an appropriate call to the native system +libraries on the target machine. This involves mangling between +different calling conventions, etc.

+

Automatic Endian +Detection/Reversal:

+

There are various problems raised when attempting to run little endian x86 code on a big endian +chip, such as a PPC. +These problems are dealt with in a manner that is entirely transparent +to the user.

+

Configuration:

+

Warnings:

+

By default the build script should compile the program with a set of +switches such that while compiling the program it generates one error +(which I feel is useful advice). The program should generate no further +compiler errors while it is running (yes, the program can generate +compiler errors while it is running). If you do not wish to see this +error, or if the program generates any further error when compiled using +your C compiler please remove the -Dwarning='-Dprocessor' +line and the $$warning from the compiler invocation.

+

Optimization

+

The build script contains a -O1 switch for the compiler. +Increasing the optimization level will make the program run +slower, while compiling the program without any optimization +will allow it to run faster.

+

Obfuscation

+

The most obvious part of the obfuscation is probably the mess of +#defines at the top. This may seem a somewhat tired old +obfuscation - however since many of these macros are (sometimes only) +used by the program once it has dynamically recompiled itself, they are +only referenced within the source code from within strings - and +therefore the macros cannot be expanded. Furthermore, some of these +strings of code are not given as strings, but instead are wrapped up in +macros that use the # preprocessor operator to turn them +into strings. In the hope of throwing off a few C beautifiers the macro +to generate the strings is not contained within the source code but +instead is passed in on the command line.

+

Buried under all this, and the fact that the entire program is just a +call to exit(3), there are some nice subtle little +obfuscations. For example, you may notice that there are a couple of +macros that use the ## preprocessor operator to build pairs +of functions. One of these macros is used to build pairs of functions of +which only one has local variables which shadow global variables: so one +modifies the global state, and the other doesn’t.

+

There is also quite a nice trick where I wave a magic wand, and a +chunk of code which should only be run when the program is run for the +first time (setting the PC / IP to +point at main() etc.) gets turned into a +frogstring. The C compiler sees a string by itself in +the code, thinks “yup, that’s a valid C expression”, and quietly moves +on to the next line of code.

+

Limitations

+

Due to space limitations only a handful of instructions are +supported; these instructions which are supported are supported in +somewhat non-conventional ways: chunks of the architecture (e.g. flags) +are just ignored, the ELF loader does +not really load the ELF +binary, the target library +linking can only pass up to 3 parameters to the target library +function, etc.

+

In short, please consider this a full disclaimer for any bug that may +turn up - yes the program is unsafe, but it’s pretty cool anyway.

+

Despite all this, the translator is not exclusively limited to +running the anonymous.ten program. Other +trivial x86 programs may run on the translator +- and I have successfully run a wide range of “Hello World” programs, +including one of last year’s IOCCC winners, tomx.

+

Complete Program

+

The fact that the program makes calls to system(3) and +execv(3) may imply that it is not a complete program in its +own right, as it relies on other programs. The call to +system(3) is a call to ask gcc to recompile the translator +with a new set of switches, and the call to execv(3) asks +for the newly compiled program to be executed. I would point out that +almost every other entry to this competition also require a C compiler +(well, the published winners at any rate, and I recognize that a few +don’t). There is little real difference between this program and one +like last year’s entry dhyang; both +are just C programs that generate C code as their output.

+

Enjoy and thanks!

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2001/anonymous

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2001/bellard/index.html b/2001/bellard/index.html index 96a679309..0391deec6 100644 --- a/2001/bellard/index.html +++ b/2001/bellard/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,309 @@ - - + + + + + + - - -2001 bellard - - + + + +2001/bellard + + + + + -

2001 bellard

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2001/bellard

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2001/bellard/index.html

- +
+ ← anonymous + ↑ 2001 ↑ + cheong → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Fabrice +Bellard
Location: FR

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+STATUS: doesn't work with some platforms - please help us fix
+

For more detailed information see 2001 bellard in bugs.md.

+

To use:

+
./bellard file
+

Try:

+
./bellard bellard.otccex.c
+

Judges’ remarks:

+

<JUDGES_COMMENTS> :-)

+

Author’s remarks:

+

OTCC is an Obfuscated Tiny C Compiler for i386-linux. It +generates FAST! i386 32 bit code (no bytecode) and it is powerful enough +to compile itself. OTCC supports a strict subset of C. This +subset is compilable by a standard ANSI C compiler. OTCC +compiles, assembles, links and runs C code without the need of any other +program.

+

You can use it by typing:

+
./bellard bellard.c [args]...
+

or by giving the C source to its standard input.

+

args are given to the main() function of +bellard.c (argv[0] is bellard.c).

+

Examples:

+ +
./bellard bellard.otccex.c 10
+ +
./bellard bellard.c bellard.otccex.c 10
+ +
./bellard bellard.c bellard.c bellard.otccex.c 10
+

An alternate syntax is to use it as a script interpreter: you can put +#!/usr/local/bin/otcc at the beginning of your C source if +you installed otcc at this place.

+

Supported +C language subset (read joint example bellard.otccex.c to have an introduction to +OTCC dialect)

+

Expressions:

+ +

Obfuscation:

+

No special effort was needed because obfuscation is almost +unavoidable for such a program :-) #defines must be used to +compress the code, and integrated i386 code generator leads to non +obvious code.

+

Portability:

+

OTCC only works on i386 linux because it generates i386 +code. OTCC also relies on little endianness, unaligned +memory accesses and ASCII representation of characters. It also supposes +that no valid pointers are less than 512. If all those constraints are +met, then OTCC could be theoretically used to “cross +compile”, although no such support is currently integrated.

+

It was successfully compiled with gcc version 2.95.2. You get some +warnings because old K&R prototypes are used, some casts are +implicit and some functions are used before being defined. +OTCC uses the dynamic linker to resolve symbols with +dlsym(3), so -ldl must be used when you +compile and link it.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2001/bellard

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2001/cheong/index.html b/2001/cheong/index.html index 9df7cf93a..4b7e29b7e 100644 --- a/2001/cheong/index.html +++ b/2001/cheong/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,253 @@ - - + + + + + + - - -2001 cheong - - + + + +2001/cheong + + + + + -

2001 cheong

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2001/cheong

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2001/cheong/index.html

- +
+ ← bellard + ↑ 2001 ↑ + coupard → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Raymond +Cheong
Location: US

+ + +

To build:

+
make
+

To use:

+
./cheong digits
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Be sure to give an even number of digits in the argument. Add a +leading 0 if needed.

+

The source code is nice, compact, and self documenting as all good +programs should be! :-)

+

Author’s remarks:

+

Operation

+

Compile normally and run with one argument, an integer with 2n +digits. Program will return the integer part of its square root +(n-digits). For example,

+
$ cc -o cheong cheong.c
+$ ./cheong 1234567890
+35136
+$ ./cheong 0200000000000000000000000000
+14142135623730
+

Deviation from these instructions will cause undefined results. +:-)

+

Portability

+

This program runs normally on any ANSI C compiler and is ASCII +dependent.

+

Strict compiling gives just one unavoidable warning:

+
gcc -ansi -Wall cheong.c
+cheong.c:3: warning: third argument of `main' should probably be `char **'
+

Obfuscation

+

The main obfuscation is the algorithm used to calculate square roots, +sometimes known as the longhand method. The basic algorithm is itself +obfuscated in that it only uses subtraction to calculate square roots. +For a detailed explanation, check Google or see Jack Crenshaw’s article +at https://web.archive.org/web/20011215124349/http://www.embedded.com/98/9802fe2.htm.

+

This program uses an even more obscured version which includes the +following:

+ +

Minor obfuscations:

+ +

Challenges for the masses:

+ +

Appreciation

+

Thanks goes out to Bobby Rohde for numerous suggestions on how to +shorten the program.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2001/cheong

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2001/coupard/index.html b/2001/coupard/index.html index 11db4b08e..e0e223abd 100644 --- a/2001/coupard/index.html +++ b/2001/coupard/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,296 @@ - - + + + + + + - - -2001 coupard - - + + + +2001/coupard + + + + + -

2001 coupard

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2001/coupard

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2001/coupard/index.html

- +
+ ← cheong + ↑ 2001 ↑ + ctk → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Pierre-Philippe +Coupard
Location: unknown

+ + +

To build:

+
make
+

To use:

+
./coupard
+

Try:

+

If you have access to /dev/audio or +/dev/sound/dsp:

+
./coupard > /dev/audio
+./coupard > /dev/sound/dsp
+

If you do not, first install sox. If you use macOS you +might install it from MacPorts or +Homebrew. Then you can try:

+
./coupard | sox -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio
+

Judges’ remarks:

+

You may need to run this a few times to understand exactly what is +being said. You might even need to look somewhere on your desktop, your +arm or the wall for confirmation.

+

Author’s remarks:

+

Past years’ IOCCC entries do many marvellous things in small +packages, such as console utilities, games, math, languages or even X +applications. But they all have one thing in common (despite being hard +to read obviously): when they interact with the user, they only +display things, i.e. they display either text or drawings.

+

So, for a change, this program titillates the sense of hearing +instead of sight: this program is a self-contained speech synthesizer +that tells the current time through the computer’s sound card - in just +under 2 Kb of source code !

+

In the 2001 IOCCC rules and guidelines documents, there is no +mention of what is or isn’t acceptable regarding audio I/O, but it is +mentioned that hardware-specific and/or non-portable programs are not +welcome. So, in order to do audio and satisfy those requirements, the +format required by /dev/audio has been chosen: +/dev/audio is a rather ancient fixed-format audio interface +that is supported by the majority of Unices that can do sound, as a +lowest-denominator sound I/O interface.

+

Program usage

+

To listen to what the program says directly, invoke

+
./coupard > /dev/audio
+

The program then speaks out something like

+
+

The time is HH hours MM minutes SS seconds

+
+

in military time (24 hours). Of course, you need to have permissions +to write to /dev/audio, have your sound card enabled, the +volume up, the speakers connected … :-)

+

If you want to convert the audio output of the program into another +audio format, you can pipe it to SoX for example +(sox is the Swiss army knife of Unix audio tools). The +command:

+
./coupard | sox -c1 -r8000 -tub - -c2 -r44100 -twav test.wav
+

converts the output of the program into a 44.1KHz stereo .WAV file +and saves it into test.wav.

+

The output format of the program is 8KHz, unsigned 8-bit samples.

+

NOTE: the program’s return code is meaningless.

+

Audio quality

+

The quality of the sound produced by the program is cross between a +yogurt-pot-and-string +telephone and a bad gramophone, i.e. the +S/N ratio is very low and the signal’s top frequency is very low as +well. This is because the audio is stored internally at a sampling rate +of 4KHz (the Nyquist +frequency is only 2KHz) with only 4-bit samples (adding 24db of +quantization noise to an already poor signal).

+

In short, you might have to listen twice to understand what the +program is saying. 2048 bytes including the sound generation program +doesn’t leave much room for audio quality ;-)

+

Speech generation

+

Only 9 phonemes are used to generate the speech. Beside the limited +number of words the program has to generate (66 words), the low sound +quality is actually exploited to take liberties with certain consonants +(for example, s and f sound very much the same +at 4KHz, so they can be merged into one phoneme). Because the psychoacoustic +context around those phonemes is just sufficient, the words can be +interpreted correctly most of the time despite the fact that they are +pronounced quite wrongly.

+

Internally, a table is used to generate most of the words, and +composite words such as “thirty-five” are made up by the C code +externally.

+

Data compression

+

Even at 4KHz / 4 bits, the weight of all the phoneme samples and the +word-to-phonemes table put together is over 1600 bytes, which is well +over 2048 bytes when encoded in a C string made of printable characters. +Therefore, a compression method was needed that’s both efficient and +with a decompressor that is implementable in the shortest amount of code +possible. GSM compression is very good, but needs large psychoacoustic +tables to regenerate the original signal. Raw FFT spectral compression +is efficient too, but the decompression code can’t be made small +enough.

+

The best compression compromise was found using a simple Huffman +compressor, and encoding the compressed data by blocks of 13 bits in +pairs of printable ASCII characters: the raw data is compressed to 8465 +bits, and the resulting C string is therefore about 1300 characters, +which leaves just enough room for the decompressor with a hard-coded +Huffman tree, and the code that plays the phonemes in the right +order.

+

Note on compiler warnings +and lint

+

The program should build with gcc -Wall -Werror -ansi. +If the -pedantic flag is used, gcc will complain about the +length of the data string and the sign of its type, and also the fact +that main() returns with no value. The confusion with the +sign of the char type doesn’t matter with the data string because it’s +composed only of printable characters under 127.

+

When linting the program with lclint, it complains about +a huge list of things that, if corrected to make lint happy, would +probably double the size of the source code.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2001/coupard

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2001/ctk/index.html b/2001/ctk/index.html index 3d547eed4..b851bb718 100644 --- a/2001/ctk/index.html +++ b/2001/ctk/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,220 @@ - - + + + + + + - - -2001 ctk - - + + + +2001/ctk + + + + + -

2001 ctk

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2001/ctk

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2001/ctk/index.html

- +
+ ← coupard + ↑ 2001 ↑ + dgbeards → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Chris King
+Location: unknown

+ + +

To build:

+
make
+

There is an alternate version with vi(m) key movements. See alternate code below.

+

To use:

+
./ctk
+

Alternate code:

+

This alternate version adds to the movement keys l for +right, h for left and k for straight.

+

Alternate build:

+
make alt
+

Alternate use:

+
./ctk.alt
+

Judges’ remarks:

+

No matter how careful you are, this guy eventually crashes. Most +people can make at least one successful road trip without crashing.

+

This is, of course, another of the retro games.

+

Author’s remarks:

+

This is a game based on an Apple II Print Shop +Companion Easter +egg named ‘DRIVER’, in which the goal is to drive as fast as you can +down a long twisty highway without running off the road. Use +,./, [ ], or bnm to go left, +straight, and right respectively. Use 1234 to switch gears. +q quits. The faster you go and the thinner the road is, the +more points you get. Most of the obfuscation is in the nonsensical if +statements among other things. It works best on the Linux console: you +get engine sound (!) and the * Lock keyboard lights tell you what gear +you’re in (none lit=4th). The q argument (no leading +-) will silence the sound. It won’t work on a terminal +smaller than 80x24, but it works fine with more (try it in an XTerm with +the “Unreadable” font and the window maximized vertically!).

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2001/ctk

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2001/dgbeards/index.html b/2001/dgbeards/index.html index ba30eb54e..269450d4c 100644 --- a/2001/dgbeards/index.html +++ b/2001/dgbeards/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,391 @@ - - + + + + + + - - -2001 dgbeards - - + + + +2001/dgbeards + + + + + -

2001 dgbeards

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2001/dgbeards

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2001/dgbeards/index.html

- +
+ ← ctk + ↑ 2001 ↑ + herrmann1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Doug +Beardsley
Location: US

+ + +

To build:

+
make
+

There is an alternate version based on the author’s remarks. See alternate code below for more details.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2001 dgbeards in bugs.md.

+

To use:

+
./dgbeards
+

Alternate code:

+

The author provided a way to speed it up a bit and also how to make +it so it doesn’t crash on losing. The idea that it crashes on losing was +too good to lose but this alternate version has the former change. If +you wish to remove this you can look at the author’s remarks and make +the change.

+

Alternate build:

+
make alt
+

Alternate use:

+
./dgbeards.alt
+

Try:

+

See if you can figure out how to make the computer always lose (‘win’ +:-) ). It’s a very simple thing to do. Read the author’s remarks for +clues.

+

This game crashes if it loses.

+

This is supposed to happen. As is written in the The Jargon +File:

+
That's not a bug, that's a feature.
+

Judges’ remarks:

+

This is probably the worst AI we’ve ever seen. So, then, why did the +entry win? Because it’s trying to lose.

+

This is also one of the first chess games we’ve seen.

+

Of particular interest is the author’s decision that the program +should crash if it loses. I’ve played chess with a lot of people like +that, and I appreciate the realism.

+

BTW: if your goal is to lose and you do does that mean you win? :-) +What does winning mean in a game you’re supposed to lose at?

+

Author’s remarks:

+

FAQ

+

Q: What does this program do?

+

A: It lets the user play two player or single player games of suicide chess. +Suicide Chess (also known as Losing Chess) is a variant of normal chess. +It is played on the same board and uses the same pieces. Here is a list +of the differences:

+
    +
  1. The object of the game is to get to a position where you have no +legal moves. This is usually accomplished by losing all of your pieces. +Sometimes, the game can end when you still have some pawns on the board, +but they are blocked and cannot move. The general rule is if a player +has no legal moves, the game is over. The winner is the player with +fewer pieces on the board. This is almost always the same player that +had no moves, but not always.

  2. +
  3. In suicide chess, piece captures are compulsory. If a player can +capture an opponent’s piece, he is required to do so. If he can capture +more than one of the opponent’s pieces or can capture one piece with +more than one of his own pieces, he can choose which capture to +play.

  4. +
  5. The king is not significant. There is no concept of check and the +king can be captured.

  6. +
  7. Because of rule 3, pawns are allowed to promote to a +king.

  8. +
  9. Castling is not allowed.

  10. +
+

Q: How do you use this +program?

+

A: The program is fairly straightforward. When you start the program, +it displays the opening position for a game of suicide chess and waits +for user input. Commands are as follows:

+ +

Moves are represented by the long algebraic notation for the move. +For those not familiar with long algebraic notation, a move consists of +a square to move from followed by a square to move to. Squares are +denoted by a letter and a number. The letter specifies the column or +file of the square and the number specifies the row rank. Files are +named from left to right by the letters A - H. +Rows are numbered from bottom to top with the numbers 1 - +8. A sample move from the opening position is +E2E3. This means to move a piece from square +E2 to E3. From the opening position, this +corresponds to moving the king pawn forward one square. This is +generally to be considered one of the best opening moves in suicide +chess. All moves, captures and otherwise, are represented with this +notation. A special case is pawn promotion moves. They use the same +notation followed by an = and a letter representing the +piece to promote to. The letters are R, N , +B, Q, K representing rook, +knight, bishop, queen, and king respectively. The letters must be upper +case.

+

You can also specify a command line argument of a single digit to +change the search depth of the program. If no argument is specified, it +defaults to a depth of 3.

+

Q: Are there any +limitations in your program?

+

A: Yes. The first of the limitations is that you can only play legal +moves according to the rules of suicide chess. En passant captures are +not recognized. They are rarely encountered in suicide chess and when +they do happen, they usually do not change the outcome of the game. As +mentioned above, castling is not allowed either.

+

It also does not detect the end of the game. It can see sure wins or +losses several moves ahead, but does not announce the end of a game or +the winner. Given the existing code it is easy to do this, but it was +deemed unnecessary fluff.

+

Q: What is the +playing strength of this program?

+

A: Playing strength is a relative term. Relative to other computer +programs that play suicide chess, it is about the bottom. There is one +freeware program in existence called kenny that this +program can beat, but that is about it.

+

Suicide chess is a very tactical game. Most humans who do not have +any experience in suicide chess will lose to this program. The Free Internet Chess Server is a free +online chess server that supports suicide chess. This server keeps track +of ratings. The human ratings for suicide chess range from 1000 to about +2400. This program would probably be rated somewhere around 1700-1900. +It is better than most players, but will get destroyed by experienced +human opponents.

+

This program searches to a fixed depth of 3 ply. Because +it does not search very deep, it performs very poorly in quiet strategic +positions. In such positions, it will often just shuffle pieces around +aimlessly until a tactical exchange presents itself.

+

A small amount of randomness has been added to make the program a +more interesting opponent. To avoid a call to srand(3), +rand(3) and the extra code for the required include files, +the time(3) function is used as the source of random data. +It is a slow function, and since it is executed inside the search loop, +there is a significant performance decrease. To make it faster, replace +the time(3) call with rand(3) and add the line +srand(time(0)); to the beginning of main(). I +used the more inefficient time(3) function to illustrate a +different (and somewhat obfuscated?) way of generating random +numbers.

+

Q: Why is this program +obfuscated?

+

A: Here are several reasons:

+

First, without preprocessing, the code is not easy to read. The +preprocessor is used to compress the code and obfuscate it. The main +obstacle to entering this program is the source code size limit. This is +the reason that the preprocessor was used so liberally. It is one of the +best ways to compress C source code.

+

Second, when possible, variables in the program were made global. +Their names are not descriptive and they are used for a variety of +purposes throughout the program. Because of this, it is difficult to +determine exactly what the code does even after preprocessing and +beautifying the code.

+

Third, all function names are a single character and are obviously +not descriptive of they’re actual purpose. Again this serves the dual +purpose of compression and obfuscation.

+

Fourth, most string variables have been encoded. This encoding serves +to obfuscate the program as well as reduce the number of countable +characters and get the program under the size limit of this year’s +IOCCC. There are some places where other simple encoding methods are +used to hide the real purpose of strings. These layers of obscurity +cannot be penetrated by just preprocessing and beautifying the +program.

+

Fifth, various small obfuscations have been used in places all over +the program. Short circuit evaluation is used as a substitute for +if() statements in some places. The ternary operator is +used. In the author’s opinion, use of the ternary operator is almost +always a strong argument for employee turnover.

+

Last, if you have succeeded in wading through the previous layers of +obfuscation, you are confronted by the fact that the game that it +implements is an obscure game. Casual inspection of the program might +lead one to believe that it is an implementation of classic chess, but +this is not so.

+

Q: What about the compiler +warnings?

+

A: When compiled with gcc -Wall, the compiler generated +the following warnings:

+
suggest parentheses around + or - in operand of &
+array subscript has type 'char'
+return type defaults to 'int'
+control reaches end of non-void function
+value computed is not used
+

The value computed is not used warning happens because I +use the && operator and take advantage of short +circuit evaluation instead of using an if() statement.

+

The suggest parentheses... warnings are given because of +expressions that depend on operator precedence details in the C +language. Eliminating these warnings would reduce obfuscation.

+

The other warnings are there because it would require more code to +eliminate them and that can’t be done given the size limit.

+

Q: Why does this +program crash when it loses?

+

A: What better way to admit defeat? The author thought this was +appropriate sportsmanship for a program of this genre and can think of +no worse job than trying to find an elusive bug in an intentionally +obfuscated program.

+

[Judge’s note: This was followed by a description of the bug, and the +comment:]

+

Note, if this program wins, the author thinks it would be good to +leave this information out of the remarks and encourage others to try +and figure it out for themselves.

+

[Should you be too lazy (or time-efficient or affected by ‘real life’ +:-) ) to figure it out yourself, here’s the author’s fix.]

+

This bug can be fixed in a number of ways, but there is a way that +adds only one byte to the source code. In the statement +s=(e=-V(n-1,o))>s?Y=G,e:s; change the > +to a >= and the bug will be gone.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2001/dgbeards

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2001/herrmann1/index.html b/2001/herrmann1/index.html index 822c3f28d..4971f48dd 100644 --- a/2001/herrmann1/index.html +++ b/2001/herrmann1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,460 @@ - - + + + + + + - - -2001 herrmann1 - - + + + +2001/herrmann1 + + + + + -

2001 herrmann1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2001/herrmann1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2001/herrmann1/index.html

- +
+ ← dgbeards + ↑ 2001 ↑ + herrmann2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Immanuel +Herrmann
Location: DE

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: missing files - please provide them
+STATUS: known bug - please help us fix
+

For more detailed information see 2001 herrmann1 in bugs.md.

+

To use:

+
./herrmann1.sh 'prg=file'
+

NOTE: this entry seems to rely on older versions of gcc for the +compilation stage and as such if you wish to see that part like it was +designed you will need an older compiler perhaps gcc 2.95.

+

Try:

+
./herrmann1.sh 'prg=herrmann1.times2'
+

-or-

+
./herrmann1.sh 'prg=herrmann1.gcd'
+

Judges’ remarks:

+

There are some clear hints in the source code as to the purpose of +this program. Perhaps the only way to figure out what is going on is to +look at the differences between the runs of the C preprocessor! Computer +Science students should recognize what is going on.

+

Author’s remarks:

+

Many cool things have been done with the preprocessor, +e.g. calculation of prime numbers or the Tower of Hanoi. However, up to +now, no one proved that the preprocessor is Turing complete, and I +wondered why. Well, the answer is simply that the preprocessor is +not Turing complete, at least not if the program is +preprocessed only once. This is true even if the program is allowed to +include itself. (The reason being that for a given program, the +preprocessor has only a finite number of states, plus a stack consisting +of the places which the file has been included from. This is only a +push-down automaton.)

+

Well, this entry is a Turing machine implemented in the +preprocessor; so of course, it has to be preprocessed several times. +Here are the main features:

+ +

How to use it

+

For the impatient

+

The info files herrmann1.turing and herrmann1.gcd are sample programs for the +Turing machine. For example, type

+
./herrmann1.sh 'prg=herrmann1.times2'
+

and watch the animated Turing machine multiply 8 by two (in unary +representation). Here’s a screen shot during compilation:

+
/*
+*
+* State: st2.
+*
+* _ _ _ _ _ * _ _ _ _ _ _ _ _ _ _ _ _ _
+* ... O O I I I I I O I I I I I O O ...
+* ~ ~ ~ ~ ~ * ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+*
+*
+*/
+

(As on real videos, you’ll see a bit of “white noise” at the +beginning and at the end.;-) After compilation has terminated, type +./herrmann1 to see the final result. The output will be

+

Final tape:

+
          *
+..OOIIIIIIIIIIIIIIIIOOOO..
+          *
+

(Note that the last frame of the animation is not the final +result.)

+

In the previous example, the Turing machine started on the default +tape of the program times2.turing. To provide your own +tape, type (for example)

+
./herrmann1 prg=times2.turing tape="O O O I I I O O O"
+

(The Os and Is are letters, not digits.) +You might prefer to provide only a finite portion of the tape, like I +did above. In this case, the remainder of the tape is filled with +Os. ;-)

+

If you just type:

+
./herrmann1
+

and run the program, you’ll get a usage message (and the return code +will be 2).

+

Note: To get a really nice animation, you’ll need a terminal which is +able to scroll fast enough. xterm is not very good. The KDE +terminal konsole or the text console under linux are much +better. Simply try some out.

+

Writing your own programs

+

Now, let’s assume you want to write a program which adds 1 to a +number in unary representation. (That is, a row of I’s is expected, and +one more I is appended to the row.) Let’s call it +plus1.turing. Here’s what it could look like:

+
/* Search beginning of number. */
+#define start_O O, right, start
+/* Number found. Move one step to the left. */
+#define start_I I, left, st2
+/* Write a I and stop */
+#define st2_O   I, left, stop
+

Some explanations: - The tape alphabet is always O and I. - The +states can be anything starting with “st”. “start” and “stop” are the +start and stop states, respectively. - To define a state, use two lines: +one for each letter on the tape. You may omit one of the lines if the +Turing machine will never enter the state reading that letter. (In the +example, the line defining st2_I has been left out.) - The +order of the lines is irrelevant. - You may use C-style comments. (Would +you have guessed it?)

+

Now, the program can be used with

+
./herrmann1.sh 'prg=plus1.turing' 'tape="I I I"'
+

But what happens if no tape is provided? Up to now, the Turing +machine would start on an empty tape (that is, a tape filled with +Os). For many programs, this doesn’t make much sense (as is +the case for plus1.turing). So you might want to provide a +default tape by adding a line like

+
#define tape O O O O O I I I I
+

to your program.

+

Debugging

+

When writing long programs, the most common errors are to forget to +define a state or to misspell one. Let’s assume you forgot the line

+
#define start_I I, left, st2
+

Remove it and type

+
./herrmann1 'prg=plus1.turing'
+

The output will be

+

Undefined state start.

+

Tape:

+
    *
+..OOOOOOOOIIIIOO..
+    *
+

and the return code will be 1. As you can see, the Turing machine +moved over the Os, but when it arrived at the +I (still in state start), the error occurred.

+

Note that other kinds of errors can cause compilation to fail. If +this happens, the build script will write the error message of gcc into +a file called error and then exit.

+

What the build script does

+

In principle, the build script simply runs the preprocessor over and +over again, until nothing changes anymore; then, the program is +compiled. After each preprocessing step, the script outputs the +beginning of the program; this is where the animation takes place +(except in the first and last few steps).

+

However, there’s a technical problem to overcome: Some compilers +(including gcc) insert a lot of white space during the preprocessing. +This is bad for two reasons. First, the animated picture won’t look +right. And second, after some time, the file will grow too big for your +hard disk. (The amount of white space grows exponentially.) So after +each preprocessing, the first thing the build script does is remove all +the unnecessary white space using sed.

+

(gcc would even insert #line directives if I didn’t +suppress them with the -P option.)

+

Some more details

+ +

Some technical details / +obfuscations

+ +

Compatibility

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2001/herrmann1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2001/herrmann2/index.html b/2001/herrmann2/index.html index 99abd7a99..c751cd1b7 100644 --- a/2001/herrmann2/index.html +++ b/2001/herrmann2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,355 @@ - - + + + + + + - - -2001 herrmann2 - - + + + +2001/herrmann2 + + + + + -

2001 herrmann2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2001/herrmann2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2001/herrmann2/index.html

- +
+ ← herrmann1 + ↑ 2001 ↑ + jason → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Immanuel +Herrmann
Location: DE

+ + +

To build:

+
make
+

To use:

+
./herrmann2
+

Try:

+
./try.sh
+

If you use vi(m) you can see a pattern in herrmann2.cup and +[herrmann2.ioccc][(herrmann2.ioccc]) by say:

+
/[pon]\
+

and

+
/l
+

For additional fun in herrmann2.cup +try:

+
/[po]
+/q
+

and in herrmann2.ioccc try:

+
/n
+

Judges’ remarks:

+

Be careful when staring at the source code - your eyes might cross, +but if you concentrate on your focus you will find illumination!

+

Author’s remarks:

+

You probably know those “magic eye” 3D pictures - pictures looking +like random noise, but when you look “through” the paper, you either get +a three dimensional picture or a headache. With this program, you can +create your own 3D pictures in ASCII art. And yes, the program itself is +such a 3D picture.

+

How to use it

+
    +
  1. Create a file which describes the desired 3D picture. The file +must be a block of lowercase letters the size of the desired picture. +The letters specify the depth of the corresponding pixel: a +means close to the paper, z means far away. The info files +are examples. Be aware that the size of the picture is restricted to +about 9k.

  2. +
  3. Pipe your picture into the program. The output will be your 3D +picture, constructed of random characters (with ASCII code between 32 +and 126). For example, type

  4. +
+
./herrmann2 < herrmann2.ioccc
+
    +
  1. If you want to control the characters used in the output (for +example if your picture is to consist only of digits), pass them as the +first argument. In this case, each time the program needs a new random +character, it will take the next one from the argument. When it arrives +at the end of the argument, it will start over at the beginning. +Example:
  2. +
+
./herrmann2 "234 84 045 5 6765 7487 65190 84 656 254 12 43931 818 0 6542 \
+341 45 567 76967 7244 606 976567 895 81898 095 68678 1843 4650547 \
+565980691 389 04974" < herrmann2.ioccc
+

Some hints to get better +results

+ +

Extra-Features

+ +
./herrmann2 \
+'char*d,A[9876];e;b;*ad,a,c;  tw,ndr,T; wri; ;*h; _,ar  ;on;'\
+' ;l ;i(V)man,n    {-!har  ;   =Aadre(0,&e,o||n -- +,o4,=9,l=b=8,'\
+'!( te-*Aim)|(0~l),srand  (l),,!A,d=,b))&&+((A + te-A(&(*)=+ +95>'\
+'e?(*& c_*r=5,r+e-r +_:2-19<-+?|(d==d),!n ?*d| *( (char**)+V+), ('\
+'  +0,*d-7 ) -r+8)c:7:+++7+! r: and%9- 85! ()-(r+o):(+w,_+ A*(=er'\
+'i+(o)+b)),!write,(=_((-b+*h)(1,A+b,!!((((-+, a >T^l,( o-95=+))w?'\
+'++  &&r:b<<2+a +w) ((!main(n*n,V) , +-) ),l)),w= +T-->o +o+;{ &!'\
+'a;}return _+= ' < herrmann2.ioccc
+ +

Why this program should win

+ +
./herrmann2 < herrmann2.cup
+

and let the result inspire you. ;-)

+

Requirements to the +compiler / Compatibility

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2001/herrmann2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2001/jason/index.html b/2001/jason/index.html index 9915154d4..6f9a3d02e 100644 --- a/2001/jason/index.html +++ b/2001/jason/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,267 @@ - - + + + + + + - - -2001 jason - - + + + +2001/jason + + + + + -

2001 jason

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2001/jason

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2001/jason/index.html

- +
+ ← herrmann2 + ↑ 2001 ↑ + kev → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jason +Orendorff
Location: US

+ + +

To build:

+
make
+

To use:

+
./jason
+

Judges’ remarks:

+

You are in a maze of twisty little passages, all alike.

+

The really amazing part of this is that it’s a text adventure, and +there’s not a single word in the source that isn’t a C keyword or +function name, being used as such.

+

The interface isn’t very tolerant of errors, but you can’t really +expect that from something this small.

+

Of particular interest: Go ahead, run it through the preprocessor. +You still won’t see the words that are used in the game.

+

If you run it through a beautifier you might cause a crash as most of +the whitespace is significant. Also, if you attempt to change one +character identifiers to longer names expect problems. Even swapping the +Y and Z can cause problems. Go ahead, try it! +:-)

+

Author’s remarks:

+

TED Shroyer came up with the idea that made it possible to hide all +the text. Thanks, TED. You won. :)

+
cc -o jason jason.c
+./jason
+you are in a maze of twisty little passages
+caves lead:  left forward back
+you see
+   a lamp
+> _
+

This program is a rather nostalgic little labyrinth game. Start out +by typing “get lamp”, then use the direction words +“left”, “right”, “forward”, and +“back” to explore the caves. Note that these words can +refer to different passages depending on which way you’re facing. +“back” always takes you back the way you came. Type +“quit” to quit.

+

The maze is randomly generated each time you play. The algorithm +ensures that you start at least 6 hops away from the exit. All passages +are two-way.

+

(There is a trick, well-known among Adventure +game fans, to keeping one’s bearings in games like this. Unless you know +the trick, it can be very difficult to find your way around. Try it out +first; I’ll give away the secret at the bottom of this document.)

+

The goal is to collect 8 treasures (plus the lamp) and escape into +the sunlight - or moonlight, as the case may be. After a few minutes, +the lamp runs out of oil, and things become perilous.

+

If you manage to escape, you score 50 points for your hide, 50 points +per item, and bonus points for speed.

+

Why I think this program is obfuscated:

+ +

When all warnings are enabled, some compilers express the desire to +see a few more parentheses. I respectfully submit that there are plenty +of parentheses in the program (370 in all.) Besides, any more would put +me over the size limit. gcc also generates a warning about +some calculations not being used. Having just spent 19 hours staring at +this program, sweating over every character, I swear gcc is wrong.

+

The program is formatted as a poem, to make it more readable. I find +the plaintive chorus “B? B?” particularly poignant. Also, smiley faces +are formatted flush left. (If you don’t find the game entertaining, see +if you can find

+
    the fish scales              Q)++j<
+    the shooting star         -~- ~ -~i +
+

in the source code.)

+

GAME STRATEGY SPOILER

+

The trick, of course, is to drop items in empty rooms to mark them. +That way you usually know if you’re in a room you’ve seen before. It +greatly aids mapping.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2001/jason

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2001/kev/index.html b/2001/kev/index.html index 44a140c87..7d5b5f07f 100644 --- a/2001/kev/index.html +++ b/2001/kev/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,365 @@ - - + + + + + + - - -2001 kev - - + + + +2001/kev + + + + + -

2001 kev

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2001/kev

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2001/kev/index.html

- +
+ ← jason + ↑ 2001 ↑ + ollinger → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Kevin Pulo
+Location: AU

+ + +

To build:

+
make
+

There is another version which lets you use the arrow keys rather +than the more awkward , and . keys. See alternate code below.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2001 +kev in bugs.md.

+

To use:

+
./kev # in one terminal
+
+./kev hostname # in another terminal
+

NOTE: each player’s paddle is at the bottom and the opponent at the +top.

+

Try:

+
./kev           # in one terminal
+
+./kev localhost     # in another terminal on the same host
+

If you need to change the speed you can reconfigure it like (say for +over a network and not the same host):

+
make clobber SPEED=50 all # original default value which is very fast
+

If you wish to change the port you can do so like:

+
make clobber PORT=3773 all
+

Of course if you want a port < 1024 you’ll need to be root so +don’t do that.

+

And if you know what you’re doing you can redefine the call to the +socket(2) syscall with the l_ macro, changing +the L variable like one would PORT. Of course +you can do more than one at the same time. For instance to change the +speed and port:

+
make clobber SPEED=512 PORT=3773 all
+

If you have xterm try on one system:

+
xterm -geometry 80x40 -fg green -bg black -fn 9x15bold -e ./kev &
+

and then the other, the client system:

+
xterm -geometry 80x40 -fg green -bg black -fn 9x15bold -e ./kev localhost&
+

This might look nicer than just the terminal itself.

+

Alternate code:

+

This version allows you to use arrow keys on the keyboard rather than +the more awkward , and . keys to move your +paddle.

+

Alternate build:

+
make alt
+

You can reconfigure the macros described above in the same way.

+

Alternate use:

+

Use kev.alt as you would kev.

+

What happens if you use both, one in one terminal and the other in +another terminal?

+

Alternate try:

+

If you have xterm try on one system:

+
xterm -geometry 80x40 -fg green -bg black -fn 9x15bold -e ./kev.alt &
+

and then the other, the client system:

+
xterm -geometry 80x40 -fg green -bg black -fn 9x15bold -e ./kev.alt localhost&
+

Judges’ remarks:

+

Continuing with this year’s “retro game” theme, this is another old +game; arguably, one of the oldest. Requires a functioning network, and +curses.

+

The graphics aren’t the impressive part; the graphics and network +are. How many games come out at $50 and still require you to wait for a +patch to come out before you can play multiplayer? This one works out of +the box.

+

Author’s remarks:

+

NETWORK PONG!

+

REQUIREMENTS

+ +

DESCRIPTION

+

This program is a two-player networked version of the eighties arcade +classic, Pong. It uses +standard TCP sockets to communicate over the net, and +ncurses for display. It supports variable terminal sizes +(though both players must have the same terminal size) and game speeds. +Each player has a paddle to hit the ball, and you get points for getting +the ball past your opponent’s paddle. It’s pretty fun! :)

+

RUNNING

+

Run the server first without any command line arguments, i.e.

+
./kev
+

Then run the client with a single command line argument which is the +name of the machine running the server, e.g.

+
./kev localhost
+

Make sure that the terminals on both ends are the same size. Also, +the TCP port number (by default 5455) specified in the Makefile mustn’t be blocked by a firewall.

+

Here’s a good quick example to see it in action on your own machine, +assuming you have Xwindows:

+
xterm -geometry 80x40 -fg green -bg black -fn 9x15bold -e ./kev &
+xterm -geometry 80x40 -fg green -bg black -fn 9x15bold -e ./kev localhost&
+

PLAYING

+

Your paddle is the one at the bottom of the screen, your opponent is +at the top. To move your paddle left, hold down , +(i.e. < but don’t press shift). To move your paddle +right, hold down .. To quit, either player may press +q.

+

The current score is shown on the left side of the halfway line. Your +score is the lower number, your opponents score is the upper number. +Your score is the number of times your opponent has missed the ball.

+

You can control the speed of the ball by the motion of your paddle +when the ball hits it. If your paddle is still, then the ball just +bounces normally off it. If your paddle is moving in the same direction +as the ball, then the ball’s speed in that direction will increase. If +your paddle is moving in the opposite direction to the ball, then the +ball’s speed in that direction will decrease (or if the ball is going +slowly enough, it’ll turn around).

+

You might want to increase your keyboard repeat rate before playing. +On the Linux console try kbdrate -r 24.0 -d 250 +(kbdrate might be “hidden” from normal users in +/sbin, and you might need to be root anyway), in +Xwindows try xset r rate 250 24 (find out your +current rate first with xset q, so that you can reset it +later).

+

Look below in the Building section for info on how to speed up or +slow down the game (useful if you increase or decrease the terminal +size).

+

BUILDING

+

Just run make to use the Makefile as above. The +SPEED variable in the Makefile controls the speed of the +game (defaults to 50). This speed is the delay between +frames in milliseconds. Thus a value of 0 will make the game go as fast +as your network can handle, and values less than 50 are useful for +larger terminals or more exciting games. The program needs bandwidth +equal to 1/s bytes per second (where s is the speed value). +Any latency on the network will be added to s - so you +should probably subtract any latency from the value of s +you want to have. Given that loopback and fast Ethernet +LANs are both much less than 1ms of latency, you should only need to +worry about this if you plan on playing over a slower link like a cable +modem, DSL, or (God-forbid) dial-up.

+

The TCP port to use for network communications is specified by the +PORT variable in the Makefile. If the default of +5455 is blocked for whatever reason, you can change it to +something else. Of course if you use a port < 1024, you’ll need to be +root.

+

OBFUSCATION

+

The program’s broad structure is fairly straightforward, but +individual tasks are rarely done in a straightforward manner. ;)

+

Identifier names have mostly been chosen to resemble paddles and +balls, and to generally decrease readability.

+

The source has been cleverly formatted to resemble one of the paddles +from the game, rotated 90 degrees. ;) (The “source paddle” has +approximately the same aspect ratio as the game at 80 columns wide, +which is 1:10.)

+

Finally, the number of “non-whitespace characters” (as defined by the +rules) in the file is exactly 2048, which I think is rather unexpectedly +cool. :)

+

BUGS

+

There are 3 warnings when I compile with gcc 2.95.3 +(-Wall -ansi -pedantic) on my Linux system, but all are +completely harmless.

+

I don’t like the curses and/or termcaps/terminfos on IRIX and Solaris +(the only two non-Linux systems I have access to). Despite calling +timeout(0);, notimeout(win, TRUE);, +nodelay(win, TRUE); and/or +keypad(win, FALSE);, it still seems to force a delay into +calls to getch() - I’m guessing at a termcap/terminfo +level. At any rate, I can’t seem to force no delay. This is a shame, +because it basically plays havoc with the input code, particularly the +read-ahead canceller. It still works, but not nearly as well (key +presses are dodgy and holding down keys doesn’t always work), and so I +much prefer and recommend Linux libncurses.

+

Sometimes when q is pressed in one, the other will crash +out with Broken pipe.

+

If the specified port can’t be bound or connected to, the program +segfaults.

+

If your terminal is too wide (we’re talking gigantic here - over 500 +characters wide) then the program can segfault. It’s also possible to +crash the program a player scores over a billion points (1e9). Maybe you +can consider that the goal… ;)

+

If you run the client and server on different architectures, both +architectures need to have the same character systems (i.e. don’t try +mixing ASCII and EBCDIC). It is independent of endianness though.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2001/kev

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2001/ollinger/index.html b/2001/ollinger/index.html index f77474312..e948d774b 100644 --- a/2001/ollinger/index.html +++ b/2001/ollinger/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,260 @@ - - + + + + + + - - -2001 ollinger - - + + + +2001/ollinger + + + + + -

2001 ollinger

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2001/ollinger

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2001/ollinger/index.html

- +
+ ← kev + ↑ 2001 ↑ + rosten → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Nicolas +Ollinger
Location: FR

+ + +

To build:

+
make
+

To use:

+
./ollinger integer
+

Try:

+
./ollinger 1000 | cut -c -200
+

Try the above command in a large window, say 200 chars wide and 100 +high (200x100) with a tiny font.

+

Judges’ remarks:

+

Do get lost in the program’s line of thought! :-)

+

Author’s remarks:

+

What’s this?

+

What do you see? On the left, you will see an enumeration of all +successive primes from 2 to +the parameter you gave to the program. On the right part, you can see +the sieve used to find these primes. The big diagonals from right to +left are used to erase composed numbers. When no diagonal crosses a +number, then the left cell take value 1 and the number is prime.

+

The parallel version of this algorithm works in real time +n. This C sequential version is slower as it works in +O(n*log n). But you have some nice picture instead… the +cost is a constant number of operation for each character printed on the +screen.

+

Why did I write this ?

+

Let’s just quote the FAQ:

+

Q: Are there types of entries that are submitted so frequently that +the judges get tired of them?

+

A: Yes, there are types of entries that show up over and over again. +The guidelines say:

+
We tend to dislike programs that:
+are similar to previous winners
+
+We like variety. However too often we see (please look at the winning
+examples given to be aware of the level of the competition):
+
+(snip)
+
+generating small primes (below is the list of all prime related winners)
+
+    1985/august
+    1988/applin
+    1994/weisberg
+    1995/makarios
+    1996/dalbec
+    2000/bellard
+
+As you can see, just a list of primes (let alone small primes)
+does not cut it anymore.
+
+(snip)
+
+entries that use some complex state machine/table to print something
+
+      1988/isaak
+      1988/phillipps
+
+Unbeaten for 12 years and counting...
+

I think this is enough motivation for trying to submit a program +which uses some complex state machine/table to generate small primes and +print them.

+

The way it works

+

This program simply prints the space-time diagram of some particular +cellular automaton. The automaton is a 9-state automaton by Ivan +Korec in 1998. It is an optimization of an old automaton for +recognizing primes designed by Fischer in 1965.

+

The table of the automaton is encoded into the string e +and consists of 345 transitions of the kind +ff(left,middle,right). This encoding into e is +obfuscated to reduce its size, restrict it to characters 32 to 127 and +guarantee a constant time.

+

The main loop simply iterates this transition function on each +cell.

+

“The rest is silence” (Hamlet, V.2)

+

Enjoy!

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2001/ollinger

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2001/rosten/index.html b/2001/rosten/index.html index ca7fd93b2..d637e288d 100644 --- a/2001/rosten/index.html +++ b/2001/rosten/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,277 @@ - - + + + + + + - - -2001 rosten - - + + + +2001/rosten + + + + + -

2001 rosten

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2001/rosten

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2001/rosten/index.html

- +
+ ← ollinger + ↑ 2001 ↑ + schweikh → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Edward Rosten
+Location: GB

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: missing files - please provide them
+

For more detailed information see 2001 +rosten in bugs.md.

+

To use:

+
./rosten [number]
+

WARNING: this will mess with your mouse and can make it hard to quit +the program. Use at your own risk.

+

NOTE: number is floating point.

+

Try:

+
./rosten 1.03
+./rosten 1.00
+

For some abuse, try:

+
./rosten 0.99
+

Judges’ remarks:

+

Friction can be your friend if it does not rub you (or your mouse +cursor) in the wrong way. :-)

+

Author’s remarks:

+

NAME

+

rosten - make the mouse act as if it has been +greased

+

SYNOPSIS

+
./rosten [greasiness]
+

DESCRIPTION

+

This program is designed primarily to make your X windows interface +more obfuscated. Try doing something mouse driven (such as using a mouse +driven editor on this program) whilst it is running. If you’re not sure +what it does, looking at the code should give a fair idea.

+

It also has a [cat] man page if you want to install it as a +‘utility’.

+

OPTIONS

+

It only takes one optional option: the greasiness factor. This is the +number that the speed is divided by on each iteration. The default is +1.03. A setting of 1 - no friction - is fun as is 0.99.

+

Being an X program, it recognises the DISPLAY +variable.

+

PORTABILITY

+

The program is very portable, even to non X architectures. All that +is required is a large desk and some good grease.

+

COMMENTS

+

It is really rather surprising that code like this should not only be +portable, but compile with almost no warnings on most of the compilers +tested. It’s a kind of shame that none of the compilers do anything like +this:

+
$ make greasymouse
+cc greasymouse.c -o greasymouse -lX11
+greasymouse.c:30: This macro should have more text and spaces in it
+greasymouse.c:32: This is a really stupid way to perform this operation
+greasymouse.c:42: This program would look better with a newline here
+greasymouse.c:48: That's a really silly thing to do
+greasymouse.c:55: So is that
+...
+greasymouse.c:58: This program is rubbish. I'm not going to link it.
+

The code is best viewed with tab stops every 8 +spaces.

+

BUGS

+

The mouse gets stuck completely if you give it an option of less than +1 and leave it for too long. This is quite annoying if it didn’t leave +the terminal it was run from in focus.

+

It gets very jerky if the processor is being used. There are better +time functions than clock() but I haven’t used them.

+

It deflects slightly when it gets very slow.

+

It annoys other people if you run it on their display too often. +Maybe I should make future versions print funny jokes to keep the humor +fresh.

+

It’s pretty ropey over a 56K modem.

+

It’s even ropier over a 56K modem and tunneled through 3 ssh +links.

+

WARNINGS

+

Pages and pages and pages of things, with GCC at any rate.

+

It suggests loads of ()s where they’re not needed.

+

It reckons I have not used some of the values I have computed. I +would never do a thing like that: I just haven’t used them in the way +it’s used to.

+

The MIPS compiler suggests an == instead of an += in expressions such as:

+
&&(a=b)
+

but its suggestions would break my program. It also reckons that +r() has no prototype.

+

Giving the -pedantic option to the MIPS compiler causes +it to generate warnings about its own header files, but not any extra +ones with this program.

+

With all warnings enabled, the DEC compiler, oddly enough finds some +problems with its own include files, but none with my program.

+

ERRORS

+

The DEC compiler of this version: +DEC C V5.6-079 on Digital UNIX V4.0 (Rev. 878) can’t +compile the code. It thinks that preprocessor lines can not have +whitespace preceding the #. Moving the preprocessor +directives to the beginning of the line wrecks the layout but makes it +compile.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2001/rosten

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2001/schweikh/index.html b/2001/schweikh/index.html index f9f060b18..ca9403732 100644 --- a/2001/schweikh/index.html +++ b/2001/schweikh/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,259 @@ - - + + + + + + - - -2001 schweikh - - + + + +2001/schweikh + + + + + -

2001 schweikh

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2001/schweikh

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2001/schweikh/index.html

- +
+ ← rosten + ↑ 2001 ↑ + westley → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jens +Schweikhardt
Location: DE

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2001 schweikh in bugs.md.

+

To use:

+
./schweikh string string2
+

This program will very likely crash or do something else if you do +not give it two args.

+

Note also that the glob pattern must match the whole string. See the +author’s comments for details and a workaround.

+

There’s also no way to escape meta characters.

+

This is supposed to happen. As is written in the The Jargon +File:

+
That's not a bug, that's a feature.
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Do you get the pattern here?

+

Author’s remarks:

+

This one-liner program is a glob pattern matcher. It understands the +glob characters * meaning ‘zero or more characters’ and +? meaning exactly one character, just like your unix +shell.

+

Run it with two args, the string and the glob pattern. The exit +status is 0 (shell true) when the pattern matches, 1 otherwise. The glob +pattern must match the whole string, so you may want to use +* at the beginning and end of the pattern if you are +looking for something in the middle.

+

You can use it for your shell scripting needs similar to a silent +grep (and without stdout redirected to +/dev/null):

+
if prog "${VARIABLE}" '<glob>'; then
+    echo VARIABLE matches
+else
+    echo no match
+fi
+

Bugs

+

There is no way to escape the meta characters. Dammit Jim, I’m a +one-liner, not a regexp lib.

+

All obfuscation is obviously in the recursive m() +function, an 86 character glob pattern evaluator, returning nonzero for +a match:

+ +

The recursion wonderfully and magically takes care of iteration and +backtracking. I could tell you how it works but then I would have to +kill request a NDA from you :-) Run it under a debugger +with several inputs, it will be quite helpful and instructive. Handling +of ? is straightforward; for * start out with +*foo and foo* against foo. How +does it deal with sequences of adjacent *? How could this +be improved? If all else fails, recode the ?: operators +with if/else and try again. For extra credit +implement character classes like [a-z].

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2001/schweikh

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2001/westley/index.html b/2001/westley/index.html index 0b05e7ad8..b498fc4f2 100644 --- a/2001/westley/index.html +++ b/2001/westley/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,352 @@ - - + + + + + + - - -2001 westley - - + + + +2001/westley + + + + + -

2001 westley

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2001/westley

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2001/westley/index.html

- +
+ ← schweikh + ↑ 2001 ↑ + williams → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Brian Westley
+Location: US

+ + +

To build:

+
make
+

There are two additional programs based on the author’s remarks and +the original version, provided as alternate code as it might be less +portable. See sorted code, punch card code and alternate code below.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: uses gets() - change to fgets() if possible
+STATUS: missing files - please provide them
+

For more detailed information see 2001 westley in bugs.md.

+

To use:

+
./westley 2>/dev/null
+# enter some input, terminate with EOF
+
+echo foo | ./westley 2>/dev/null
+
+./westley < westley.c 2>/dev/null
+

Try:

+
./try.sh
+

Sorted code:

+

The author stated that one can sort (ignoring leading blanks +i.e. sort -b) the code by line and it will always sort the +order of the input.

+

This is compiled by default; use westley.sort as you +would westley above.

+

Punch card code:

+

The author also stated that if you just sort the code you’ll get the +with sort) version that just prints out the punch card. The +westley.punch.c code is specifically so +that Westley can punch everyone in the face! :-) This is also compiled +by default.

+

Punch card try:

+
echo 'Brian Westley does it again!' | ./westley.punch 2>/dev/null
+

Alternate code:

+

An alternate version of this entry, westley.alt.c, is provided. This alternate code +might be less portable.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use westley.alt as you would westley +above.

+

Judges’ remarks:

+

Try copying the source to a new file and changing around the order of +the lines. Does it produce the exact same output?

+

By changing the order of the source, figure out in how many different +ways this program can transform input to output.

+

This assortment of obfuscated lines takes position-independent +code to a new level! :-)

+

We find it amazing that with just 28 lines of code (not counting +comments and blank lines) there are 28! or +304,888,344,611,713,860,501,504,000,000 versions of the +program, all valid C!

+

Author’s remarks:

+

Punch cards, +or Hollerith cards, were becoming obsolete just as C was becoming more +popular*; this is rather unfortunate, because C has an advantage over +many other languages when it comes to punch cards - C programs can be +written to be “drop proof”.

+

Consider the following C program:

+
main(){a();b();c();}
+a(){printf("A");}
+b(){printf("B");}
+c(){printf("C");}
+

This program will compile and run no matter what order the lines are +in. If you punch it on cards (one line of code per card, naturally) and +drop them, you don’t need to put them in any particular order**; it will +always produce ABC as output.

+

You can also use global variables:

+
char *greet = "Hello, world!";
+char *greet; main(){puts(greet);}
+

It would be trivial to write an entire C program that is “drop proof” +using the above techniques; surprisingly, it’s possible to write a +program that will always compile but behave differently depending on the +line order:

+
test(a,b){return a;}
+#define test(a,b) test(b,a)
+main(){if (test(0,1)) printf("T"); else printf("F");}
+

This program will print out T if the +#define statement falls between the declaration of +test() and its use in main(), otherwise it +will print out F. Furthermore, you can use the same call to +test() repeatedly in different lines to return different +values:

+
#define test(x,y) test(y,x)
+main(){int i=0;a(&i);b(&i);c(&i);d(&i);printf("%d\n",i);}
+a(i)int*i;{if (test(0,1)) *i += 1;}
+b(i)int*i;{if (test(0,1)) *i += 2;}
+c(i)int*i;{if (test(0,1)) *i += 4;}
+d(i)int*i;{if (test(0,1)) *i += 8;}
+test(x,y){return x;}
+

If you enter the above program on punch cards, throw them up in the +air, gather them up, and run it, you will get a number from 0 to 15 +printed out. Now that’s a random number generator…

+

Of course, there are drawbacks to C programming on punch cards; an +80-character line limit can be restricting, and (to be maximally +portable) you need to use trigraphs for the characters +^[]{}\ (these aren’t found on every keypunch, and have +various encodings).

+

My C program entry does the following:

+
    +
  1. Reads in lines.

  2. +
  3. Rearranges the lines, or not.

    +
      +
    • if it rearranges the lines, they are sorted or scrambled.
    • +
  4. +
  5. Reverses the order of the lines, or not.

  6. +
  7. Prints out the lines as either text or EBCDIC punch +cards.

  8. +
+

The code, as written, scrambles the input and prints it out as normal +text, so you can simulate ‘dropping’ the cards. You can repeatedly +scramble the code to get all 12 variants (but the scrambling isn’t very +random; it’s just a bubble sort with a random number, so some variants +are more common than others). You can also just swap the arguments in +the calls to t() in all combinations to get all the +variations.

+

If you sort the lines, you will get the version that just prints out +the input as punch cards (you will need to display at least 82 columns +of text, or clip the last few chars by piping it through +sed s/...$//). If you use this on the original code, you +will see that it spells out HOLLERITH when punched on cards +(you can see the tall, thin letters spelling out HOLLERITH +if you turn the C code sideways). You will also see why +/KC 0000 K is a Hollerith emoticon. +Unrecognized characters are punched as a lace column. (You can see an +ASCII simulation of the code as punch cards by looking at +card.gif.)

+

For a nice test pattern, try

+
&-0123456789ABCDEFGHIJKLMNOPQR/STUVWXYZ:#@'=".<(+|!$*);,%_>?abcmnoxyz^[]{}\
+

If you want to analyze the program, sorting the lines while ignoring +leading blanks works best (sort -b). This will produce the +version that just reverses the line order, and the routines in the code +are in a sensible order.

+

This program should work on EBCDIC computers. It assumes that the +time_t ptr param to time(3) will work with an +int ptr, and that “passing through” a char[][] +array as a simple char * is OK. Your compiler MUST +understand trigraphs, or it will miss the trigraph backslash before the +double quote in the K string and complain about a malformed +string; for GNU C, use -ansi or -trigraphs. +Entering a line of more than 80 characters, or more than 81 lines, will +jam the card reader.

+

I’ve used the a[b] ==> *(a+b) trick, +because this is actually shorter than the trigraph version of +a??(b??).

+

With 28 lines of code (not counting the blank lines or the comment), +there are technically 28! different programs, or +304,888,344,611,713,860,501,504,000,000 different versions, +all legal C.

+
* except in Florida voting machines
+
+** all cards must be face down, nine-edge first, of course.
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2001/westley

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2001/williams/index.html b/2001/williams/index.html index 7a64bc31b..33af7e70b 100644 --- a/2001/williams/index.html +++ b/2001/williams/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,226 @@ - - + + + + + + - - -2001 williams - - + + + +2001/williams + + + + + -

2001 williams

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2001/williams

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2001/williams/index.html

- +
+ ← westley + ↑ 2001 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: John Williams
+Location: unknown

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: known bug - please help us fix
+

For more detailed information see 2001 williams in bugs.md.

+

To use:

+
./williams
+

Judges’ remarks:

+

A strange game. The +only winning move is not to play. No, really; you can’t actually +win. :)

+

The formatting really wants a wide screen; if you can’t read it that +way, it’s the standard “three triangles around a circular” logo for +nukes.

+

This is a pretty straightforward game.

+

Author’s remarks:

+

What this program does:

+

It plays Missile +Command, complete with MIRVs, smart bombs, extra cities, and +scoring.

+

Command line arguments and input files are ignored.

+

To play, just point and click where you want your ABMs to +explode.

+

The score is 10 points for each missile which is destroyed before it +reaches the ground, -1 point for each ABM used, and 100 bonus points for +each city left at the end of a level.

+

The game ends when you lose all your cities, although you will have +to wait until the level finishes raining down to see your final +score.

+

Obfuscation

+

The main obfuscation technique is the need to compress the code to +fit all the functionality within the size limits. I could not have +included smart bombs without the rule excluding {}; +characters in the counts. All of the #defines are there to +reduce code size.

+

On the other hand, I did waste a few characters in order to include +some rather obfuscated math in the program. It uses fixed-point +arithmetic, resulting in the overuse of bitwise shift operators. Another +example is (x|1), which is used in a couple different ways. +The purpose of A/(x|1) is probably obvious, but what does +(x|1)%2 do?

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2001/williams

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2004/anonymous/index.html b/2004/anonymous/index.html index 58b20a817..17b38c4e3 100644 --- a/2004/anonymous/index.html +++ b/2004/anonymous/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,293 @@ - - + + + + + + - - -2004 anonymous - - + + + +2004/anonymous + + + + + -

2004 anonymous

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2004/anonymous

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2004/anonymous/index.html

- +
+ first entry + ↑ 2004 ↑ + arachnid → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Anonymous +2004
Location: SG

+ + +

To build:

+
make
+

To use:

+
./anonymous 'foo' > bar.pgm
+

Now open the output using your favourite pgm viewer. +If you don’t have a pgm viewer then we suggest the netpbm toolkit to convert the +image to a graphics format that you can view. Most graphical web +browsers can display PNG or JPEG images.

+

Try:

+
./anonymous "ash nazg durhbatuluhk, ash nazg gimbatul, \
+    ash nazg thrakatuluhk, agh burzhumh-ishi krimpatul." >ring.pgm
+
+./anonymous "My Precious. Yes, my Precious." > precious.pgm
+

NOTE: technically the text is supposed to be in all lower case but +the above still works for demonstration purposes.

+

Judges’ remarks:

+

Did you know that in the first edition of The Hobbit Gollum was +willing to give up the ring? It was not the Ruling Ring, the One Ring, +the Ring of Power or anything like that: it was simply a literary device +that could make one invisible. When Bilbo won the famous riddle game +Gollum went to fetch the Ring - not to kill and eat Bilbo but to give it +to him! But Bilbo had already found it just like in the later editions. +Gollum profusely apologised and begged for forgiveness. Bilbo told him +never mind because he would have had it anyway. But he’d let him off on +one condition: that he show him the way out. It was at this point that +Bilbo slipped the ring on and Gollum saw him vanish and understood that +he already found it. But there was no call of thief and no hatred of +Bilbo.

+

If you want to read the first edition they reprinted it some years +back: The Hobbit Facsimile First Edition. The details are +also discussed in History of Middle-earth [HoMe] VI, The +Return of the Shadow, part one of the history of The Lord of the +Rings of a twelve volume set - as well as in The +History of the Hobbit.

+

p.s. Frodo lives!

+

An important aside :-)

+

BTW: if you haven’t read The Lord of +the Rings what are you waiting for? :-) You’ll find out the source +of the text above though you’ll see that there are some circumflexes +missing! That’s okay though due to I/O of the entry and in earlier +drafts sometimes the û with an umlaut had no umlaut but H after the +u it. The real text is:

+
+

Ash nazg durbatulûk, ash nazg gimbatul, ash nazg thrakatulûk, agh +burzum-ishi krimpatul.

+
+

which when translated from Black Speech +means:

+
+

One Ring +to rule them all, One Ring to find +them,
+One Ring to +bring them all and in the darkness bind them.

+
+

Author’s remarks:

+

This program takes a single command line argument, transcribes the +argument text into Tolkien’s Elvish letters, and writes the +transcription to standard output as a portable +graymap (PGM) file.

+

The specific transcription mode is the Black Speech +(Tengwar +mode), as used in the inscription on the One Ring. The +program handles the following digraphs:

+ +

Punctuation marks other than commas and periods are ignored, as are +whitespace characters. In addition, the argument text must be entirely +in lower case.

+

The following command thus writes a rendering of the Ring +inscription to the file ring.pgm:

+
./anonymous "ash nazg durhbatuluhk, ash nazg gimbatul, \
+    ash nazg thrakatuluhk, agh burzhumh-ishi krimpatul." >ring.pgm
+

The source code assumes the ASCII character set; also, due to space +constraints, the program uses rather inefficient algorithms, so it may +waste a lot of time and space even when rendering moderately long +strings.

+

The code contains a vector font which was derived by toying with Harri Perälä’s Tengwar Cursive font. +Currently, only the glyphs used in the Ring +inscription are included in the font.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2004/anonymous

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2004/arachnid/index.html b/2004/arachnid/index.html index 4094d03fb..1de9bc6a3 100644 --- a/2004/arachnid/index.html +++ b/2004/arachnid/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,235 @@ - - + + + + + + - - -2004 arachnid - - + + + +2004/arachnid + + + + + -

2004 arachnid

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2004/arachnid

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2004/arachnid/index.html

- +
+ ← anonymous + ↑ 2004 ↑ + burley → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Nick Johnson
+Location: NZ

+ + +

To build:

+
make
+

There is an alt version for rogue players, vi(m) users and Dvorak +typist (i.e. those who need hljk for moving left, right, +down and up. See alternate code below.

+

To use:

+
./arachnid [mazefile]
+

Try:

+
./arachnid arachnid.info
+

and then try:

+
./arachnid arachnid.c
+

Navigation is through the use of the wasd inverted-T +formation on QWERTY keyboards. Rogue players, vi users, and Dvorak +typists are invited to get lost (or use the alt version)!

+

Alternate code:

+

If you don’t like the wasd movement keys you can try the +vi(m) movement keys instead.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use arachnid.alt as you would arachnid +above.

+

Judges’ remarks:

+

The fun part comes when you realize that the maze scrolls. The +overall visual effect is quite pleasing (at least on some displays), +and, well, it’s a lot of fun.

+

Author’s remarks:

+

This program accepts ASCII formatted mazes as input, and renders them +on screen for the user to explore, complete with Line Of Sight - you +cannot see parts of the maze your avatar (the @) could not +have seen.

+

The maze files will be interpreted with spaces ' ' as +gaps, tilde ~ symbols (if any) as exits (which get +represented as a NetHack style +< once loaded), and any other characters as walls.

+

Feed the program its own source for a default maze. Running it with +no command line parameters will do this. In a nice symmetry, the +character constant ~ that recognises exits to input mazes +itself forms the exit to the default maze. Another maze, arachnid.txt has also been provided. This maze +is 255x255, about the largest maze supported, for the particularly +insane maze explorers out there.

+

Usage

+
./arachnid [mazefile]
+

You can explore the maze using the +w,a,s, and d +keys.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2004/arachnid

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2004/burley/index.html b/2004/burley/index.html index 3e4cd8f02..bced2086d 100644 --- a/2004/burley/index.html +++ b/2004/burley/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,232 @@ - - + + + + + + - - -2004 burley - - + + + +2004/burley + + + + + -

2004 burley

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2004/burley

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2004/burley/index.html

- +
+ ← arachnid + ↑ 2004 ↑ + gavare → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Brent Burley
+Location: US

+ + +

To build:

+
make
+

NOTE: We FORCE the use of -O0 even if someone overrides it because +this entry will not work with it enabled.

+

To use:

+
./burley
+

NOTE: you need to input a number first. See judges’ remarks below for +information on how to play.

+

Judges’ remarks:

+

This is a draw +poker program. You start with $100. Input alternates between your +bet and which cards to keep. Example:

+
5       <== you enter a bet of $5 (defaults to $1)
+J Q J 9 5   <== your hand is Jack of Clubs, Queen of Hearts,
+C H D S C       Jack of Diamonds, 9 of Spades, 5 of Clubs
+123     <== you enter which cards you want to keep
+            (enter 0 to 5 digits between 1 and 5)
+J Q J J Q   <== your new hand is Jack of Clubs, Queen of Hearts,
+C H D S C       Jack of Diamonds, Jack of Spaces, Queen of clubs
+$145 (45)   <== Your new balance is now $145.  You had a Full House
+            so your payoff is 9 times your bet == 45
+

The payout is according to “Vegas rules”:

+
Straight Flush     50 times your bet
+Four of a Kind     25 times your bet
+Full House          9 times your bet
+Flush               6 times your bet
+Straight            4 times your bet
+3 of a Kind         3 times your bet
+2 Pair              2 times your bet
+Jacks or Better     1 times your bet
+

The program allows you to go into debt. However I’m sure you would +never control-C to kill the program just because you got behind, right? +On the other hand the program never willingly exits, so you have to +leave even when you are ahead. :-)

+

Can you figure out a winning betting “strategy”? Then can you modify +the program so this “strategy” no longer works?

+

Notice the clever use of setjmp(3) and +longjmp(3) calls. Can you keep track of what state is being +saved and restored?

+

NOTE: the author talks about how it is a single statement. This might +not be strictly true in 2023 for the fixes for it to work so you can +look at the original file burley.orig.c to +see what is meant.

+

Author’s remarks:

+

This program plays draw poker. What is unusual about it is that it is +written as a single statement – count the semicolons! (OK, there are +really three statements if you count the variable declarations.) To keep +things simple, I have avoided the C preprocessor and tricky statements +such as if, for, do, +while, switch, and goto.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2004/burley

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2004/gavare/index.html b/2004/gavare/index.html index afc3403dc..117165e80 100644 --- a/2004/gavare/index.html +++ b/2004/gavare/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,268 @@ - - + + + + + + - - -2004 gavare - - + + + +2004/gavare + + + + + -

2004 gavare

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2004/gavare

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2004/gavare/index.html

- +
+ ← burley + ↑ 2004 ↑ + gavin → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Anders Gavare
+Location: SE

+ + +

To build:

+
make
+

There are three alternate versions; see alternate code below for more details.

+

To use:

+
./gavare
+

Try:

+
./gavare > ioccc_ray.ppm
+

Alternate code:

+

The alt code, gavare.alt.c, allows you to +change the size of the image as well as the anti-alias setting, when +compiling.

+

The author also provided on their web page for +the entry an unobfuscated version that was used during development, +which we have included in the file gavare.r3.c.

+

Finally, there’s a version, gavare.alt2.c +that sets binary mode on stdout which theoretically should +work in Windows.

+

Alternate build:

+

To build the configurable and unobfuscated versions:

+
make alt
+

To change the default size from 1024x768 try:

+
make clobber XX=640 YY=480 alt
+

You might also wish to change the anti-alias setting:

+
make clobber AA=2 alt
+

This is not possible with the author’s version but it is with the alt +versions (Windows - see below - and otherwise).

+

As the Windows version will not compile on most viewers’ systems we +do not build it with make alt; instead try:

+
make alt2
+

Alternate use:

+

Use gavare.alt, gavare.r3 or +gavare.alt2 as you would gavare above.

+

Judges’ remarks:

+

For users of systems that distinguish between text and binary mode +(you know who you are), add a library call that specifies binary mode +for stdout as the first statement of main(), +or use freopen("ioccc_ray.ppm", "wb", stdout); and do not +use redirection.

+

A freely distributable command-line version of Microsoft Visual C +exhibits an optimizer bug when compiling this entry. Disable +/Og for best results.

+

The judges were able to figure out how to control position (in all 3 +coordinates), size, and color (to some extent) of the balls.

+

Author’s remarks:

+

It is possible to write some kinds of programs in C without using +reserved words. For very short and trivial programs, it usually isn’t +very hard to write a variant using no reserved words, but with this +program I want to show that also non-trivial programs can be written +this way. This IOCCC entry contains no reserved words (I don’t count +main as a reserved word, although the compiler gives it +special meaning) and no preprocessor directives.

+

The program is a small ray-tracer. +The first line of the source code may be modified if you want the +resulting image to be of some other resolution than the predefined. The +A value is an anti-alias factor. Setting it to +1 disables the anti-aliasing feature which makes the output +look bad, but setting it too high makes the trace take a lot more time +to complete.

+

The ppm image can then be viewed using an image viewer of your own +choice. (Running the ray-tracer may take several minutes, even on fast +machines, so be patient.)

+

I am very much aware about the fact that I’m breaking the guidelines. +For example, the word int is a reserved word and therefore +all variable declarations are implicit. There will no doubt be +lots of warnings, no matter which compiler is used. Still, the +source code should be word- length-independent and +endianness-independent.

+

Humor

+

Another reason for writing code without using reserved words is that +many text editors will make all reserved words turn BOLD when printed on +paper. Since I care for the global environment, we shouldn’t waste any +more laser toner, or ink, than necessary. Everyone should write C code +with no reserved words, and our world will be a better place.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2004/gavare

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2004/gavin/index.html b/2004/gavin/index.html index c3269aea7..63a77c7ad 100644 --- a/2004/gavin/index.html +++ b/2004/gavin/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,336 @@ - - + + + + + + - - -2004 gavin - - + + + +2004/gavin + + + + + -

2004 gavin

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2004/gavin

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2004/gavin/index.html

- +
+ ← gavare + ↑ 2004 ↑ + hibachi → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Gavin +Barraclough
Location: unknown

+ + +

To build:

+
make
+

There is an alternate version for those who wish to use QEMU rather +than having to reboot and rely on having a floppy drive (if you even +remember what those are :-) ) etc. See alternate code below.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: compiled executable crashes - please help us fix
+STATUS: doesn't work with some platforms - please help us fix
+STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2004 +gavin in bugs.md.

+

To use:

+
./gavin
+

Try:

+

To enjoy the results (on a Linux/x86 machine) with a floppy drive +(remember those? We do!):

+
su
+

Make a floppy with an ext2 filesystem (mke2fs /dev/fd0 +replacing fd0 with whatever the floppy device is!), mount +it under /mnt/floppy and then:

+
cp kernel fs.tar lilo.conf boot.b /mnt/floppy
+

NOTE: If the version of your lilo is not 21.4, use the appropriate +boot.b file.

+

NOTE: If your floppy drive is not /dev/fd0, edit +lilo.conf appropriately.

+
lilo -C /mnt/floppy/lilo.conf
+

Boot from the floppy on an x86 machine with a PS/2 keyboard and +mouse. Move the window away from the corner.

+
vi gavin.c
+

Scroll up and down the file with up-arrow and down-arrow.

+
sh
+

You can have several shell windows:

+
vi README.md
+./prim
+

Press and hold any key.

+

Alternate code:

+

This version’s main difference is that the macro K is +redefined to 1 so that you can use it with +QEMU.

+

Alternate build:

+
make alt
+

Alternate use:

+

The use is mostly the same as gavin except that one +initially executes gavin.alt (which make alt +will do) and one will have to use QEMU instead. The files +generated are the same names. See to use and try above as well as the judges’ remarks below plus gavin.md.

+

Judges’ remarks:

+

Over the years, we’ve seen a program that immediately dumps core if +executed on the “wrong” architectures (1984/mullender) and a program that +dumps core after a while (2001/bellard). This entry will +happily compile and execute on most any architecture - the trick is that +the result, to be useful, must be produced (and can only be enjoyed) on +a particular architecture. We have not decided yet whether to disallow +this for future contests.

+

If you do not want to mess with a floppy and you use GRUB, see gavin.md.

+

You can put additional text files in fs.tar for browsing +with vi.

+

If you do not want to bother rebooting your computer at all, see http://bellard.org for QEMU +(Fabrice Bellard is an IOCCC +2001 winner), but your experience will be limited; use the alternate code instead. You’ll have to move +the mouse to trigger the initial screen update.

+

The judges were able to write a few more programs to run in this OS. +What are the limitations for such programs?

+

What can you do and what can you not do in such programs?

+

The program called prim, written by the judges, computes +and prints prime numbers.

+

Author’s remarks:

+

This is a 32-bit multitasking operating system for x86 computers, +with GUI and filesystem, support for loading and executing user +applications in ELF binary format, with PS/2 mouse and keyboard drivers, +and VESA graphics. And a command shell. And an application - a simple +text-file viewer.

+

The OS has ended up as a traditional monolith with one entry point +for syscalls, with apps treated as cooperative-multitasking tasks that +can be sent different messages (e.g. ‘initialize’, ‘key hit’, ‘render to +buffer’) through their main entry point, and which will return control +to the OS after having performed the necessary work. Applications are +passed a pointer to their task structure, which is partially defined by +the OS, and partially for the application’s own use.

+

The program compiles into a tool to build a kernel image, so having +built the program, the Makefile will run it, +redirecting the output into a file called kernel. The +Makefile will then proceed to build a root filesystem image. This +involves rebuilding the program with different compiler flags, then +building a tarball containing the resulting programs (the filesystem +format supported by the OS is the tarball format).

+

For further usage information see gavin.md.

+

The filenames vi and sh are significant, +and should not be changed.

+

Known ‘features’

+

Known issues are really too plentiful to list.

+

If the mouse pointer goes off the left hand side of the screen it +will reappear on the right, and vice-versa. If it goes off the top or +bottom, it will go and corrupt some memory.

+

The file system is kinda optimistic about matching names, so, for +example if you type the command shell into a command-line +it will execute the program sh - close enough a match for +it.

+

The ELF +binaries are not loaded at the correct address, and their entry +point must be the start address of the text segment.

+

The keyboard driver can cope with the basic alpha-numeric keys, but +gets confused by fancy things like shift or +backspace.

+

In the text-file viewer, vi, the up/down and PgUp/PgDn +keys scroll up or down by one line. There is nothing to stop you from +scrolling above the top of the file, and pressing any other keys might +have an undefined effect.

+

The x86 is bootstrapped into 32bit mode in 6 instructions, with 4 +more to set up data/stack segments and a stack-pointer to allow C code +to be run. On top of this there are also about a dozen instructions to +switch the video card into graphics mode. All in all, a relatively tiny +number of instructions next to the size of the C program. Also, the +string is mostly composed of data - a Linux-esque kernel header for the +bootloader, protected mode descriptor tables, keyboard maps, etc. (I +should also mention that it contains mini functions to perform an x86 +in and out instruction - to allow the keyboard +& mouse to be driven from C code).

+

Porting to another architecture should be relatively easy* - the +string simply needs be replaced with one containing data & code +suitable for the new target platform. Accesses to data in the string are +made relative to the define V, so these may need updating +as appropriate (0x90200 is the address at which a Linux +bootloader loads an x86 kernel image).

+
\* ;-)
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2004/gavin

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2004/hibachi/index.html b/2004/hibachi/index.html index 0a3fd9c6d..b09833c46 100644 --- a/2004/hibachi/index.html +++ b/2004/hibachi/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,421 @@ - - + + + + + + - - -2004 hibachi - - + + + +2004/hibachi + + + + + -

2004 hibachi

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2004/hibachi

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2004/hibachi/index.html

- +
+ ← gavin + ↑ 2004 ↑ + hoyle → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Anthony C. +Howe
Location: CA

+ + +

To build:

+
make
+

To use:

+
cd build; ./hibachi-start.sh &
+

Try:

+
cd build; ./hibachi-start.sh &
+

Then use your web browser to visit +http://localhost:8008/. When you’re finished make sure to +kill hibachi.

+

NOTE: you must be in the build directory when running +hibachi for this to work.

+

Judges’ remarks:

+

This entry violates the guidelines +in so many ways! We are not exactly sure how many organisations will be +upset with this entry, but we are considering starting an IOCCC +standards body just to reign in the likes of Mr Howe.

+

This entry also has the dubious honour of being the only one to have +been submitted with its own configure +script.

+

NOTE: the author states there is a tarball hibachi.tgz +but this was extracted so the file does not exist here.

+

Author’s remarks:

+

README.TXT (Feb 2004)

+

Hibachi is a simple, small, and (probably) very secure +web server.

+

There is a hibachi.tgz file that unpacks several support +files and a subdirectory tree containing the documentation and examples. +It can be viewed by:

+
tar -zxf hibachi.tgz
+lynx hibachi/localhost/index.html
+

Or once Hibachi is running, use a web browser +(preferably one that supports images and JavaScript, to view the +documentation and try some of the CGI examples) to visit: +http://localhost:8008/.

+

Building

+

To build just the executable:

+

For Cygwin, FreeBSD, Linux (newer), Mac OS X:

+
gcc -o hibachi hibachi.c
+

For Linux (older):

+
gcc -DSHUT_WR=1 -o hibachi hibachi.c
+

For SunOS:

+
gcc -o hibachi hibachi.c -lnsl -lsocket
+

Since some systems place socket and network functions into other +libraries, a GNU +autoconf configure +script has been provided to figure out the necessary link libraries, to +verify all the necessary headers and functions are present, and setup +the #! paths for the CGI examples. In which case the +preferred build commands are:

+
./configure [--enable-port=number]
+make
+

To start the server on the default port (8008):

+
cd build;
+./hibachi-start.sh &
+

To test the server:

+
lynx http://localhost:8008/
+

To stop the server:

+
kill %1
+

Features

+ +

Comments

+ +

Known Issues

+ +

Suggested IOCCC Categories

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2004/hibachi

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2004/hoyle/index.html b/2004/hoyle/index.html index 5ba13efde..a62e0ba98 100644 --- a/2004/hoyle/index.html +++ b/2004/hoyle/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,221 @@ - - + + + + + + - - -2004 hoyle - - + + + +2004/hoyle + + + + + -

2004 hoyle

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2004/hoyle

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2004/hoyle/index.html

- +
+ ← hibachi + ↑ 2004 ↑ + jdalbec → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jonathan +Hoyle
Location: US

+ + +

To build:

+
make
+

To use:

+
./hoyle point ...
+

Try:

+
./hoyle 10 0.5
+./hoyle 1 1 1 1
+./hoyle 2 0 1 0 -0.001
+

Judges’ remarks:

+

The obfuscation functions at several levels. Note the clever use of +use of #defines. The #define do(if,else), for +example, is delightful. The code itself contains a bunch of curves +designed to throw you off axis. :-)

+

Author’s remarks:

+

This application graphs polynomials on a standard Cartesian +coordinate system. Polynomials of the form +ax^0 + bx^1 + cx^2 + ... are graphed by passing the +coefficients a, b, c, etc. as +double precision arguments. It allows up to 8 parameters (thus up to +x^7).

+

Points of note:

+ +

For example, to graph y = x^2:

+
./hoyle 0 0 1
+

Note that:

+
./hoyle 0 0 2
+

will produce the same graph, since the y-axis is auto +scaling.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2004/hoyle

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2004/jdalbec/index.html b/2004/jdalbec/index.html index 7dee7ba3a..122f72bbd 100644 --- a/2004/jdalbec/index.html +++ b/2004/jdalbec/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,369 @@ - - + + + + + + - - -2004 jdalbec - - + + + +2004/jdalbec + + + + + -

2004 jdalbec

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2004/jdalbec

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2004/jdalbec/index.html

- +
+ ← hoyle + ↑ 2004 ↑ + kopczynski → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: John Dalbec
+Location: US

+ + +

To build:

+
make
+

There is an alternate version that allows one to control the number +of numbers to print on a line. See alternate +code below.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2004 jdalbec in bugs.md.

+

To use:

+
./jdalbec number ...
+

Try:

+
./try.sh
+

Alternate code:

+

This version lets you control how many numbers to show on a line +before adding a newline as it can be harder to see when there are a lot +of numbers. For lines that don’t end up having too many line breaks it +also makes it easier to see which line it is on.

+

Alternate build:

+
make alt
+

The macro Ag (silver) controls how +many number of lines to print on a line. Set at default to 11 protons, +salt, if you wish to make it silver, 47 (a prime) protons, do:

+
make clobber Ag=47 alt
+

though it might be odd to have 47 numbers on a line as it would +defeat the purpose. :-) Or if you prefer some prime, golden irony:

+
make clobber Ag=79 alt
+

Alternate use:

+

Use jdalbec.alt as you would jdalbec +above.

+

Alternate try:

+
./try.alt.sh
+

Judges’ remarks:

+

We still aren’t sure whether or not this is a useful program, but +it’s the first atomic fission we’ve seen in the IOCCC.

+

Author’s remarks:

+

It’s elementary!

+

See http://mathworld.wolfram.com/LookandSaySequence.html and +http://mathworld.wolfram.com/CosmologicalTheorem.html +and the references listed there.

+

Go read the web pages and come back.

+

This program implements the look-and-say +sequence (one of the above listed links) with the added feature that +each “decay product” is automatically split into its constituent +“elements” separated by spaces. Furthermore, arguments passed to the +program are treated as separate elements for the purpose of computing +further decay products. (Compare the output of ./jdalbec 1, +./jdalbec 11, and ./jdalbec 1 1.) This allows +output lines from the program to be passed back to the program as input +(minus the initial generation number).

+

The common elements are listed in CosmologicalTheorem.html. +The non-primordial +transuranic +elements are the isotopes of Neptunium and Plutonium. Isotopes +of a given element differ +only in the last digit. Four common elements could also be written as +isotopes of these two elements: He=Np(2), +Li=Pu(2), Ta=Np(3), W=Pu(3). To +get other isotopes, just change the last digit to a number greater than +3.

+

The build file runs jdalbec.c through the C +preprocessor to generate jdalbec2.c which is edited with +ed(1) (NOTE: this was changed to sed(1) by the +judges) to correct spacing problems caused by some preprocessors. (I +know you dislike Perl, but hopefully ed(1) is more common +on POSIX systems than Perl.) The build file then compiles +jdalbec2.c] and removes the jdalbec2.c +file.

+

I don’t think I’m abusing the Makefile since +I’m only using 147 characters including white space and the +#! line and the commented-out -Wall -pedantic +options. The rules for the 16th IOCCC +specifically allowed build files up to 521 characters long so my build +file would have been well within those limits. (What typo?)

+

gcc -E -Wall -pedantic complains that trigraphs are +present and that +"pasting ... does not yield a valid processing token".

+

gcc -ansi -Wall -pedantic complains about +#line directives, trigraphs, and expressions and statements +that have no effect. The last complaint is false in all but one case. +Removing the offending expressions causes some compilers to report +syntax errors because they can’t determine whether a name refers to a +variable or a type.

+

Since buffer overflows are a common security problem these days I +have stolen the idea of using a “safe” buffer API from +vsftpd. This means the program should never crash, +right?

+

The program was tested on: AMD K6/MMX 266MHz, Debian GNU/Linux +testing “Sarge”, gcc 3.3.2 Intel 486DX 33MHz, Red Hat Linux 7.3, gcc +2.96 PowerPC Macintosh G4 Quicksilver, Mac OS X 10.3.2, gcc 3.3 PowerPC +Macintosh G4 Quicksilver, Mac OS X 10.1.5, cc 2.95.2 PowerPC Macintosh +Performa 5200CD, Mac OS 8.6, CodeWarrior 11 Sun SPARC Ultra 10, Solaris +8, gcc 3.2

+

Compiling on Mac OS 8.6 requires some degree of manual intervention +because Mac OS 8.6 doesn’t have shell scripting or even a normal command +prompt. The CodeWarrior 11 compiler is the reason I had to +use trigraphs. I have to preprocess jdalbec.c without +trigraphs, save the result as jdalbec2.c, then compile +jdalbec2.c with trigraphs to get the program to work. I +also have to add an include file and a function call to the program to +get a pseudo command line so I can pass arguments. The compiler also +requires function prototypes by default, which is why I have prototypes +for all my functions.

+

Compiling on Mac OS X 10.1.5 requires changing ??= to +# on line 3 because the compiler doesn’t recognize +??= as a trigraph (which I consider a compiler bug). The +initial preprocessing step on Mac OS X 10.1.5 generates lots of errors +in “smart mode” because the “smart” preprocessor expects a valid C +program as input. The preprocessor then falls back to “basic mode” and +preprocesses jdalbec.c successfully without +warnings, even when I give it the -Wall -pedantic options. +It inserts a lot of extra spaces into the preprocessed output which is +why I had to add the ed(1) step to the build file so that +my macro #defines would work. The compile step gives the +usual messages with -Wall -pedantic. The link step +generates a warning about a name conflict between my BC() +and a BC() from curses in the main system library.

+

BUGS FEATURES:

+

Arguments matching /[^2]22$/ cause the program to +segfault after rapidly exhausting the available stack space. I could +probably fix this by adding some special cases to the code, but [Blaine +the Mono] it’s quite a bit more exciting this way, don’t you +think?[/Blaine] Since the trailing 22 will be its own atom +anyway, you can just insert a space in front of it if you run into this +feature (e.g. 1 22 instead of 122).

+

Note: you may want to be sure you have a limit on stack size before +trying this. I ran it on Debian GNU/Linux and discovered that I did not +have a limit on stack size. Fortunately the OS killed the process after +a while. This is consistent with the output of 1996/schweikh3 which reports +malloc lied! Killed by SIGKILL.

+

Arguments matching /(?:.){10,}/ will produce visually +incorrect results (e.g., generation 1 starting from 1111111111 will +print as : 1), but there’s nothing interesting about these +arguments that can’t be modeled using shorter runs of the same +symbol.

+

Arguments matching /(?:.){257,}/ may produce +mathematically incorrect results (e.g., generation 1 starting from a +string of 257 1s will be calculated as 11); +the remark from the previous paragraph applies here also.

+

The program has exactly 2004 IOCCC countable bytes. It’s tailor-made +for this competition!

+

Although there are no comments, the program still manages to be +self-documenting in an obscure fashion (periodic table of the +(non-primordial) elements, “OBFUSCATED C”).

+

Obfuscation

+

The program is obfuscated:

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2004/jdalbec

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2004/kopczynski/index.html b/2004/kopczynski/index.html index e12f2ab1e..8329e04d2 100644 --- a/2004/kopczynski/index.html +++ b/2004/kopczynski/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,372 @@ - - + + + + + + - - -2004 kopczynski - - + + + +2004/kopczynski + + + + + -

2004 kopczynski

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2004/kopczynski

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2004/kopczynski/index.html

- +
+ ← jdalbec + ↑ 2004 ↑ + newbern → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Eryk +Kopczynski
Location: PL

+ + +

To build:

+
make
+

NOTE: We FORCE the use of -O0 even if someone overrides it because +this entry will not work with it enabled.

+

To use:

+
./kopczynski < input_file
+

Try:

+
./try
+

What happens if you feed the program source to the program? Can you +figure out why?

+

Alternate code:

+

The judges modified the program to print its result. The original +program returned the result as an exit code which is what the alternate +version does.

+

Alternate build:

+
make alt
+

Alternate try:

+
./kopczynski.alt < kopczynski-10
+echo $?
+

Judges’ remarks:

+

What is in a line? A lot when you obfuscate the way Eryk Kopczynski +did it. This small one line program is an outstanding technical work of +art as well as one of the better one-liner programs that we have seen in +years!

+

Compile and run without arguments. As input, give it an ASCII +graphics figure 8, 9, 10, or 11 made of pound signs and spaces, of any +size, shape, or orientation (that’s right, an upside down 9 is still 9 +:-) ). There is one restriction: the only line not containing “#” +characters must be the last.

+

The program will print what it thinks you’ve entered. If you enter +anything that does not resemble 8, 9, 10, or 11, the result is seemingly +arbitrary. Actually it is not pseudo-random; can you find a pattern when +it does not resemble 8, 9, 10 or 11?

+

Here is a related puzzle: how to continue the sequence:

+
1, 0, 0, 0, 0, 0, 1, 0, 2, 1, ...
+

With certain arguments, you can alter the exit value / output. Can +you figure out how and why?

+

Author’s remarks:

+

The program proves it is not as hard to recognize numbers. The +current one liner version should correctly recognize all numbers from 8 +to 11. (Unless you give it some very hard cases. For example, it cannot +recognize negatives, zeros which have dots or slashes inside them, +digits should be separated, and numbers should be “complete”.)

+

This program returns the number as its exit status. (In most shells, +you can see the exit status of the last command with +echo $? (or just $?).)

+

NOTE: The judges altered the primary version to output a +number.

+

On the input, give numbers formed as a sequences of empty spaces and +# signs (you can also use dots instead of spaces), ending +with an empty line. (No number has an empty line in it.) The program +should return the number from 8 to 11 that it thinks it is.

+ +

Portability

+

It only requires two’s complement arithmetics, as far as I know. The +maximum length of an input line is N-9, where +N is the size of int in bits (you can try to +compile with an option '-Dint=long long' for longer +lines).

+

Algorithm & Obfuscation

+
    +
  1. This program works by calculating the Euler +characteristics of input, plus 9. It is the number of digits +(i.e. separated #-regions) minus the number of holes in +them. It turns out that this algorithm works correctly for all numbers +from 8 to 11.

  2. +
  3. We know that Euler +characteristics is the number of “vertexes”

  4. +
+
        #
+

minus the number of “edges”

+
       ## # #. .#
+          # .# #.   ('.' must be empty)
+

plus the number of “faces”

+
       ##
+       ##
+
    +
  1. If we fill all these patterns to 2x2 squares,
  2. +
+
       #? ## #? #. .# ##
+       ?? ?? #? .# #. ##
+       +1 -1 -1 -1 -1 +1
+

substitute all possible “values” of ? and sum them up, +we get that it is enough to calculate:

+
       #. .# ##
+       .. #. #.
+       +1 -1 -1
+

Note now it is simple and obfuscated enough to be used as a “magic +trick”.

+
    +
  1. I make a 16-character array; when indexed by 4-bit value which +represents the 2x2 squares, it will return a number to add/subtract +{-1,0,+1}

  2. +
  3. We convert lines of input to bitmaps (N-bit +integers). Additionally, it is heavily obfuscated by using negative +numbers (two’s complement). For example, it turns out that +6 in z=6 is the only 1-digit number which +works here (and it’s not only because we have z>5 in the +following while). The conversion routine also sets +n=8 in an obfuscated and concise way.

  4. +
  5. Since we always return the number from 8 to 11, we can calculate +modulo 4. Instead of 16 {-1,0,+1} values, we use a +15-character string which agrees modulo 4 to the array in +(4). ('\0' fits very well as the 16th +character, so we use 15-character string.)

  6. +
  7. Since the rule found in (3) did not produce any funny messages, I +changed it until it did. (The # character to find vertexes +is in the top right corner, not the top left one.) The following +messages will also work instead of +has dirtiest IF:

  8. +
+
HighlandYachter
+TestDirtiestTen
+has lintiest IF
+TighterLaughter
+HustlerDaughter
+TighterDemoThen
+

They can be mixed, of course!

+
    +
  1. NOTE: item 8 was removed by the judges so as to not spoil the +challenge of figuring how arguments can be used to alter the exit +value.

  2. +
  3. The variable names are confusing.

  4. +
  5. Finally, the program tries to be as concise as possible. Some +obfuscation comes from this. For additional obfuscation and conciseness, +if means while.

  6. +
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2004/kopczynski

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2004/newbern/index.html b/2004/newbern/index.html index b1c8f666e..649e165c3 100644 --- a/2004/newbern/index.html +++ b/2004/newbern/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,213 @@ - - + + + + + + - - -2004 newbern - - + + + +2004/newbern + + + + + -

2004 newbern

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2004/newbern

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2004/newbern/index.html

- +
+ ← kopczynski + ↑ 2004 ↑ + omoikane → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jeff Newbern
+Location: unknown

+ + +

To build:

+
make
+

To use:

+
./newbern [file.dat arg]
+

Try:

+
./newbern newbern.dat "IOCCC 2004"
+echo SOS | ./newbern
+

Judges’ remarks:

+

The program is formatted using the same font glyphs as the example +data file.

+

Author’s remarks:

+

This is a configurable banner(1)-like program.

+

Examples:

+ +
./newbern char < some_nicely_shaped_text >> data_file
+ +
./newbern data_file a_string
+

Extra functionality

+

The program can also act as a Morse encoder, unarguably.

+

It also has double-super-secret encryption capabilities. Decryption +is left as an exercise for the reader.

+

Portability

+

The program assumes an ASCII operating environment.

+

The program is best viewed with tab-stops set to 8.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2004/newbern

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2004/omoikane/index.html b/2004/omoikane/index.html index 6a2e8929b..ca3ed867d 100644 --- a/2004/omoikane/index.html +++ b/2004/omoikane/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,294 @@ - - + + + + + + - - -2004 omoikane - - + + + +2004/omoikane + + + + + -

2004 omoikane

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2004/omoikane

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2004/omoikane/index.html

- +
+ ← newbern + ↑ 2004 ↑ + schnitzi → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Don Yang
Location: +US

+ + +

To build:

+
make
+

To use:

+
./omoikane infile layout outfile
+

Try:

+
./omoikane omoikane.info omoikane.info omoikane.output
+

Judges’ remarks:

+

For extra credit, spot the checksum in the source file itself. What +makes this one particularly interesting is that the checksum, strictly +speaking, isn’t being computed at all. Rather, the file is modified to +have the desired checksum! This does, we suppose, solve the problem that +inserting a checksum would change the file’s checksum; if you have to +change it, you might as well change it!

+

This program was submitted under the name Rinia, so the +Author’s Comments refer to it as such.

+

Author’s remarks:

+

Rinia (1/14/04)

+

Rinia is a tool for embedding CRCs in text files. No +need to assign strange file names or package .SFVs with your files! +Rinia will insert a human-readable checksum string in the +text itself! ^_^

+

Usage

+
./omoikane <infile> <layout> <outfile>
+

All three arguments may reference the same file. All files is assumed +to be of ASCII character set.

+

Input

+

Any file larger than 8 bytes is valid. Upper limit on file size is +limited by memory.

+

If input file can’t be loaded for any reason, Rinia will +say “bad input” and exit immediately.

+

Layout

+

The layout file contains a map of where Rinia can patch. +The content consists of marker characters (where Rinia is +allowed to change in the original text) and other characters (where the +original text will stay as is). Rinia will select the +marker character using these heuristics:

+
    +
  1. Ignore all space/control/extended characters.
  2. +
  3. Select characters that appeared 8 times in a row.
  4. +
  5. Of those selected characters, pick one with the lowest +frequency.
  6. +
+

One way to create the layout file is to make a copy of the original +file, replace where you want Rinia to match with a rare +character, then replace the remaining ones with space. Often it’s +possible to write the original file in such a way that it can be used as +a layout.

+

Example file/layout:

+
file:                layout:
+   crc = ########       ... . XXXXXXXX
+   patch = ######       ..... . XXXXXX
+   other text here      ..... .... ....
+

And Rinia may generate a file similar to this:

+
crc = 1bad73cf
+patch = #FR-QQ
+other text here
+

Note that the original file by itself is a valid layout file, since +Rinia will recognize that only # marks enough +space to hold the checksum, and has the lowest frequency.

+

If layout file can’t be used for any reason, Rinia will +say “bad layout” and exit immediately.

+

Output m

+

If Rinia finds a usable checksum, she will say “OK.” and +write to the specified output file. Otherwise the exit message is “fail” +and nothing is written.

+

Chances of success and how long it takes to run to completion is +completely dominated by the layout file design. In general, +Rinia runs faster if the checksum is placed before the +other marker characters rather than after, e.g.:

+
 a: X X XXX      b: XXXXXXXX     c: XXXXXXXX
+    XXXXXXXX        X X XXX         XXXXX
+
+

a usually takes the longest time, while c +usually is the fastest.

+

That said, each run is randomized with respect to system time, so +it’s not always certain whether Rinia will succeed in a +short time or not. In general, 5 marker characters are sufficient, and +takes a few minutes.

+

For reference, rinia.c was produced on a 1.7GHz machine +(the checksum is at line 17). Out of 25 runs, the shortest was 2 seconds +while the longest took 5 minutes. Average was about a minute. Checksum +for this file (b7a81524) took about 4 minutes.

+

Algorithm

+

Inserting a checksum in the file you are computing the checksum of +isn’t quite trivial, since changing the file content would change the +final checksum value.

+

To insert the checksum, Rinia first assumes a random +final checksum, inserts that string, then modifies other parts to +compensate for the change in content.

+

The compensation bytes are very easy to compute for binary files with +enough consecutive scratch areas, but for text files with +non-consecutive areas and limited degrees of freedom, Rinia +has to try out all character combinations. This is done in a +hierarchical fashion, computing only smallest partial checksum after +each change.

+

For computers a few years old, this is probably still too slow to be +acceptable… but at the speed the IOCCC judges run the contest these +days, I am sure you have enough patience for it _^

+

Source code

+

rinia.c should compile anywhere (but with a few +warnings). I don’t have a big-endian machine to test but +Rinia should work there as well. ASCII character set +required though.

+

Code is formatted to the shape of “Rinia” from the +anime/game “Moekko Company”. Of course at 90x50 it’s hard to recognize +anything ^_^

+

Rinia is the slow but hardworking android. On some jobs +she does very well, on others she would spend lots of time and effort +but still fail…

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2004/omoikane

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2004/schnitzi/index.html b/2004/schnitzi/index.html index 98f179205..f47d84b23 100644 --- a/2004/schnitzi/index.html +++ b/2004/schnitzi/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,297 @@ - - + + + + + + - - -2004 schnitzi - - + + + +2004/schnitzi + + + + + -

2004 schnitzi

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2004/schnitzi

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2004/schnitzi/index.html

- +
+ ← omoikane + ↑ 2004 ↑ + sds → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Mark +Schnitzius
Location: unknown

+ + +

To build:

+
make
+

To use:

+
./schnitzi <foo | vi -n
+

Try:

+
./try.sh
+

NOTE: if you’re one of those who don’t know how to exit +vi :-) don’t worry as it will exit for you.

+

Judges’ remarks:

+

This exemplifies the meaning of Visual Editor, but we don’t think +that any benchmarking sites are going to use this to tout the +performance of the latest hardware!

+

Author’s remarks:

+

If you’ve ever pasted a large chunk of text into an editor (such as +vi) without first putting it into insert mode, or turning +off the auto-indent, you know the dismay of watching your screen fill up +with misaligned junk.

+

It’s not the editor’s fault. The editor is just acting just as if you +typed exactly what you’re pasting. (Of course, you could blame the +editor for being modal in the first place, but that’s a discussion for +another time.)

+

It occurred to me that you could get interesting results by pasting a +carefully designed string into the editor. In fact, if the pasted string +contains cursor navigation commands, you can go back and overwrite +things that were already inserted earlier in string, anywhere on the +screen. Can you see where this is going?

+

ANIMATION!

+

The program takes input from stdin which defines the +animated elements (sprites) that appear on the screen. For each sprite, +you can specify exactly when and how long it will appear, and which +direction it is moving. Also, the sprite can oscillate between up to +four different views, which appear in subsequent frames. Forgive me, +animators, if I’m mangling the terminology. Sprites which appear later +in the input file will be drawn in front of sprites which appear +earlier.

+

The output, written to stdout, is a string which, when +pasted into vi, will perform the animation defined in the input. (The vi +editor is a common (and ancient) editor that should be available on most +Unix, Linux, Solaris, and macOS systems; you can get it on Windows by +installing Cygwin, which is how I do it.)

+

THE INPUT

+

It’s easiest to place the input in a file, so you can redirect it to +stdin when running the program. What follows is a detailed +description of the input file format.

+

The first line is specified thusly:

+
[duration] [timefactor]
+

The first parameter, duration, defines how long the +animation will run. The second, timefactor, is used as sort +of a fudge factor for machines that run too fast to see the animation. A +timefactor of 0 means, “run the animation as fast as you +can”. On a pretty fast machine, I’ve had to set it as high as 2000 to +get the animation to slow down sufficiently. Note that the higher the +timefactor, the longer the output string that you’ll have +to copy and paste, as extra characters are necessary to “waste time” +between frames.

+

Following the first line parameters, you may have up to nine +different sprites, each up 50 by 50 in size, and with up to four +different ‘views’ of that object, which are cycled through with each +successive frame. Each sprite begins with a line of parameters of the +following form:

+
[start] [end] [x] [y] [dx] [dy] [cols] [rows] [viewcount]
+

where:

+ +

Each such parameter line will be followed by viewcount +view frames, each with rows rows and cols +columns.

+

Input is terminated by end of file. Duh.

+

Two samples input files are included; one a nice pastoral park scene, +the other a bit of scrolling text.

+

RUNNING THE ANIMATION

+

Try one of these methods to get the animation to run:

+
    +
  1. Redirect the output directly to vi, like this:
  2. +
+
./schnitzi < input.dat | vi
+
    +
  1. Redirect the output to a file, like this:
  2. +
+
./schnitzi < input.dat > output.dat
+

Then, open the output file, select the text, and copy it to your +system pasteboard/cut/selection buffer and paste it into vi. The paste +is NOT the vi paste command, but rather an action you take within your +operating system. On a Windows machine running vi via Cygwin, +“Edit|Paste” is a right-click menu option on the top window bar.

+
    +
  1. Memorize the output, and type it into vi really really fast.
  2. +
+

A FINAL NOTE

+

I would like to remind the Pixar Animation Studios that I retain +royalties on this technique.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2004/schnitzi

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2004/sds/index.html b/2004/sds/index.html index 3334114e6..05d2b2c94 100644 --- a/2004/sds/index.html +++ b/2004/sds/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,258 @@ - - + + + + + + - - -2004 sds - - + + + +2004/sds + + + + + -

2004 sds

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2004/sds

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2004/sds/index.html

- +
+ ← schnitzi + ↑ 2004 ↑ + vik1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Stephen Sykes
+Location: FI

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2004 +sds in bugs.md.

+

To use:

+
./sds
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Why not use the program to hide another program in the program? It +must have seemed reasonable at the time.

+

The ability to hide a message in plain text is quite charming, +really. We must admit to a bit of uncertainty about where you’d find +such messages, or how useful they’d be. Or, of course, whether all those +horribly badly formatted emails spammers send might contain secret +messages. Annoyingly, it’s a little too obvious that SOMETHING has been +done to a message for us to hide one in the remarks. :)

+

Author’s remarks:

+

Steganography is +the term for the family of techniques used for hiding information within +other information. Today, it has many real world uses, particularly for +digital watermarking.

+

This program uses a steganographic technique to hide information in +any text file. The specific technique used is aimed at writers of +obfuscated programs for the IOCCC, as the hidden information is encoded +in the whitespace in the source file. As we know, there are up to an +additional 2048 characters of whitespace available to entrants to the +IOCCC, so it turns out that this is an ideal place to hide things.

+

The program as provided is the steganographic decoder. Rather than +provide a separate encoding program, you should not be surprised to +learn that I opted to steganographically hide the encoder inside the +decoder.

+

Try it out. Compile the program, then type

+
./sds < sds.c
+

You should see the encoder program displayed. Now save it, like:

+
./sds < sds.c > encoder.c
+

Then compile encoder.c. You now have the complete system +ready.

+

The encoder expects to get a filename as an argument. This filename +is the name of the file containing the information to be hidden. It +expects the file in which to hide the information to be on the standard +input, and will output the results on the standard output.

+

You can use it like this (assuming you have a file called +remarks):

+
echo 'Hello, World!' > message
+./encoder message < remarks > remarks_msg
+

Then to decode:

+
./sds < remarks_msg
+Hello, World!
+

C programs are mostly unaffected by adding steganographic content, +but it is possible in certain circumstances for whitespace to be changed +inside strings where it should be left alone. Plain text files are good +candidates for hiding information in, but the added spacing may render +the text somewhat difficult to read.

+

Obfuscation

+

This program is obfuscated in a number of ways:

+ +

Compiling the program

+

The program (and the encoder program) should compile on any +reasonable compiler. In particular, they are known to compile under GNU +C.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2004/sds

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2004/vik1/index.html b/2004/vik1/index.html index 974060615..45a162e8f 100644 --- a/2004/vik1/index.html +++ b/2004/vik1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,275 @@ - - + + + + + + - - -2004 vik1 - - + + + +2004/vik1 + + + + + -

2004 vik1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2004/vik1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2004/vik1/index.html

- +
+ ← sds + ↑ 2004 ↑ + vik2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Daniel Vik
+Location: US

+ + +

To build:

+
make
+

To use:

+
./vik1 [arg]
+

Try:

+
./vik1
+./vik1 a
+./vik1 d2
+./vik1 ad3
+

Can you figure out how to cheat?

+

Judges’ remarks:

+

Daniel Vik has presented a tour de force feature rich X11-based +racing game that fit within the contest size limits. Take a glance at +the feature list he provided below. Amazing!

+

The author posted a video of this on YouTube: https://www.youtube.com/watch?v=xTseqWCtAUA.

+

Happy touring on the road and in the code!

+

Author’s remarks:

+

Features

+

This program is a complete car race game with a lot of nice +features:

+ +

Build and Run

+

Compile the source code and link X libraries if necessary. The +program takes three options which have to be typed in a specific order +as described below.

+
Usage: ./vik1 ['a']['d'][#]
+
+a   - Advanced racing in a winter landscape
+d   - Racing in at night in the dark
+#   - Race track selection 1-3 are valid numbers
+

Here are a few examples:

+
Command line:               Description:
+
+$ ./vik1                    Run track 1 at daytime in the summer
+$ ./vik1 a                  Run track 1 at daytime in the winter
+$ ./vik1 d                  Run track 1 at night in the summer
+$ ./vik1 3                  Run track 3 at daytime in the summer
+$ ./vik1 d3                 Run track 3 at night in the summer
+$ ./vik1 ad2                Run track 2 at night in the winter
+

Note that the order in which the argument characters are entered is +important. It is for example not possible to type +./vik1 da. (Well it is possible, but the result will not be +as expected.)

+

The space key accelerates the car. Releasing the space key slowly +reduces the speed. The left and right arrow keys are used to steer the +car.

+

Obfuscation

+

The main obfuscation is the fact that the program is extremely +compact. There are a few things I didn’t want to do, e.g. define +#define to a single letter to save some space, or to remove +casts to save some space.

+

The program uses a lot of variables. In fact, all letters +a-z are used and most letters A-Z.

+

The constants are chosen very carefully and they have multiple +purposes, e.g. a constant can be both the length of the track and a +color.

+

Most of the code is kept inside five for loops each +without a body. Each for loop does many things. One +for loop draws all cars by restarting a couple of times. +Another draws the road, mountains, and the sun.

+

main() is called recursively. The return value and +output depends on the arguments. main() can return the +current time, draw lines and of course be the entry point of the +application.

+

The program frequently uses the ?: operator mainly to +save space but it makes the program more obscure.

+

Compiler warnings

+

There are no compiler warnings when compiling with -ansi +but there are many warnings from lclint. Mainly because the program is +very optimized for code size.

+

Limitations

+

The program only compiles and runs on X based systems.

+

The program requires a display with 24 bit color depth. It also +assumes that the byte order of the colors are as on my Linux PC. That +is, The colors are represented by a 32 bit value where the bytes (from +high to low) are { 0, RED, GREEN, BLUE }.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2004/vik1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2004/vik2/index.html b/2004/vik2/index.html index e85f8212b..a7444685a 100644 --- a/2004/vik2/index.html +++ b/2004/vik2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,378 @@ - - + + + + + + - - -2004 vik2 - - + + + +2004/vik2 + + + + + -

2004 vik2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2004/vik2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2004/vik2/index.html

- +
+ ← vik1 + ↑ 2004 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Daniel Vik
+Location: US

+ + +

To build:

+
make
+

To use:

+
./vik2
+

Judges’ remarks:

+

The fun thing about CPP abuses is +that, in most cases, running the preprocessor on +them doesn’t help you decipher the obfuscated code. That’s assuming your +preprocessor can take it at all.

+

Author’s remarks:

+

Introduction

+

It’s been a while since the last pre-processor +killer won the IOCCC. I thought it was time to relive hour long compile +times so I made a program that does (almost) all computation in the +pre-processor. The program even causes gcc (and other +pre-processors) to crash when configured to do maximum number of +computations. The default configuration of the Makefile is set to make the program compile in a not +too long time.

+

I’ve got cpp to crash in a couple of different ways. +Most common is to get a segmentation fault, but a couple of times it +just got stuck in some infinite loop.

+

I actually had to write my own pre-processor to +verify that the program was doing the right thing…

+

Since it takes a very long time to compile the program, there is a +symbol that can be defined to shorten the compile time and avoid +compiler errors.

+

Features

+

The program implements an 11-bit ALU in +the pre-processor. +The ALU has two registers, +X and Y, for calculations and one status +register SR. Each bit in the registers are represented by +one symbol that are either defined or undefined.

+

The ALU has six instructions:

+ +

Internally the ALU +implements a one bit adder with a carry in and carry out. This adder is +the core of the ALU. The ADD instruction uses the one bit +adder to create the 11-bit adder. The SUB instruction is +implemented by adding ~Y to X and then add 1. +Finally the TST instruction calculates X-Y and +checks the result and the CARRY bit in the +SR register to +set the EQ and LT bits.

+

All calculations are made using only #ifdef, +#ifndef, #else, #endif, +#define and #undef. I never assign a value to +a defined symbol. The logic is done by assuming that a defined symbol is +1 and an undefined symbol is 0. (I guess this means that I have +unlimited memory as long as I only store zeroes (!)).

+

The application that uses the pre-processor ALU is a +prime number +generator. The application uses the same pre-processor directives. +Needed variables are stored in memory represented by one defined or +undefined symbol per bit. When doing arithmetics, the variables are +loaded into the X and Y registers by defining +/ undefining the X and Y register +bits. Then the calculation is made and the result is moved back to the +memory.

+

The choice of application may be a bit unfortunate since we’ve +already seen a winning entry calculating prime numbers in +the pre-processor. +There is a big difference though. The 1988/applin entry uses pre- processor +arithmetic (in a very nice way though). This program only defines and +undefines symbols in a well defined ;) way and doesn’t do any +pre-processor arithmetics.

+

The reason why I chose to do a prime number +application is that the algorithm can be written to do a lot of +calculations without a lot of nesting (GNU cpp allows only +200 nested includes).

+

Build and Run

+

First, do a first pre-processing of the initial definitions. The +FNAME symbol must be defined to the name of the output +file. If you want to speed up the compilation, define the +STOP symbol to anything from _3 to +_10. (The default value is _10 which will make +the compilation take some time.) Prime numbers up to 2^STOP +will be calculated.

+
cpp '-DSTOP=_5' '-DFNAME="tmp1.c"' prog.c tmp1.c
+

Then use cpp or any other pre-processor to +do the actual work. This will take some time….

+
cpp tmp1.c > tmp2.c
+

Finally compile the pre-processed file

+
cc -O tmp2.c -o prog
+

Then run the program to reveal all prime numbers up to 32 (if you +used STOP=_5 as above):

+
./vik2
+

Verification

+

I wasn’t able to compile the full program which calculates prime numbers up +to 1024 using GNU cpp (or any other pre-processor) +so I had to write my own. Knowing how the program works it was quite +easy to reduce the compilation time from several hours to about one +second. I also added some statistics to my home made pre-processor and I +found that calculating prime numbers up to 1024 makes the program +include itself over 6.8 million times (see the statistics table +below).

+

Obfuscation

+

Well, since 98.5% of the program is preprocessor +directives, the main obfuscation is the use of preprocessor +directives.

+

Doing arithmetics without actually using any arithmetic operations +makes the program quite hard to follow.

+

In order to actually do the calculations, the program includes itself +a lot.

+

The symbol names are made as short as possible to meet the space +limits. This of course adds to the obfuscation (even though the program +is quite obfuscated with longer, readable macro names.

+

Finally, I made the 1.5% C code a bit harder to read by breaking all +lines after three characters.

+

The program has 1029 lines which makes it the longest entry (so +far).

+

Even though the pre-processed and indented output is easier to read, +it is quite hard to find the code in it. The size of the pre-processed +file is several Mb when using GNU cpp.

+

Limitations

+

In order to fit the program within the space limits, I had to define +the #define, #endif, and some other directives +as single character symbols. This does not compile on all pre-processors +but using GNU cpp as a first compilation step solves +this.

+

Statistics

+

The table below contains some interesting statistics about the +compilation of the program. The intermediate file size is the size of +the output file of the cpp pre-processor. +The times taken to pre-process the program were measured using GNU +cpp on my 2.0MHz P4 with 512Mb ram and a lot of disk.

+
        Generated   Recursive  Max nest  Intermediate
+    Level   prime nrs   includes   count     file size          Time
+
+      _3     < 8           2 322       9         74 748            4"
+      _4     < 16          4 672       9        182 652            9"
+      _5     < 32         14 237       9        629 121           32"
+      _6     < 64         43 748       9      1 998 134         1'41"
+      _7     < 128       149 851      11      6 823 575         5'50"
+      _8     < 256       526 874      17     24 028 933        20'37"
+      _9     < 512     1 920 272      38     65 527 808(*)  1h 42'19"(*)
+     _10     < 1024    6 826 389     114     63 782 912(*)  2h 47'58"(*)
+
+     (*) Before cpp crashed.
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2004/vik2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2005/aidan/index.html b/2005/aidan/index.html index 6bf813fdf..01d886bff 100644 --- a/2005/aidan/index.html +++ b/2005/aidan/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,469 @@ - - + + + + + + - - -2005 aidan - - + + + +2005/aidan + + + + + -

2005 aidan

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2005/aidan

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2005/aidan/index.html

- +
+ first entry + ↑ 2005 ↑ + anon → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Aidan +Thornton
Location: GB

+ + +

To build:

+
make
+

There is an alternate version based on the author’s remarks. See alternate code.

+

To use:

+
./aidan < puzzle
+
+./aidan seed
+

where seed is a number.

+

Try:

+
./try.sh
+

Alternate code:

+

This code is formatted differently and is not the approach used by +the author which is slower, inelegant and not as obscure, as the author +put it.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use aidan.alt as you would aidan above.

+

Alternate try:

+
./try.alt.sh
+

Judges’ remarks:

+

Are you puzzled about puzzles? This entry might puzzle you more while +it puzzles out some puzzles: all in a puzzling way!

+

goto the source and notice the lack of functions. Jump +to the switch statement. And if you think you can puzzle it +out better, try solving insane1.sudoku all +by yourself!

+

NOTE: the tarball named by the author was removed after the files +were extracted into the directory instead. These files were added to the +list.

+

Author’s remarks:

+

This program can solve a type of logic puzzle known as a Sudoku, and also +generate new ones.

+

Contents

+ +

Yes, the test suite really is 5 times larger than the actual program. +You did say this was a parody of the software +development process…

+

IMPORTANT

+

test.perl expects the +sudoku-sf executable to be ./sudoku-sf. If you +rename it, please change the definition of $sf_exe to the +new name.

+
+

Judges’ note: this was done.

+
+ +

This program comes with NO WARRANTY, not even that it’ll do what I +say it should. Any misfortunes that occur as a result of using this are +not my fault. Go find some unpopular multinational to sue instead.

+

This program is not copyrighted and is entirely my work. Distribute +or modify it as you wish, though please give me credit.

+

What is a sudoku?

+

(If you know, feel free to skip this section. Get more details from +the wikipedia +entry)

+

A sudoku is a type of logic puzzle. You are given a grid of 9x9 +boxes, some of which contain digits. This is divided into a 3x3 set up, +e.g. (from the Wikipedia article - fairly easy):

+
        . . . | 1 . . | 7 4 .
+        . 5 . | . 9 . | . 3 2
+        . . 6 | 7 . . | 9 . .
+        ------+-------+------
+        4 . . | 8 . . | . . .
+        . 2 . | . . . | . 1 .
+        . . . | . . 9 | . . 5
+        ------+-------+------
+        . . 4 | . . 7 | 3 . .
+        7 3 . | . 2 . | . 6 .
+        . 6 5 | . . 4 | . . .
+

You have to fill in the remaining boxes so that each row, column, and +smaller box contains all of the digits 1-9. That’s all the information I +needed to figure out how to solve them, but there’s a useful tutorial on +http://www.sudoku.org.uk/, which is roughly affiliated +with the Daily Telegraph, a +UK newspaper.

+

Now, with modern computers this can be solved using +brute force, e.g.:

+
#include <stdio.h> /* sudoku-bfi.c */
+#define S(t) for(n=0;n<9;v[n++]=0);for(n=0;n<81;n++)if(i[n]){z=1<<i[n];if(v[t]\\
+&z)for(;;){if(p<0)goto d;if(i[p]++<9)goto f;i[p]=0;p=s[p];}v[t]|=z;}
+int i[82],s[81],v[9],n,p,z;int main(void){for(n=0;n<81;){p=getchar()^48;if(p==
+30)p=0;if(p<10)i[n++]=p;}i[81]=0;p=-1;f:S(n%9)S(n/9)S(n%9/3+n/27*3)if(p>80)goto
+d;for(n=p;i[++p];);s[p]=n;i[p]=1;goto f;d:z=p<81;printf("\n%s!\n\n",z?"Fail":
+"Success");for(n=0;n<81;){p=i[n];printf("%c %s",(p?p|48:'.'),(++n%3?"":n%9?"| "
+:n%27?"\n":n%81?"\n------+-------+------\n":"\n\n"));}return z;}
+
+

Judges’ note: this was added as aidan.alt.c.

+
+

That isn’t the approach I’ve used; it’s slow (particularly in +worst-case or nearly so scenarios), inelegant, and not a good starting +point for sudoku generation. It’s also much too easy to understand ;-) +Instead, I’ve written a program which solves them in much the same way +as I do, only a lot faster (and hopefully more reliably).

+

Oh, and if you think that example sudoku is too easy, try this one +(which my program generated):

+
--- insane1.sudoku --
+. . 4 | . . . | . 5 6
+5 . . | . 7 2 | . . .
+. . 1 | . . . | 8 . .
+------+-------+------
+. . . | . . . | . . .
+. . . | 6 9 3 | . . 5
+. . . | . . . | 7 3 4
+------+-------+------
+. 5 . | 2 . 1 | 4 . 8
+3 . . | . . . | . . .
+. . . | . . . | . 6 1
+

Be warned - it’s evil! (I certainly haven’t been able to solve it by +hand. The brute-force program given above, sudoku-bfi.c (aidan.alt.c), also has trouble - it took 66 +seconds to solve it - but probably for different reasons. That’s the +worst performance I’ve had from brute-force so far!)

+

Usage

+

Building

+
cc -o sudoku-sf sudoku-sf.c
+

or, if using gcc, try:

+
gcc -O2 -Wall -Wextra -ansi -pedantic-errors -o sudoku-sf sudoku-sf.c
+

Testing (optional)

+
perl ./test-su.perl
+

Note that this requires Perl 5 (I use 5.8.5, earlier versions +untested) and is somewhat slow (should take under a minute on a fairly +modern PC - try appending -n 0 if you’re in a hurry). I +wrote it mostly for my own benefit, really.

+

Solving

+
./aidan < somefile.txt
+

Input should be the numbers of each row in turn. Empty spaces can be +represented as a full stop (.) or zero (0). +Other characters are ignored, so you can cut-and-paste either example +sudoku puzzle from above into a file and feed that in. The program has +coped with every input I’ve thrown at it so far, including an empty grid.

+

Output consists of the problem, then the solution, then a message of +success/failure.

+

./aidan U may also be useful, or perhaps not. It only +took an extra 15 bytes of (very simple) code to add, so it doesn’t +really matter to me. (It’s the same as the normal mode for most input +you’re likely to feed it, though slightly slower. See if you can figure +out what it does.)

+

Generating

+
./sudoku <seed>
+

Output is a blank grid, then the solution, then the problem. There’s +no control over the difficulty. Sorry. However, all generated sudokus +should have exactly one solution - if one doesn’t, that’s a bug.

+

Speed

+

Fast enough. Solving and generating are practically instant on my +1Ghz Duron. Of course, there could be some cases which take longer…

+

More precisely - 400 random sudokus are generated and solved in about +45 seconds in tests on my PC (1Ghz Duron, gcc 3.4.1, -O2 +optimisation - takes about 60 seconds with no optimisation). If that +isn’t fast enough, what on Earth are you doing with it?

+

Bugs

+

None known - hopefully I’ve worked out all the major ones. Nothing +has come up in testing since the last bug fix, but what does that +mean?

+

Tested on:

+ +

RETEST Borland C 4.5, 16-bit DOS .exe (small memory +model)

+

I don’t count the fact that it first prints a blank grid whenever +asked to generate a sudoku as a bug - just a minor quirk. The fix is +slightly awkward and would make the program slightly longer, so I +haven’t bothered - it’s not important.

+

Missing Features

+ +

Portability

+

Dependant on ASCII, requires that an int is at least 15 +bits and a long at least 32. (No, that isn’t a typo - I did +say 15, not 16).

+

Also requires that cpp can properly handle something +like:

+
#define foo(x,y) x y
+foo(bar,)
+

Apparently, a few can’t (ANSI C specifically doesn’t require that +this works, though it usually does). Unfortunately, I didn’t discover +this issue until too late. (It was mentioned in the notes for people +modifying GCC in the “beware of obscure compiler limitations” section, +so I’m figuring it’s quite unusual.)

+

Compiler warnings

+

Some when compiled with +gcc -Wall -Wextra -ansi -pedantic:

+ +

Borland C also spots some code in expressions which has no effect, +and some uses of = where you’d expect a comparison +operator.

+

Obfuscation

+

Let’s see now:

+ +

So basically, just what you’d normally expect in an IOCCC entry.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2005/aidan

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2005/anon/index.html b/2005/anon/index.html index 0d14ca229..c16e455a1 100644 --- a/2005/anon/index.html +++ b/2005/anon/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,603 @@ - - + + + + + + - - -2005 anon - - + + + +2005/anon + + + + + -

2005 anon

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2005/anon

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2005/anon/index.html

- +
+ ← aidan + ↑ 2005 ↑ + boutines → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Anonymous +2005
Location: unknown

+ + +

To build:

+
make
+

NOTE: there is an alternate version for vi(m) like movements. See alternate version below. If your terminal has +problems with the stty(1) commands try:

+
make anon-no_stty
+

This will compile anon.c as anon to +not use stty(1).

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2005 +anon in bugs.md.

+

To use:

+
./anon x y [z]
+

Try:

+
./anon 4 4
+./anon 3 3 3
+

After a very large number of moves this program will deliberately +force itself to destroy its runtime stack. This is the author’s way to +prevent you from being frustrated (which might happen as it likes to +create unsolvable puzzles just to hook you) and spending too much time +playing. :-)

+

This is supposed to happen. As is written in the The Jargon +File:

+
That's not a bug, that's a feature.
+

If you want to see this in action you can easily do this:

+
yes 'please crash on me :-)' | ./anon 4 4
+

What happens if you specify a larger board? For instance:

+
yes 'please crash on me :-)' | ./anon 10 10 10
+

If you specify more than three args the program might also crash or +do something strange. This might also happen if you specify excessively +large board dimensions. Try 100 100 100 for instance and +see what happens!

+

Alternate version:

+

The alternate version uses vi(m) like movement keys.

+

Alternate build:

+
make alt
+

To compile the version without stty(1):

+
make alt-no_stty
+

Alternate use:

+

Use anon.alt as you would anon with the +change in movements:

+
k | Move empty spot up
+h | Move empty spot left
+j | Move empty spot down
+l | Move empty spot right
+J | Move empty spot forwards
+K | Move empty spot backwards
+

Judges’ remarks:

+

Taking the 4x4 board with 15 tiles to a whole new level, this entry +takes this puzzle to a whole new dimension! While you puzzle out this +puzzle, we invite you to take a good LONG look how and WHY +main() is recursively called and how the runtime stack is +used.

+

Author’s remarks:

+

ABOUT THE GAME ITSELF

+

Remember Sam Loyd’s Fifteen Puzzle? It +consists of a 4x4 board with 15 tiles numbered 1 to 15, and an empty +spot. The goal of the game is to slide the tiles around without lifting +them off the board, so that they become sorted.

+

Well, that was then. This program is the 21st century version of the +Fifteen Puzzle: not only does it allow arbitrary board sizes, it also +supports 3D boards! The tiles are numbered from 1 to N, where N +is one less the number of spaces on the board, and the goal is to +rearrange them so that they appear sorted in the order they appear on +the screen.

+

The program takes 2 or 3 arguments, specifying the dimensions of the +board. For example, to play the original version of the Fifteen +Puzzle:

+
./anon 4 4
+

To play with a 3D board, do something like this:

+
./anon 3 3 3
+

WARNING: do NOT run the program with more than 3 command-line +arguments. This will trigger a bug that will cause it to crash or do +something strange. :-)

+

Also, resist the temptation to create very large puzzles. The program +does not attempt to resize your terminal for you, and will produce +confusing output. It may also crash on you if you insist on running it +with excessively large board dimensions. :-) (10x10x10 is considered a +safe upper limit.)

+

The empty space on the board is represented by a space filled with +# characters instead of digits. To slide the tiles around, +use the following keys:

+
i | Slide the tile above the current empty space downwards.
+j | Slide the tile to the left of the current empty space to the right.
+k | Slide the tile below the current empty space upwards.
+l | Slide the tile to the right of the current empty space to the left.
+o | Slide the tile behind the current empty space forwards.
+n | Slide the tile in front of the current empty space backwards.
+

To quit the game:

+
q | Quit the game.
+

Note that, for example, sliding the tile above the current empty spot +downwards will fill up the empty spot, and create a new empty spot above +where the current empty spot was. Hence, you could think of the movement +keys in terms of how they effectively “move” the empty spot:

+
i | Move empty spot up
+j | Move empty spot left
+k | Move empty spot down
+l | Move empty spot right
+n | Move empty spot forwards
+o | Move empty spot backwards
+

NOTE: as a measure of alleviating +counter-productivity due to addiction to this game, particularly for +those hardcore gamers who insist on solving a 10x10x10 puzzle during +work hours, and also to give an upper bound to user frustration when the +program generates an unsolvable puzzle (which it does roughly half the +time, just to hook you), the program will, after a very large number of +moves (which is system-specific) terminate itself by forcefully +destroying its own runtime stack. This will result in a core dump and/or +an abnormal termination message; but this is a feature, not a bug! +:-)

+

COMPILE NOTES

+

This program complies with ANSI/C99. It uses ANSI terminal control +sequences, and so requires a terminal that understands ANSI sequences, +such as VT100 or xterm.

+

Some compilers may emit lots of warnings about how things ought to be +parenthesized (e.g. gcc -Wall). This is deliberate, since +if everything were parenthesized “properly” the program would fail to +work. It (ab)uses C operator precedence to accomplish some cool hacks. +:-) However, there are no compiler errors. I have tested this with +gcc -pedantic -std=c99.

+

The program also uses stty cbreak. If this breaks on +your system, compile it with -DNO_STTY. The game interface +will be a bit annoying (you will need to hit enter after every key), but +it works.

+

The game requires lots of space on the runtime stack space due to +deep recursion, among other things. :-)

+

See spoilers below for more notes about portability.

+

ABOUT THE CODE

+

Clearly, the author is very, very confused. Although he has broken up +the file into sections labelled with helpful headings, and although he +has left ample whitespace between all those #defines to +make them easier to read, :-) and although he has helpfully formatted +the code with beautiful indentation, something is clearly very, very +wrong.

+

In fact, the closer you look at this code, the more you realize +something is horribly wrong with it. For example, why is it that the +first statement in main() is a return? What do +all those nested do loops do (pun intended)? Why is the +first statement inside the first do loop a mere integer +literal? Why are there such strange statements, like that empty string +on line 65, or that isolated || on line 68?

+

But wait… why aren’t any statements terminated by semicolons? Why is +there only ONE semicolon in the entire program?! Why is the author +opening nested blocks by such strange things as || and +(, and closing them by || and ))? +The for loop isn’t a for loop! The +do loop isn’t a do loop! Or… are they? Well, +the for loop is defined in terms of a while +loop. But wait, the while loop is defined in terms of the +do loop. And the do loop is defined in terms +of … Huh???

+

And that switch statement toward the end of the program… +wait a minute, that’s not a switch statement! Why is a +case defined in terms of a switch statement?! +And that initial return isn’t a return! Well, it is… but not what you +might think!

+

Let’s see if it all makes sense after we run it through CPP…

+

Uh oh. The result looks like the diseased imagination of a mind more +confused than the one who wrote the original code. Unfortunately, unless +you’re a Lisp expert, it is probably easier to understand the program in +its original form. (And even then.) But that’s just so, so wrong…

+

The entire program consists of a single expression, returned from +main(). There are no if statements, no +for loops or any looping or control constructs besides the +return, in spite of the misleading appearance of the +original source. :) Yes I know, this has been attempted before, using +?: and the bad old comma operator. BUT this program does +NOT use the ?: operator, and there are only TWO comma +operators in the entire program–and they are only there because +srand() and exit() return void.

+

The entire program consists of a single boolean expression returned +from main(). Looping is achieved by recursion, of course, +and branching is achieved by exploiting short-circuit evaluation of +boolean expressions. :-)

+

But this is not all.

+

It is comprehensible that the program can achieve branching and +looping using only boolean expressions and recursion. But HOW does the +program STORE DATA??? There are no variables of any kind in the program +except for the two arguments to main(). There are certainly +no arrays declared anywhere. The program does not call any memory +allocation routines, nor any function that indirectly returns allocated +memory. Yet it happily looks up array references without crashing. +How??

+

One might be tempted to think that this program would be highly +non-portable because of such insane hacks. However, it has been tested +and proven to work on the following architectures:

+ +

It probably will also compile and work on many (all?) other *nix +platforms as well. How does it achieve this incredible feat?

+

SPOILER

+

Read the following only if you give up figuring it out :-)

+

The Evil Hack

+

The program (ab)uses an implicit assumption underlying practically +all architectures, and that is that parameters to C functions are +implicit local variables allocated on the runtime stack. This runtime +stack is a contiguous section of memory, and therefore, after +N recursive calls of main() to itself, there +is enough room on the stack to store whatever the program desires, so +long as it does not exceed the maximum stack size.

+

(Theoretically, the runtime stack doesn’t have to be +contiguous… but all current architectures that are worth consideration +make this assumption. I submit that this implies this program is 100% +portable, even though theoretically it shouldn’t even work in the first +place.) :-)

+

There are two types of architectures the program must handle: those +that allocate the stack top-down, and those that allocate the stack +bottom-up. The program correctly detects this at runtime, and adjusts +itself accordingly. :-) (It is a simple matter of testing if the address +of argc in a recursive call is greater or less than in the +parent call.)

+

To avoid having to handle issues of int sizes, memory +alignment, what exactly is on the stack between successive locations of +argc, etc., the program (ab)uses the fact that +argc must necessarily be allocated on an aligned address, +and therefore, the range of memory between two argcs is +aligned, and therefore safe to use as an array of longs.[*] +The program also compares the pointers as long* pointers, +so that it will not have to deal with mapping bytes to larger types. The +initial memory allocation is done by recursively calling +main() until there is enough space on the stack (the exact +number of recursive calls is, of course, architecture-dependent).

+

[*] long was chosen instead of int, in +order to skirt around pointer-size issues on architectures like ia64. It +really can be made anything large enough to hold both ints +and pointers. :-)

+

After the stack is deemed to have grown deep enough to be a +sufficiently long array (pun intended), the program begins +its real code. It uses argc to keep track of what it’s +supposed to be doing (since main() is the only function), +and argv to point to the base of this array (which is +computed differently based on how the architecture allocates the stack). +Since this fills up the only two variables in the program, everything +else is stored in the MASS [**] array.

+

[**] for “Memory Allocated by Stack Smashing” :-)

+

Note that from this point on, all bets are off as to what the +contents of the runtime stack are below the current recursive call to +main(). We are overwriting frame pointers, return +addresses, etc., with data. Hence, the program must never return from +this call, otherwise it will crash horribly. That’s why I had to call +exit() even though it meant I can no longer claim the +program doesn’t need the comma operator. :-) (I was going to skirt +around the issue by indirectly calling exit(), such as via +bsearch() or raise(), but I was getting too +close to the size limit.)

+

Some notes about the macros

+

In spite of the frightening appearance, it is probably easiest to +understand the code in its original form. (Don’t even try running +indent on it: on my system it chokes and complains about +nesting errors.)

+

Most of the #defines are just to keep the code size +down, due to the abusive amounts of type casting employed. The others +define a bizarre “programming language” (in the crudest, most twisted +sense of the word) that the author used to write this mess.

+

R(i) and W(i,j) are macros to read/write +the ith position of the MASS.

+

A(i) retrieves the ith command-line +argument. This is slightly tricky, because by the time the +MASS is setup, we no longer have access to the original +values of argc and argv. So what is done is +that the initial memory allocation code will save argc and +argv into positions 8 and 9 in the MASS after +the allocation. It does this by using argv, which at that +time contains a pointer to the top-level argc, to compute +the location of the top-level argv. This is done before the +rest of the MASS is used, since otherwise they may be +overwritten.

+

do(x,y) has nothing to do with do loops. +:-) It defines a “state” in main(), essentially, what to do +when main() is called with argc containing a +particular value. (This is why the user must never run the program with +more than 3 arguments. :-) The state number is x, and +y is the code. The program’s boolean expression consists of +a number of states &&d together. Within each state, +it is assumed that statements are separated by ||. All +statements are assumed to evaluate to false. This makes it easy to write +conditional statements: if (a) { b } ... can simply be +written a && b || .... All states created by +do(x,y) are assumed to evaluate to false. There is only 1 +state which can return true or false: state 5, a “manually-implemented” +state which determines whether the system uses top-down or bottom-up +stack allocation. It’s the only state that needs to return a value from +the boolean expression, since once the MASS is initialized +any return value can simply be stored in a well-known location in the +MASS.

+

if(p,q,r,s) is, in fact, an if statement. +:-) It is equivalent to:

+
if (p) { q; r } else {s}
+

Why are q and r split up? Because it’s +cleaner (in whatever twisted sense of the word that can be applied to an +IOCCC entry) to implement using boolean expressions. Keep in mind that +all statements are assumed to evaluate to false. The proof that this +macro in fact implements an if-then-else construct is left +as an exercise for the reader.

+

while(x,y,z) is actually a while loop after +all. :-) It implements the loop using, of course, recursive calls to +main(). However, this macro doesn’t actually run a +while loop; it implements the loop in the state numbered +x. It is used for defining a while loop, which +can then be called from another state using f(x). (The +reason we can’t directly implement a while loop inside +another state ought to be clear: we can’t recursively call +main() to enter into the middle of a state.)

+

However, it is possible to implement a for loop +directly inside a state! The for(s,i,x,y,z,Z) macro does +exactly this. Well, actually, technically speaking this macro can only +be used as the last thing in a state, because it secretly closes the +current state and opens a new one behind the programmer’s back. :-) Its +intended usage is this: s is the state number for the loop +body, and i is the index variable (well, the index into the +MASS of the index variable); x and +y-1 define the starting and ending values of +i, and z is the loop body. Z is +the post-loop code in the current state. For example:

+
for(s,i, 0, 10,
+some_code       ,
+other_code)
+

is equivalent to:

+
for (i=0; i&lt;10; i++) {
+    some_code;
+}
+other_code;
+

Note the “wrong” indentation in the former: the author prefers to +write it that way, since the analogy to the usual for loop +is clearer. This is why it’s easier to understand the pre-CPP code, +since after CPP, the macro reshuffles some_code after +other_code so that it can close the current state and +define the one containing the loop body. (Have I told you that the +author of this program is horribly, horribly, confused? :-) This +confusion also shows up in the superficial appearance of the program, +which heavily suffers from wrong indentation.)

+

In spite of all appearances, switch() really is just a +shorthand macro for reducing code size. The evil choice of macro name is +just to instill more confusion into the would-be decipherer of this +entry. :-) After all, case() really is the +equivalent of a case statement, implemented using +&&, and conveniently encapsulating code common to +the cases in the only switch statement in the program, +which is the code that decides what to do with a key press. What could +be more fun than to define such a case in terms of a +switch? :-)

+

Finally, for those who give up deciphering this horribly confused +code, here are the mappings of various locations of the +MASS to their usage in the program, and what the various +state numbers are meant to do:

+

MASS usage map

+
0  | Function return value
+1  | Function argument 1
+2  | Function argument 2
+3  | Function argument 3
+4  | Scratch register 1
+5  | Scratch register 2
+6  | Scratch register 3
+7  | Scratch register 4
+8  | Value of original argv :-)
+9  | Value of original argc :-)
+11 | Zero register (always set to 0)
+12 | Width of board
+13 | Length of board
+14 | Height of board
+15 | Current position of hole
+16 | Random seed for rand_r(3)
+18 | Scratch register used by state 18 :-)
+31 | field width for printing tiles
+32 | Start of board data
+

(CAVEAT: not all of these mappings ended up in the +final version of the program, mainly due to size limitations which +entailed the trimming off of a lot of neat features in the game. It is +left as an exercise for the reader to figure out which of these are +actually used.)

+

Note that argv and argc necessarily need to +stay away from lower indices of the MASS, because otherwise +they may overwrite their original values when the memory allocation code +saves them. Index 8 is deemed “safe enough”. (It seems to be on all +tested architectures.)

+

State number assignments

+
1  | showhelp
+2  | showhelp
+3  | is 2D: start init
+4  | is 3D: start init
+5  | find allocation type
+6  | MASS init, bottom-up
+7  | MASS init, top-down
+8  | main program
+9  | generate() outer loop
+13 | render()
+14 | render() loop
+15 | exit(0)
+16 | pick a tile that hasn't occurred yet
+17 | inner loop of 16.
+18 | main loop
+19 | checkwin() loop
+

Note that some of the manually-implemented states (those not +implemented by do()) respond to multiple state numbers. +Also note that states 1-4 conveniently correspond to what the program +should do when 1-4 arguments are given at the command-line. :-)

+

The original intention was to include a parity-checking routine in +the game so that it will always generate a solvable game. However, size +limits necessitated the removal of this code. And besides, the game is +more addictive when it’s sometimes unsolvable. Especially when it taunts +the user with a smiley. :-)

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2005/anon

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2005/boutines/index.html b/2005/boutines/index.html index 1033e1fe3..e069bf816 100644 --- a/2005/boutines/index.html +++ b/2005/boutines/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,325 @@ - - + + + + + + - - -2005 boutines - - + + + +2005/boutines + + + + + -

2005 boutines

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2005/boutines

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2005/boutines/index.html

- +
+ ← anon + ↑ 2005 ↑ + chia → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Francois +Boutines
Location: FR

+ + +

To build:

+
make
+

To use:

+

You will need an SVG viewer. +Look here to find some SVG +Viewer Implementations.

+

The following will create an SVG file:

+
ruby -e '20.times{puts "#{rand} #{rand}"}' | ./boutines > test.svg
+

Try:

+
./boutines < input.txt > result.svg
+

After running the above commands, use ImageMagick’s +convert tool to convert the images to a png file:

+
convert test.svg test.png
+
+convert result.svg result.png
+

and then open it with your preferred graphics viewer or editor.

+

If you have a program that opens SVG files then +you could open the test.svg file directly. An example +program is Inkscape. See the list +cited above for others.

+

Judges’ remarks:

+

Can you explain the author’s remark “[generated files] are not as +scalable as their name suggests”?

+

Author’s remarks:

+

In memory of my father Pierre Boutines-Vignard.

+

Walk-through

+

My program works as follows:

+

Input

+

A list of 2D points in the unit square.

+

Output

+

A Voronoi +diagram of the set as an SVG stream.

+

This will possibly save a compressed SVG file and may be useful:

+
./boutines | gzip > result.svg.gz
+

Input consists of a list of floating points values separated by +whitespaces (ranging preferably in [0,1]). Alternating a +horizontal coordinate, a whitespace then the other coordinate (pointing +downwards in the resulting graph) and a newline will just go fine:

+
0  0
+0  1
+1  0
+1  1
+.5 .5
+

Strictly speaking, you have to provide a set of +points. If there are duplicates in the list, there is no guarantee on +the one to be shown (in addition their labels will overlap) in the +resulting colored Voronoi +diagram.

+

Caution

+

This program might have been a lot shorter, but nearly impractical +even for medium sized datasets. On the other hand it could have been a +lot faster, but hard to qualify under the IOCCC size limit. So guess +what I did? A compromise favoring innermost obfuscation, sacrificing +sometimes speed and other tedious factors.

+

Therefore this entry is limited to

+
+
+floor(-1) + +
+
+

points and won’t even be suitable for more than a few thousand; +although generated files did pass the W3C SVG +Validator, and are highly compressible, they are not as scalable as +their name suggests… For serious applications about Voronoi +diagrams, see Qhull, CGAL and the like but you may still +encounter large output volumes (and have to handle some sort of clipping +in order to represent properly infinite regions of the diagram in SVG).

+

Beware, compilation may report warnings about precision loss, linting +may be a disaster, but the code should remain portable, and the output +accurate enough for most devices (including many inkjet printers). If +you ever miss precision on a particular dataset or peripheral, you may +want to dive in and let U be the next power of +__LINE__.

+

NOTE: bad inputs will be sanctioned by the production of the 42nd Mersenne prime +(i.e. 2^25964951 -1); memory will be kept.

+

Why I think this code is +Obfuscated ?

+

I’m quite divided on the subject because I wrote:

+ +

Be sure to check the antepenultimate line of code.

+

Missing Features

+

Color control

+

Cell colors are chosen randomly (with a questionable rejection +scheme). It might have been useful to input them along with sites +coordinates, turning the application into a puzzling graphics +engine.

+

Site labelling

+

The points are implicitly numbered in the order they were entered +(starting at one). This can be overridden however, via a simple XSL +transformation.

+

Site radius

+

The site radius is hardcoded in the code, I still wonder why I did +not design it as a function of the underlying cell’s area (which can be +averaged for free) or at least a command line parameter. Same with the +char set, the viewport and potentially every SVG +property.

+

See Also

+ +

Example Output

+
+
+ + +
+
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2005/boutines

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2005/chia/index.html b/2005/chia/index.html index 5ad2828cd..4a2d35e8c 100644 --- a/2005/chia/index.html +++ b/2005/chia/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,225 @@ - - + + + + + + - - -2005 chia - - + + + +2005/chia + + + + + -

2005 chia

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2005/chia

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2005/chia/index.html

- +
+ ← boutines + ↑ 2005 ↑ + giljade → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: V. Chia
Location: SG

+ + +

To build:

+
make
+

To use:

+
./chia
+

Judges’ remarks:

+

Have you had your morning cup of Java? You might want a second cup +before parsing this entry. And give your C pre-processor a triple shot +as it tries to handle parameters for “stringification”.

+

Author’s remarks:

+

Two things inspired this entry. First, there were the C programs +which were #define’d to look like Pascal +or Visual +Basic: the /bin/sh code from +V7 Unix +(which reportedly was the motivation behind this contest!), the VAL Linker by +David Troendle, the 2000/primenum IOCCC entry, … +Looking at these programs, I thought, “hmm… if it’s possible to make C +code look like some weird cross between Pascal, VB, and COBOL, then how +about making C code look like some other language?”

+

As chance would have it, I was writing some Java +code at that time, and one of my net friends was also working on someone +else’s Java code. We both hated Java; indeed, I hated Java so much that +I was tired of hating it. Then I remembered my earlier idea: “Of course! +Why not write C code that looks like Java? And poke fun at Java while +I’m at it? All ye behold, as I turn anger into action! PH34R MII!!!!!!!” +And so, this entry was born. :-)

+

Besides carrying a revolutionary message in the comments, this entry +also draws a spiffy little Koch snowflake +fractal on the screen, with the help of ANSI escape +sequences.

+

The code requires a preprocessor that can stomach all kinds of +nonsense that are passed as parameters to macros for stringification. +GNU cpp +handles such things just fine, but certain broken preprocessors may +decide to freak out when they see macro parameters that don’t look like +C tokens.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2005/chia

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2005/giljade/index.html b/2005/giljade/index.html index 214590cf8..1b5d0fd9e 100644 --- a/2005/giljade/index.html +++ b/2005/giljade/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,329 @@ - - + + + + + + - - -2005 giljade - - + + + +2005/giljade + + + + + -

2005 giljade

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2005/giljade

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2005/giljade/index.html

- +
+ ← chia + ↑ 2005 ↑ + jetro → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Gil Dogon
+Location: IL

+ + +

To build:

+
make
+

NOTE: We FORCE the use of -O0 even if someone overrides it because +this entry will not work with it enabled.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2005 giljade in bugs.md.

+

To use:

+
./giljade
+

Try:

+
./giljade > out
+

Open an xterm with 78 lines.

+
vi out
+

Press ^F (control F) repeatedly.

+

Self-test feature to try:

+
./giljade > out
+./giljade out
+

Judges’ remarks:

+

This entry takes editorial in how it deals with its output. After +using vi(1) (or vim(1)) to look at the source, +use vi(1) (or vim(1)) to look at its output. +We especially recommend it on a 78 column xterm while leaning on +Control-F.

+

If you really understand expressions, then understand this:

+
s=s^(b=s&s-1^s)
+

… and understand why it is found in the source code.

+

Author’s remarks:

+

So what do we have here ?

+

Just run the executable with no command line args and look at the +output. In order to properly enjoy it you will need two good old +programs: xterm(1) and vi(1) (or +vim(1)). Do the following: open an xterm(1) +with precisely 78 lines, and use the tiny font size for best results. +Then vi(1) (vim(1) will also do) the output. +Type ^F repeatedly or hold it down and enjoy the show …

+

The program solves (very very fast) a sliding block puzzle. There are +many variants of such puzzles which are usually made from wood or +plastic pieces. The start position can be recognized by looking at the +program itself. The goal is to move the big piece (2 by 2) to the center +top, which takes 179 steps in the shortest move sequence.

+

Notice that the step count used by the program is longer than the +traditional step count for such puzzles, as normally if the same piece +is moved twice in a row it is counted as only one step, but here it is +counted as two.

+

The printout of the solution however is in a rather unorthodox form, +as can be easily discerned. As you have probably suspected each of the +steps in the solution printout is a C program which compiles to result +in - surprise surprise! - the original (well almost).

+

Actually, This program is smarter than merely printing ITSELF in 180 +different layouts. It is self-improving, in that the programs it prints +have three advantages over the original:

+
    +
  1. Their layout is more precise (Notice the annoying \ +at the 10’th line of the original program which is actually a ‘layout +bug’).

  2. +
  3. Their binary output does not rely on the source file being in the +same directory, and will not dump core if it doesn’t (like the original +does). :)

  4. +
  5. They have much more comments (Not very helpful ones +though).

  6. +
+

In addition as we all know bugs can creep up on us in the most +unexpected of places, and checking that indeed the output is composed of +180 legal C programs by hand can be quite tedious, hence the program +also include a self- test mode. Just run it with the output file as +command line argument. It will then try to compile each of the programs +(printing the line number where the program starts). It will stop where +any compilation fails and the culprit program would be in the file +c.c. The exit code of the self-test will be non-zero in +that case. In case this entry wins, I do hope nobody by the name of ‘c’ +also wins this year otherwise that part of the program would have to be +changed!

+

Notice that the self-test does not try to run the result of the +compilations but this can easily be done. Try it and diff the output of +any of the 180 results with the original output. Of course all 180 +programs also include the self-test mode.

+

Why I think this program +is obfuscated

+ +

Known +Bugs/problems/warnings/portability issues

+

Some cpps issue a warning about empty macro +parameters.

+

-pedantic informs me that ‘ISO C’ does not allow extra ; +outside of a function, and to this I say to ISO what ???

+

-Wall of course will suggest adding a lot of +parenthesis, function prototypes, and remove some unnecessary +expressions, and to this I say: if I listen to you where is my freedom +to obfuscate in style?

+

As mentioned earlier if you try to run the original program without +its source in the working directory it will dump core.

+

The program relies heavily on the ASCII coding system (have I seen +this comment before ?). It also implicitly assumes that +sizeof(int) = sizeof(FILE *). On systems when that is not +the case expect a core dump…

+

Challenges

+

What use are the ;; for ?

+

Why do I use 126& in the program? (except for the +rather obvious fact that it serves as comment obfuscater).

+

Why not write s^= instead of s=s^ In the +expression I’m most proud of ?

+

What is 40-(h&62) doing ?

+

Use the program to solve for a different starting position. It is not +that difficult. Notice however that if there are more than two empty +spaces the outputs would not compile as the layout would not be +sufficient to contain the program.

+

Use the program to solve for board size different than +4*5. That’s a bit more tricky.

+

Hint for the challenges

+

Just try to change the program, and use the self test to see what +happens …

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2005/giljade

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2005/jetro/index.html b/2005/jetro/index.html index 0ee77af2e..125e068ec 100644 --- a/2005/jetro/index.html +++ b/2005/jetro/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,204 @@ - - + + + + + + - - -2005 jetro - - + + + +2005/jetro + + + + + -

2005 jetro

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2005/jetro

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2005/jetro/index.html

- +
+ ← giljade + ↑ 2005 ↑ + klausler → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jetro Lauha
+Location: FI

+ + +

To build:

+

This entry requires SDL to be installed.

+

See the FAQ for information on how to install +it if you haven’t already.

+

If you have SDL installed:

+
make
+

To use:

+
./jetro
+

Judges’ remarks:

+

We have seen entries with SDL graphics in the past, now it’s time for +SDL sound. This entry can even be run on a computer without a sound card +with an appropriate setting of an environment variable - for that you’ll +have to dig into the SDL documentation.

+

Can you figure out how the notes are encoded and program a different +melody?

+

Author’s remarks:

+

To compile the entry you need SDL library, which is used only for +audio output. To run the entry make sure you have audio output +available. The entry plays 22KHz 16 bit mono music with a small +softsynth. When the music plays, you can stop the application by +pressing enter, as the code will just wait with one call to +getchar() before it quits.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2005/jetro

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2005/klausler/index.html b/2005/klausler/index.html index 400a171da..6a0a2c488 100644 --- a/2005/klausler/index.html +++ b/2005/klausler/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,230 @@ - - + + + + + + - - -2005 klausler - - + + + +2005/klausler + + + + + -

2005 klausler

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2005/klausler

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2005/klausler/index.html

- +
+ ← jetro + ↑ 2005 ↑ + mikeash → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Peter +Klausler
Location: US

+ + +

To build:

+
make
+

To use:

+
./klausler arg1 arg2 | head
+

Try:

+
./try.sh
+

Judges’ remarks:

+

To reduce the size of the source, include other people’s data. That +is what Peter suggests when he describes how to generate a critical +header file.

+

In other words: make use of other words! :-)

+

Rules might have to be changed!

+

Author’s remarks:

+

A useful tool to help one appear extra smart and witty when IRCing, or +even to just be highly annoying.

+

Finds best anagrams for word or phrase given as program arguments. +Use only lower-case letters in these arguments. Output is sorted firstly +in ascending order of word count (fewer words are better) and secondly +in descending order of word length. Pipe the output into +more(1)/less(1)/head(1) and +you’re likely to find the most amusing possibilities in the first few +screenfuls of output. For example, +./klausler fawlty towers | more quickly prints “waterfowl +sty”. The fewer obscure short words in your system’s dictionary, the +better the quality of the output; indeed, all one-letter words apart +from a, i, and s (for plurals) +are ignored when the dictionary is constructed by +make dict.h.

+

Some history and explanation: When I noticed the call for entries in +this year’s IOCCC, I submitted two of them. I worked on the first one +very hard to obfuscate it beautifully, using a goofy algorithm, +wonderful two’s-complement arithmetic tricks, and cute formatting. It +was a glorious work so lovely as to make even strong men weep in +admiration… but it didn’t win anything. On the other hand, this crappy +little other program, which was only mildly obfuscated from its original +hacked form, took home an award!

+

I’m embarrassed to admit that I don’t even know which specific rule +this entry has abused. It’s just yet another anagram generator and it +was written very late one night. And now I honestly do not know how it +works, so please don’t ask. Upon reviewing the program after its +unexpected honor, I guess that it’s remarkable only for its complete +lack of macros, sneaky naming, main() recursion, or other +tricks. Enjoy!

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2005/klausler

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2005/mikeash/index.html b/2005/mikeash/index.html index 9a9f85298..45b621abf 100644 --- a/2005/mikeash/index.html +++ b/2005/mikeash/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,310 @@ - - + + + + + + - - -2005 mikeash - - + + + +2005/mikeash + + + + + -

2005 mikeash

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2005/mikeash

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2005/mikeash/index.html

- +
+ ← klausler + ↑ 2005 ↑ + mynx → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Michael Ash
+Location: US

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2005 mikeash in bugs.md.

+

To use:

+
./mikeash
+

NOTE: the author stated that they tested this under i386 machines but +this works under 64-bit (x86_64, arm64) machines too.

+

Try:

+
./try.sh
+

Judges’ remarks:

+

Having problems speaking code? Do you LISP? +Parenthetically speaking, this entry takes advantage of C99 features, +while speaking parenthetically. Best of all, it self-reproduces!

+

John McCarthy might not have imagined it quite like this! :-)

+

Author’s remarks:

+

This program is a self-reproducing program, which is on the IOCCC’s +list of discouraged program types. Worse, it’s a self-reproducing +program written in Common Lisp. What’s +this doing as an entry to the IOCCC?

+

Start over: this program, when compiled with a C99 compiler, is an +interpreter for an extremely limited and highly broken subset of Common Lisp.

+

It requires C99 because of C99’s ability to declare +variables in the initializer of a for loop. Unfortunately, +C99 mode typically warns about implicitly declared functions, and +preprocessor directives prevent the program from being valid Common Lisp. As a +result, several warnings will be printed about implicit declarations of +functions. There are also warnings about unknown escape sequences in the +constant string, due to different string escape semantics in C and Lisp, +and some implicit integer-to-pointer conversions due to the +implicitly-declared functions.

+

Try:

+
echo '(format t "~s" (+ 2 2 ))' | ./mikeash
+

You should see 4" echoed on your command prompt. The +" after the 4 and the lack of a newline are due to the +somewhat broken implementation of the format function. More +sophisticated arithmetic expressions may be used:

+
echo '(format t "~s" (* (+ 2 2 ) (- 5 (/ 9 3 ))))' | ./mikeash
+

This evaluates the expression (2+2) * (5 - 9/3) giving +the correct result, 8" (with the same issue of no newline +after the "). Note that due to the highly ad-hoc nature of +the tokenizer, the spaces before the closing parentheses are +mandatory.

+

The program can also be run in an interactive mode, by simply +executing ./mikeash and then typing lisp expressions, but +this is difficult due to the lack of proper editing facilities and the +total lack of error recovery in the interpreter. Typos will most likely +crash the program.

+

Aside from being required to put spaces between tokens and closing +parentheses, there are other limitations on the dialect of Common Lisp that +this program understands:

+ +

Basically, the LISP +interpreter is good for some basic math operations, and for running +itself. To do the latter, try this:

+
./mikeash < mikeash.c > mikeash2.c
+diff mikeash.c mikeash2.c
+

The program can also be run from an implementation of common lisp. To do +this, run the common lisp compiler and then type the following +command:

+
(load "mikeash.c")
+

The source code of mikeash.c will be +printed.

+

Obfuscation

+

Lispob is obfuscated in several ways. First, it’s +actually two programs in one, which actually share a small amount of +code. Running a C code beautifier will destroy the LISP +program contained within. Second and more importantly, it is very badly +written, which will presumably confuse people who are used to looking at +well-implemented interpreters.

+

The program comes in at just under 2k of significant characters. +However, this size is exaggerated, because it contains a complete copy +of itself for the self-reproducing LISP +program, making it twice the size. This doubling effect made it +something of a challenge to fit inside the IOCCC’s size limit.

+

This code should be highly portable. It was tested under Mac OS X and +Linux on i386, but it should run elsewhere. It requires ASCII due to +hardcoding various character constants. Other than this requirement, it +should run anywhere there’s a conforming C99 compiler and a standard C +library.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2005/mikeash

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2005/mynx/index.html b/2005/mynx/index.html index ce53f141d..51a3aec9c 100644 --- a/2005/mynx/index.html +++ b/2005/mynx/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,274 @@ - - + + + + + + - - -2005 mynx - - + + + +2005/mynx + + + + + -

2005 mynx

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2005/mynx

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2005/mynx/index.html

- +
+ ← mikeash + ↑ 2005 ↑ + persano → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Anthony C. +Howe
Location: CA

+ + +

To build:

+
make
+

There is an alternate version that scans for (ONLY scans) +the string https as a starting point. See alternate code below.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2005 +mynx in bugs.md.

+

To use:

+
./mynx http://<domain>
+

You can specify a port by appending to the domain :port. +See notes below on the issue of https.

+

Try:

+
./mynx http://www.textfiles.com
+
+./mynx manual.html
+

Alternate code:

+

Obviously this will not work with https as it only scans +for http in the URL (if not specified it tries to open it +as a local file). But even if it scanned for https one +would need to do more work as it would have to set up a secure +connection before http commands could be sent. Fortunately or +unfortunately many more websites use https so this entry will not work +as well as it used to. If one were to try and connect to https://ioccc.org with this +entry they’ll just get a 301 error.

+

The alternate code is a starting point that scans for +https too (note you have to specify the port in this case) +but that is all it does. It will not work with https websites as it does +not set up a secure connection. But should anyone wish to either come up +with a pipeline (or some other command line) that allows it to work with +https or to update the code to support https they may. Otherwise you +must just appreciate the entry for what it once was.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use mynx.alt as you would mynx. You’d have +to specify a port at the end of the URL like:

+
./mynx.alt https://www.ioccc.org:443
+

but again unless you have a clever workaround or hack to the problem, +this sadly won’t work.

+

Judges’ remarks:

+

This little mynx will give any Fiery Fox a run for its +money. A nice complement to last years winning hibachi. The judges double dare +any eager Obfuscationalists to submit the missing pieces to get a +functioning LAMP stack.

+

Author’s remarks:

+

I was rather impressed by last year’s mini webserver. So much so that +it inspired me to try my hand at writing the client side complement.

+

A typical build command would be:

+
cc -o mynx mynx.c
+

While some others like to be a little different:

+
cc -o mynx mynx.c -lnsl -lsocket
+

I even managed to figure out a basic configure script, given last +year’s example, which is kinda of useful when you consider how many OSes +put all the network functions in a variety of places. So a simpler build +command sequence would be:

+
cd source ; ./configure ; make
+

After which, the rest of the documentation can be read by saying:

+
./mynx ../manual.html
+

Manifest:

+
mynx.c
+makefile                pre-built generic Unix
+README.md
+manual.html
+makefile.in             makefile template
+entities.txt            ISO 8859-1 entites
+configure.in            configure script description
+configure               pre-built configure script
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2005/mynx

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2005/persano/index.html b/2005/persano/index.html index 4f8242bab..cc10f8cbc 100644 --- a/2005/persano/index.html +++ b/2005/persano/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,304 @@ - - + + + + + + - - -2005 persano - - + + + +2005/persano + + + + + -

2005 persano

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2005/persano

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2005/persano/index.html

- +
+ ← mynx + ↑ 2005 ↑ + sykes → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Mauro Persano
+Location: BR

+ + +

To build:

+
make
+

There is an alternate version of this entry which should work for +Windows by setting binary mode on stdout. See alternate code below.

+

To use:

+
./persano p q [num frames]
+

Try:

+
./persano 3 16 > knot3-16.gif
+

Open the GIF file +with a viewer capable of displaying animated GIFs and watch closely at +the bottom of the picture (you may need to use gifsicle - a great tool to +manipulate animated GIFs - to slow down the animation and to compress +the GIFs generated by the entry).

+

Alternate code:

+

This (untested as we have no Windows system) version uses the Windows +API functions _setmode() and _fileno(3) to set +binary mode on stdout which should let it work with +Windows.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use persano.alt as you would persano +above.

+

Alternate try:

+
./persano.alt 3 16 > knot3-16.gif
+

Follow the same instructions, using different tools if necessary, as +the above try section.

+

Judges’ remarks:

+

If your system is one of those that distinguish between text and +binary streams, you must know what to do to switch the standard output +into binary mode (e.g., adding a line to the source code or specifying a +linker option).

+

What needs to be done to fix the problem?

+

Solving the author’s exercises below may or may not help.

+

At the time of judging, the approximation of π used in the program could +not be found on https://mathworld.wolfram.com.

+

Author’s remarks:

+

knot writes animated GIF images of rendered torus knots to +standard output.

+

SYNOPSIS

+
./persano p q [num frames]
+

DESCRIPTION

+

A (p,q)-torus knot is a +closed, non-intersecting curve on the surface of a torus in R3 that winds +p times around one cycle of the torus and q +times around the other. p and q should be coprime; +otherwise, the resulting curve will not be a knot (that is, +imagining the resulting curve as a loop of rubber, there will be a way +to bend, twist and stretch it, without cutting it 1, +until it ends up looking just like a circle embedded in R3 2).

+

Sample usage:

+
./persano 3 2 1 > foo.gif
+

writes a non-animated GIF (a single frame) stream of a rendered +trefoil knot to the file foo.gif.

+
./persano 5 2
+

writes a GIF stream with a rendering of Solomon’s Seal +knot to standard output; since the number of frames is not +specified, an animation with 40 frames will be written.

+

Please view the code with 8-character tabs!

+

OUTPUT FORMAT

+

The program writes fully valid GIF 89 streams.

+

It is suggested that the output be viewed with a program capable of +displaying animated GIFs, such as almost any graphical HTTP browser.

+

Due to code size constraints, full LZW +compression was not implemented 3. In fact, the output +images are even somewhat expanded, thanks to GIF overhead.

+

The GIF format supports only a limited number of bits per pixel, so +the program uses ordered dithering to emulate full RGB output.

+

PORTABILITY

+

The program was tested on Linux, with gcc 3.1; Cygwin, with gcc 3.3; +and Solaris/SPARC, with Sun’s C compiler.

+

The only major portability issue should be reliance on ASCII.

+

It should also be mentioned that the program won’t work on systems +that distinguish between text and binary streams; however, since hardly +anyone uses such systems in this day and age, this is a minor issue. 4

+

EXERCISES FOR THE READER

+
    +
  1. (1 point) The surface is composed of many small polygons. Try to +make it smoother by increasing the number of polygons.

  2. +
  3. (2 points) Figure out how to change the radius of the tube cross +section.

  4. +
  5. (5 points) Locate the famous transcendental constant π in the code.

  6. +
+

FOOTNOTES

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+
+
+
    +
  1. You can call such a transformation an “ambient isotopy” +if you want to impress people at parties.↩︎

  2. +
  3. Also known as the “unknot”, which sounds slightly less +impressive than “ambient isotopy”.↩︎

  4. +
  5. Unfortunately (for the author), the convenient excuse +that LZW compression was not implemented in order to avoid the Unisys +patent can no longer be used.↩︎

  6. +
  7. ;)↩︎

  8. +
+
+ + +

Inventory for +2005/persano

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2005/sykes/index.html b/2005/sykes/index.html index 3a4dddfab..b301a81dd 100644 --- a/2005/sykes/index.html +++ b/2005/sykes/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,433 @@ - - + + + + + + - - -2005 sykes - - + + + +2005/sykes + + + + + -

2005 sykes

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2005/sykes

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2005/sykes/index.html

- +
+ ← persano + ↑ 2005 ↑ + timwi → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Stephen Sykes
+Location: FI

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2005 +sykes in bugs.md.

+

To use:

+
./sykes binary_file
+

Try:

+
./try.sh
+

Judges’ remarks:

+

For those who fondly remember their first PET, this entry +will start you down memory lane … starting with $C000 of +course!

+

We encourage you to try and grok the obfuscated expression on line +56, after the C pre-processor gets finished with it!

+

We downloaded the ROM contents to use +the emulator in PET mode as +follows:

+
wget http://www.zimmers.net/anonftp/pub/cbm/firmware/computers/pet/basic-2-c000.901465-01.bin
+wget http://www.zimmers.net/anonftp/pub/cbm/firmware/computers/pet/basic-2-d000.901465-02.bin
+wget http://www.zimmers.net/anonftp/pub/cbm/firmware/computers/pet/edit-2-n.901447-24.bin
+wget http://www.zimmers.net/anonftp/pub/cbm/firmware/computers/pet/kernal-2.901465-03.bin
+

We then created:

+
dd bs=2k count=1 if=/dev/zero of=nullfill.bin
+

For your convenience, we have added the above mentioned files to this +entry directory. They were used to form the pet.rom +file.

+

Author’s remarks:

+

This program is not only a complete Motorola +6502 processor emulator, but also an +emulation of the Commodore PET +2001.

+

This is the second version of the same entry, but this one takes care +to not include any possibly copyrighted items in the info files, to be +sure to not infringe the rules.

+

Test

+

Compile the program, then test the 6502 +emulation like +this:

+
./sykes 6502test
+

A basic test is done for each instruction and addressing mode, all +tests should pass. At the end of the tests, it loops forever - break out +with control-C.

+

PET EMULATION

+

Cast your mind back to 1977… a little company called Commodore +introduced the PET, the Personal +Electronic Transactor.

+

The machine was +a hit, and history +was made.

+

Now you can relive those wonderful times with this PET emulator!

+

Make sure you have a terminal +window of 40x25 chars or bigger, and then run the emulator like +this:

+
./sykes pet.rom
+

You should see the startup message. Try typing in some BASIC - for instance:

+
PRINT "HELLO, WORLD"
+

There is an optional numeric parameter, which controls the speed. For +a slower cursor blink, try

+
./sykes pet.rom 6
+

and for faster

+
./sykes pet.rom 2
+

The default is 4.

+

The control keys are as follows:

+
^A HOME
+^L CLR
+^R RVS
+^E OFF
+^Y INST
+^X STOP (break)
+^F cursor forward
+^B cursor back
+^N cursor down
+

Supplied also is a short demo program written in BASIC. Try typing

+
LOAD "DEMO"
+RUN
+

Many other old programs will run in this emulator too. Files with a +.PRG extension should work. (Look, for instance, here: http://www.zimmers.net/anonftp/pub/cbm/pet/ALLFILES.html,
+or try this one: http://www.zimmers.net/anonftp/pub/cbm/pet/games/english/dungeon.prg)
+The filenames must be upper case in order to be loaded by the +emulator.

+

You can save programs too - try

+
10 PRINT "HELLO!"
+SAVE "HELLO"
+NEW
+
+LOAD "HELLO"
+RUN
+

You also might try typing this to see an ancient Easter +egg:

+
WAIT 6502,12
+

6502 EMULATION

+

The program is basically a 6502 +emulator, and it +does NOT need the Commodore ROM to work.

+

Supplied as a demonstration is a compiled-for-6502 +version a chess program (heh, I found a use for a previous losing entry +:) ). Try:

+
./sykes chess
+

It works as you would expect (it plays very badly). There’s no +castling or en-passant, and to win you must actually take the opponent’s +king.

+

You can write your own programs too, any 6502 assembler +should work.

+

The emulator +loads the supplied file at $C000, and starts execution from +that address also (the reset vector is ignored).

+

The screen memory begins at $8000, and is +40 columns * 25 rows. Key presses appear when they occur in +memory location $A2, and are ORed with +$80 - this is a way of indicating a fresh character. The +program can frequently check this byte, and when it sees a new +character, it can AND it +with $7F to indicate that it has been read.

+

The 6502 +emulator receives +an interrupt 60 times a second or so, you may want to disable interrupts +(with the SEI instruction) if you do not need this.

+

In 6502 +emulation mode the +special PET +character codes are not used and the screen understands normal ASCII.

+

Lastly, before emulation starts, the +low byte from a time(3) call is placed at address 0 - this +can be used as a random seed.

+

Technical description

+

Most of the program comprises the 6502 +emulator. +curses is used for the screen and keyboard handling.

+

Much of the obfuscation comes from the need to squeeze in the 6502 +emulation as well +as faking enough of the PET hardware for +it to work.

+

If the supplied file is exactly 16384 bytes, the emulator assumes it is +a PET ROM, and goes into +PET emulation mode. Otherwise some PET specific features are skipped +during normal 6502 +emulation.

+

The main processing all happens in a heroic expression containing no +less than 64 ternary operators (after cpp) starting on line +56. This decodes the 6502 +instructions according to a table and executes them.

+

The addressing mode is decoded in a similar expression starting on line +53.

+

Bugs

+

The machine emulated is an older 40 column PET, so 80 column +programs will not show correctly.

+

There is no emulation of PET graphics +characters.

+

The parameter controls the speed of the 60Hz “jiffy clock”, and not +the processor speed. This means many games may run too fast to be usable +- it really depends on the speed of your machine.

+

Although the PET emulator can do +LOAD and SAVE, it cannot VERIFY +or OPEN and CLOSE files.

+

The PET +hardware emulation +is not at all complete - features such as the hardware timers are +completely missing. Some programs will not run correctly.

+

The 6502 +emulation does not +include the seldom used decimal mode, or any of the “undocumented” +instructions.

+

IMPORTANT NOTE

+

I think it is great fun to run the PET emulation and mess +around with Microsoft BASIC. However, this +obviously needs the ROM file to work. My +program is original and completely free of any copyright, but, of +course, the pet.rom is not my work. So I ask the user to +download it from the Internet. This is to avoid directly infringing any +copyright.

+

Finally

+

What does this do?

+
./sykes pet.rom -1
+

Have fun!

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2005/sykes

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2005/timwi/index.html b/2005/timwi/index.html index 6612851c7..f96378736 100644 --- a/2005/timwi/index.html +++ b/2005/timwi/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,246 @@ - - + + + + + + - - -2005 timwi - - + + + +2005/timwi + + + + + -

2005 timwi

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2005/timwi

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2005/timwi/index.html

- +
+ ← sykes + ↑ 2005 ↑ + toledo → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Arne Timwi +Heizmann
Location: DE

+ + +

To build:

+
make
+

To use:

+
./timwi < bf_program
+

Try:

+
(echo "20 : ,-->+.>+.<<[>[>>+>+<<<-]>[>>+>+<<<-]>"; echo "[<+>-]>[<<<+>>>-]>[-]<<<<.<-]") | ./timwi
+

Judges’ remarks:

+

Unlike most BF +interpreters that we have been receiving for the last few years, this +one, in our opinion, is the most obfuscated albeit the most discourteous +to the language it interprets. A simple 3-character fix will make it +slightly less so.

+

Quite a few BF programs found on the Net expect byte-based memory, +quite a few exceed the capacity of this interpreter, but there are many +that work. Some small quines work, +some don’t.

+

Why?

+

Author’s remarks:

+

This is an interpreter for the programming language BrainFuck (BF).

+

Input must be provided in the following format: First a sequence of +integers separated by whitespace (this will be the input to the BF +program), then a : (colon), then the BF program itself.

+

You must not pass any command-line arguments.

+

Features

+ +

Limitations

+

Since the program, naturally, uses ints, the +calculations must not exceed the range of an int. (But then +again, you can use the integer overflow to further obfuscate your BF +programs in creative ways!)

+

You are limited to 3125 input integers and 3125 instructions. If you +exceed one of these limits, the behaviour is undefined.

+

Obfuscations

+

Some of the superficial obfuscations are pretty obvious: I’m using +#defines to make everything look nice and lineal, and the +program is merely a recursive main() function with only a +single return statement which uses nested ternary operators +to make even the pre-processed code unreadable.

+

However, the more subtle obfuscations relate to the way the program +works. After applying the pre-processing, you will see a lot of +1+1+1…etc., and even if you replace these with their +result, those numbers will still not represent (or even relate to) the +ASCII codes of the BF instructions.

+

The program will first read in all the input integers, but it will +begin execution immediately and only read program instructions as they +are needed. Yet there is no global variable storing how far it has read! +Perhaps the hardest thing to figure out is how it finds the matching +square brackets.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2005/timwi

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2005/toledo/index.html b/2005/toledo/index.html index d0e65879c..e1c968f3d 100644 --- a/2005/toledo/index.html +++ b/2005/toledo/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,300 @@ - - + + + + + + - - -2005 toledo - - + + + +2005/toledo + + + + + -

2005 toledo

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2005/toledo

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2005/toledo/index.html

- +
+ ← timwi + ↑ 2005 ↑ + vik → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Oscar Toledo +G.
Location: MX

+ + +

To build:

+
make
+

To use:

+
./toledo [a ...]
+

Try:

+
./toledo a
+./toledo a b
+

Alternate code:

+

Two alternate versions of this entry, toledo2.c and toledo3.c are +provided.

+

Alternate build:

+

To compile the alternate versions:

+
make alt
+

Alternate use:

+

Use Use toledo2 and toledo3 as you would +toledo above.

+

Judges’ remarks:

+

Challenge yourself with your ability to look 5, 6 or more moves +ahead. Challenge your knowledge of C operator precedence. The following +is the move analysis via recursion while it executes moves. All while +playing by the rules of C and Chess within a single function!

+

Historical note:

+

When this entry was submitted the code was a recursive call to +main() - that was it. In 2023 due to problems with +clang main() calls another function, +pain(), which calls itself. But it might be said that the +Chess is still a single function.

+

Author’s remarks:

+

What does this program

+

This is a chess +program, it can work in two modes: two-players, and one player (always +white) against the machine. To get the first mode, run the program +without arguments:

+
./toledo
+

The other mode is accessible running the program with one argument +(5-ply +analysis):

+
./toledo a
+

Two arguments for 6-ply +analysis:

+
./toledo a b
+

And each successive argument will analyze one ply more. +There is no ply limit, but beyond 7 ply is very slow, try it at your own +risk and computing time.

+

Entering movements

+

When it is your turn, you can enter your move, for example, as +d2d4 and press the enter key. This will move the pawn at +D2 to D4, assuming that a pawn is there (as it +would be in the beginning). The computer will check move legality and +will warn you of illegal moves. All legal chess moves are permitted.

+

One special case is when you are doing promotion, you must enter the +move with an extra letter indicating the desired piece.

+

For example f7f8n (supposing you have a pawn on +F7), will promote it to a knight; substitute n +for the desired piece +(N/Q/R/B).

+

Note that the program requires the piece letter; it will not select +automatically a queen, so don’t be surprised if it doesn’t accept your +move.

+

Game status

+

The computer will check for checkmate and stalemate. Also, after each +machine move, it will show the score of the position: a higher number is +better for the computer, i.e. worse for you.

+

Quirks

+

None.

+

Program operation

+

This is a good example of a chess program reduced to the essential. +In order to get it into the contest limits, I used short but slow and +unintelligible algorithms.

+

The interface accounts for only a fraction of the code, the core does +multiples functions: it is called recursively to analyze and evaluate +each ply, +does alpha-beta +pruning, move generation, machine playing, check detection, illegal +move verification and does moves after they are verified.

+

It also sets a standard on ultra-mini-chess programs. The player and +the computer can do all legal chess moves.

+

Additional features

+

Other features are:

+ +

Obfuscation tricks

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2005/toledo

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2005/vik/index.html b/2005/vik/index.html index 02c84d657..aed0dacf0 100644 --- a/2005/vik/index.html +++ b/2005/vik/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,291 @@ - - + + + + + + - - -2005 vik - - + + + +2005/vik + + + + + -

2005 vik

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2005/vik

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2005/vik/index.html

- +
+ ← toledo + ↑ 2005 ↑ + vince → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Daniel Vik
+Location: US

+ + +

To build:

+
make
+

To use:

+
./vik [file.map]
+

Try:

+
./vik maze.map
+

Judges’ remarks:

+

An amazing use of the X libraries with twisty code passages, all +different. One risks running in code path circles as main() +is called again and again. Be sure to pay attention to commas! :-)

+

Author’s remarks:

+

This entry is a Wolfenstein style +graphics +engine where a user can navigate in a 3D world. +The maze has walls with +bitmap +textures. The application contains a default world with textures, +but the power of the engine is exposed through user configured maps. User defined worlds +support up to 26 different wall textures that can even be animated. One +example of a user defined world is submitted with the entry.

+

Features

+

This program is a complete 3D engine with

+ +

Build and Run

+

Compile the source code and link in X libraries if necessary. +The program takes three options which have to be typed in a specific +order as described below.

+
./vik [-w <width>] [mapfile]
+

where:

+
width   - Specifies the width of the window
+mapfile - Filename containing a map
+

Examples

+

Start the engine using a built in labyrinth and texture bitmaps:

+
./vik
+

Start the engine and loads the labyrinth defined in the file maze.map:

+
./vik maze.map
+

Start the engine using maze.map in a window +that is 400 pixels wide:

+
./vik -w 400 maze.map
+

Note that the mapfile has to be the last argument and +the -w option if present has to be the first. The map +definition files and the bitmap files should be located in the current +directory.

+

Use the cursor keys to navigate through the labyrinth.

+

Creating mazes

+

A maze consists of a map file and texture bitmap files. The map file +is an ASCII text file where lower case letters represent walls. The +letter tells the engine what bitmap texture file to use. The +* character lets the engine know where to position the +user. The example below shows how a map file can look:

+
aaaaaaaaaaaaa
+a           a
+a      *    a
+a    bbbb   cccccccc
+c                  c
+cccccccccccccccccccc
+

The engine loads the map, and creates walls. When a character in the +range a-z is found, the engine will load the corresponding +texture bitmap. The bitmap file must be named *.bmp where +* is substituted with the letter of the wall in the map +(note that only a, b and c +exist).

+

So to load the map above, the files a.bmp, +b.bmp, and c.bmp should be located in the same +directory as the engine executable (or rather in the current +directory).

+

Obfuscation

+

The program is obfuscated in several ways:

+ +

Compiler warnings

+

There are no compiler warnings when compiling with -ansi +but there are quite a few warnings from lclint. Mainly +because the program is very optimized for code size.

+

Limitations

+

The program only compiles and runs on X based +systems.

+

The program does not run that smooth under Cygwin. It seems to be a +priority issue with Cygwin and it can easily be solved by increasing the +priority of the application a little bit.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2005/vik

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2005/vince/index.html b/2005/vince/index.html index a37797048..aef2df546 100644 --- a/2005/vince/index.html +++ b/2005/vince/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,267 @@ - - + + + + + + - - -2005 vince - - + + + +2005/vince + + + + + -

2005 vince

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2005/vince

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2005/vince/index.html

- +
+ ← vik + ↑ 2005 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Vincent +Weaver
Location: US

+ + +

To build:

+

Before building, make sure that you have the OpenGL development +libraries installed.

+
make
+

To use:

+
./vince
+

Try:

+

When running this in the program’s window try hitting space a few +times and see what happens!

+

Alternate code:

+

The vince.alt.c code of the submission will +run on SGI IRIX and also has the recursive CPP macro (which +sneaked in accidentally) removed.

+

Alternate build:

+

To compile this alternate version:

+
make alt
+

Alternate use:

+

Use vince.alt as you would vince above.

+

Alternate try:

+

Try it just like vince as above.

+

Judges’ remarks:

+

This beauteous entry makes use of visual {}s and +whitespace to instruct the OpenGL +development libraries to create beauteous visuals. Even hitting the +space bar while the program runs produces a “spacey” effect! :-)

+

NOTE: when hitting space bar make sure that the program window is in +focus!

+

Challenge: Try modifying the texture to something of your own +design.

+

Author’s remarks:

+

ABUSE OF RULES

+ +

Requirements

+ +

Background

+

I was annoyed after the last IOCCC because I slaved away on a clever +text based game only to find all of the game winners used X11. X11 isn’t +standard C!

+

So to one up them, I decided to use OpenGL. It’s standard, and most +Unix-like systems these days have either accelerated graphics or else +software rendering.

+

Obfuscation

+

It was a challenge getting the source code below the 2k limit. OpenGL +has way too many ‘GRATUITOUSLY_LONG_CONSTANTS’ and +‘glLongStudlyFunctionNames();’.

+

Therefore, much of the obfuscation comes secondary to just reducing +the code size to fit under the limit while still having some semblance +of a demo.

+

There are some interesting abuses scattered about.

+

Usage

+

Try hitting the space bar when the program is running.

+

For Fun

+

Try modifying the texture to your own custom design…

+

Thanks

+

Many thanks to John Clemens for testing this on various machines for +me.

+

Errors you can get

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2005/vince

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2006/birken/index.html b/2006/birken/index.html index 044f03139..f603983f5 100644 --- a/2006/birken/index.html +++ b/2006/birken/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,279 @@ - - + + + + + + - - -2006 birken - - + + + +2006/birken + + + + + -

2006 birken

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2006/birken

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2006/birken/index.html

- +
+ first entry + ↑ 2006 ↑ + borsanyi → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Michael +Birken
Location: US

+ + +

To build:

+
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.

+

To use:

+
./birken < file.tofu
+

Try:

+
./try.sh
+

etc.

+

Judges’ remarks:

+

Q: EDAMAME?

+

A: Electronic Design Automation - Mechanical Abstract Machine +Emulator

+

What is TOFU? It’s not a veggie friendly food, nor it is Verilog or VHDL It is not even 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 manuals to learn. :-)

+

For a small but non-trivial design, try implementing a Linear Feedback Shift +Register

+

And for those who are still confused, see http://en.wikipedia.org/wiki/Edamame and http://en.wikipedia.org/wiki/Tofu.

+

Author’s remarks:

+

If man is capable of creating tofu hot dogs (simulated +meat), then why not tofu circuitry +(simulated circuits)? This program is my tribute to the early computer +pioneers like Konrad +Zuse. It’s an educational tool designed to introduce students to +digital circuit theory using technology that was considered state of the +art in the 1940s! To enable you to fully understand the capabilities of +this circuit simulator, I have included a 55 page manual (info.pdf) in the info portion of the entry +submission.

+

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 to +the one who discovers the hidden program within the source.

+

Note that the shape of the source is a wave, not a waveform.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2006/birken

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2006/borsanyi/index.html b/2006/borsanyi/index.html index f2ba6cf09..28c0c2476 100644 --- a/2006/borsanyi/index.html +++ b/2006/borsanyi/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,248 @@ - - + + + + + + - - -2006 borsanyi - - + + + +2006/borsanyi + + + + + -

2006 borsanyi

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2006/borsanyi

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2006/borsanyi/index.html

- +
+ ← birken + ↑ 2006 ↑ + grothe → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Szabolcs +Borsanyi
Location: DE

+ + +

To build:

+
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.

+

To use:

+
./borsanyi string > file.gif
+

Try:

+
./borsanyi ioccc@example.com > example.gif
+

Judges’ remarks:

+

This entry uses a very user-friendly representation of the font it +uses (with a few exceptions). Check out the source and see 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 anti-CAPTCHA +tools.

+

Author’s remarks:

+

Email address to gif +converter

+

Introduction:

+

Most spam robots collect email addresses from the web sites of +innocent people, like you. Conference organizers cannot disclose the +participant’s address to prevent malicious users from grabbing them. One +solution is to write as my_email _at_ address _dot_ com. +But robots are clever enough to sort that out. A more sophisticated +approach is to create an image file with the email address and put that +on the web page.

+

This program creates a GIF image file from the address given in the +command line. To avoid complications with patent issues the LZW +compression feature is not used. A typical email address is stored +in less than 1-2 kilobytes.

+

Usage:

+
make all
+./borsanyi my@example.com > email.gif
+my_favourite_gif_viewer email.gif
+

The address cannot be longer than 42 characters, and may consist of +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 for obfuscation. The +preprocessor is used to keep the program 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:

+
    +
  1. How can you add a further supported symbol?
  2. +
  3. Can you alter the look of the output characters?
  4. +
  5. What limits the number of input characters to 42?
  6. +
+

Portability:

+

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 program is not expected to depend on endianness. The +standard output is used for a binary output, which might cause problems. +To avoid most caveats, the program does not output the octet +0x0a. The program assumes the use of ASCII.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2006/borsanyi

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2006/grothe/index.html b/2006/grothe/index.html index de6866019..812d72ae0 100644 --- a/2006/grothe/index.html +++ b/2006/grothe/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,289 @@ - - + + + + + + - - -2006 grothe - - + + + +2006/grothe + + + + + -

2006 grothe

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2006/grothe

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2006/grothe/index.html

- +
+ ← borsanyi + ↑ 2006 ↑ + hamre → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Aaron Grothe
+Location: US

+ + +

To build:

+
make
+

To use:

+
./grothe carrier_freq pixelclock horizontal_total < some_input.txt
+

Try:

+
./grothe 65000000 10000000 1344 < twinkle.txt
+

… and then put on your “electronic ears”. You may find using a +tunable scanning electronic ear helps.

+

There are other text files you may wish to try:

+
./grothe 65000000 10000000 1344 < arabian.txt
+./grothe 65000000 10000000 1344 < olympics.txt
+./grothe 65000000 10000000 1344 < test.txt
+

Judges’ remarks:

+

Most of the time, interference is annoying. This entry is the +exception that proves the rule. What is a bug to some is a feature to +this entry. :-)

+

Author’s remarks:

+

The program draws patterns on the screen that can be picked up by a +shortwave +radio. It emulates the frequencies for an old fashion touch tone +phone, so old songs can be played by hitting +0-9,#, and *.

+

To be able to run the program you need to determine the following +parameters:

+
carrier_freq     - base frequency used to host music
+pixelclock       - refresh rate of the monitor
+horizontal_total - total scan along the horizontal axis
+

If you have xvidtune installed you can get the +pixelclock and horizontal_total with the +following command

+
xvidtune -show | head -n 1 | awk '{ print "pixelclock " $2 * 1000000 " horizontal_total = " $6 }'
+

Example from my laptops:

+
./grothe 65000000 10000000 1344 < twinkle.txt
+

Even if the user gets a setting off, the sound will usually be able +to be heard on AM at a +multiple of the original frequency.

+

The core idea of using a machine to play music on AM radio goes all +the way back to the Altair computers +and Timex Sinclair +ZX-81s.

+

Several example songs

+

Olympics Fanfare - from antang@phakt.usc.edu - Tony:

+
4-9-91231,2222-321123123-9-91231,2222-32112321
+

Twinkle Twinkle Little Star - from fsufunkyb@aol.com - +Ben Schmidt:

+
1199##9-6633221-9966332-9966332-1199#9-6633221-
+

Generic Arabian Tune - from rdippold@qualcomm.com - Ron +“Asbestos” Dippold:

+
453,54,4569564459,9#95458,8987453 54
+

Others can be found by doing a search for “touch tone phone +songs”.

+

Obfuscations

+ +

References

+

Tempest for Eliza - Basis +for Algorithms.

+

Tempest +AM - Another early program in this field. See here +for a bit more information on the program (search for +Tempest-AM Radio Signal Transmitter).

+

The paper Soft Tempest: +Hidden Data Transmission Using Electromagnetic Emanations by Markus +G. Kuhn’s and Ross J. Anderson’s.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2006/grothe

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2006/hamre/index.html b/2006/hamre/index.html index 9624b26a2..bd0c147d5 100644 --- a/2006/hamre/index.html +++ b/2006/hamre/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,228 @@ - - + + + + + + - - -2006 hamre - - + + + +2006/hamre + + + + + -

2006 hamre

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2006/hamre

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2006/hamre/index.html

- +
+ ← grothe + ↑ 2006 ↑ + meyer → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Steinar Hamre
+Location: NO

+ + +

To build:

+
make
+

To use:

+
./hamre math_expression_string
+

Try:

+
./try.sh
+

Judges’ remarks:

+

An irrationally coded source presents rational things!

+

A rational person might want to attempt the irrational task of +supporting a new operator by way of an existing macro in the source. And +can you determine which macro this is and understand the purpose of its +arguments?

+

Author’s remarks:

+

This is a calculator for rational +numbers. 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 +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.

+
./hamre '-1+4/3*(2+1/(3/2*(7/2-7/3+1/6)))/2'
+2/3
+

If you do not supply an argument, the calculator will crash. Other +arguments are ignored. Supplying more arguments may further limit the +number of nested operators supported.

+

Remember that 1/0 is not a rational number. You will not +get any answer if you divide by zero.

+

By default, only 31 nested levels of operators are supported.

+

The code is well documented, even with an example. In fact this +documentation accounts for 100% of the source. Personally I find +preprocessing or re-indenting the program counterproductive when it +comes to understanding the source. The preprocessed source becomes +rather verbose.

+

IOCCC entries are often loaded with all kinds of hard-coded numbers. +I have restricted myself to mostly use sensible numbers +(<= 7) as smaller numbers are much easier to remember. +Also the macros really help hide most of the uses of these numbers away. +All macros and variables are easy-to-remember single character +abbreviations, from some language, meaningful to the purpose(s) of the +macro, I hope.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2006/hamre

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2006/meyer/index.html b/2006/meyer/index.html index d10dbbf06..ae722b969 100644 --- a/2006/meyer/index.html +++ b/2006/meyer/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,271 @@ - - + + + + + + - - -2006 meyer - - + + + +2006/meyer + + + + + -

2006 meyer

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2006/meyer

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2006/meyer/index.html

- +
+ ← hamre + ↑ 2006 ↑ + monge → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Raphael Meyer
+Location: US

+ + +

To build:

+
make
+

To use:

+
./meyer [SEED]
+

Try:

+
./meyer [SEED]
+

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:

+

This entry turns a newspaper solitaire puzzle into a competition with +the computer to be the last one moving. The object of this source code is to determine the object of this source code! :-)

+

Author’s remarks:

+

I wanted submit a fully object-oriented entry to show that +object-orientated code:

+
    +
  1. is ridiculously bloated.
  2. +
  3. is unreadable.
  4. +
  5. isn’t ‘WYWIWID’ (‘what you write is what it does’) +anymore.
  6. +
+

But I just totally failed. No, I didn’t fail in showing any of the +points above. Before I even had the chance to prove any of these claims, +(1) already brought me to my knees. The code got so bloated up, that I +missed the size limit by a few hundred bytes. Therefore, I broke the +only rule in this contest, I think you shouldn’t break in any case: Rule +Nr 2, The size of …

+

The degree of claim (2) actually depends on the compiler. As I +manually translated it from a generic object-oriented +programming language to C, it didn’t just end up unreadable, but awfully +messed up, i.e. obfuscated.

+

As it is already (pre)translated to C, you could also call it an +object- disoriented program.

+

Comparing this program to a potential object-oriented implementation, +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;
+

might do something similar as

+
struct not_an_object o;
+

But this program reveals that it doesn’t. Even worse, this program +only reveals the tip of the iceberg, what kind of black magic is +involved in a simple declaration of an object.

+

A few things you can explore about object-orientation in this program +include:

+ +

It is left as an exercise to the reader to find a corresponding +implementation in a popular object-oriented programming language.

+

Starting the game

+
./meyer [SEED]
+

Gameplay

+

It is a sudoku +based game. The goal of the game is to be able to do the last valid +‘move’.

+

On your turn you have to set a free cell to a value between 1 to 9 +without breaking the following rule. Any number must be unique in +its:

+
    +
  1. row
  2. +
  3. column
  4. +
  5. 3x3 block.
  6. +
+

Expected input for your move:

+
row column number
+

where

+
row:    [a-i]
+column: [0-8]
+number: [1-9].
+

The game can be aborted with q.

+

The one who can do the last move wins the game.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2006/meyer

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2006/monge/index.html b/2006/monge/index.html index 7f461460e..4fcd0803e 100644 --- a/2006/monge/index.html +++ b/2006/monge/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,401 @@ - - + + + + + + - - -2006 monge - - + + + +2006/monge + + + + + -

2006 monge

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2006/monge

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2006/monge/index.html

- +
+ ← meyer + ↑ 2006 ↑ + night → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Maurizio +Monge
Location: IT

+ + +

To build:

+

Make sure you have the SDL1 (not SDL2!) development environment +installed.

+
make
+

There is alternate version that lets you redefine the width and +height and number of iterations to use. See Alternate code below.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: doesn't work with some platforms - please help us fix
+STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2006 +monge in bugs.md.

+

To use:

+
./monge expression ...
+

Try:

+
./monge "z = 0" "z = z*z*z + c; Abs2(z) < 4"
+

Incorrect formulas will ungracefully crash the program.

+

This is supposed to happen. As is written in the The Jargon +File:

+
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, +just do:

+
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:

+
make clobber WIDTH=500 HEIGHT=500 alt
+

If you wish to keep the dimensions the same but change the iterations +to 512:

+
make clobber ITERATIONS=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, this program is best described +as “1994/tvr meets 2001/bellard”. Here you have +mouse-manipulated fractals AND generated binary code, all in one +package.

+

A more appropriate award could have been “Best abuse of the rules”, +because on a non-x86-based architecture this program is, quite +predictably, a dud.

+

At the time of judging we were too mesmerized by the graphics to +realize it; and, after all, this entry does take a special effort to +work on both i386 and x86_64. Portable it is! +:)

+

Author’s remarks:

+

For the impatient:

+
    +
  1. Compile using the Makefile, or just run:
  2. +
+
gcc monge.c -o monge -O3 `sdl-config --libs --cflags`
+
    +
  1. Run:
  2. +
+
./monge "z = 0" "z = z*z + c; Abs2(z) < 4"
+
    +
  1. Keep clicking with left or right button to zoom in or +out.

  2. +
  3. Use the number pad + and - to +increase/decrease the iteration count when needed.

  4. +
  5. Enjoy, unless you’re more interested in trying to understand how +it works. :)

  6. +
+

Introduction

+

This is a fractal generator that supports custom formulas and real +time zoom. The program needs to be run with two arguments, the first +being a semicolon separated list of assignments to do once per pixel, +and the second a semicolon separated list of assignments and conditions +that will be executed (and conditions checked) for each iteration (up to +the maximum). Using the left and right mouse buttons you will be able to +zoom in and out (a la XaoS), the zooming +algorithm is a bit slower than XaoS’s but it should give +slightly better results.

+

Formulas can use all a-z (lowercase) variables, and the +special variables c and i are respectively set +by default to the complex coordinate of the pixel and to the complex +imaginary i.

+

All the constant numbers will be interpreted as real double values. +Each expression must be an assignment ([variable] = [expr]) +or a comparison with < or > +([expr1] < [expr2] or +[expr1] > [expr2]), and you can add spaces as you like +(as understood by the C function isspace()).

+

Supported operations and functions are:

+
Operation | Description
+:-------- | :----------
+ +,-,*,/    | Arithmetic operations, priority of  * , /  over  +,-  is
+        | respected.
+        |
+ <,>        | 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.
+

Here are a few examples of fractals you can draw:

+ +
./monge "z=1" "z=z*z+c; Abs2(z)<4"
+ +
./monge "z=c" "z=z*z+c; Abs2(z-c)>0.0001"
+ +
./monge "z=c; c=0.31+i*0.5" "z=z*z+c; Abs2(z)<4"
+ +
./monge "z=c; c=0.31+i*0.5" "z=z*z+c; Abs2(z-c)>0.0001"
+ +
./monge "z=c" "p=z; z=0.6666*z+0.3333/(z*z); Abs2(p-z) > 0.001"
+ +
./monge "z=0" "p=z; z=z-(z*z*z + (c-1)*z - c)/(3*z*z+c-1); Abs2(p-z) > 0.001"
+ +
./monge "z=0; q=0" "t=z; z=z*z+Re(c)+Im(c)*q; q=t; Abs2(z)<4"
+ +
./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(2) function (as +#defined 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 +paranoid systems (like OpenBSD IIRC) that do not allow rwx +memory).

+

However I was able to compile and make work the program under Linux +(Debian/x86 and openSUSE/x86_64) and under Cygwin/x86. A friend of mine +was able to make it work under macOS too.

+

If you want you can change the window width and height, or the +default number of iterations (that one can be tweaked at runtime, +anyway) by changing the definitions of W, H +and I at the beginning of the code.

+

Caveats (I just a +selected few of them!)

+ +

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 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 (more ‘high +level’, in the sense that they require an understanding of how all the +program works to be worked out).

+

This program is a formula parser that outputs machine code that +calculates the formula and check the given conditions. The machine code +targets the x87 stack based FPU, and it +is almost identical for x86 and x86_64 (except for the comparison +instructions, that have to be generated differently). The program keeps +track of the FPU stack (the FPU has a cyclic stack of 8 registers) and +will automatically swap to and from the main memory when required (i.e., +adds instructions to the generated machine code to take care of this +issue).

+

The formulas are parsed recursively and machine code for the inner +iteration loop is also generated.

+

After generating the machine code, a big event loop creates (or zooms +into) the fractal executing the generated code when needed, and then +waits for input events.

+

The zooming algorithm works by remembering for each pixel the +floating point offset to where the value was actually calculated. When +zooming, the best match is searched, and if the offset is too big +(>1) the pixel is recalculated.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2006/monge

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2006/night/index.html b/2006/night/index.html index fecf450ea..9db367282 100644 --- a/2006/night/index.html +++ b/2006/night/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,273 @@ - - + + + + + + - - -2006 night - - + + + +2006/night + + + + + -

2006 night

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2006/night

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2006/night/index.html

- +
+ ← monge + ↑ 2006 ↑ + sloane → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Christopher +Night
Location: US

+ + +

To build:

+
make
+

There is an alternate version that supports arrow keys. See the alternate code section below.

+

To use:

+
./night
+

Alternate code:

+

This version allows you to use arrow keys instead of the more awkward +wasd keys.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use night.alt as you would night above.

+

Judges’ remarks:

+

You’d never guess, from looking at the code, that there is a genetic +algorithm involved. Somewhere. But what does it do? Well, it might +take you a while to navigate the results, let alone the code.

+

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 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 maze. It uses a very simple genetic algorithm: a maze +layout’s DNA is +represented as a 32-bit integer, and mutations consist of flipping three +different bits. The algorithm is simple in that it doesn’t employ sexual +reproduction, only mutations, and it has a population size of 1. So much +for diversity!

+

This particular optimization problem, I believe, has a unique +maximum: there is but one maze out of 2^32 that requires 64 +moves to solve. The program will run until finding this global maximum, +or if you get bored, you can accept a sub-optimal solution by pressing +any key. On my system, it takes an average of 15 minutes to find the +maximum, whereas a random search would take an average of 3.5 days.

+

Should you take my word for it that the maze it generates requires as +many moves as I say it does? The answer is yes. But if you’re not +convinced, you can try to solve it yourself. The goal is to traverse +from the upper-left to the upper-right and out the top, where the number +of moves remaining is printed. Use the arrow keys for suckers +(w, a, s, d) to move +around. q quits and r restarts. Also, the maze +changes as you move through it, in a predictable way. It should be easy +enough to figure out the pattern. For best results, use a display with +bold-text capabilities and color.

+

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 added +for obfuscation purposes. No, really!

+

My compiler warns of nulls in a string literal, and the redefinition +of the macro T.

+

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 +pretty opaque. As a hint, the optimum layout’s DNA is, in base 4, +2102231031201230. Try getting from there to the maze that +appears on screen.

+

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 ribosomes manage.

+

Overloaded symbols, such as G and G().

+

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.

+

Keypad support was removed to save space. To restore, modify the +following two macros to:

+
        #define ATG srand(time(0)); initscr(); cbreak(); noecho(); start_color(); keypad(stdscr,1);
+        #define AGG A&2?KEY_UP:KEY_DOWN:A&1?KEY_RIGHT:KEY_LEFT
+

Code on!

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2006/night

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2006/sloane/index.html b/2006/sloane/index.html index 0d5039bdd..de5a7728d 100644 --- a/2006/sloane/index.html +++ b/2006/sloane/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,270 @@ - - + + + + + + - - -2006 sloane - - + + + +2006/sloane + + + + + -

2006 sloane

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2006/sloane

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2006/sloane/index.html

- +
+ ← night + ↑ 2006 ↑ + stewart → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Andy Sloane
+Location: US

+ + +

To build:

+
make alt
+

We recommend the alt version so that you can see what this looked +like back in 2006. If you wish to see the original faster version see original code below.

+

To use:

+
./slone.alt
+

Try:

+

The 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 +75000 but you can easily change it. To do so try:

+
make clobber SLEEP=70000 clobber alt
+./sloane.alt
+

If you wish to make it like the original, as if the below Original code was being used, you can do:

+
make SLEEP=0 clobber alt
+./sloane.alt
+

Original code:

+

Should you wish to see the original you may do so with the original +code, sloane.c.

+

Original build:

+
make clobber all
+

Original use:

+
./sloane
+

WARNING: if you are easily overstimulated with fast movement or have +photosensitivity please be careful running this version and instead see +the above!

+

NOTE: again as above, to see what is going on, we recommend that you +instead use the alternate code which we described in the To build and try sections +above.

+

Judges’ Comments:

+

Looks almost good enough to eat, dunnit? I suppose you could argue +that, 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(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 think. There are also no #includes, so +there may be warnings for 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 not render +properly – it’s worked on every system I’ve tried so far though.

+

You will need some kind of VT100-ish emulation; so while this +compiles and runs OK in Windows, you will need PuTTYcyg or something +like that.

+

The shape of the source gives a hint about its output: it’s a little +animation of a shaded donut rotating over an infinite checkerboard. Like +many IOCCC entries, it is thus self-documenting.

+

I wanted to create something as “pure” as I could - meaning that the +entire source code is shaped into a work of art, without being prefixed +by any #define hacks, or even #includes, +and is portable enough to not require any special libraries to +do the animating. I achieved this with two standard 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 the ASCII logo. The first two are programmed in a +straightforward way (with z-buffering even!), +but the mathematics for drawing them is “optimized”. The ASCII logo has +been shrunk 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:

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2006/sloane

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2006/stewart/index.html b/2006/stewart/index.html index ce8506b92..3d0522843 100644 --- a/2006/stewart/index.html +++ b/2006/stewart/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,439 @@ - - + + + + + + - - -2006 stewart - - + + + +2006/stewart + + + + + -

2006 stewart

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2006/stewart

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2006/stewart/index.html

- +
+ ← sloane + ↑ 2006 ↑ + sykes1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Thomas +Stewart
Location: US

+ + +

To build:

+
make
+

To use:

+
./stewart width_and_height iterations file > file.xbm
+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.

+

Try:

+
./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
+

Now open the images in your favourite graphics viewer or a web +browser.

+

Judges’ remarks:

+

Note the interesting choice of using a #define in the +output. The selection of input files makes this one endlessly fun to +play with. Many image viewers will be able to read the results, as will +a reasonably experienced user who can parse formats in their mind. +:-)

+

Author’s remarks:

+

Execution

+

The program should be run with the following

+
./stewart <m> <n> <ifs>
+

where:

+
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 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:

+
./stewart 1024 1000000 gasket > gasket.xbm
+

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.

+

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).

+

Entry originality

+

In looking through past winners, there seem to be only 2 (92 and 94) +that generated fractals. Both of those were Julia fractals from +the Mandelbrot +set. Those do make for some pretty pictures. I figured it would be +nice to add some more fractals to the IOCCC, since one hasn’t won since +1994.

+

Instead of something that has already won I figured I would go with +another kind of fractal, those from the Iterated +Function System (IFS).

+

Input File

+

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>
+.
+.
+.
+

This file describe an IFS.

+

One of the most well known would be the Sierpinski +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
+

or the 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
+

etc…

+

Included in my submission will be a tarball of some IFS files, +including one that attempts (not very well) to mimic the IOCCC logo (I +figure it can’t hurt to attempt to suck up, right?).

+

I would try to explain how to create an IFS file but I am not smart +enough to condense it down to something that is coherent.

+

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 image file.

+

The a b c d e f are used to iterative find points that +lie in the IFS from the algorithm

+
x = a * prevx + b * prevy + e;
+y = c * prevx + d * prevy + f;
+

The p is for the probability that the equation will +run.

+

Obfuscations

+

The main obfuscation is using a void * as my only +variable (aside from 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 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.)

+

The other main obfuscation being that it generates an +IFS. Which isn’t 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 on first glance will looks like a possible bug. (When you run it +through a C-beautifier this will be removed.)

+

I decided not to use rand() to generate a pseudo-random +number. Instead I use XOR and bit shifting.

+

The input file is used to make the program flexible and to allow it +to generate many different IFSs. This has the added bonus +of hiding 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 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.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2006/stewart

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2006/sykes1/index.html b/2006/sykes1/index.html index 919124ac0..75034b353 100644 --- a/2006/sykes1/index.html +++ b/2006/sykes1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,356 @@ - - + + + + + + - - -2006 sykes1 - - + + + +2006/sykes1 + + + + + -

2006 sykes1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2006/sykes1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2006/sykes1/index.html

- +
+ ← stewart + ↑ 2006 ↑ + sykes2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Stephen Sykes
+Location: FI

+ + +

To build:

+
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.

+

To use:

+
./sykes1
+

Next point your browser to the file: sykes1.html.

+

Try:

+
./sykes1 10
+

Refresh your browser.

+

Also try:

+

If you have all day :-) and wish to find out how fast your machine +can solve the maximum:

+
time ./sykes1 19186
+

This was done on a Rocky Linux 9.2 server with +Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz with 16 cores (via +HyperThreading):

+
real    6m35.524s
+user    6m35.159s
+sys 0m0.002s
+

and done with macOS Sonoma with the Max M1 chip:

+
real    7m10.786s
+user    7m8.322s
+sys 0m0.110s
+

Judges’ remarks:

+

Read the sykes1.html page source. Now then +read the C source. Confused? :-) If it’s not clear try:

+
diff -s sykes1.c sykes1.html
+

For extra credit, understand what happens when you give this entry an +negative number argument, and why.

+

See the author’s remarks for how to make your own shapes as well.

+

Author’s remarks:

+

This cube shaped program solves the fiendishly difficult “Bedlam +Cube”.

+

If you did not get one for Christmas, there is an article about these +puzzles in wikipedia.

+

Some instructions on how to make your own cube are in the included +file bedlam-cubes.pdf.

+

Finally, you can watch it being solved at https://www.youtube.com/watch?v=a8s1AcYMLBc.

+

Actually the cube is very hard to do by hand by just trying to fit it +together. I have not known anyone to solve it in this way - you would +need to be very lucky indeed to stumble across a solution.

+

Instructions

+

Compile the program, then test that it works:

+
./sykes1
+

Shortly you should see the first solution pop out on your screen. It +shows you how to build the cube piece by piece, rendered in glorious 3D +ASCII.

+

ASCII art is all very well, but you also have a web browser, right? +Well, just open the file sykes1.html. This +html file is just a copy of sykes1.c, which +helpfully contains an html document that should make the browser display +for you a nice animated GIF, showing you how to build the cube. Rendered +in glorious 3D color.

+

Want to see another solution? Try:

+
./sykes1 some_number
+

The program will discard solutions up to the number, and output +numbered solution. Refresh your browser window to see the new +solution.

+

Try some more - there are exactly 19186 solutions to +choose from.

+

If you have a fast machine you might try the last solution:

+
./sykes1 19186
+

On my machine this takes about half an hour to run.

+

Implementation

+

The implementation is an optimized recursive algorithm that tries to +fit the pieces into the cube one by one. The cube pieces are defined +near the start of the program:

+
int s[ ] = { 186, 94, 1426, 3098
+    ,1047 , 122 , 1082 , 3083 , 1039
+    , 569 , 527 , 1054 , 531  }  ;
+

Each piece is a bitmap, and represents a 3x3x3 cube.

+

For instance the first piece is 186 - this is +010111010 in binary. Written out like this you can see that +it is the cross shaped piece:

+
010
+111
+010
+

The other pieces are defined similarly. Most of the rest require more +than one layer, such as piece 3 (1426):

+
000
+000
+010
+
+110
+010
+010
+

Imagine the two layers on top of each other, and you should see this +shape:

+
          +---------+
+         / +----+  /|
+        +-/    /| / |
+        |+----+ |/  +
+        ||    | +  /
+        +|    |   /
+         |    |  /
+         |    | /
+         |    |/
+         +----+
+

Making your own shapes

+

The program is in fact a general solver - you can change the shape of +the pieces, and provided that a solution is possible, it will be +found.

+

For example, if you modify line 13 of the source like this, the +program will solve for a different piece set:

+
int s[ ] = { 187, 94, 402, 3098
+

And of course you can make your own.

+

After the pieces are defined, the first thing the program does it to +fit them into a 4x4 cube. It collects every possible placing of each of +the pieces.

+

Once those placings are ready, the program recursively checks each +combination thereof.

+

In order to complete in a reasonable time, care is taken to eliminate +any branches that cannot result in a solution. This is done by checking +after each placing if all the remaining pieces can be placed somewhere, +and that all the free space in the cube can be filled by at least one +viable placing. Also if a piece is found to only have one possible +placing, it is placed immediately without invoking a recursive function +call.

+

Once the solution is found, the ASCII and GIF representations are +generated. Care must be taken to render cubes in the right order such +that pieces further back are occluded by those in front.

+

In the ASCII output care must be taken with drawing the edges of each +1/64th cube (edges must be removed within each piece). In +the GIF 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 called. In fact if you select solution 19186 it will be +called exactly 159,260,759 times.

+

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.

+

I recommend compiling with the most aggressive optimization options +your compiler supports. I find --unroll-loops to be helpful +with gcc.

+

The program relies on long long int being 64 bits, but +has no other special 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 +browsers have good error recovery and amongst other things will ignore +the /* at the beginning, and won’t mind the missing html +and head tags and the lack of end tags.

+

The generated GIF is not compressed. This could be argued as an +advantage - at least I don’t violate any of those old Unisys +patents!

+

The pieces aren’t really those colors. Unless you make your own.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2006/sykes1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2006/sykes2/index.html b/2006/sykes2/index.html index 71b7d8f0e..ece6789a5 100644 --- a/2006/sykes2/index.html +++ b/2006/sykes2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,216 @@ - - + + + + + + - - -2006 sykes2 - - + + + +2006/sykes2 + + + + + -

2006 sykes2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2006/sykes2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2006/sykes2/index.html

- +
+ ← sykes1 + ↑ 2006 ↑ + toledo1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Stephen Sykes
+Location: FI

+ + +

To build:

+
make
+

To use:

+
./sykes2
+

Try:

+
./try.sh
+

This will repeatedly remake the program and run it then sleep for one +second for a nice show of time.

+

Judges’ Comments:

+

As they say, “Lather, rinse, repeat”! :-)

+

If you have the time :-), figure out how this small 1-line entry +works!

+

Author’s remarks:

+

At 130 characters of C code (without the newline at the end), this +should fit into the “1-liner” category.

+

The clock numerals are rendered as an old fashioned 7 segment +display. The encodings for which segments light for which number, and +for where each segment appears on screen are hidden in the two +strings.

+

When reading the program, you may want to refer to a table of +operator precedence (try man 7 operator) - careful choices +were made to keep the usage of brackets to a minimum, and to keep the +character count as low as possible.

+

One interesting bit of obfuscation - the null at the end of the +second string actually forms part of the lookup table.

+

Intel CC warns about the lack of a declaration for the argument to +main(). (gcc does not notice this though, even +with -Wall.) But anyway it can easily be declared as int at +the expense of 4 more characters.

+

I’m not sure of the effects on a hard disk of rewriting the same file +multiple times per second for a long time. Run at your own risk!

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2006/sykes2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2006/toledo1/index.html b/2006/toledo1/index.html index deab36edb..78a07e2df 100644 --- a/2006/toledo1/index.html +++ b/2006/toledo1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,212 @@ - - + + + + + + - - -2006 toledo1 - - + + + +2006/toledo1 + + + + + -

2006 toledo1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2006/toledo1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2006/toledo1/index.html

- +
+ ← sykes2 + ↑ 2006 ↑ + toledo2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Oscar Toledo +G.
Location: MX

+ + +

To build:

+
make
+

To use:

+
./toledo1 [0-9][0-9]
+

where [0-9][0-9] is a two digit number.

+

Try:

+
./try.sh
+

Judges’ remarks:

+

For most of the arguments (e.g. those above) the resulting path is +not circular, but at least one starting point yields a circular +path.

+

Why do some of the “illegal” starting points work more or less as +could be expected, and some dump core?

+

Author’s remarks:

+

Can you place a knight on a chess board and make it visit the 64 +squares without repeating them?

+

If not, this program does it, just run it with an argument giving +initial position.

+
./toledo1 11       # start is A8
+./toledo1 18       # start is H8
+./toledo1 81       # start is A1
+./toledo1 88       # start is H1
+./toledo1 44       # start is D5
+

It will print move order. The algorithm is so simple that you can +read it in the source code. At the first glance it can appear checkered. +Nevertheless, don’t be dismayed, jar, jar. :-)

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2006/toledo1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2006/toledo2/index.html b/2006/toledo2/index.html index f7934a94f..d82f53474 100644 --- a/2006/toledo2/index.html +++ b/2006/toledo2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,395 @@ - - + + + + + + - - -2006 toledo2 - - + + + +2006/toledo2 + + + + + -

2006 toledo2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2006/toledo2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2006/toledo2/index.html

- +
+ ← toledo1 + ↑ 2006 ↑ + toledo3 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Oscar Toledo +G.
Location: MX

+ + +

To build:

+
make
+

There is alternate code that is based +on the author’s notes for DOS/Windows. This cannot be tested by us, not +even to compile, but it appears that it should be fine, after the proper +header files were added.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2006 toledo2 in bugs.md.

+

To use:

+
./toledo2
+

To end execution press ctrl-z. As mentioned in the +author’s remarks and in the below section, it is supposed to crash on +termination though some noted this does not seem to happen in macOS or +linux in 2023.

+

Try:

+
./toledo2
+

and then type in the following:

+
10 PRINT "HELLO WORLD!"
+LIST
+RUN
+

To end the program hit ctrl-z.

+

Alternate code:

+

This version, as noted, should work for DOS/Windows. It uses +non-standard functions in place of read(2) and +write(2).

+

Alternate build:

+
make alt
+

Alternate use:

+

The author noted that for PC/DOS you will have to add +ANSI.SYS to your CONFIG.SYS but this is also +something we can’t test.

+

Use toledeo2.alt as you would toledo2 +above.

+

Judges’ remarks:

+

We’re impressed! Last year, it was a 6502 +emulator; this year, it’s 8080! It requires an +input file (C) to be present, but it does not have to be +one of C.BASIC or C.BIOS - you’re welcome to +write a standalone 8080 program yourself! How about C.FORTH +or C.LISP?

+

In addition to the functionality you could expect from a program of +this size, it allows importing files from the host file system (one by +one, so you’ll have to be patient).

+

Remember the good old days and play (or let your kids play) Adventure (in the directory +ADVENTUR); walking in a maze of twisty little passages all +alike is easier than understanding the code!

+

NOTE: The KAYPROII.ZIP file originally +came from http://www.retroarchive.org/cpm/os/KAYPROII.ZIP. +For your convenience, we have included KAYPROII.ZIP in this +entry. Both the make all and the make alt +unzip that file, and the make clobber removes those files +extracted from the KAYPROII.ZIP.

+

Author’s remarks:

+

This program emulates a complete Intel(r) 8080 +processor, along with a teletype and a disk controller, just like at the +start of the personal computers revolution (circa 1975).

+

It needs an initial memory image to do something usable, so along +with it you will find two files: (C.BASIC and C.BIOS). Rename C.BASIC to +C (NOTE from the judges: running make will do +this for you), run the emulator, and et voila! you have the public +domain Palo Alto Tiny +BASIC (by Li-Chen Wang), published in the very first volume of Dr. Dobb’s +Journal.

+

Type using uppercase letters. Here are three example programs. Press +Enter after each line:

+
10 PRINT "Hello, world!"
+LIST
+RUN
+
+10 FOR A=1 TO 10
+20 PRINT A\
+30 NEXT A\
+LIST\
+RUN
+
+10 INPUT A
+20 INPUT B
+30 PRINT A+B
+LIST
+RUN
+

Press Ctrl+Z to quit. By the way, the segmentation fault is normal at +this point.

+

All good programmers started learning BASIC, now, what about a +CP/M emulator?

+

Copy CPM64.COM to files named A and +B (these will be the disk drives). Now rename the provided +C.BIOS to C and run the emulator.

+

Now you have a running CP/M system!, with two +files on A: drive, HALT.COM to stop the emulator (so it +closes drives) and IMPORT.COM to introduce new files. The +two files are created automatically by the provided C.BIOS.

+

To get a complete CP/M system, you will need +the following files from the SOURCE directory:

+
    ASM.COM  DDT.COM   DUMP.COM   ED.COM   LOAD.COM
+    PIP.COM  STAT.COM  SUBMIT.COM XSUB.COM
+

To import them, you must run the emulator with an argument, by +example:

+
./toledo2 DDT.COM
+

When the > prompt appears, do:

+
IMPORT DDT.COM
+

When it ends, do HALT, so the file is closed, and you +can start the same process with another file.

+

At this time I have tested successfully the following software from +http://www.retroarchive.org:

+ +

Some programs require installation to configure the terminal, locate +ANSI or VT-100.

+

What is an 8080?

+

It is simply the little brother of the Z80; it has no +extended registers (AF', BC', +DE', HL', IX or IY), +no relative jumps, and no instruction beginning with CB, +DD, ED or FD exists.

+

The flags are only S (Sign, bit 7), Z +(Zero, bit 6), P (Parity, bit 2) and C (Carry, +bit 0).

+

Porting it

+

It is easy if your platform has +getch()/kbhit() and ANSI terminal:

+
read    -->  Z=kbhit()?getch():0
+write   -->  putchar(7[o])
+system  -->  nothing
+

Notice that you’ll have to do #include <conio.h> +as well.

+

Also add the following to trap Ctrl-C:

+
    #include <signal.h>
+    signal(SIGINT, SIG_IGN);
+

NOTE: this is what the alternate code +is for!

+

NOTE from the judges: in Unix like systems getch() is +part of curses but this is not what is needed.

+

On PC/DOS you need to add ANSI.SYS to +CONFIG.SYS.

+

In Unix the min 0 on stty is required but circa 2001 it +was not required.

+

How it works (SPOILER)

+

The l array contains the 64K memory; it is initialized +with a boot image loaded from the C file. The program counter +is the c pointer and registers +are in o[]. The main loop reads every opcode and separates +them in one of three common forms. A lot of ternary operators selects +the instruction.

+
o[0] = B register   o[1] = C register
+o[2] = D register   o[3] = E register
+o[4] = H register   o[5] = L register
+o[6] = Flags        o[7] = A or accumulator
+

The following instructions do peripheral operation:

+
76           Quits emulator
+DB 00        Reads key pressed status
+DB 01        Reads key
+DB 02        Reads byte from file (Carry=EOF)
+D3 xx        Writes byte from acc. to console
+ED ED 02     Reads sector
+ED ED 03     Writes sector
+

Memory addresses:

+
FBFA = Low source/target direction
+FBFB - High source/target direction
+FBFC - Sector
+FBFD - Low cylinder
+FBFE - High cylinder
+FBFF - Drive.
+

The BIOS is tailor made for this emulator, and helps to simplify +it.

+

Other notes

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2006/toledo2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2006/toledo3/index.html b/2006/toledo3/index.html index d7459780c..fa19a5aaa 100644 --- a/2006/toledo3/index.html +++ b/2006/toledo3/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,290 @@ - - + + + + + + - - -2006 toledo3 - - + + + +2006/toledo3 + + + + + -

2006 toledo3

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2006/toledo3

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2006/toledo3/index.html

- +
+ ← toledo2 + ↑ 2006 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Oscar Toledo +G.
Location: MX

+ + +

To build:

+
make
+

The author provided two alternate versions, one which adds a status +bar and another that makes it text only. The author also provided a +version that they tested with Windows. See alternate code below.

+

To use:

+
./toledo3 [1 | 2 | 3 [b]]
+

Try:

+
./toledo3 1
+

Alternate code:

+

The author provided two additional versions, toledo3-sbar.c and toledo3-txt.c. Respectively these create a +status bar and make the game text only.

+

Alternate build:

+

With the exception of the Windows version, these are built by +default. To build the Windows version, toledo3.alt.c, you will have to figure out how +to compile Windows code.

+

Alternate use:

+

Use toledo3-sbar and toledo3-txt as you +would toledo3 above.

+

As for the Windows version, toledo3.alt, we presume you +can open it like any other application.

+

Judges’ remarks:

+

It’s pretty obvious from looking at it what this program does, since +it’s clearly spelled out in the code. The interesting question is +whether this is easier or harder to understand than the code for Deep +Blue.

+

Author’s remarks:

+

There are so many text-based chess programs, what is that of +A1, H5, C4, D5? The +queen is really pointing to the king?

+

So I managed to do a graphical X11 chess program +(‘WYSIAIE’, or ‘What You See Is An IOCCC Entry’). Pointing +and clicking to move pieces is the only required action, and of course +the command-line options:

+
./toledo3        # Two-players mode (useful if you don't have a board at hand)
+./toledo3 1      # Human white - Computer black, level 1 (fast)
+./toledo3 2      # Human white - Computer black, level 2 (medium)
+./toledo3 3      # Human white - Computer black, level 3 (slow)
+./toledo3 1 b    # Human black - Computer white, level 1 (fast)
+./toledo3 2 b    # Human black - Computer white, level 2 (medium)
+./toledo3 3 b    # Human black - Computer white, level 3 (slow)
+

The computer will check that your moves are legal. Full legal chess +moves are allowed, except minor promotions on human side.

+

The game will continue up to its logical conclusion, you make a +mistake and the computer surpasses you. ;)

+

WHAT ABOUT THE ENGINE

+

Uses an alpha-beta search up +to a depth of 3+level ply, extended +with quiescence search, that helps playing strength, something around +1500 ELO (level 1) to 1700 ELO (level 3).

+

It searches the board and generates moves for each piece located. A +lot of comparisons are used for en passant, castling +and promotion. Would be faster with optimizations, but that +optimizations use valuable IOCCC characters.

+

It plays a different game every time, using the C library random +number generator.

+

Because it is resource-hungry, I strongly recommend to compile it +using maximum optimization. With GCC you can use:

+
gcc -O3 -fexpensive-optimizations prog.c -o prog -lX11
+

KNOWN “FEATURES”

+
    +
  1. Because this is my second X11 program (the first was point n +click happy face), I added sentences everywhere until it worked. +:)

  2. +
  3. It is portable to Windows (using the supplied layer.c file) +Change #include <X11/Xlib.h> to #include "layer.c" +and use a Windows compiler (only tested with Dev C/C++ 4.9.9.2) The play +level is fixed, though you can change it easily. Of course, this is an +example of an obfuscated Windows program (there exists another way of +write them?).

  4. +
  5. It will give warnings on compilation, so you can be sure that +your compiler works.

  6. +
  7. It will not update the window while it is “thinking”

  8. +
  9. The space character has many useful applications, especially when +it comes to the character limit (8).

  10. +
  11. I still don’t understand what to do after semicolons. :P

  12. +
+

CHALLENGES

+

It is possible to convert this code into JavaScript with a graphical +interface. Can you do it?

+

Can the evaluation function be enhanced to make the program play +stronger?

+

UPGRADES

+

Using toledo3-sbar.c (which is too large +for this IOCCC size rules) creates a status display about gameplay on +the window title bar.

+

Using toledo3-txt.c turns this into being +purely text based.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2006/toledo3

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2011/akari/index.html b/2011/akari/index.html index 830fed876..cd97f51f1 100644 --- a/2011/akari/index.html +++ b/2011/akari/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,275 @@ - - + + + + + + - - -2011 akari - - + + + +2011/akari + + + + + -

2011 akari

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2011/akari

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2011/akari/index.html

- +
+ first entry + ↑ 2011 ↑ + blakely → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Don Yang
Location: +US

+ + +

To build:

+
make
+

To use:

+
./akari [ input_file | - ] [ output_file | - ]  [even]
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Akari is an image downsampling utility that accepts 3 +input formats:

+ +

Anything that is not parsable as PGM or PPM +will be downsampled as ASCII art.

+

Author’s remarks:

+

Akari is an image downsampling utility. She accepts up +to 3 arguments:

+

The first argument is the input image. If it’s - or +unspecified, Akari will read from stdin.

+

The second argument is the output image. If it’s - or +unspecified, Akari will write to stdout.

+

The third argument, if specified, causes Akari to keep +even pixels on even scanlines. By default +Akari will keep odd pixels on odd scanlines.

+

Examples:

+
gcc akari.c -o akari
+./akari < example.ppm > odd_output.ppm
+./akari - - even < example.ppm > even_output.ppm
+./akari example.ppm odd_output.ppm
+

Akari accepts 3 input formats:

+ +

This is useful for decoding some curiously interlaced images, such as +the included example.ppm.

+

Anything that is not parsable as PGM or PPM +will be downsampled as ASCII art. Since the source code is formatted as +ASCII art, it’s only natural to try:

+
./akari akari.c akari2.c
+

akari2.c is also a valid C program, and accepts up to 1 +argument. By default, this second program reads text from +stdin and writes expanded output to stdout. If +the extra argument is specified, the output text will also pass through +a rot13 filter.

+
gcc akari2.c -o akari2
+./akari2 < input.txt > expanded_output.txt
+./akari2 rot13 < input.txt > expanded_and_rot13_output.txt
+

You can combine the two programs together to have just a regular +rot13 filter:

+
./akari2 rot13 < input.txt | ./akari > rot13.txt
+

Of course, we wouldn’t stop with just 2 programs, you can downsample +the source again and get yet another C program:

+
./akari < akari.c | ./akari > akari3.c
+

We must go deeper:

+
./akari < akari.c | ./akari | ./akari > akari4.c
+

akari3.c and akari4.c are still (mostly +valid) C programs. gcc -Wall will output a few warnings, +but still produce output executables. The output executables each print +a message to stdout.

+

It takes quite a bit of skill and obfuscation to interleave a C +program 4 levels deep, it’s much easier to interleave something like a +brainf#$% program in a C program, for example. For +comparison, a brainf#$% program is embedded inside akari.c.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2011/akari

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2011/blakely/index.html b/2011/blakely/index.html index 74ed8270c..ec376d600 100644 --- a/2011/blakely/index.html +++ b/2011/blakely/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,369 @@ - - + + + + + + - - -2011 blakely - - + + + +2011/blakely + + + + + -

2011 blakely

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2011/blakely

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2011/blakely/index.html

- +
+ ← akari + ↑ 2011 ↑ + borsanyi → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Philip +Blakely
Location: GB

+ + +

To build:

+
make
+

To use:

+

Zoom out and make your terminal window 53 or more lines deep.

+
./blakely < blakely.c | head -300
+

Try:

+
./try.sh
+

For those who have a lot of time, try:

+
./blakely < t0_3.dat
+

though one might or might not need to kill it, depending on your +boredom threshold.

+

Judges’ remarks:

+

This program plays Life +(see also here), computes Pi to 16 +digits if given its own source as input, and allows to check if your +garden is a Garden +of Eden, all in one source.

+

If you have enough time to spare, put the plan of your garden in a +text file, and run:

+
./blakely - < garden.txt
+

Author’s remarks:

+

This program uses a well-known algorithm in order to display pi to +fifteen decimal places. The source-layout itself demonstrates the +importance of using the correct amount of whitespace in code and the +clear superiority of spaces over tabs.

+

In order to see the main feature of the code, type:

+
./blakely < blakely.c
+

and wait for about four seconds before using Ctrl-C (or whatever) to +end the program. The results are best viewed in a terminal window at +least 60 characters high and wide. Alternatively, redirect the output to +a separate file (killing when necessary).

+

Overview

+

The program emulates John Conway’s cellular automaton known as “The Game of Life”, using standard +input as a starting grid. The layout of the source-code is such that it +evolves to a digital representation of the first 15 decimal places of pi +after 4 time steps. This was setup using the other feature of the +program which can be demonstrated as follows:

+
./blakely - < 3.dat
+

The program will first display the grid given in 3.dat, and then three more grids (taking a few minutes +to display the last). Waiting for any more grids will take a substantial +amount of time. The final grid has been put into evolve_to_3.dat, and if you type

+
./blakely < evolve_to_3.dat
+

then the 3 will reappear after three time steps.

+

As should now be clear, this use of the program will attempt to +evolve a given setup backwards in time according to the Life rules. The +resulting grid is clearly not necessarily unique. The program will +evolve backwards given any single command line option.

+

When evolving forwards, the code can only be stopped by killing the +program. In the reverse direction, the code can either be killed, or +will stop if it is unable to find a grid that will evolve to the current +layout correctly. This can be seen with the sample grid t0_3.dat, which evolves backwards by only two +time-steps.

+

Input file format

+

The input files must encode a square grid, where a space is a dead +cell, and any other character (except a newline) is a living cell. Each +line must be the same length, and end with a single newline character +\n (ASCII 10), including the last line. When designing +grids, it may help to type full-stops (dots) in place of spaces, and do +a global replace afterwards. Any deviation from this format will cause +errors in the output.

+

Limitations

+

This is only an approximation to the original Life, as it takes place +on a finite grid, with borders that are automatically killed off before +each time step. However, when evolving backwards, the resulting grids +will not cause any cells on the boundaries to come alive. As the display +is performed before killing off the borders, some boundary cells may +sometimes appear to be alive, but not be treated as such for the +following time-step, although any living cells on the right border will +never be displayed.

+

The maximum grid size is currently 99 by 99 (exceeding this will +cause a segfault), but changing the two 9802s to +MAX_SIZE*MAX_SIZE+1 will solve this, although some +reformatting of the code might have to be done to allow larger +numbers.

+

Compiler warnings/assumptions

+

When compiled with the -Wall -pedantic -ansi options of +gcc, some warnings suggesting extra parentheses occur (not necessary for +anyone fully conversant with operator precedence). There is one unused +variable, v, but unnamed function parameters are not +permitted in ANSI C, so naming it is necessary, and gcc no longer warns +about its existence, although earlier versions do.

+

Since the program calculates ASCII character values for display, an +ASCII based system is required to run it. Also, as mentioned above, any +system that uses anything other than a plain \n to end a +line will cause problems when reading in files.

+

Obfuscation

+

Given the finely-tuned layout required to evolve into pi, this is one +of the main obfuscations used in the code. However, running the code +through the preprocessor, expanding the #defines, and +applying GNU’s indent, although making the location of functions and +statements clear, by no means makes the code entirely clear. Note that +expanding out the #defines does not take the program over +the character limit. The main reason for these is to do with the layout, +since there are few places that keywords or tokens of over 2 characters +can be fitted, and requiring the first few lines to be +#includes would cause similar problems.

+

Other obfuscations used are:

+ +

Algorithm

+

The forwards evolution of the grid is straightforward.

+

The reverse evolution is done using a brute-force method. As far as I +know, a brute-force method is the only viable automatic approach for +general grids, although more intelligent algorithms would be possible +given more space.

+

The program starts with an empty “trial” grid and, starting from the +top-left, tries all possibilities for the neighbours of the current cell +that will cause the cell to evolve to the required state. It then +proceeds to the right and down. Thus, it only ever needs to look at the +cells below and to the right when testing. However, the already defined +cells above and/or to the left of the cell may mean that there are no +possibilities that will give the correct state, in which case the code +backtracks and tries other possibilities on previous cells. The program +knows it has a valid grid if it gets to the last cell. If it cannot find +a valid grid, the program exits.

+

Since this uses brute-force, it can be very slow. (In fact, the +various obfuscations have, at least for the gcc compiler, caused a +substantial slowdown.)

+

Program layout

+

The “calculation” of pi was chosen purely because algorithms to find +pi are numerous, but the Game of +Life is rarely (if ever?) used for this purpose. Also, separate +digits made determining the layout somewhat easier.

+

Deriving the layout was the most complicated part of the program. As +is clear from the final layout featuring pi, the grid was divided into +sixteen squares, and layouts that would evolve to each of the nine +digits required were found. (This used the three-by-five digit-layout +embedded in, at first, a nine-by-nine grid, then in larger grids, until +fifteen-by-fifteen was reached.) The fifteen-by-fifteen grids give +enough blank cells around them that the digits will not collide when +evolving.

+

However, this did not allow for sufficient characters to fit the code +into. Therefore it was necessary to add some regions that would quickly +die off without expanding to collide with the digits’ evolution. Groups +of cells such as singletons, pairs, and larger groups like

+
* * * * * * * * * *
+ *****************
+* * * * * * * * * *
+

were useful in this regard.

+

Other problems were keywords which need to be all in one string, +keywords requiring space after them, and multi-character tokens. Some of +these problems were dealt with by using the #defines and +#includes given in the build-script, as there was no way to +have sufficient separate lines in the code to do this without causing +many difficulties. Some rejigging of the grid’s layout as the code was +fitted into its format was also done, resorting to trial-and-improvement +in some cases. Occasional use of constructs such as f -= -3 +was made as f += 3 could not be fitted into the required +format. The fact that the borders would be killed off immediately was +also helpful.

+

It should be noted that evolving a full 60-by-60 grid backwards using +this code would probably take us at least up to the heat-death of the +universe.

+

The command ./blakely - < blakely.c is therefore +not recommended.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2011/blakely

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2011/borsanyi/index.html b/2011/borsanyi/index.html index cc34c2cbe..0abb077e2 100644 --- a/2011/borsanyi/index.html +++ b/2011/borsanyi/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,255 @@ - - + + + + + + - - -2011 borsanyi - - + + + +2011/borsanyi + + + + + -

2011 borsanyi

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2011/borsanyi

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2011/borsanyi/index.html

- +
+ ← blakely + ↑ 2011 ↑ + dlowe → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Szabolcs +Borsanyi
Location: DE

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2011 borsanyi in bugs.md.

+

To use:

+
./borsanyi < some_data_file
+

Try:

+
./try.sh
+

Judges’ remarks:

+

This is a nice quick histogram plotter. A +useful utility when you need to look at the distribution of some +data.

+

Challenges:

+

You can modify the number of histogram bins and the +scaling of the histogram by editing the source. Try to find them!

+

If you look at the source you will notice that the usual array of +histogram bins is missing. The source contains no arrays and it does not +use malloc(3) or alloca(3). How does it build +the histogram?

+

While the input does not need to be sorted, the histogram output is +sorted. How does it put the data into buckets? Why does it +fork(2) 22 times?

+

Author’s remarks:

+

This small piece of program is meant to be a useful tool, when there +are some data around and you need a quick glance at the histogram. I am +all too often logged in to a remote machine with slow X connection, and +a terminal-based program would be of great help.

+

Limitations

+ +

Obfuscation

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2011/borsanyi

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2011/dlowe/index.html b/2011/dlowe/index.html index f79b3f7a4..2562ac21b 100644 --- a/2011/dlowe/index.html +++ b/2011/dlowe/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,582 @@ - - + + + + + + - - -2011 dlowe - - + + + +2011/dlowe + + + + + -

2011 dlowe

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2011/dlowe

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2011/dlowe/index.html

- +
+ ← borsanyi + ↑ 2011 ↑ + eastman → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: J. David Lowe
+Location: US

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: missing or dead link - please provide them
+STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2011 +dlowe in bugs.md.

+

To use:

+
./dlowe -<n_iterations> corpus1/ [...] corpus0/ < start.net > trained.net
+

NOTE: In the above command, the directory args MUST end in a +/.

+

Then to use trained.net:

+
./dlowe file [file ...] < trained.net
+

Try:

+

Try these pre-trained networks:

+
./try.sh
+

NOTE: The dlowe-aux-data/ directory, which try.sh refers to, was created by:

+
tar -jxf dlowe-aux-data.tar.bz2
+

Judges’ remarks:

+

This entry is a ghoulish example of a brain (dead?) neural network +classifier. It comes with a set of corpora for you to try.

+

ioccc-winlose-trained.net

+

You can create your own trained networks. For example, we trained a +network on the C code of entries that were supplied to the 20Th +IOCCC.

+

The ioccc-winlose-trained.net was trained using the earlystop.pl tool:

+
rm -f ioccc-winlose-trained.net
+./earlystop.pl ioccc-winlose-trained.net ioccc_won_training/ ioccc_lost_training/ ioccc_won_test/ ioccc_lost_test/
+

where:

+ +

NOTE: The above directories were not shipped and everything from the +entries that did not win were flushed to /dev/null.

+

The earlystop.pl tool wrote:

+
training 1 to 1001...
+training 1001 to 2001...
+prior error = 56.746974766043; current error = 58.095691135305
+

The resulting ioccc-winlose-trained.net file was +included in the dlowe-aux-data.tar.bz2 tarball.

+

The dlowe.c was explicitly excluded from this +trailing set, so this test is interesting:

+
./dlowe dlowe.c < dlowe-aux-data/ioccc-winlose-trained.net
+

NOTE: this is done in try.sh.

+

The match of dlowe.c to the lose/win trailed +network was:

+
dlowe.c 0.125108
+

NOTE: The non-artificially intelligent decisions of the IOCCC judges +include random quirks and their non-linear judgment calls not found in +the ioccc trained network. Just because C code is or isn’t scored highly +by this network does not mean it will win or lose a future IOCCC. On the +other hand … it just might!

+

other data sets to try

+

While we cannot supply you with the losing IOCCC source code, the +author did supply a number data sets on which to test:

+

We created the english-trained.net as +follows:

+
./dlowe -8000 dlowe-aux-data/english-1/ dlowe-aux-data/english-0/ < /dev/null > dlowe-aux-data/english-trained.net
+ +

We created the png-trained.net as +follows:

+
./dlowe -8000 png-1/ png-0/ < /dev/null > dlowe-aux-data/png-trained.net
+ +

We created the xor-trained.net as +follows:

+
./dlowe -8000 dlowe-aux-data/xor-1/ dlowe-aux-data/xor-0/ < /dev/null > dlowe-aux-data/xor-trained.net
+ +

NOTE: The directory args must end in +a / for them to work.

+

Author’s remarks:

+

Synopsis

+

This is an artificially +intelligent judging tool to help the IOCCC judges. Here’s to +shorter, more frequent contests!

+

Description

+

This is a multilayer perceptron (a feedforward +artificial neural network) which can be trained, using on-line backpropagation, +to classify input files.

+

It has a fixed topology of 2^16 input neurons, 6 hidden +neurons and 1 output neuron.

+

The neurons’ activation function is the logistic function +1 / (1 + e ^ -x).

+

Classifying

+
./dlowe file [file ...] < trained.net
+

To classify files, one specifies a trained network (on +stdin) and one or more files to classify. The program will +output one line per successfully-classified file to stderr, +with the filename and the classification: a number between 0 and 1.

+

The interpretation of the classification number depends on how the +network was trained, but it’s geared toward interpretation as a +probability or a confidence.

+

Training

+
./dlowe -<n_iterations> corpus1/ [...] corpus0/ < start.net > end.net
+

NOTE: The directory args must end in +a / for them to work.

+

To train a network, one specifies a starting network (on +stdin), two or more corpora (directories containing +training data), and the number of training iterations to run. The +program will write some progress data to stderr and, when +it’s done, will serialize the updated network to +stdout.

+

If no input network is given, a random new network will be generated +as a starting point (i.e. provide an empty stdin).

+

The first corpus will be assigned a target value of 1. +The last will be assigned a target value of 0. Intervening +directories (if any) will be assigned intermediate target values.

+

The learning rate is hard-coded as 0.3. No momentum +factor is used.

+

png corpora

+

The png-1 corpus was obtained by +manually scraping the first results from an https://images.google.com search for “obfuscate +filetype:png”.

+

The png-0 corpus was obtained by +manually scraping the first results from an https://images.google.com search for “obfuscate +filetype:gif”.

+
Results:
+ +

produced a network with about 87% accuracy

+

English corpora

+

The english-1 corpus was +obtained by manually scraping the first results from a https://www.google.com/webhp?lr=lang_en search for “paris +filetype:txt”.

+

The english-0 corpus was +obtained by manually scraping the first results from a https://www.google.com/webhp?lr=lang_fr search for “paris +filetype:txt”.

+
Results:
+ +

produced a network with 100% accuracy.

+

xor corpora

+

The xor-1 corpus consists of two +files containing 01 and 10 respectively.

+

The xor-0 corpus consists of two +files containing 00 and 11 respectively.

+
Results:
+

Using these corpora as a training set takes about 8000 iterations to +learn xor to within a tolerance of <0.01.

+

Limitations

+

The program can’t tell you anything meaningful about files with less +than two bytes in them (I’m looking at you, smr.c!)

+

You must include the trailing directory separator on training +directories (this allows the program to be portable without wasting +precious bytes on figuring out how to concatenate directory and file +names…).

+

Serialized network files are only portable between systems with the +same floating-point +representation and endianness.

+

Making sure not to overfit +the network to the training data is a bit of a black art. I have +enclosed earlystop.pl, a wrapper script that +implements a simple ‘early stopping’ algorithm; other techniques are +possible.

+

Bad input (e.g. nonexistent files, non-numeric number of iterations, +etc.) tends to result in empty output.

+

Given exactly one corpus, the program will crash or produce +garbage.

+

Leaks memory and file descriptors while processing files.

+

Will crash and die horribly if it runs out of memory.

+

The Microsoft C compiler doesn’t provide a dirent API, +so to get this working on a Windows system you’ll need cygwin+gcc +(tested) or a dirent compatibility library (untested, but +they do exist).

+

Backpropagation doesn’t always converge: if you play with this long +enough, you’ll eventually have a training session that completely fails +to converge.

+

Obfuscation

+ +

… but mostly zombies!

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2011/dlowe

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2011/eastman/index.html b/2011/eastman/index.html index ffe3a2646..30009d8ad 100644 --- a/2011/eastman/index.html +++ b/2011/eastman/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,252 @@ - - + + + + + + - - -2011 eastman - - + + + +2011/eastman + + + + + -

2011 eastman

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2011/eastman

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2011/eastman/index.html

- +
+ ← dlowe + ↑ 2011 ↑ + fredriksson → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Peter Eastman
+Location: US

+ + +

To build:

+
make
+

To use:

+
./eastman
+

Try:

+

Quit the program. Resize your terminal window. Run it again.

+
./eastman
+

NOTE: to restore your cursor in your shell, try +reset.

+

Judges’ remarks:

+

This round program will generate a classic spherical result!

+

You will need a terminal capable of displaying coloured ANSI +characters (for example an xterm or a Terminal.app window in macOS).

+

You might also want to turn off any scrollback history. The program +will size itself to the initial geometry of your terminal.

+

If you are ambitious, make the font really small and the window +really large for hi-res graphics!

+

Author’s remarks:

+

This program uses ANSI graphics to recreate the classic Boing Ball +demo from the Commodore Amiga. See https://www.youtube.com/watch?v=-ga41edXw3A if you +aren’t familiar with it. Back in its day, this demo inspired lust and +awe in geeks around the world.

+

The graphics are +[raytraced](https://en.wikipedia.org/wiki/Ray_tracing_(graphics), with +procedural textures on the ball and the back wall. I did cheat a little +to simplify the calculations: it uses a parallel projection, but +textures the back wall to look as if there were a floor being viewed in +perspective. The shadow is also just part of the texture, not an actual +raytraced shadow.

+

This program automatically adapts to the size of the terminal it is +running in, so try enlarging the window to get higher resolution. Don’t +resize while the program is running, though. It only checks the size +once, when it starts up.

+

To compile:

+
cc -lm eastman.c
+

Portability

+

It should be completely portable. I’ve tested with gcc on Mac OS X +10.7 (Lion) and Fedora 10. I would expect it to work in any Unix-like +environment.

+

Obfuscation

+

I have merged expressions wherever possible, making extensive use of +ternary operators, commas, return values of assignment operators, etc. +The entire raytracing computation, include ray intersection tests and +procedural texture evaluations, is a single expression involving 41 +operators.

+

Variables are named alphabetically in the order they are +declared.

+

The third argument to ioctl(2) should really be a +struct winsize, and I should then look up the +ws_row and ws_col fields, but that makes it +way too obvious what I’m doing there. Since a +struct winsize just contains four +unsigned shorts, I replaced it with an array. And since all +the values will be much less than 32767, I further +simplified the type to just short[].

+

A wonderful thing about ANSI graphics is that it produces nearly +unintelligible code. Consider the printf(3) spec to print a +single space in a desired color: "\x1B[%dm. I could have +done something to further obfuscate it, but it’s already +indistinguishable from line noise, so why bother?

+

There are lots of other minor obfuscations to make the code less +obvious. For example, I could have written the outer loop as +while(1), but why write a 1 when I can calculate it from +the return value of usleep(3) instead? And I could have +written usleep(80000), but usleep(79383) just +looks so much better. And so on.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2011/eastman

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2011/fredriksson/index.html b/2011/fredriksson/index.html index efffe1156..3663a4509 100644 --- a/2011/fredriksson/index.html +++ b/2011/fredriksson/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,443 @@ - - + + + + + + - - -2011 fredriksson - - + + + +2011/fredriksson + + + + + -

2011 fredriksson

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2011/fredriksson

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2011/fredriksson/index.html

- +
+ ← eastman + ↑ 2011 ↑ + goren → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Kimmo +Fredriksson
Location: FI

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2011 fredriksson in bugs.md.

+

To use:

+
./fredriksson [-icvtnk#] regexp < file
+

Try:

+
./try.sh
+

NOTE: you need to be allowed to change your stack size or else the +last command in the script would likely cause the program to dump core, +which is why the script checks the exit code of ulimit +first.

+

Judges’ remarks:

+

The author of this entry was making sure that it does not win the +“Best Short Program” award. On the outside, the program behaves as an +approximate grep. On the inside, it is a Burrows-Wheeler +transform decompressor that produces the source code of the actual +obfuscated approximate grep program and calls it. As an +exercise, try writing the compressor.

+

Author’s remarks:

+

Approximate grep

+

Implements a variant of grep.

+

Usage

+

To search regexp from file, do:

+
./fredriksson [-icvtnk#] regexp < file
+

Pipes might not work, see the section Limitations. The options +-i, -c, -v and -n +are the classic ones:

+ +

This version of grep recognizes two more options, not +present in normal grep implementations:

+ +

Of course, one could construct a standard regexp that matches the +same patterns, but the problem is that such a regexp grows exponentially +in size when the number of allowed edit +operations is increased.

+

This version does not recognize all regular expressions, but the +following are allowed:

+ +

The special characters must be escaped, if they are to be taken +literally (e.g. \. to match period). You might want to +protect these with ', i.e. use 'foo\[bar' +instead of foo\[bar. If you want to use the literal +- in bracket expression, protect that too +(\-), otherwise this is not needed. Note that the syntax +differs from standard (?) grep a bit, i.e. in plain grep you can use +] and - in bracket expressions by putting +] as the first character, and putting - +last.

+

Other uses

+ +
./fredriksson -k3 cat < file
+ +
./fredriksson -nk3 cat < file
+

Other features

+ +

Limitations and remarks

+ +

Obfuscations (a.k.a. +spoilers…)

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2011/fredriksson

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2011/goren/index.html b/2011/goren/index.html index 6a2b3ff60..d0b6c02f2 100644 --- a/2011/goren/index.html +++ b/2011/goren/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,248 @@ - - + + + + + + - - -2011 goren - - + + + +2011/goren + + + + + -

2011 goren

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2011/goren

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2011/goren/index.html

- +
+ ← fredriksson + ↑ 2011 ↑ + hou → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Uri Goren
+Location: IL

+ + +

To build:

+
make
+

To use:

+
echo "some text" | ./goren
+

Try:

+
./try.sh
+

Judges’ remarks:

+

In the words of René François Ghislain +Magritte Magritte:

+
+ + +
+

One may ask the surrealist question:

+
echo 'If | is just a representation of a pipe, then how can data stuff it?' | ./goren
+

However if one takes a firm stand and declares:

+
echo '| is just a representation of a pipe because I say so! So stuff it!' | ./goren
+

something happens! Why?

+

Author’s remarks:

+

This program was written in homage to Rene Magritte’s +picture “La +trahison des images” (The Treachery of Images).

+

In order to show my unconditional admiration of this work, I avoided +using conditions.

+

In this work, Magritte points out that a picture of a pipe is not a +pipe. But what IS a pipe? This program tries to provide an answer.

+

Magritte’s test for +pipes is:

+
The famous pipe. How people reproached me for it! And yet, could
+you stuff my pipe? No, it's just a representation, is it not?
+

Accordingly, this program only approves pipes which can be used for +stuffing data.

+

One thing I tried to achieve is condition free programming. Many have +noted that conditions make the code harder to read and understand. A +good example would be: Brent Burley’s +2004 IOCCC winner.

+

That entry omits conditional statements such as if and +while. His achievement in improving clarity by omitting +conditions is impressive, but I think it can be taken further, in two +ways.

+

First, conditional operators, such as ?:, +&& and ||, can be thrown away. Second, +using setjmp(3) and longjmp(3), which are +unfortunately not in common use, might make it difficult for a novice +programmer to understand the code without referring to the man page.

+

By removing these, the code is 100% condition free, and every +function runs its instructions in perfect order. Naturally, this makes +the program flow trivial to understand. This can be verified by +disassembling the compiled code and looking for conditional jumps (when +compiled with gcc on x86, there are none).

+

Compatibility:

+

The program should compile with any C compiler, but was tested mostly +with gcc on Linux.

+

It doesn’t support 64 bits (due to integer-pointer casts, and +a >>31). It does work on 64-bit Linux, because all +functions are below 4GB.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2011/goren

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2011/hamaji/index.html b/2011/hamaji/index.html index 60427c00b..34618da77 100644 --- a/2011/hamaji/index.html +++ b/2011/hamaji/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,394 @@ - - + + + + + + - - -2011 hamaji - - + + + +2011/hamaji + + + + + -

2011 hamaji

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2011/hamaji

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2011/hamaji/index.html

- +
+ ← konno + ↑ 2011 ↑ + richards → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Authors:

Name: bsoup
Location: JP

Name: Shinichiro +Hamaji
Location: JP

+ + +

To build:

+
make
+

To use:

+
./hamaji < a_nonogram_file
+

Try:

+
./try.sh
+

If you have perl installed you should be able to reproduce dragon.nono like:

+
perl c2nono.pl hamaji.c | ./hamaji
+

Judges’ remarks:

+

This program solves Nonograms which is also +known as “Paint by Numbers”.

+

This entry roars as the Year of the Dragon: A year considered some to +be good luck. Well it was certainly true that the IOCCC was lucky to get +such a fine submission!

+

The source code is a solution to a Paint by Numbers puzzle when you +paint by C. Try your hand at solving a few of the other +.nono files and then compare your solution with this +program!

+

NOTE: NONOGRAM (r) is a registered Trademark and is used with +permission. See https://nonogram.com for more information.

+

Author’s remarks:

+

The format of the input files are as same as this site: https://web.archive.org/web/20130218055139/http://codegolf.com/paint-by-numbers.

+

For example, for a simple problem which shows a glider of Conway’s +Game of Life:

+
   1
+   .
+  112
+
+1  X
+1   X
+3 XXX
+
+

the input should be

+
1
+1
+3
+-
+1
+1.1
+2
+

The width and the height of an input puzzle should be less than or +equal to 60.

+

When this solver finds the problem has no solution, it prints +“invalid”. This means the problem is indeed broken. For +example, this happens for an input like

+
2
+-
+2
+

When this solver cannot find a solution, it prints +“failed”. This failure can happen when the problem has more +than one solution or the solver cannot solve the input problem. Here is +an example input of the former:

+
1
+1
+-
+1
+1
+

There are two solutions:

+
  11
+
+1 X
+1  X
+

and

+
  11
+
+1  X
+1 X
+

Detail

+

Solving Nonogram is NP-complete, so +we cannot make a solver which solves all puzzles. However, we can write +a solver which solves most problems solvable by humans. There are a +bunch of ways to write such programs. The two most obvious approaches +are:

+
    +
  1. Check all possible solutions with backtracking.
  2. +
  3. Implement all techniques which humans use.
  4. +
+

The former, brute-force approach is easy to implement. However, it +works only for smaller problems (width and height should be at most 30 +or so). Similarly, using generic probabilistic metaheuristics +such as simulated +annealing doesn’t work for big problems.

+

See: http://ccl.northwestern.edu/netlogo/models/community/Nonogram.

+

By its definition, the latter method works for all human-solvable +problems. The issue of the latter approach is this kind of program tends +to be lengthy. This approach still requires some recursions. The most +difficult problems which are considered human-solvable may require some +“guesses”. For these kinds of problems, we need to assume a cell is a +space or a box, go ahead some steps with simple methods and mark the +tried cell as a box (or a space if we assumed the tried cell is a box) +if a contradiction is found.

+

My program uses an approach like “Set based solver” introduced in https://wiki.haskell.org/Nonogram#Set_based_solver. This +should be equivalent to the combinations of simple methods (no advanced +reasoning with guess). My solver also runs a non-recursive guess for +each undetermined cells. So, my program should be able to solve most +human-solvable problems (assuming humans cannot execute deeper +recursions).

+

Obfuscation

+

First of all, as you see, my program looks like a nonogram puzzle +which results in a dragon. +This puzzle is dragon.nono in this directory. +Note that whitespaces in character literals, a string literal, and +around the last comment are considered as a boxed cell.

+

My program is based on bit operations for speed. Many values are +stored using negative logic (0 means on and 1 means off) to utilize the +initial value of global variables. Thus, it might be difficult to figure +out how it works.

+

My program is decently shortened, because the size of source code is +limited by IOCCC’s rule (2048 non-whitespace characters) and a lot of +characters are just wasted for numbers around the picture.

+

The three requirements (dragon, speed, and size) naturally ended up +with the well obfuscated code.

+

Portability

+

This program uses two C99 features. One line comments and +long long. GCC’s -ansi -pedantic check should +pass:

+
cc -ansi -pedantic -std=c99 hamaji.c
+

I checked my program with gcc-4.6.2 on linux, llvm-gcc-4.2 on Mac, +and clang-3.0 on Mac.

+

Note that the behavior of scanf(3) differs on linux and +mac, but this program supports both semantics.

+

This program should not depend on sizeof(int), +sizeof(void*), ASCII, memory layout, undefined evaluation +order (e.g., a[i++]=i), etc. This program won’t work if the +size of long long literal is less than 8. By grepping the +source code of gcc

+
grep LONG_LONG_TYPE_SIZE gcc/config/*/*
+

I found long long may be 32bit integers only on AVR.

+

A few more things

+

This code is considered as a new +year’s postcard in Japan. We chose the dragon because 2012 is the year of +dragon.

+

The second author wrote the picture, and the first author did +everything else.

+

The dragon.nono, samurai.nono, and penguin.nono were written by the second author. +The soccer.nono was from a wikipedia entry. +This file is important because it requires some guesses. The random.nono file was randomly generated. The codegolf.nono and face.nono were taken from https://web.archive.org/web/20130218055139/http://codegolf.com/paint-by-numbers.

+

You can reproduce dragon.nono from hamaji.c using c2nono.pl:

+
perl c2nono.pl hamaji.c | ./hamaji
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2011/hamaji

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2011/hou/index.html b/2011/hou/index.html index fa842fc5d..bbb93a662 100644 --- a/2011/hou/index.html +++ b/2011/hou/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,265 @@ - - + + + + + + - - -2011 hou - - + + + +2011/hou + + + + + -

2011 hou

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2011/hou

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2011/hou/index.html

- +
+ ← goren + ↑ 2011 ↑ + konno → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Qiming HOU
+Location: CN

+ + +

To build:

+
make
+

To use:

+
./hou 'expression'
+

Try:

+
./try.sh
+

As the script asks you, what does the last one mean? Can you get it +to report a different value? Hint: it’s in this file, kind of.

+

Judges’ remarks:

+

This self-documenting scientific calculator compiles clean with no +warnings under the most strict pedantic mode of gcc and clang.

+

The first example, along with the correct result appears in the +source code. What does it mean?

+

The calculator obeys the precedence rules and allows parenthesis.

+
./hou '1+2*3'
+./hou '(1+2)*3'
+

What exactly does the text formatting do?

+

What does this evaluate to in C?

+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
+

Self documenting source

+

Comments would almost be redundant. :-}

+

The ASCII art is valid C +code

+

… and not just fancy formatted comment removed by the C +Pre-processor.

+

The only +multi-byte strings are format strings

+

The code does not contain some simple string-encoded lookup table for +calculator operations.

+

Example input and output +in the source

+

The example input and output in the C code is significant. Can you +find out why?

+

The button layout

+

The button layout in the C code is significant … not just a nice +looking layout.

+

Input parsing

+

The parser is functionally equivalent to a normal arithmetic parser +for all valid inputs. For another fun challenge: try to determine how it +parses the command line argument.

+

Author’s remarks:

+

Obfuscations

+

This program is designed to be self-documenting. It doesn’t just +provide an example command line. It also provides the expected output +and illustrates all supported functionality using embedded ASCII +art.

+ +

Portability

+ +

Spoilers

+

The parser parses function names, subtraction, and division as +single-letter unary operators. A bitmask encoded hash table is used to +check no-ops/digits and another hash function maps the ASCII to a +function ordinal, which is then executed by the button panel.

+

Both hash functions were found using a separate search program. +Another program was used to find a way to format one hash function as +example input such that it produces something resembling the bitmask +hash table as part of its output.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2011/hou

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2011/konno/index.html b/2011/konno/index.html index fd7f7058b..c70541c26 100644 --- a/2011/konno/index.html +++ b/2011/konno/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,210 @@ - - + + + + + + - - -2011 konno - - + + + +2011/konno + + + + + -

2011 konno

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2011/konno

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2011/konno/index.html

- +
+ ← hou + ↑ 2011 ↑ + hamaji → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Taketo Konno
+Location: JP

+ + +

To build:

+
make
+

To use:

+
./konno lower_case_word
+

Try:

+
./try.sh
+

Judges’ remarks:

+

This tiny program outputs what looks like a tiny keyboard. OK, so the +letters are missing. But that is no problem because this program +identifies the lower case letters that were pressed!

+

It is one of those minimal keyboards without all of those confusing +symbols keys. No shift for SHOUTING CAPS but at least it does not have +that useless CAPS LOCK key!

+

We recommend that you completely deconstruct / figure out how this +program works and does what it does. Can you extend this program to deal +with a full QWERTY keyboard? Can you then minimize the size of that +code?

+

Author’s remarks:

+

Limitation

+

This program ignores non-lower case letters.

+

Obfuscation

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2011/konno

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2011/richards/index.html b/2011/richards/index.html index 390fb81ef..f08dada77 100644 --- a/2011/richards/index.html +++ b/2011/richards/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,265 @@ - - + + + + + + - - -2011 richards - - + + + +2011/richards + + + + + -

2011 richards

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2011/richards

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2011/richards/index.html

- +
+ ← hamaji + ↑ 2011 ↑ + toledo → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Gregor +Richards
Location: US

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: doesn't work with some platforms - please help us fix
+

For more detailed information see 2011 richards in bugs.md.

+

To use:

+
./richards
+

Try:

+
echo '10 9 8 7 6 5 4 3 2 1*p*p*p*p*p*p*p*p*p' | ./richards
+echo '64 256 128 p/p*p' | ./richards
+

Judges’ remarks:

+

Oh no, yet another dc-style +calculator? (see 2000/dlowe using an embedded +Perl interpreter and deemed Worst Abuse of the Rules). +Well, this one does it (expression calculation, that is, not the rule +abuse) in a different way. The author claims that his calculator does +just-in-time compilation. What would you do to prove or disprove his +claim without attempting to unravel the source?

+

Author’s remarks:

+

This is an implementation of the classic UNIX dc +command, the reverse +Polish calculator. Actually it’s a pretty bad implementation, since +it only implements 32-bit integers (well, sizeof(int)-sized +integers). It only implements the commands +, +-, *, /, p (only for +numbers), register stacks, macros and comparisons. Wow, you’d think I +could’ve done better in 2K of code.

+

OH! I forgot to mention! It’s a JIT.

+

Wait, don’t stop reading! I know what you’re thinking, +platform-specific code is discouraged in IOCCC. But do you see any +platform-specific code? There’s no assembler here! This JIT +works on a dozen platforms, and the only platform-specific assumptions +it makes are that the stack grows down and integers are at least +32-bit.

+

You will probably get warnings while compiling the code. In +particular:

+ +

Platforms on which all known/tested optimization levels work with no +additional flags:

+ +

Platforms which work but not at all optimization levels or needing +special flags:

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2011/richards

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2011/toledo/index.html b/2011/toledo/index.html index 66c758586..c270c443a 100644 --- a/2011/toledo/index.html +++ b/2011/toledo/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,415 @@ - - + + + + + + - - -2011 toledo - - + + + +2011/toledo + + + + + -

2011 toledo

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2011/toledo

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2011/toledo/index.html

- +
+ ← richards + ↑ 2011 ↑ + vik → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Oscar Toledo +G.
Location: MX

+ + +

To build:

+

If you have X11 installed:

+
make
+

There are two alternate versions, one that +lets you reconfigure the controls and size and another that should work for Windows. See Alternate code below.

+

To use:

+
./toledo
+

Alternate code:

+

The first alt version, toledo.alt.c, +allows you to reconfigure the controls and the dimensions more +easily.

+

The second version, toledo.alt2.c, should +work for Windows but does not allow you to reconfigure the keys or +dimensions. This is because it cannot be tested by us.

+

Alternate build:

+

For the one that lets you reconfigure the keys you will want to look +at the included header file, keysym.h, to find +the correct macros. Once you have the right names you can define the +macros FIRE, FORWARD, BACKWARD, +LEFT, RIGHT, WIDTH and +HEIGHT. Here are the defaults:

+
FIRE= XK_BackSpace:XK_Tab
+FORWARD= XK_Up:XK_w
+BACKWARD= XK_Down:XK_s
+LEFT= XK_Left:XK_a
+RIGHT= XK_Right:XK_d
+WIDTH= 512
+HEIGHT= 288
+

but you can change them about however you like, even with other keys. +For instance to swap LEFT and RIGHT:

+
make clobber LEFT=XK_Right:XK_d RIGHT=XK_Left:XK_a alt
+

but you can specify something completely else and you can pick and +choose which controls you wish to redefine. You might also wish to +change the dimensions of the game, WIDTH and +HEIGHT which have an arbitrarily selected lower limit as +well as the default values.

+

Observe that each of the controls are a pair in the form of +player2:player1 (yes, player 2 comes first!).

+

Judges’ remarks:

+

This two player game uses X11. The control keys can be configured by +modifying the A, B, C, +D and E macros at compilation.

+

After a quick splash screen the objective should be clear. There are +Red, Green and Cyan tanks. A larger window can be made by altering the +source early on, right before the code gets hard to follow, or using the +alternate version.

+

Like Oscar’s previous winning X11 program for the 19th IOCCC, if you +remove both the X11 include files and replace them with

+
#include "layer.c"
+

you ought to be able to compile and run this program on Windows. +NOTE: this is what toledo.alt2.c is for.

+

Author’s remarks:

+
        /=========\\
+        \==\   /==/                ||
+           || ||   /====\  |\/=\   ||      //==\   ==\ |=\
+           || ||       ||  ||  ||  ||  //  ||       =| | |
+           || ||   //===|  ||  ||  ||=//   \\=\\   ==/ |=/
+           || ||   ||  ||  ||  ||  || \\      ||   User's
+           \===/   \\==//  ||  ||  ||  \\  \==//   Manual
+

This is a color X11 3D tank-game for two players, just compile and +run it without arguments.

+

You will see briefly a tank spinning before each level.

+

The Left half of the window shows the red player view and the right +half shows the green player view; the background will change to blue +when the view goes inactive.

+

The objective is to chase and destroy the other player’s tank. There +is also an aqua tank for testing your aim and getting extra points.

+

Caveat: You can shoot only 3 bullets at a time.
+Trick: You can fire faster if they explode on anything.
+Believe it or not, it has strategy!

+

When only one tank remains on the field, the level will advance. +Don’t forget to destroy the aqua tank.

+

The battleplayground is surrounded by mountains and +each level is filled with random obstacles (pyramids and cubes).

+

The bars show players energy and score; each bar shows energy and +indicates the current player view (wider on the left). The right part +grows with every point.

+

Keys for player 1 (lowercase):

+ +

Keys for player 2:

+ +

Note: Numeric keys don’t work.

+

If you don’t like the keys assignment, you can change it in the +Makefile or use the alternate version.

+

PARENTAL ADVISORY WARNING:

+

This game is highly violent: when the tank explodes you can see the +little stick man blowing in parts.

+

Not really, just kidding :D

+

PLATFORMS TESTED:

+ +

COMPLETE FEATURE SET:

+ +

FEATURES THAT +PROGRAMMERS WILL FIND APPEALING:

+ +

OBFUSCATION TRICKS:

+ +

+                                       ....,,,,---++++++--,,..\
+                     .,,,.......     .$@@@@@@@@@@@@$$@@@@@@@@@@@@@@#+\
+                     @@@@@###@@@@$$$@@@@$$$@@@-......-@+......,,,,,,##\
+                     =++==++++++++=@@$==#$$$$$---,,,,@@@,,,,,,-------@@,..........,,.\
+        ,===#$$$$$$###$####=======@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+=##$@@@@@@@@.
+        +@,,++++++++=+=========++++===++++++++++-+++@@-,,,,,,,,---+++=++++--,,...   @.
+        .@.                      .......,,,,-----++=@=++==@$=+--,,...               @.
+         $#         S P O I L E R              .,,-#@--,,,@$.....                   @.
+         .@                           ..,--+==++-,,,,.,,,,=@+++++====+++++---,,,....@.
+          @+                ..,,-+++++++-,,..              @.         ....,,,,,---+@@\
+          ,@       ..,--+++=+++,,..                        $#                   .==+\
+           @#--++==++-,,..                                 ,@  S P O I L E R  .==+\
+           ,#@@$+,,.                                        @.               ==+\
+               .,,+++++,,.            S P O I L E R         $=             +=+\
+                     ..,-==++-,.                            ,@           ---\
+                            .,-+=+++,..                      @.       .++-\
+                                  .,,++=++-,.                @+      ==+\
+                                        .,-++==+-,.          +@    ==+\
+                                              ..,+++=+-,..   .@. +=+\
+                                                     .,-+++++,@@==
+
+

THE HISTORY OF THIS PROGRAM:

+

When I started working on this program, I figured that it would be +easy to fit on the character limit, but I missed three things: the +enormous X11 names, the non-portable key codes and my 2 KB of +artwork.

+

Very hard coding did the first thing. In fact I worked out +twenty-nine different versions and at one step I had four parallel +versions with different characteristics removed (mountains, horizon +lines, score/status bars and explosions) but I’ve managed to fit it all +together!

+

The second thing was solved using the Makefile: it is under 160 bytes +and you get adjustable controls. The greatest mystery on the Earth is +why X11 gives non-portable key codes to the user.

+

And finally, the third “Thing” was growing and growing, and growing, +eating bytes for lunch… after endless rounds of crunching I obtained +three-hundred seventy-eight bytes of artwork and guess what? It doesn’t +fit.

+

So I had to integrate a decompressor based on the space, tabulators +and other non-counted characters.

+

The final program is composed of eight micro-functions: one is the +core and does most of the hard work and the other functions help do the +X11 things, explosion effects, 3D calculations and viewing.

+ +

The source code was formatted as a cube using a specially written +program. This program is smaller and obfuscated what is needed so the +reformatting doesn’t exceeded the character limits. The crunched vectors +were generated by another special program and the tank that surrounds +this text was generated by yet another program.

+

Have fun!

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2011/toledo

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2011/vik/index.html b/2011/vik/index.html index e74a4f33c..53def5ce0 100644 --- a/2011/vik/index.html +++ b/2011/vik/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,324 @@ - - + + + + + + - - -2011 vik - - + + + +2011/vik + + + + + -

2011 vik

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2011/vik

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2011/vik/index.html

- +
+ ← toledo + ↑ 2011 ↑ + zucker → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Daniel Vik
+Location: US

+ + +

To build:

+
make
+

There is an alternate version that should work for Windows. See alternate code below.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2011 +vik in bugs.md.

+

To use:

+
./vik file.mod > audio_file.raw
+

Try:

+
./vik randowan.mod | mplayer -demuxer rawaudio -
+./vik mad_world.mod | mplayer -demuxer rawaudio -
+

Alternatively, you can use:

+
./vik file.mod > file.raw; ./raw2wav file.raw > file.wav
+

It is possible to download a number of music module files from The Mod Archive.

+

Alternate code:

+

This version is based on the author’s remarks and it should work for +Windows.

+

Alternate build:

+

Assuming that make is similar enough try:

+
make alt
+

Alternate use:

+

Use vik.alt as you would vik above.

+

Judges’ remarks:

+

This entry converts .MOD audio files to a playable stream in a most +pleasing manner if you don’t like tremolo or vibrato.

+

Also it abuses the C compiler and/or assembler with a partially +initialized 32MB array. Can you tell what that partial initialization +for?

+

Does it take your system a long time to compile? You may want to +do:

+
cc -S vik.c
+

and examine the resulting assembly file vik.s. On some +platforms the assembly file is about 128MB in size!

+

NOTE: The randowan.mod and mad_world.mod files were created by Henrik Bertilsson and are +included with his permission.

+

Author’s remarks:

+

Introduction

+

In 1987, Karsten +Obarski changed the +way music was handled in games and demos with the introduction of +the MOD file format on Commodore Amiga

+

A MOD file contains a set of samples, a number of patterns indicating +how and when the samples are to be played, a list of what patterns to +play in what order, and a number of effects.

+

Features

+

This program converts MOD files created with the standard trackers +for Amiga, e.g. Pro Tracker, Noise Tracker and Sound Tracker to raw 16 +bit 44.1kHz stereo audio. The program supports MOD music with 4, 6, and +8 channels MOD files with up to 31 samples.

+

The MOD format includes many effects for each audio channel and this +program supports most of them, including:

+ +

Due to size constraints tremolo and vibrato is not supported. Also, +to avoid infinite long songs, the position jump feature is ignored.

+

Songs

+

With his permission, the package includes two songs composed by +Henrik Bertilsson, also known as Deelite:

+
    +
  1. Mad World
  2. +
  3. Randowan
  4. +
+

Build

+

Compiling for Unix systems (including cygwin) is straight +forward:

+
gcc -o vik vik.c
+

Usage

+

Convert MOD +file to raw 44.1kHz stereo audio file

+
./vik mad_world.mod > audio_file.raw
+

Listen to the MOD +file (streaming to mplayer)

+
./vik randowan.mod | mplayer -demuxer rawaudio -
+

(Don’t forget the last - as it makes mplayer read from +stdin.)

+

Obfuscation

+

The IOCCC rules did not put a limit on the entropy of the source +code, and it appears that the general entropy rules don’t apply. An +estimate is that the code density entropy of this entry is +~1.2 which means that there are around 2500 characters of +code carrying information, yet there are only 2037 IOCCC characters of +actual code. Most of the additional characters are encoded with +non-counting characters in the frequency table. But there are also +~50 or so white space characters spread out through the +source code that carry information.

+

The use of macros certainly adds to the obfuscation but the reason +for using them is mainly to fit as many features as possible within the +size limits. So please excuse the use of them.

+

Once the preprocessor is run, the code gets more interesting. The MOD +player is basically a register based state +machine and all the magic +is hidden in a fog of short statements. Many of the register updates are +conditional and the program uses the ?: operator (sigh) +mainly to save space, but also to leverage the comma operator and +precedence more efficiently.

+

Portability

+

The program is portable to most platforms. The only system dependency +is that the program relies on writing binary data to +stdout.

+

Microsoft compilers adds a carriage return to newlines, and to +compile the program with this platform, the following line can be added +after the main declaration in order for the program to run +correctly:

+
_setmode(_fileno(stdout), 0x8000);
+

NOTE: this is what the alternate +version is for.

+

Limitations

+

The program only runs when a valid MOD file is passed as argument. If +no argument is passed, the program crashes.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2011/vik

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2011/zucker/index.html b/2011/zucker/index.html index 8157451c7..af74909b3 100644 --- a/2011/zucker/index.html +++ b/2011/zucker/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,346 @@ - - + + + + + + - - -2011 zucker - - + + + +2011/zucker + + + + + -

2011 zucker

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2011/zucker

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2011/zucker/index.html

- +
+ ← vik + ↑ 2011 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Matt Zucker
+Location: US

+ + +

To build:

+
make
+

There is an alternate version which should work for Windows which +distinguishes binary mode from text mode. See alternate code below.

+

To use:

+
./zucker > image.ppm
+

Try:

+
./zucker "Hello\!\!\!" > hello.ppm
+./zucker faster\! -preview > image2.ppm
+

Display the PPM image with your favorite image viewer.

+

Alternate code:

+

This version uses the Windows functions _setmode() and +_fileno() to set binary mode on stdout which +the author noted would be necessary for systems that distinguish binary +and text.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use zucker.alt as you would zucker +above.

+

Alternate try:

+

Try zucker.alt instead of zucker above.

+

Judges’ remarks:

+

The rendered image is centered and is output as a 600 by 220 pixel +PPM. The vector font is proportional.

+

This entry uses no local variables. None! At! All!

+

Author’s remarks:

+

An image generator

+

What it does:

+

This program makes pretty pictures. To see the default output, try +running

+
./zucker > ioccc2011.ppm
+

On the author’s 2.5 GHz MacBook Pro, this command takes approximately +1 minute and 18 seconds to run – your runtime may vary. You will need an +image viewer capable of displaying Netpbm images in order +to display the output. On the Mac, the system supplied +Preview.app works well; otherwise ImageMagick and/or GraphicsMagick are both +capable of displaying Netpbm files, and are available on multiple +platforms.

+

With macOS you can type at the command line:

+
open ioccc2021.ppm
+

and it will open image in the default application Preview.app.

+

To use ImageMagick you might do something like:

+
convert ioccc2011.ppm ioccc2011.png
+

and then open ioccc2011.png in your viewer of +choice.

+

To use GraphicsMagick you might do something like:

+
gm convert ioccc2011.ppm ioccc2011.png
+

and then open ioccc2011.png in your viewer of +choice.

+

Aside from the default image, you may create your own by running the +program as follows:

+
./zucker "your text" > image.ppm
+

To mitigate long runtime, the program can be invoked in a “preview” +mode by appending -preview to the command line arguments, +like so:

+
./zucker faster\! -preview > image.ppm
+

If your platform distinguishes between binary and text streams, you +may need to insert some code to reopen standard output in binary mode at +the start of main() (the provided alternate version will set binary mode on +stdout in Windows). An ASCII platform is assumed.

+

Pedagogical value:

+

This program is quite suitable for the inexperienced programmer, due +to a number of considerations:

+ +

Further details (contains +spoilers):

+

The program is not quite a traditional ray +tracer, but a “sphere tracer” which +uses distance fields to encode proximity to objects in the scene. Using +sphere tracing to compute visibility instead of analytic ray tracing +provides two advantages: first, it greatly eases the computation of ray-torus +intersection (which would otherwise require solving a quartic +polynomial), and second, it makes it possible to compute ambient +occlusion (which is used to generate soft shadows). Unlike many +traditional ray tracers and sphere tracers, this one uses iteration +instead of recursion to compute the effect of reflections. This, +unfortunately, resulted in the programmer going insane; however, program +size was reduced and readability hindered. Neither the plaintext for the +program’s default output nor for the Netpbm header appears in the +program source, which hinders readability as well. Also, unlike some +previous IOCCC entries which render ASCII text, this one uses a vector +(as opposed to raster) font. Although the program does not generate +uppercase letters, it handles them in a reasonable manner when they +appear in the input.

+

Even when the program is pretty-printed and preprocessor macros are +translated, it should be fairly resistant to analysis due to reckless +reuse of global variables, the inherently opaque nature of the math, and +its overall density. Global variables are used to store the results of +intermediate computation. As a result, seemingly simple functions have +important side effects. Although some of the global variables are simply +constants, their use is overloaded. For instance, the variable +X is used both as the number 40 and as the +ASCII character '('. Maintainability is hindered due to +hardcoding several aspects of the program in multiple locations. As an +example, it is impossible to modify either the image width or height +without changing the source in at least three different places, +including inside the large string literal J.

+

Some of the functions are simple vector algebraic operations such as +vector construction, dot product, and normalization. However, it was +found to be much more compact to define a single operation for +multiply-and-add rather than to have separate functions for addition, +subtraction, and scaling. Again, compactness led to obfuscation.

+

This program heavily abuses for loops. The comma +operator is used to get as much mileage as possible out of statements +inside of loop declarations. Between for loops, the comma +operator, and the ternary operator, it was possible to avoid +if and while altogether.

+

Bitwise and arithmetic operators are used instead of logical +operators whenever gcc doesn’t warn about it. Conversely, integer +multiplication, division, and modulus are sometimes used in place of +traditional bitwise operators just to keep the reader on his or her +toes. Automatic casting between characters, integers, and floats is +performed just about everywhere. Fascinatingly, this doesn’t seem to +affect performance too badly. Sometimes when an explicit cast (i.e. from +float to int) is needed, the program instead +simply assigns to a free variable of the desired type instead. Both the +array[index] and index[array] notations are +used interchangeably throughout the program.

+

Two other programs were written to support development of this +program. The first used a randomized search algorithm to deduce the most +compact encoding of the vector font instructions into ASCII; the second +used a modified form of the Knuth-Plass +algorithm to layout the final text on top of a hand-generated ASCII +“stencil”. The programs were not submitted as entries for this year’s +IOCCC, not because they lack obfuscation, but because neither is written +in C (they are in C++ and Python, respectively).

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2011/zucker

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2012/blakely/index.html b/2012/blakely/index.html index 80843febf..a3b922e49 100644 --- a/2012/blakely/index.html +++ b/2012/blakely/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,300 @@ - - + + + + + + - - -2012 blakely - - + + + +2012/blakely + + + + + -

2012 blakely

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2012/blakely

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/blakely/index.html

- +
+ first entry + ↑ 2012 ↑ + deckmyn → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Philip +Blakely
Location: GB

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2012 blakely in bugs.md.

+

To use:

+
./blakely "RPN formula" resolution > output.gif
+

Try:

+
./blakely "xx*yy*+" 64 > paraboloid.gif
+
+./blakely 9 32 > empty.gif
+
+time ./blakely 0 250 > flat.gif
+

Judges’ remarks:

+

Several IOCCC themes (RPN +calculator, animated GIF generator, ray +tracing) in one package! Very impressive!

+

The checkerboard pattern in the output can be broken. Could you +figure out how?

+

Larger GIF files confuse some image viewers.

+

Author’s remarks:

+

Remarks

+

This program renders a generic RPN +expression in ray-traced +animated GIF form. The +expression in spatial variables x and y is +specified on the command-line with the required resolution, and an +animated GIF showing a fly-around of the resulting surface is output to +stdout.

+

Usage

+

The program should be run as:

+
./blakely xy* 32 > pic.gif
+

where the first parameter is a RPN +expression, and the second is the width of the required GIF, up to a maximum of +250.

+

The expressions are written in Reverse +Polish Notation with the following characters recognised:

+
+, -, *, /      - usual arithmetic operations
+^           - Exponentiation; valid for constant exponent only
+s           - sin
+c           - cos
+0-9         - single digit integers
+d           - duplicate number on stack
+t           - transpose top two elements on stack
+x           - x coordinate value
+y           - y coordinate value
+

NB: all arithmetic is done in double precision, so 23/ +is two-thirds, rather than 0.

+

The surface plotted corresponds to -1 <= x,y <= 1 +and for best results, the generated z value should lie +between -1 and 1.

+

If there is a division by zero, square-root of a negative number, or +similar operation, then the results are undefined.

+

Examples

+

For test-runs, use a resolution of 32. For simple expressions, the GIF generation should take +only a few seconds with a modern processor and full optimization. +Runtime scales as O(N^3) with +resolution N, and more complex expressions take longer to +compute. For example, increasing the resolution of +ripple.gif to 250 took ~35 minutes to render on an i7 +processor.

+
./blakely xy* 32 > saddle.gif
+
+./blakely xx*yy*1++d5*ct/ 64 > ripple.gif
+

Algorithm

+

A generic root-finding algorithm to find the point of intersection +between a ray and the surface is done using a simple forward search from +the eye. In order to make the rendering realistic, both the value of the +expression, and its derivative with respect to x and +y must be tracked. This is done using an obvious +stack-based approach.

+

Obfuscations

+

Much of the obfuscation is achieved through the use of single-letter +variables and #defines. The characters output for the GIF format are +generated in myriad and wonderful ways, making use of XOR, return values +from putchar(), and odd expressions. The layout is in the +form of X Y Z.

+

Limitations

+

ASCII is assumed since many bytes for the GIF output are generated +from characters given in the source code. On compilation a few warnings +about parentheses come up when using gcc 4.6.3, and one about no return +value from main() (who uses exit codes anyway?), but clang +3.1 emits no warnings.

+

Questions

+ +

(Note that the author may or may not be able to answer all of the +above questions.)

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2012/blakely

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2012/deckmyn/index.html b/2012/deckmyn/index.html index feb9b4595..584d5eb5d 100644 --- a/2012/deckmyn/index.html +++ b/2012/deckmyn/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,322 @@ - - + + + + + + - - -2012 deckmyn - - + + + +2012/deckmyn + + + + + -

2012 deckmyn

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2012/deckmyn

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/deckmyn/index.html

- +
+ ← blakely + ↑ 2012 ↑ + dlowe → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Alex Deckmyn
+Location: BE

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2012 deckmyn in bugs.md.

+

To use:

+
./deckmyn "$(cat deckmyn.c)" "$(cat musicfile.txt)" > sheetmusic.pbm
+

Try:

+
./try.sh
+

Judges’ remarks:

+

The C of this entry is definitely sharp. The program cleverly uses +its own source at runtime to define the notes, time signature and +accidental bitmaps.

+

In addition to sheet music, this program is also able to, given the +right input, generate an image of a 10-pin DIP chip +(a sound processor?).

+

Historical remarks:

+

We previously wrote that ironically, the way this entry is called +from the command line is an abuse of C Shell. Please use Bourne-family +shells to run this entry.

+

… but in 2023 we changed the backticks to be the bash +$(..) construct. This is not done in the author’s remarks, +however.

+

Author’s remarks:

+

Example use

+

You need the source code and example input (either one of the example +files, or manual input as below) ready and a program capable of showing +.pbm bitmap format +images.

+
./deckmyn "`cat deckmyn.c`" "`cat example_greensleeves`" > greensleeves.pbm
+

If you have macOS you can open the image like:

+
open greensleeves.pbm
+

… otherwise, you’ll have to open it in your viewer of choice how you +would normally open an image.

+
./deckmyn "`cat deckmyn.c`" "KF m44c4 c4 g4 g4 :  a4 a4 g2 :; " > short_bass.pbm
+

If you have macOS you can open the image like:

+
open short_bass.pbm
+

… otherwise, you’ll have to open it in your viewer of choice how you +would normally open an image.

+

Description

+

Every major C competition should have an entry capable of producing C +major. This is a music notation program. It produces bitmaps +(.pbm) of music based on ASCII input. A full manual is +added as a separate file. Some musical examples +are also included.

+

The program is capable of printing notes, rests, (double) bar lines +and accidentals on a single melodic line (multiple staves). No chords, +polyphony etc.

+

The program expects two command line arguments. The first is +a (very long) string that contains the complete music font. Note that it +should not be given as a file name! The default music font is +encoded in the (whitespace of the) source code deckmyn.c itself. Therefore, the first argument +should be "`` cat deckmyn.c +``".

+

The second command line argument is the music itself. This is, again, +a string, not a file name. All music signs are entered as tokens of +exactly 3 characters. The code is very sensitive to bad spacing! So for +instance, if you use a file to write the music (e.g. example_greensleeves), you should keep +in mind that newline is also a character!

+

Internals

+

To minimise the memory footprint, this program has no variable +declarations at all, except for the arguments to +main(). The only available memory space is from the command +line arguments and count (argv and argc). +Parts of argv are cast as int when values +under 0 or beyond 127 are expected.

+

The “music font” is defined by the source code itself. The first few +lines are not part of the font definition, as this memory space will be +modified by the program. (So as required by the rules, it is only a +(memory) copy of the source code that is modified.)

+

As there is no memory available, output is directly to +stdout, byte by byte, from the top left to the bottom right +pixel.

+

LIMITATIONS

+

The memory locations of argv are used for various +purposes. Therefore, the program name (default deckmyn) +must be at least 4 characters long, including possibly the +path. This, along with the ending '\0', gives minimum 5 +bytes of useful memory space. Otherwise, the program may attempt to +write outside the string.

+

The code is quite sensitive. Errors in the input can lead to strange +results. The code does not read beyond the end of the music input, but +that is about the only error checking available. Any input that is not +according to the rules in the manual, may cause +errors.

+

The program has no special hardware limitations or requirements, +other than 8bit char (signed or +unsigned) and two’s complement negatives.

+

The limitations of using char as counters for e.g. the +number of music staves are minor. 127 staves to a page is rather a +lot.

+

Obfuscations

+

The code has no declared variables other than the command line +variables. Not even pointers (we all know how messy code can get with +too many pointers!). As more than one variable needs values beyond 127, +parts of the command line memory are cast to int using a +macro.

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2012/deckmyn

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2012/dlowe/index.html b/2012/dlowe/index.html index bf3cc802a..a1b749994 100644 --- a/2012/dlowe/index.html +++ b/2012/dlowe/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,260 @@ - - + + + + + + - - -2012 dlowe - - + + + +2012/dlowe + + + + + -

2012 dlowe

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2012/dlowe

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/dlowe/index.html

- +
+ ← deckmyn + ↑ 2012 ↑ + endoh1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: J. David Lowe
+Location: US

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2012 +dlowe in bugs.md.

+

To use:

+
./dlowe
+

Try:

+
./dlowe
+

Watch for a while if you like, then press a key within the +window.

+

Use up and down keys to escape death.

+

Judges’ remarks:

+

The judges lose playing this game. This entry wins!

+

Q: How did we get past the variadic macro problem on a Mac?

+

A: Don’t use -pedantic-errors in the Makefile.

+

Author’s remarks:

+

Conway’s Game of DEATH

+

This is a challenging, fast-paced arcade game, based on the famous Game of +Life.

+

Story

+

In the game, you are Mr.C, a lightweight spaceship making a futile +dash for escape from the rigid rules and predictability of life in the +B3/S23 universe.

+

Use the up and down arrow keys to steer: collisions are fatal for +Mr.C! Learn to spot incoming gliders, skim the surfaces of beehives and +blocks, and give blinkers plenty of space. Things get crazier as Mr.C +picks up speed… can he escape?

+

No. There is no winning. Sadly for Mr.C, this universe goes on +forever. Just see how far you can make it!

+

Press q any time to quit.

+

Features

+ +

Limitations

+ +

Wish List

+ +

Hosts Tested

+ +

Obfuscations

+

The code is formatted into a 14-cell shape which will evolve into a +glider in 19 generations.

+

Lots of globals, including a global struct whose members +have the same names as global variables.

+

Global variables getting reused in different contexts.

+

Huge and convoluted expressions, abusing ternary operators and +operator precedence.

+

Lots of magic numbers, abuse of the relationships between magic +numbers, and abuse of the arithmetic properties of magic numbers.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2012/dlowe

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2012/endoh1/index.html b/2012/endoh1/index.html index 4bd8eab39..cf64311e1 100644 --- a/2012/endoh1/index.html +++ b/2012/endoh1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,467 @@ - - + + + + + + - - -2012 endoh1 - - + + + +2012/endoh1 + + + + + -

2012 endoh1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2012/endoh1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/endoh1/index.html

- +
+ ← dlowe + ↑ 2012 ↑ + endoh2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yusuke Endoh
+Location: JP

+ + +
make
+

There are two alt versions that let you control the compile time +variables that control the fluid behaviour and the added variables to +speed up or slow down the fluid as well as setting a timeout (if not 0): +one for the original black and white and the colour one added by the +author at the request of the judges. Another version is the deobfuscated +version provided by the author as well. See alternate code below for more details.

+

To use:

+
./endoh1 < configuration.txt
+

Try:

+
./endoh1 < endoh1.c
+
+./endoh1 < pour-out.txt
+
+./endoh1 < fountain.txt
+

Also try using endoh1_color as you would +endoh1 above. make will compile this by +default.

+

Alternate code:

+

The files endoh1.alt.c and endoh1_color.alt.c correspond to endoh1.c and endoh1_color.c but which allow you to speed up +or slow down the fluid and change the behaviour of the fluid. The file +endoh1.alt2.c is deobfuscated and was +provided by the author.

+

Alternate build:

+

For the default values, try:

+
make alt alt2
+

The alt2 is only necessary if you wish to compile the +deobfuscated version but it is equivalent in function to the original +entry, endoh1.c.

+

In the alt versions a default time of 10 seconds is set +as an alarm so that one can more easily go through the list of files to +see them all in succession for fun. That is controlled by the variable +A; 0 disables it.

+

If you wish to change the speed you should do:

+
make clobber SLEEP=N alt
+

where N is number or the letter I.

+

WARNING: if you’re sensitive to flashing colours or any flashing at +all do make sure you don’t decrease the value of S, the +sleep time passed to usleep(3), too much.

+

If however you wish to change the gravity factor, pressure factor +and/or viscosity factor, you should redefine the values G, +P and/or V macros, respectively, with the same +caveat about numbers for S above. For instance if you wish +to change the viscosity and pressure factors but leave the other macros +alone:

+
make clobber VISCOSITY=X PRESSURE=Y alt
+

where X and Y are numbers or the letter +I and which are, respectively, the viscosity and pressure +factors.

+

There is no restriction on what the number is because doing so +prevents the macros from being defined to I which would +prevent the author’s remarks about it from being done.

+

If you want to disable the alarm time, set A to 0:

+
make clobber TIMER=0 alt
+

It cannot be < 0 or > 60 (arbitrarily selected).

+

Try slowing down the display by increasing the sleep time from +12321 to 50000:

+
make clobber SLEEP=50000 alt
+

Now try using both endoh1.alt and +endoh1_color.alt as you would endoh1 +above.

+

Also try speeding up the display by decreasing the sleep time from +12321 to 9999:

+
make clobber SLEEP=9999 alt2
+

WARNING: again, be careful with too low a value if you’re sensitive +to flashing colours or anything at all.

+

Now try using both endoh1.alt and +endoh1_color.alt as you would endoh1 +above.

+

You might also wish to try redefining the macros G, +P and/or V. For instance:

+
make clobber GRAVITY=5 PRESSURE=5 VISCOSITY=5 alt
+

You might try even:

+
make clobber GRAVITY=I alt
+

See the author’s remarks for details on these macros.

+

Alternate use:

+

Use endoh1.alt, endoh1_color.alt and +endoh1.alt2 as you would endoh1 and +endoh1_color above.

+

Alternate try:

+

To see two different ways run on the source file and each of the text +files, try:

+
./try.alt.sh
+

The second run of each will be with the gravity factor set to +I.

+

Judges’ remarks:

+

Let’s play Jeopardy!

+

A: An obfuscated program that deals with complex numbers and produces +animated ASCII graphics. Q: What is a Mandelbrot simulator?

+

Bzzzt!

+

Such heavily squeezed fluid simulation (this is parsed uniquely as +fluids are not squeezable) has a few quirks that the judges were happy +to experiment with.

+

One configuration file was inspired by an XKCD +what if? entry.

+

Author’s remarks:

+

Synopsis

+

DO NOT FORGET -DG=1 -DP=4 -DV=8 and +make your terminal window larger than 80 x 25.

+
cc endoh1.c -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -o endoh1 -lm
+./endoh1 < endoh1.c
+./endoh1 < logo.txt
+./endoh1 < column.txt
+./endoh1 < pour-out.txt
+./endoh1 < tanada.txt
+

What it is

+
    ,___. ,.       ,.    ,.   ,___. ,.              ,.       ,.
+    |/--' ||       `'    ||   |/--' `'              ||       |\_.
+    |\__. || ,. ,. ,. ,__/|   |\__. ,. ,____. ,. ,. ||  ,_.  |/-'  ,_.  ,__.
+    |/--' || || || || |/-\|   `--\| || |/\/\| || || || ,/-\. ||   ,/-\. |/-\.
+    ||    || `\_/| || |\_/|   ,__/| || |||||| `\_/| || `\_/\.`\_. `\_/' || `'
+    `'    `'  `--' `' `---'   `---' `' `'`'`'  `--' `'  `-'`' `-'  `-'  `'
+
+
+     ,.,.                      ,.,.
+    ,/\/\. ,.       ,.    ,.  ,/\/\. ,.              ,.      ,__.
+    |||#/' ||       `' ,_.||  |||#/' `',_.,__.       ||      ||\\.        ,.
+    |||#\. || ,. ,. ,.,/#|||  |\//\. ,.|#||##| ,. ,. || ,.,. |\/-' ,.,. ,.|\.
+    |\/--' ||,/\.|| |||#/\/|  `\#||| |||#||/\|,/\.|| ||,/'`\.|#|  ,/'`\.|\/-\.
+    `\|    ||`\#||| |||#||\|  ,//\/| ||`\|||||`\#||| ||`\.,/\/\|,.`\.,/'`\| `'
+     `'    `' `-'`' `'`-'`-'  `-'`-' `' `'`'`' `-'`' `' `'`--'`'`' `'`'  `'
+
+
+    ,_.,_. ,.       ,.    ,.  ,_.,_. ,.              ,.      ,.
+    |#||#| ||       `'    ||  |#||#| `'              ||      ||,_.
+    ||\/#| ||,.  ,. ,.,_.,/|  |\||#| ,.,_.,__.,.  ,. || ,.,. |||#| ,.,. ,.,_.
+    |||##| ||||  || |||#||#|  |#||#| |||#||##|||  || ||,/||\.||`-',/||\.|||#\.
+    ||`--' ||`\_.|| |||\||#|  |#||#| ||||'||\|`\_.|| ||`\||#|`\.,.`\||/'||`--'
+    `'     `' |#||| `'|#||#|  |#||#| `'`' `'`' |#||| `' |||/' |||| |||| `'
+              `-'`'   `-'`-'  `-'`-'           `-'`'    `'`'  `'`' `'`'
+
+
+

This program is a fluid simulator using the Smoothed-particle +hydrodynamics (SPH) method.

+

The SPH particles represent the fluid flow. Particles have +information about the position, density, and velocity. In every +simulation step, they are changed by pressure force, viscosity force, +and external force (i.e., gravity).

+

This program reads a text from standard input, and uses it as an +initial configuration of the particles. The character # +represents a “wall particle” (a particle with a fixed position), and any +other non-space characters represent free particles.

+

The compilation options -DG=1 -DP=4 -DV=8 represent, +respectively, the factor of gravity, pressure, and viscosity. By +changing their values, you can see different fluid behavior.

+

Marching +square-like algorithm is used to render the particles.

+

Portability

+

The program requires a C99 compiler; it uses complex +types and one-line comments. It also uses usleep(3), which +may require -D_BSD_SOURCE or so to build with no warning. +Under these conditions, it should be portable. At least, recent +compilers with -std=c99 -Wall -W -Wextra -pedantic say +nothing.

+
gcc -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -std=c99 -Wall -W -Wextra -pedantic endoh1.c
+
+clang -DG=1 -DP=4 -DV=8 -D_BSD_SOURCE -std=c99 -Wall -W -Wextra -pedantic endoh1.c
+

I expect it to work in any Unix-like environment. VTxxx/ANSI +sequences are used to clear screen and move cursor to home.

+

I’ve tested with gcc-4.6.3 and clang-3.0 on Linux (Ubuntu 12.04) and +gcc-4.5.3 and clang-3.1 on Cygwin. On Cygwin, gcc and clang complain +about a usage of I (complex’s imaginary unit), but I bet +this is cygwin’s issue; it is surely a C99 feature.

+

Obfuscation w/ Spoiler

+

First of all, the source code itself serves as an initial +configuration. Preprocessing directives (such as +#include)’s # serve as walls.

+

This program uses double complex to represent any 2D +vector. But, note that the x-axis and y-axis +are swapped (real axis = y-axis, imaginary axis = x-axis). The purpose +of swapping is not only obfuscation, but also short coding: for example, +to add gravity to total force, force += G suffices, rather +than force += G*I.

+

(Incidentally, you can exert horizontal gravity by using for instance +-DG=I)

+

Every five entries of double complex a[] contain +information of one particle: position, wall-flag, density, force, and +velocity, in turn.

+

You can use G, P, and V as a +guide to find the calculation code of gravity, pressure, and viscosity +forces.

+

Though some assignments may look meaningless, they are actually +meaningful; they extract “integer part of real part” from a complex +value by assigning (and casting) it to an integer-type variable.

+

Notes about Additional Files

+

logo.txt is a source of the logo in this +remark file.

+

column.txt is a water column collapse, which +is a popular demo of SPH.

+

pour-out.txt pours you a cup of tea.

+

tanada.txt simulates “Terrace farming”. +(“Tanada” means a “terraced rice +fields” in Japanese.)

+

clock.txt is a “water” clock created by +HAMANO Tsukasa.

+

Other *.txt files are from the judges.

+

endoh1_color.c is a variant that shows +the density by using terminal 256 colors.

+

Acknowledgments

+

I would like to thank my wife @hirekoke for her teaching me the SPH +method.

+

The judges ordered suggested creating a color +version after the contest.

+

The judges and HAMANO Tsukasa (The silver medalist at this IOCCC) +kindly provided many configuration files.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2012/endoh1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2012/endoh2/index.html b/2012/endoh2/index.html index 72f8a226d..56e28c37d 100644 --- a/2012/endoh2/index.html +++ b/2012/endoh2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,302 @@ - - + + + + + + - - -2012 endoh2 - - + + + +2012/endoh2 + + + + + -

2012 endoh2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2012/endoh2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/endoh2/index.html

- +
+ ← endoh1 + ↑ 2012 ↑ + grothe → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yusuke Endoh
+Location: JP

+ + +

To build:

+
make
+

To use:

+
./endoh2 > pi.c
+gcc -o pi pi.c
+./pi > 314.c
+

and:

+
./endoh2 e > e.c\
+gcc -o e e.c
+./e > 271.c
+

…

+

Try:

+
./try.sh
+

Judges’ remarks:

+

A pi/e +printing quasi-[quine](https://en.wikipedia.org/wiki/Quine_(computing) +in ASCII art with +a compressed font in it; what else to wish for in this program? Virtual machine +emulation?

+

Author’s remarks:

+

Yeah, “Again”. Sorry. But I don’t feel guilty or uncomfortable.

+

This entry is based on ‘over-used themes’ such as self reproducing +program and pi or e) +computation. I know you’re tired of them.

+

But have you ever seen them all-in-one?

+

What it is

+

This program generates a new program in the shape of the Greek letter +pi. Then, the generated program:

+ +

One more thing… When you give a command line argument e +to the first program, the generated one will compute Napier’s +constant) rather than pi.

+

Obfuscation

+

This program itself is in the shape of a spigot. This is +derived as an analogy with spigot +algorithm which infinitely computes the value of a mathematical +constant such as pi or e.

+

The two sets of programs, 314*.c and +271*.c, are almost the same except their shape and constant +computational part. I tailored the common part to parse in both shapes +(3.14... and 2.71...), by tweaking the +computational order and adding meaningless code fragments.

+

On the other hand, to make it fit inside one screen (80 x 25), my +program is shortened properly, more than it looks. (As you may know, quines need +to make its program size doubled.) For example, this program involves +3x5 bitmap font data of ten characters (0 – +9), as just 20 bytes: G1%xJ{;Q7wunmuGuu%uu. We +can decode character n as +275*s[n+10] - 8*s[n] - 8. I solved the system of Bézout’s +identity to find the magic string, with the aid of a brute force. +See find-font-table.rb in detail.

+

I used many other tricks for short coding.

+

I’m sorry that many ASCII-art-style winning entries of IOCCC ignore C preprocessor +directives. In my program, #include is a part of +ASCII-art with comments padded.

+

These design requirements made my program well-obfuscated +willy-nilly.

+

Portability

+

I expect it to work in any major environment and C compiler. To build +with no warning, it requires two C99 features: allow string literal to +be more than 509 characters and not requiring a return in +main(). In fact, recent compilers with +-std=c99 -Wall -W -Wextra -pedantic would say nothing.

+
gcc -std=c99 -Wall -W -Wextra -pedantic spigot.c
+clang -std=c99 -Wall -W -Wextra -pedantic spigot.c
+

I’ve tested with gcc-4.6.3 and clang-3.0 on Linux (Ubuntu 12.04) and +gcc-4.5.3 and clang-3.1 on Cygwin.

+

Synopsis

+
cc endoh2.c -o endoh2
+
+./endoh2 > pi.c
+cat pi.c
+
+cc pi.c     -o pi     ; ./pi     > 314.c     ; cat 314.c
+cc 314.c    -o 314    ; ./314    > 3141.c    ; cat 3141.c
+cc 3141.c   -o 3141   ; ./3141   > 31415.c   ; cat 31415.c
+cc 31415.c  -o 31415  ; ./31415  > 314159.c  ; cat 314159.c
+cc 314159.c -o 314159 ; ./314159 > 3141592.c ; cat 3141592.c
+etc...
+
+./endoh2 e > e.c
+cat e.c
+
+cc e.c      -o e      ; ./e      > 271.c     ; cat 271.c
+cc 271.c    -o 271    ; ./271    > 2718.c    ; cat 2718.c
+cc 2718.c   -o 2718   ; ./2718   > 27182.c   ; cat 27182.c
+cc 27182.c  -o 27182  ; ./27182  > 271828.c  ; cat 271828.c
+cc 271828.c -o 271828 ; ./271828 > 2718281.c ; cat 2718281.c
+etc...
+

You can do make everything for the process (with no +cat).

+

Note: The executable may return a failure (non-zero) exit status +unless -std=c99 option is given.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2012/endoh2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2012/grothe/index.html b/2012/grothe/index.html index 62e78dea6..c3865feb7 100644 --- a/2012/grothe/index.html +++ b/2012/grothe/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,309 @@ - - + + + + + + - - -2012 grothe - - + + + +2012/grothe + + + + + -

2012 grothe

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2012/grothe

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/grothe/index.html

- +
+ ← endoh2 + ↑ 2012 ↑ + hamano → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Authors:

Name: Aaron Grothe
+Location: US +

Name: David +Madore
Location: FR

+ + +

To build:

+
make
+

To use:

+

To create a shared secret shared among M people with +N+1 needed to reconstruct:

+
./grothe -secret 1-/dev/urandom 2-/dev/urandom ... \
+    N-/dev/urandom 1+shared1 2+shared2 ... M+sharedM
+

To reconstruct the original (an arbitrary combination of +N+1 or more shared files with their proper numbers):

+
./grothe I-sharedI J-sharedJ K-sharedK ... +reconstructed
+

Try:

+
./grothe -grothe.c 1+grothe.c.1 2+grothe.c.2
+
+./grothe -cookie_recipe.txt 1-/dev/urandom 2-/dev/urandom 1+cookie_piece1.dat 2+cookie_piece2.dat 3+cookie_piece3.dat 4+cookie_piece4.dat
+
+./grothe 1-cookie_piece1.dat 2-cookie_piece2.dat 4-cookie_piece4.dat 4+cookie_recipe_restore.txt
+

Judges’ remarks:

+

Also known as ‘Best abuse of the judging process’.

+

The IOCCC 2012 submission page didn’t enforce the 2048 meaningful +character limit. This entry, as submitted, weighed in at 2222 chars but +lucky for it, it was extremely easy to bring down below the limit. There +were a number of strings that when concatenated allowed the program to +slide under the limit.

+

It was clear to the judges that the extra size was an entry +beautification step. Had it not been, this entry would have been +rejected in round 0.

+

The judges also took some liberty obfuscating this entry a little +more.

+

How does this entry work? The only place multiplication is used is to +perform the atoi(3) conversion.

+

Author’s remarks:

+

Description

+

This program implements a version of Shamir’s +Secret Sharing. Shamir’s Secret Sharing allows you to encrypt a file +into N parts where it will take M parts to +recreate the original file. E.g. you can split the secret recipe for +Crystal Pepsi into 3 parts and require two of them be available to +extract the original recipe.

+

Actually surprisingly useful for an IOCCC entry :-)

+

Usage

+

To share a secret. For example:

+ +

Example usage

+

To split a secret into 4 pieces of which at least 3 will be needed to +get it (in this case the cookie recipe) back:

+
./grothe \
+    -cookie_recipe.txt\
+    1-/dev/urandom 2-/dev/urandom\
+    1+cookie_piece1.dat 2+cookie_piece2.dat 3+cookie_piece3.dat 4+cookie_piece4.dat
+

To put the recipe back together using the first, second and fourth +pieces:

+
./grothe \
+    1-cookie_piece1.dat 2-cookie_piece2.dat 4-cookie_piece4.dat
+    +cookie_recipe_restore.txt
+

Limitations

+

The program is limited to 256 input and output files and will slow +down dramatically when you get past 20-50 inputs and outputs.

+

Obfuscations

+ +

References

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2012/grothe

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2012/hamano/index.html b/2012/hamano/index.html index cb0a70015..f341cb279 100644 --- a/2012/hamano/index.html +++ b/2012/hamano/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,247 @@ - - + + + + + + - - -2012 hamano - - + + + +2012/hamano + + + + + -

2012 hamano

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2012/hamano

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/hamano/index.html

- +
+ ← grothe + ↑ 2012 ↑ + hou → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Tsukasa +Hamano
Location: JP

+ + +

To build:

+
make
+

To use:

+
./hamano < textfile > output.pdf
+

Try:

+
./try.sh
+

The script will generate a number of PDF files and it will suggest +you look at them as well. You can read hint.pdf with a PDF +reader like acroread hint.pdf or +evince hint.pdf. With macOS you can do +open hint.pdf which by default will open +Preview.app. You may of course use your pdf viewer to open +the file directly instead.

+

One of the PDF files generated is this README.md file as a PDF, +obfuscated, and the PDF file will then be compiled as C (itself!) and +executed so that it shows README.md!

+

Another PDF file generated is obfuscated C code. Once this is done it +will compile the PDF as if it was C and then run it like:

+
echo 'int main(){puts("Hello World!");}' | ./hamano > hello.pdf
+cc -Wno-implicit-function-declaration -xc hello.pdf -o hello2
+./hello2 | gcc -Wno-implicit-function-declaration -xc - -o ./hello3
+./hello3
+

Judges’ remarks:

+

This entry treads into a new territory for IOCCC - generating PDF +files.

+

The originally submitted entry could have been thought of as a “Best +abuse of Ghostscript” winner. :-)

+

The source code and rendered pages are obfuscated for humans (where +is the font?), and the submitted entry created PDF files that left +Ghostscript confused.

+

The results can be viewed with Acrobat Reader, evince and Apple’s Preview.

+

The updated version can also be viewed using Ghostscript.

+

There is something strange about the little flags in the output. A +search of English literature will provide a hint. The conclusion you +might draw is too elementary. :-)

+

So what do those flags really mean?

+

The Dancing +men algorithm might be useful.

+

Don’t forget to take a look at the generated PDF. Perhaps you might +even want to compile the output with a C compiler. When you run it, what +does it output?

+

Author’s remarks:

+

This program obfuscate text file into PDF file with Dancing +men algorithm.

+

Probably, the output PDF file is compliant with PDF 1.3 and it’s also +available to compile as C code.

+

I’ve tested it with GCC 4.7 and Clang 3.0 with Linux, and the +following PDF Readers:

+ +

Obfuscations

+

This program is obfuscated by using classical methods. But can you +find the embedded font in the fragmented glyph?

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2012/hamano

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2012/hou/index.html b/2012/hou/index.html index 2d663d227..254ae1e66 100644 --- a/2012/hou/index.html +++ b/2012/hou/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,319 @@ - - + + + + + + - - -2012 hou - - + + + +2012/hou + + + + + -

2012 hou

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2012/hou

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/hou/index.html

- +
+ ← hamano + ↑ 2012 ↑ + kang → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Qiming HOU
+Location: CN

+ + +

To build:

+
make
+

To use:

+
./hou syntax-file file-to-process
+

Try:

+
./try.sh
+

View the remarks.htm file in your web browser.

+

The result is best viewed in a 80x25 console with ANSI colors.

+

Try (Windows):

+
copy header.htm hou.htm /y
+hou html.txt hou.c >> hou.htm
+start hou.htm
+

Judges’ remarks:

+

What a versatile entry! It can be used to check the size of IOCCC +entries and to publish them as HTML.

+

For extra credit: what is the meaning of the number +2321237?

+

Author’s remarks:

+

Disclaimer

+

The reviewer may have already noticed that the 2nd page of this +program is a dense blob, which is discouraged by the contest rules. We +wish to point out that a majority of state-of-art programming editors +support syntax highlighting, which should be enabled when reading this +entry. Anticipating that the reviewer’s preferred color setting may +produce a suboptimal visual effect, a few syntax files is provided to +highlight the source code under an author-provided setting, using the +submitted program itself. Syntax highlighting would also visually +improve the 3rd page.

+

The code may throw a few warnings due to formatting constraints. The +author did try to remove warnings under gcc and Visual Studio, +though.

+

The author does not own the original anime series where the embedded +ASCII arts come from. For comparison, original non-ASCII art depictions +of the relevant characters and objects can be found by googling the +embedded text messages.

+

Syntax files

+

The syntax file consists of a number of rewriting rules. Each rule +consists of a regular expression, a space, a format string, and a +newline. All text matching the regular expression would be replaced by +the format string. In case of a conflict, rules appearing earlier would +take precedence. One can refer to the original text in the format string +using %s. Other % characters in the format +string must be escaped with another %. The space character +can be used in the regular expression by escaping it with +[] or "".

+

The following regular expression operators are supported:

+
() [] * + ? | ""
+

For example, one can use the following expression to match a certain +declaration statement in hou.c:

+
    "char"[ *]*[a-zA-Z_][0-9a-zA-Z_]*[ ]*((=[0-9a-zA-Z_ ]+)|(\[[0-9a-zA-Z_ ]*\]))?[ ]*(,[ *]*[a-zA-Z_][0-9a-zA-Z_]*[ ]*((=[0-9a-zA-Z_ ]+)|(\[[0-9a-zA-Z_ ]*\]))?[ ]*)*;
+

The regex engine is also algorithmically efficient. To illustrate the +point, ansi.txt contains a pathological +expression 1 that guarantees a hang for the +competing Perl engine while matching itself. Try to compare these two +engines:

+
./hou ansi.txt ansi.txt
+perl patho.pl < ansi.txt
+

Limitations

+

Finally, there are a few limitations…

+ +

Why obfuscated

+

The first layer of obfuscation comes from the challenge of embedding +a large ASCII art in a dense blob. The entire art is composed using only +keywords, strings and character constants. That results in a number of +otherwise useless #defines and quite a number of +unconventionally written constants. While the preprocessor may remove +the former, the later would remain regardless of beautification and +preprocessing.

+

The second layer of obfuscation comes from the need to squeeze a +reasonably powerful regex engine into the remaining area that isn’t +occupied by excessive keywords and useless constants. To achieve this, +the regex compiler is written using the same threaded virtual machine 2 that parses the regex. Due to +compiler limitations, the generated VM code also ends up obscured by a +large amount of spaghetti branches and virtual thread creations. +Finally, the VM in 3 is extended to track multiple +expression matches for the actual formatting.

+

As an extra tweak, the text message actually does something useful. +Remove the “Make a contract with me” catch line and the program would +cease to function.

+

References

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+
+
+
    +
  1. Regular Expression +Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, +Ruby, …)↩︎

  2. +
  3. Russ +Cox, Regular Expression Matching: the Virtual Machine Approach↩︎

  4. +
  5. Russ +Cox, Regular Expression Matching: the Virtual Machine Approach↩︎

  6. +
+
+ + +

Inventory for +2012/hou

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2012/kang/index.html b/2012/kang/index.html index 86541e8fc..f17dc1edd 100644 --- a/2012/kang/index.html +++ b/2012/kang/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,375 @@ - - + + + + + + - - -2012 kang - - + + + +2012/kang + + + + + -

2012 kang

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2012/kang

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/kang/index.html

- +
+ ← hou + ↑ 2012 ↑ + konno → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Seonghoon +Kang
Location: KR

+ + +

To build:

+
make
+

There is alternate code which fixes some German at the expense of +other German. See Alternate code below for +the (fun) rationale here.

+

To use:

+
echo "full spelling of an English cardinal numeral less than a quadrillion" | ./kang
+

Try:

+
./try.sh # try various languages
+
+./en.sh # English 0 through 13
+
+./de.sh # German 0 through 13 with both umlauts and without (additional 'e')
+

How does it have no u or o in a string in +the source code and yet it gets uno right?

+

Alternate code:

+

This alternate code fixes the program that would throw off those who +know German where the sound of ‘V’ is ‘F’ and so the program had the +letter be ‘F’. A problem, however, with changing it is that it breaks +other words including in German. Thus there is the alternate version +instead which fixes a problem for Germans that causes problems for +Germans so if you’re German you’ll just have to deal with it :-) It is, +however, good as you might be able appreciate the entry even more.

+

Alternate build:

+
make alt
+

Alternate use:

+
echo vier | ./kang.alt
+echo uno | ./kang.alt
+

Alternate try:

+
./de.alt.sh # German 0 through 13 both with and without umlaut
+./en.alt.sh # English 0 through 13
+

What does it get right? What does it get wrong? How does it compare +to the original entry without the change of f to +v?

+

Finally why does it get what it gets wrong wrong?

+

Judges’ remarks:

+

The judges were able to appreciate the Indo-European language family +relation by making this entry successfully recognize some +French, German, Italian, Russian, and Spanish numerals.

+

Also worth mentioning is this entry’s ability to understand the +colloquial year numbers of the last millennium.

+

We’ve added a linefeed to the print format for convenience.

+

Can you explain why:

+
echo f hundr|./kang
+

correctly reports 500 but:

+
echo hundr|./kang
+

does not report 100, instead printing 0?

+

Author’s remarks:

+

Synopsis

+

This short program reads a spelt number (e.g. forty-two) +and writes a corresponding decimal number (e.g. 42). Too +long for one-liners, alas, but it still qualifies as a short +program as it has less than 0x100 bytes.

+

It accepts a variety of spelt numbers:

+ +

It does not accept some spelt numbers, which I found mostly +irrelevant:

+ +

Requirements

+

This program is quite portable, only requiring the following:

+ +

The design of the program explicitly allows for EOF even +if it does not equal -1 (it has to be negative per the +standard but not necessarily -1) and both +signed char and unsigned char, for example. +Furthermore it is endian-independent.

+

Obfuscations (SPOILERS!)

+

Many obfuscations used are typical for standard IOCCC entries:

+ +

Other obfuscations are more subtle:

+ +

But the most important obfuscation is the clever construction of +lookup table. The program uses 11 different characters required for +recognizing 22 lexemes:

+
zero        one         tw-         th(i)r-     fo(u)r-     fi-         six-
+seven-      eigh-       nin-        ten         eleven      twelve
+hundred(s)  thousand(s) million(s)  billion(s)  trillion(s)
+a           and         -teen       -ty
+

So that they are internally represented as like:

+
r        n        tw-      tr-      fr-      f-       s-
+sn-      g-       nn-      tn       ln       twl
+nr(s)    tsan(s)  lln(s)   blln(s)  trlln(s)
+a        an       -tn      -ty
+

The stemmer recognizes the longest matching prefix, so every lexeme +can be recognized by at most three characters (e.g. trl +instead of trlln). This is also handy for ignoring plurals. +But that would make it so that the table does not fit in the printable +byte—112 is already almost 27!

+

The trick is to use octal; three characters (a, +b and g) are interpreted as sequences of two +characters (ny, nn and nw +respectively). Asides from a smaller lookup table, it has many good +consequences:

+ +

Having said this important trick, other details should be relatively +easier to follow. The order of lookup table, for example, is very +important, and the biggest constant 6177 is not arbitrarily chosen.

+

More spoilers can be found at https://gist.github.com/lifthrasiir/3909337

+

Acknowledgement

+

The cleaner (size-optimized) version of this program was originally +published in my website in July 2011. Sun Park and others have reviewed +it and made me aware of possible improvements. I’d also like to thank +Seo Sanghyeon for proof-reading remarks.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2012/kang

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2012/konno/index.html b/2012/konno/index.html index e705b8885..23f7e5063 100644 --- a/2012/konno/index.html +++ b/2012/konno/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,229 @@ - - + + + + + + - - -2012 konno - - + + + +2012/konno + + + + + -

2012 konno

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2012/konno

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/konno/index.html

- +
+ ← kang + ↑ 2012 ↑ + omoikane → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Taketo Konno
+Location: JP

+ + +

To build:

+
make
+

There is an unobfuscated version of this entry. See Alternate code below.

+

To use:

+
./konno N
+

NOTE: N is an integer from 0 to 255.

+

Try:

+
./try.sh
+

Alternate code:

+

An alternate version of this entry, konno.alt.c, is provided. This alternate code is +an unobfuscated version of the winning code.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use konno.alt as you would konno above.

+

Judges’ remarks:

+

This entry is a good one-liner to analyze completely.

+

For extra credit, what are the minimal changes to convert it to +64-bit integers so that it could print 32 lines?

+

Author’s remarks:

+

Remarks

+

This program outputs elementary +cellular automaton patterns.

+

Try:

+
./konno 30
+./konno 90
+./konno 102
+./konno 109
+./konno 165
+

There are 256 (from 0 through 255) possible rules.

+

Obfuscation

+

This program uses bit operations. I think

+
7&O<<!o>>!o+29
+

is an interesting operation. This isn’t equal to

+
7&O>>29
+

operation. What is the operation doing?

+

Limitation

+

This program assumes that the size of int is 4.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2012/konno

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2012/omoikane/index.html b/2012/omoikane/index.html index 119c6f472..c6af4edf6 100644 --- a/2012/omoikane/index.html +++ b/2012/omoikane/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,336 @@ - - + + + + + + - - -2012 omoikane - - + + + +2012/omoikane + + + + + -

2012 omoikane

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2012/omoikane

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/omoikane/index.html

- +
+ ← konno + ↑ 2012 ↑ + tromp → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Don Yang
Location: +US

+ + +

To build:

+
make
+

There is an alternate version that will read from the compiled file +itself, in case you don’t have a /dev/urandom file. There +is also a version that should theoretically work with Windows which +distinguishes binary and text. See alternate +code below.

+

To use:

+
./nyaruko [seed.txt] < original.bin > output.c
+bash output.c > key.c
+perl output.c > data.c
+
+cat key.c data.c > output.c
+
+cc output.c -o output
+./output > regenerated.bin
+

NOTE: if your OS does not have /dev/urandom then you +should specify a seed file or use the alternate version which reads in the compiled +binary itself.

+

Try:

+
./try.sh
+

The script try.sh will check if you have perl +before trying to use the perl parts of the script.

+

Alternate code:

+

The alternate version will, if no file is specified, read in the +compiled binary itself rather than trying to open +/dev/urandom, which is the default for the original entry. +This is useful if your system does not have a /dev/urandom +file and you do not want to specify an extra file. The second alternate +version is like the first except it also should theoretically work with +Windows, setting binary mode on stdin and +stdout.

+

Alternate build:

+

For the first version:

+
make alt
+

For the second version:

+
make alt2
+

Alternate use:

+

Use nyaruko.alt or nyaruko.alt2 as you +would nyaruko above.

+

Alternate try:

+

For the first alternate version:

+
./try.alt.sh
+

We have no way to test the second version, sorry (tm Canada :-) +)!

+

Judges’ remarks:

+

The judges have nothing to add that has not already been written +about in the spoiler.html (requires +JavaScript) file! :-)

+

Author’s remarks:

+

Usage

+

Nyaruko is a binary to text filter. Given some input on +stdin, Nyaruko will produce C code that +reproduces this input on stdout:

+
./nyaruko < original.bin > output.c
+gcc output.c -o output
+./output > regenerated.bin
+

Output is encrypted, but both key and data are included in the +output. To separate the key from the data, run these commands:

+
bash output.c > key.c
+perl output.c > data.c
+

The key-less data.c still compiles, but produces a +different message on stdout instead of the original input. +This message is a hint to why the code is formatted the way it is.

+

To combine the key and data, concatenate them together in either +order:

+
cat key.c data.c > output.c
+cat data.c key.c > output.c
+

By default, Nyaruko generates a unique random key for +every message, using /dev/urandom as the seed. If given an +extra command line argument, Nyaruko will seed using that +file instead of /dev/urandom:

+
./nyaruko seed.txt < input.bin > output.c
+

This makes the output key deterministic, allowing the same key to be +shared across different files. On operating systems that do not have +/dev/urandom, users should always specify this extra seed +argument to avoid indeterministic keys, or else use the alternate +version which will by default read the compiled alternate version +itself, which might or might not be deterministic, depending on where +and how it’s used.

+

Features

+

Implementation details that make Nyaruko more obfuscated +than usual programs:

+ +

Output code has these features:

+ +

Code layout is meant to resemble Nyaruko, also +known as Nyarlathotep, the Crawling Chaos. The most obvious +thing to do with chaos is to make a random number generator, and the +most obvious thing to do with a random number generator is to make one-time-pads for +encryption.

+

Compatibility

+

Nyaruko has these environment dependencies:

+ +

Output code has the same dependencies, with the additional +requirement that the compiler must support arbitrarily long string +literals. Maximum input size that can be encoded while still producing +standard-compliant output is ~276 bytes for C89, and ~3168 bytes for +C99.

+

Nyaruko has been to verified to work with these +compiler/OS combinations:

+ +

Note that on MingW, stdin and stdout are +not opened in binary mode by default, this means Nyaruko +may not faithfully encode files on MingW.

+

Extra files

+

spoiler.html - Contains full recording of +how the code went from blank state to an obfuscated program, gzipped to +fit under 1MB. Requires JavaScript.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2012/omoikane

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2012/tromp/index.html b/2012/tromp/index.html index 370a0ad55..762c14fe5 100644 --- a/2012/tromp/index.html +++ b/2012/tromp/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,618 @@ - - + + + + + + - - -2012 tromp - - + + + +2012/tromp + + + + + -

2012 tromp

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2012/tromp

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/tromp/index.html

- +
+ ← omoikane + ↑ 2012 ↑ + vik → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: John Tromp
+Location: US

+ + +

To build:

+
make all        # On a 64-bit machine (default)
+
+make tromp32        # On a 32-bit machine
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2012 +tromp in bugs.md.

+

To use:

+
./tromp [-b]
+

Use ./tromp32 as you would ./tromp if on a +32-bit machine.

+

To use:

+
cat ascii-prog.blc data | ./tromp -b
+cat binary-prog.Blc data | ./tromp
+

Try:

+
./try.sh
+

Judges’ remarks:

+

The judges dare to say that the data files this entry is processing +are more obfuscated than the entry itself.

+

Author’s remarks:

+

This program celebrates the close connection between obfuscation and +conciseness, by implementing the most concise language known, Binary +Lambda Calculus (BLC).

+

BLC +was developed to make Algorithmic +Information Theory, the theory of smallest programs, more concrete. +It starts with the simplest model of computation, the lambda +calculus, and adds the minimum amount of machinery to enable binary +input and output.

+

More specifically, it defines a universal machine, which, from an +input stream of bits, parses the binary encoding of a lambda calculus +term, applies that to the remainder of input (translated to a lazy list +of booleans, +which have a standard representation in lambda calculus), and translates +the evaluated result back into a stream of bits to be output.

+

Lambda is encoded as 00, application as 01, and the variable bound by +the nth enclosing lambda (denoted n in +so-called De +Bruijn notation) as 1^{n}0. That’s all there is to BLC!

+

For example the encoding of lambda term +S = \x \y \z (x z) (y z), with De Bruijn +notation \ \ \ (3 1) (2 1), is +00 00 00 01 01 1110 10 01 110 10.

+

In the closely related BLC8 +language, I/O is byte oriented, translating between a stream of bytes +and a list of length-8 lists of booleans.

+

The submission implements the universal machine in the most concise +manner conceivable. It lacks #defines and +#includes, and compiles to a (stripped) executable of under +6K in size.

+

Without arguments, it runs in byte mode, using standard input and +output. With one (arbitrary) argument, it runs in bit mode, using only +the least significant bit of input, and using characters 0 +and 1 for output.

+

The program uses the following exit codes:

+
0: OK; result is a finite list
+5: Out of term space
+6: Out of memory
+1,2,3,4,8,9: result not in list form
+

The size of the term space is fixed at compile time with +-DA.

+

A half byte cat

+

The shortest (closed) lambda calculus term is \x x (\ 1 +in De Bruijn +notation) which is the identity function. When its encoding +0010 is fed into the universal machine, it will simply copy +the input to the output (well, not that simply, since each byte is +smashed to bits and rebuilt from scratch). Voila: a half byte cat:

+
$ echo " Hello, world" | ./tromp
+Hello, world
+

Since the least significant 4 bits of the first byte are just +arbitrary padding that is ignored by the program, any character from +ASCII 32 (space) through 47 (/) will do, e.g.:

+
$ echo "*Hello, world" | ./tromp
+Hello, world
+

Bad programs

+

If the input doesn’t start with a valid program, that is, if the +interpreter reaches end-of-file during program parsing, it will crash in +some way. E.g. the following might dump core:

+
echo -n "U" | ./tromp
+

Furthermore, the interpreter requires the initial encoded lambda term +to be closed, that is, variable n can only appear within at +least n enclosing lambdas. For instance, here the term +\ 5 is not closed, causing the interpreter to crash when +looking into a null-pointer environment:

+
echo ">Hello, world" | ./tromp
+

will likely dump core.

+

Since these properties can be checked when creating BLC +programs, the interpreter doesn’t bother checking for it.

+

A Self Interpreter

+

The BLC +universal machine may be small at 650 bytes of C (952 bytes including +layout), but written as a self interpreter in BLC it is downright +minuscule at 232 bits (29 bytes):

+
      01010001
+       10100000
+        00010101
+         10000000
+          00011110
+           00010111
+            11100111
+             10000101
+              11001111
+              000000111
+             10000101101
+            1011100111110
+           000111110000101
+          11101001 11010010
+         11001110   00011011
+        00001011     11100001
+       11110000       11100110
+      11110111         11001111
+     01110110           00011001
+    00011010             00011010
+

The byte oriented BLC8 version weighs in at 43 bytes (shown in +hexadecimal).

+
     19468
+      05580
+       05f00
+        bfe5f
+         85f3f
+          03c2d
+         b9fc3f8
+        5e9d65e5f
+       0decb f0fc3
+      9befe   185f7
+     0b7fb     00cf6
+    7bb03       91a1a
+
+
$ (cat uni8.Blc; echo " Ni hao") | ./tromp
+Ni hao
+

A prime number sieve

+

Even shorter than the self-interpreter is this prime number sieve in +167 bits (under 21 bytes):

+
    000100011001100101000110100
+     000000101100000100100010101
+     11110111          101001000
+     11010000          111001101
+     000000000010110111001110011
+     11111011110000000011111001
+     10111000
+     00010110
+    0000110110
+
+

The nth bit in the output indicates whether n is +prime:

+
$ cat primes.blc | ./tromp -b | head -c 70
+0011010100010100010100010000010100000100010100010000010000010100000100
+

For those who prefer to digest their primes in decimal, there is +oddindices.Blc, which will print the indices of all odd +characters (with LSB = 1) +separated by a given character:

+
$ (cat oddindices.Blc; echo -n " "; cat primes.blc | ./tromp -b) | ./tromp | head -c 70
+2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
+

A Space filling program

+

The program hilbert.Blc, at 143 bytes, is a very twisty +“one-liner” (shown in hexadecimal):

+
    1818181   8111154   6806041   55ff041
+    9d   f9   de   16   ff   fe   5f   3f
+    ef   f615ff9   46   84   058117e   05
+    cb             fe   bc             bf
+    ee86cb9   4681600   5c0bfac   bfbf71a
+         85   e0             5c   f4
+    14d5fe0   8180b048d0800e078   016445f
+    fe                                 5f
+    f7   ffffe5fff2fc   02f7ad97f5bf   ff
+    ff   bf        ff   ca        af   ff
+    7817ffa   df76695   4680601   57f7e16
+              05             c1
+    3fe80b2   2c18581   bfe5c10   42ff805
+    de   ec        06   c2        c0   c0
+    60   8191a00167fb   cbcfdf65f7c0  a20
+

It expects n arbitrary characters of input, and draws a +space filling Hilbert curve of +order n:

+
$  (cat hilbert.Blc; echo -n "1") | ./tromp
+ _
+| |
+
+$ (cat hilbert.Blc; echo -n "12") | ./tromp
+ _   _
+| |_| |
+|_   _|
+ _| |_
+
+$ (cat hilbert.Blc; echo -n "123") | ./tromp
+ _   _   _   _
+| |_| | | |_| |
+|_   _| |_   _|
+ _| |_____| |_
+|  ___   ___  |
+|_|  _| |_  |_|
+ _  |_   _|  _
+| |___| |___| |
+
+$ (cat hilbert.Blc; echo -n "1234") | ./tromp
+ _   _   _   _   _   _   _   _
+| |_| | | |_| | | |_| | | |_| |
+|_   _| |_   _| |_   _| |_   _|
+ _| |_____| |_   _| |_____| |_
+|  ___   ___  | |  ___   ___  |
+|_|  _| |_  |_| |_|  _| |_  |_|
+ _  |_   _|  _   _  |_   _|  _
+| |___| |___| |_| |___| |___| |
+|_   ___   ___   ___   ___   _|
+ _| |_  |_|  _| |_  |_|  _| |_
+|  _  |  _  |_   _|  _  |  _  |
+|_| |_| | |___| |___| | |_| |_|
+ _   _  |  ___   ___  |  _   _
+| |_| | |_|  _| |_  |_| | |_| |
+|_   _|  _  |_   _|  _  |_   _|
+ _| |___| |___| |___| |___| |_
+

A Brainfuck +interpreter

+

The smallest known BF interpreter is written in… you guessed it, BLC, +coming in at 112 bytes (including 3 bits of padding):

+
$ od -t x4 bf.Blc
+0000000          01a15144 02d55584               223070b7        00f032ff
+0000020          7f85f9bf        956fe15e        c0ee7d7f 006854e5
+0000040          fbfd5558        fd5745e0        b6f0fbeb 07d62ff0
+0000060          d7736fe1 c0bc14f1               1f2eff0b        17666fa1
+0000100          2fef5be8        ff13ffcf        2034cae1 0bd0c80a
+0000120          e51fee99        6a5a7fff        ff0fff1f d0049d87
+0000140          db0500ab 3bb74023               b0c0cc28 10740e6c
+0000160
+

It expects its input to consist of a Brainfuck program +(looking only at bits 0, 1 and 4 +to distinguish among ,-.+<>][) followed by a +], followed by the input for the Brainfuck program.

+
$ more hw.bf
+++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.]
+$ cat bf.Blc hw.bf | ./tromp
+Hello World!
+

Curiously, the interpreter bf.Blc is the exact same size +as hw.bf.

+

A BLC assembler

+

Writing BLC programs can be made slightly less painful with this +parser that translates single-letter-variable lambda calculus into +BLC:

+
$ echo "\f\x f (f (f x))" > three
+$ cat parse.Blc three | ./tromp
+000001110011100111010
+

Converting between bits and +bytes

+

The program inflate.Blc and its inverse +deflate.Blc allow us to translate between BLC and BLC8. If +you assemble a byte oriented program, you’ll need to compact it into +BLC8:

+

So we could assemble an input reversing program as

+
echo "\a a ((\b b b) (\b \c \d \e d (b b) (\f f c e))) (\b \c c)" > reverse
+cat parse.Blc reverse | ./tromp > reverse.blc
+

and change it to BLC8 with

+
$ cat deflate.Blc reverse.blc | ./tromp > rev.Blc
+$ wc rev.Blc
+    0 1 9 rev.Blc
+

and then try it out with:

+
$ cat rev.Blc - | ./tromp
+Hello, world!
+^D
+!dlrow ,olleH
+

Symbolic Lambda Calculus +reduction

+

BLC8 program symbolic.Blc shows individual reduction +steps on symbolic lambda terms. Here it is used to show the calculation +of 2^3 in Church numerals:

+
$ echo "(\f\x f (f (f x))) (\f\x f (f x))" > threetwo
+$ cat parse.Blc threetwo | ./tromp > threetwo.blc
+$ cat symbolic.Blc threetwo.blc | ./tromp
+(\a \b a (a (a b))) (\a \b a (a b))
+\a (\b \c b (b c)) ((\b \c b (b c)) ((\b \c b (b c)) a))
+\a \b (\c \d c (c d)) ((\c \d c (c d)) a) ((\c \d c (c d)) ((\c \d c (c d)) a) b)
+\a \b (\c (\d \e d (d e)) a ((\d \e d (d e)) a c)) ((\c \d c (c d)) ((\c \d c (c d)) a) b)
+\a \b (\c \d c (c d)) a ((\c \d c (c d)) a ((\c \d c (c d)) ((\c \d c (c d)) a) b))
+\a \b (\c a (a c)) ((\c \d c (c d)) a ((\c \d c (c d)) ((\c \d c (c d)) a) b))
+\a \b a (a ((\c \d c (c d)) a ((\c \d c (c d)) ((\c \d c (c d)) a) b)))
+\a \b a (a ((\c a (a c)) ((\c \d c (c d)) ((\c \d c (c d)) a) b)))
+\a \b a (a (a (a ((\c \d c (c d)) ((\c \d c (c d)) a) b))))
+\a \b a (a (a (a ((\c (\d \e d (d e)) a ((\d \e d (d e)) a c)) b))))
+\a \b a (a (a (a ((\c \d c (c d)) a ((\c \d c (c d)) a b)))))
+\a \b a (a (a (a ((\c a (a c)) ((\c \d c (c d)) a b)))))
+\a \b a (a (a (a (a (a ((\c \d c (c d)) a b))))))
+\a \b a (a (a (a (a (a ((\c a (a c)) b))))))
+\a \b a (a (a (a (a (a (a (a b)))))))
+

As expected, the resulting normal form is Church numeral +8.

+

Taking only the first line of output gives us a sort of BLC +disassembler, an exact inverse of the above assembler. The prime number +sieve disassembles as follows:

+
$ cat symbolic.Blc primes.blc | ./tromp | head -1
+\a (\b b (b ((\c c c) (\c \d \e e (\f \g g) ((\f c c f ((\g g g) (\g f (g g)))) (\f \g \h \i i g (h (d f))))) (\c \d \e b (e c))))) (\b \c c (\d \e d) b)
+

Hardly any less obfuscated…

+

The last line of

+
cat symbolic.Blc primes.blc | ./tromp | head -16
+

starts out as

+
\a \b b (\c \d c) (\c c (\d \e d) (\d d (\e \f f) (\e e (\f \g g) ((\f (\g \h \i
+

The \a is for ignoring the rest of the input (to which +the universal machine applies the decoded lambda term). The +\b b (..) (...) is the list constructor, usually called +cons, applied to a head (a list element) and a tail +(another list). In this case the element is (\c \d c), +which represents the boolean true, and which we use to represent a 0 +bit. This is the bit that says 0 is not prime. The next list element +(following another cons) is (\d \e d). Another +0 bit, this time saying that 1 is not prime. The third list element is +(\e \f f), a 1 bit, confirming our suspicion that 2 is +prime. As is the next number, according to (\f \g g). We +can see that the tail after the first 4 elements is still subject to +further reduction. The bit for number 4 will show up for the first time +in line 30, as (\g \h g), or 0, as the result of zeroing +out all multiples of the first prime, 2.

+

Since my computer reaches swap hell before line 40, we can’t see the +next bit arriving, at least not in this symbolic reduction.

+

Performance

+

Performance is quite decent, and amazingly good for such a tiny +implementation, being roughly 50% slower than a Haskell implementation +of the universal machine using so-called Higher +Order Abstract Syntax which relies on the highly optimized Haskell +runtime system for evaluation. Of course individual BLC programs running +under the interpreter perform much worse than that same program written +in Haskell.

+

Our interpreter copes well with extra levels of interpretation:

+
$ time cat primes.blc | ./tromp -b | head -c 210 > /dev/null
+real    0m0.043s
+$ time cat uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
+real    0m0.191s
+$ time cat uni.blc uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
+real    0m1.919s
+$ time cat uni.blc uni.blc uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
+real    0m23.514s
+$ time cat uni.blc uni.blc uni.blc uni.blc primes.blc | ./tromp -b | head -c 210 > /dev/null
+real    4m52.700s
+

Obfuscation

+

Obfuscation is due entirely to conciseness. Some questions to +ponder:

+

Which of the term space codes 0, 1, +2, 3 serve multiple purposes?

+

Why is the environment pointer pointing into the term space?

+

What does the test u+m&1? do?

+

How does the program reach exit code 0?

+

And how do any of those BLC programs work?

+

Portability

+

The program freely (without casting) converts between +int and int *, causing many warnings;

+
  note: expected 'int *' but argument is of type 'int'
+  warning: assignment from incompatible pointer type
+  warning: assignment makes integer from pointer without a cast
+  warning: assignment makes pointer from integer without a cast
+  warning: incompatible implicit declaration of built-in function 'calloc'
+  warning: incompatible implicit declaration of built-in function 'exit'
+  warning: passing argument 1 of 'd' makes pointer from integer without a cast
+  warning: passing argument 1 of 'p' makes pointer from integer without a cast
+  warning: pointer/integer type mismatch in conditional expression
+

Avoiding these would make the program substantially longer, and +detract from its single minded focus on conciseness.

+

It implicitly declares functions read(2), +write(2), exit(3) and calloc(3), +the latter two incompatibly. 32 bit and 64 bit executables are separate +Makefile targets, involving a change from +int to long and from a hardcoded sizeof of 4 +to 8.

+

The program has been tested to work correctly on Linux/Solaris/MacOSX +both in 32 and 64 bits.

+

How the program works

+

See the file how.md.

+

Acknowledgements

+

Christopher Hendrie, Bertram Felgenhauer, Alex Stangl, Seong-hoon +Kang, and Yusuke Endoh have +contributed ideas and suggestions for improvement.

+

References

+

Binary Lambda Calculus - https://tromp.github.io/cl/Binary_lambda_calculus.html

+

G J Chaitin, Algorithmic information theory, Volume I, Cambridge +Tracts in Theoretical Computer Science, Cambridge University Press, +October 1987. https://web.archive.org/web/20121125233450/https://www.cs.auckland.ac.nz/~chaitin/cup.html

+

Jean-Louis Krivine. 2007. A call-by-name lambda-calculus machine +Higher Order Symbol. Comput. 20, 3 (September 2007), 199-207. http://www.pps.univ-paris-diderot.fr/~krivine/articles/lazymach.pdf

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2012/tromp

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2012/vik/README.md b/2012/vik/README.md index bcd89ead8..2d4d06af6 100644 --- a/2012/vik/README.md +++ b/2012/vik/README.md @@ -111,9 +111,9 @@ additional chunks are copied into the resulting image. For some reason the chocolate image seems to have some special properties. Apart from being quite big and a little bit noisy, it appears that when embedded into another image and extracted, the bitmap data is also a valid -[brain$#@$](https://en.wikipedia.org/wiki/Brainfuck) program. It is of course +[brain\$#@\$](https://en.wikipedia.org/wiki/Brainfuck) program. It is of course possible to get the bitmap data from the extracted image, and run it through any -of the previous winning brain$#@$ interpreters, but I thought it would be easier +of the previous winning brain\$#@\$ interpreters, but I thought it would be easier to include an interpreter in the program to avoid the hassle: ```sh @@ -122,7 +122,7 @@ to include an interpreter in the program to avoid the hassle: ``` It is of course also possible to embed a -[brain$#@$](https://en.wikipedia.org/wiki/Brainfuck) program as a text file +[brain\$#@\$](https://en.wikipedia.org/wiki/Brainfuck) program as a text file (as explained above) and decode it, e.g.: ```sh @@ -172,7 +172,7 @@ program to crash. Since a lot of care was taken to keep the code simple, it turned out to be quite easy to extend functionality. I did include a small -[brain$#@$](https://en.wikipedia.org/wiki/Brainfuck) after I +[brain\$#@\$](https://en.wikipedia.org/wiki/Brainfuck) after I realized that the chocolate image had some interesting properties. But there is more functionality I added that didn't fit within the size @@ -181,9 +181,9 @@ format source code based on a PNG image. So the format of the program is actually done by the program itself. And to be honest, the chocolate image did not have a -[brain$#@$](https://en.wikipedia.org/wiki/Brainfuck) program +[brain\$#@\$](https://en.wikipedia.org/wiki/Brainfuck) program embedded to begin with. I added functionality to the program to embed a -brain$#@$ into a PNG image and used it to create the image provided with +brain\$#@\$ into a PNG image and used it to create the image provided with the entry. I also added a method to analyze PNG images, to print the size and format, diff --git a/2012/vik/index.html b/2012/vik/index.html index b69f0a019..3399acddf 100644 --- a/2012/vik/index.html +++ b/2012/vik/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,310 @@ - - + + + + + + - - -2012 vik - - + + + +2012/vik + + + + + -

2012 vik

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2012/vik

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/vik/index.html

- +
+ ← tromp + ↑ 2012 ↑ + zeitak → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Daniel Vik
+Location: US

+ + +

To build:

+
make
+

This entry requires Zlib.

+

There is an alternate version which might work for Windows. See Alternate code section below.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2012 +vik in bugs.md.

+

To use:

+

To embed text (from file or command line):

+
./vik e base.png filename > encodedimg.png
+

or

+
./vik e base.png SomeRandomText > encodedimg.png
+

To extract the embedded text:

+
./vik d encodedimg.png
+

To embed a PNG into another:

+
./vik e base.png source.png > encodedimg.png
+

To extract the embedded PNG:

+
./vik d encodedimg.png > restored.png
+

Try:

+
./try.sh
+

Alternate code:

+

For those few who might use Windows this alternate code might +work.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use vik.alt as you would vik above.

+

Judges’ remarks:

+

References to chocolate had no effect on judging this entry. We +guarantee it.

+

Can you discern hidden pieces of chocolate in chocolate-in-ioccc.png?

+
+ + +
+

Author’s remarks:

+

Introduction

+

This program is a steganography +application for embedding an image or text into another image as well as +extracting the embedded image or text back. The program stores the +embedded image or text in the low bits of the RGB values.

+

The program supports any 8 bit true color PNG images (RGB, RGBA, +greyscale, and greyscale+alpha). The output image is always 8 bit RGB. +When embedding one image into another, the width and height needs to be +the same.

+

The program only updates the IDAT and IHDR +chunks of the source image. Any additional chunks are copied into the +resulting image.

+

Bonus Extractor:

+

For some reason the chocolate image seems to have some special +properties. Apart from being quite big and a little bit noisy, it +appears that when embedded into another image and extracted, the bitmap +data is also a valid brain$#@$ program. It +is of course possible to get the bitmap data from the extracted image, +and run it through any of the previous winning brain$#@$ interpreters, +but I thought it would be easier to include an interpreter in the +program to avoid the hassle:

+
./vik e ioccc.png chocolate.png > encodedimg.png
+./vik b encodedimg.png
+

It is of course also possible to embed a brain$#@$ program as +a text file (as explained above) and decode it, e.g.:

+
./vik e ioccc.png .+[.+] > encodedimg.png
+./vik b encodedimg.png
+

Obfuscation

+

I really wanted to keep the program simple, so instead of adding +multiple macros or helper methods that can be confusing, I placed all +functionality in the main() function. main() +is called recursively and quite extensively, but it gives the benefit +that all invocations of the function have the same parameters, +argv and argc. This really helps readability, +as a programmer doesn’t need to remember several variable or function +names. I also tried to reduce the number of keywords, and the program +only has four for loops followed by a single +return statement. There is a little bit of use of the +ternary (?:) operator, but this is really there to keep the +program as simple as possible.

+

Portability

+

The program is portable to most platforms that have zlib available. The only system +dependency is that the program relies on writing binary data to +stdout.

+

By default, Microsoft compilers adds carriage returns to new lines, +and to compile the program on this platform, the following line can be +added after the variable declarations in the main declaration in order +to run correctly:

+
_setmode(_fileno(stdout), 0x8000);
+

NOTE: this is what the Alternate code +does.

+

Limitations

+

The program doesn’t have many error checks so passing in invalid +arguments or images of mismatching sizes, or unsupported pixel formats +will cause the program to crash.

+

Extendability

+

Since a lot of care was taken to keep the code simple, it turned out +to be quite easy to extend functionality. I did include a small brain$#@$ after I +realized that the chocolate image had some interesting properties.

+

But there is more functionality I added that didn’t fit within the +size limits and could not remain included. For example, I added a method +to format source code based on a PNG image. So the format of the program +is actually done by the program itself.

+

And to be honest, the chocolate image did not have a brain$#@$ program +embedded to begin with. I added functionality to the program to embed a +brain$#@$ into a PNG image and used it to create the image provided with +the entry.

+

I also added a method to analyze PNG images, to print the size and +format, as well as the scan line filters.

+

All these features were quite easy to add, much thanks to the +(actually pretty good) design of the code.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2012/vik

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2012/zeitak/index.html b/2012/zeitak/index.html index f221e2a7b..195d00217 100644 --- a/2012/zeitak/index.html +++ b/2012/zeitak/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,320 @@ - - + + + + + + - - -2012 zeitak - - + + + +2012/zeitak + + + + + -

2012 zeitak

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2012/zeitak

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2012/zeitak/index.html

- +
+ ← vik + ↑ 2012 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Adar Zeitak
+Location: IL

+ + +

To build:

+
make
+

There is an alternate version that is slightly deobfuscated. See alternate code below.

+

To use:

+
./zeitak < file.c
+

where file.c is the file to be checked for nesting +errors. For example, you may try incorrect.c +and the program itself.

+

Try:

+
make test
+

NOTE: it prints an error and exits on the first nesting error so it +will not detect multiple issues!

+

Alternate code:

+

This version, zeitak.alt.c, is a version +that has been slightly deobfuscated. You may find reading it helpful in +your attempt to understand this extremely subtle entry.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use zeitak.alt as you would zeitak +above.

+

Judges’ remarks:

+

This is an extremely subtle and twisted piece of Gold award winning +code!

+

The judges had spent a considerable amount of time analyzing this +entry. At one point we spent 18 +minutes just to understand 18 key characters of this code.

+

Author’s remarks:

+

Nesting Errors Detector

+

What does it do

+

As you have probably understood by looking at the source*, this +program has something to do with parenthesis (and equality of opening +and closing parenthesis, if you look close enough). It goes over the +file given to it and checks that every opening (, +[, or { has a matching closing one and vice +versa. It also checks that every " or ' is +closed.

+

If an error is detected, an error message will be printed. If the +problem is a superfluous closing bracket, it will even print a few +characters around it’s position.

+

* Make sure you view the source with 4 spaces tab width.

+

Features

+ +
printf(")");
+ +

Mis-Features

+ +
printf("\"");
+

Obfuscation

+

IOCCC winners already contain entries +without digits, control-flow keywords and certain operators in their +source. This entry has an even more limited source, that is:

+ +

So, what’s left? Parenthesis, and lots of them, as looking at the +source will reveal immediately. The main obfuscation is building the +whole algorithm using only function calls, typecasts, array lookups and +pointer operators.

+

Additional obfuscations +include:

+ +

Compilation/Portability/Running +Notes

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2012/zeitak

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2013/birken/index.html b/2013/birken/index.html index e7fe608a2..4e2a1a5e1 100644 --- a/2013/birken/index.html +++ b/2013/birken/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,775 @@ - - + + + + + + - - -2013 birken - - + + + +2013/birken + + + + + -

2013 birken

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2013/birken

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2013/birken/index.html

- +
+ first entry + ↑ 2013 ↑ + cable1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Michael +Birken
Location: US

+ + +

To build:

+
make alt
+

We recommend that you use the alt version first to see what this +entry looked like back in 2013 (with a configurable speed). If you wish +to use the original version see the original +code section below.

+

To use:

+
./birken.alt < 17_columns_wide_paint_by_numbers_file
+

NOTE: if your terminal is messed up after running this (perhaps from +exiting before it finishes) try using reset to restore the +terminal. This will clear the screen.

+

Try:

+

This alternate version, which we recommend that you use in order to +see what is happening with modern systems, and to not flash colours too +quickly, which can be problematic for some people, can be configured to +different speeds by way of the value used in usleep(3). The +default is 13500 but you can reconfigure it should you wish +(see below).

+

To see the program run on each text file, try:

+
./try.alt.sh
+

If you have perl installed it will also try a random run.

+

Finding the ‘right’ default value was a fine line; the default, 15000 +microseconds (0.015 seconds), will take quite a while to finish but it +allows one to more easily see what is going on. Even easier to see would +be 25000 but these values make it quite slow and one could easily lose +interest. Like some other entries where this was made an alternate +version it is configurable at compile time. If you wish to speed it up +by 100% you can instead do:

+
make clobber SLEEP=7500 alt
+

and then try birken.alt as above.

+

If you wish to speed that up 200% (300% total) you can use instead +try SLEEP=3750. Doing this you might find the right value +to your liking; use ctrl-c to terminate the program early but note that +the terminal is likely to be messed up. In that case try:

+
reset
+

to make it sane again (running to completion will do that for +you).

+

Original code:

+

The original code will run faster with modern systems which is likely +to make it hard to see the art of the entry but you may do so if you +wish.

+

Original build:

+
make all
+

Original use:

+

Use birken as you would birken.alt +above.

+

Original try:

+

To use the demo script with the original code, try:

+
./try.sh
+

PLEASE be careful if you are sensitive to flashing colours!

+

Judges’ remarks:

+

This program also wins the “Most amusing abuse of the iocccsize tool” +award; although not the absolute best: it is possible to achieve 0 by +writing:

+
    /* *\
+    /....
+

The game of Tetris had been used in many endeavors, from studying algorithmic complexity to treating +PTSD and it’s even been put on MIT’s +Green Building. Using it for painting by numbers looks like a novel +idea.

+

Author’s remarks:

+

About This Document

+

This document is best viewed as an HTML file in a browser that +supports animated GIFs.

+

See the files: *.txt, *.png and +*.gif.

+

Abstract

+

By rotating, positioning and dropping a predetermined sequence of +pieces, this program exploits the mechanics of Tetris to generate +arbitrary images.

+

Algorithm Overview

+

The algorithm converts pixels from a source image into squares in the +Tetris play-field, +one row at a time from the bottom up. To generate an individual square, +the algorithm assembles a structure consisting of a rectangular region +fully supported by a single square protruding from the bottom. When the +rectangular region is completed, its rows are cleared, leaving behind +the protruding square. Three examples of the process appear below.

+

+

+

+

During construction of a row, all of the squares produced by this +method must be supported. In the images above, the generated squares are +supported by the floor of the play-field. However, if an arbitrary row +contains holes, it may not provide the support necessary for the +construction of the row above it. The algorithm solves this problem by +constructing a flat platform on top of the row with holes. In the +animation below, a platform is built above a row comprising of a single +red square. The platform is a temporary structure and inserting the +final piece removes it.

+

+

Below, a row containing 5 red squares is deposited above a row +containing 3 red squares. This is accomplished by building a flat +platform on top of the lower row. The platform provides the support +necessary to generate the 5 red squares. Finally, the platform is +removed by inserting its final piece and the new row drops into place. +Note, if the algorithm needed to generate the rows in the opposite order +(a row of 3 red squares above a row of 5 red squares), a platform would +not be necessary.

+

+

Single Square Emitters

+

For reference, the names of the 7 tetriminos (the game +pieces or actually a kind of geometric shape used in Tetris) appear in the +table below.

+

+

This algorithm was tailored specifically to render sprites from early +video games. Those games packed graphics into 8x8 tiles where 2 bits +were dedicated to each pixel. Consequentially, sprites usually contained +only 3 colors plus transparent regions and they were typically sized +either 16x16 or 16x32 pixels.

+

The animation below depicts all the patterns used to emit single +squares. J, T and L tetriminos are used +interchangeably within each pattern to produce the protruding square at +the bottom. The algorithm assigns those tetriminos to the 3 colors +present in the sprite. The remaining tetriminos are assigned arbitrary +colors. And, all the colors remain constant during gameplay.

+

+

It is not possible to emit a square of all 3 colors in the first 2 +and the last 2 columns due to the shapes of the 3 tetriminos. As a +result, the minimal width of a play-field to accommodate a 16 pixel wide +sprite is 2 + 16 + 2 = 20 squares. However, it turns out +that 20 is too small.

+

As illustrated below, the region above the protruding square cannot +exclusively consist of a single row because the only pieces that could +fit, the I tetriminos, are +unsupported.

+

+

With 2 rows, the only means of spanning the full play-field width in +a way that remains supported is to use S and Z +tetriminos. But, +that will always leave holes in the upper row.

+

+

The minimal number of rows required above the protruding square is 3 +and as shown repeatedly above, such patterns do exist. 20 squares is the +minimal width required to fit a 16 pixel wide sprite. But, +20 * 3 + 1 = 61, which is not evenly divisible by 4 and +hence not constructible out of tetriminos. However, +a width of 21 yields 21 * 3 + 1 = 64, which can be built +with 16 tetriminos. That width actually enables the algorithm to render +sprites up to 17 pixels wide.

+

The original Tetris play-field is 10 +x 20 squares, a 1:2 ratio. The program maintains that ratio by using a +play-field of 21 x 42 squares.

+

Since J, T and L tetriminos are used +interchangeably to produce the emitted square and 3 squares of those +tetriminos contribute to the row above it, there are +21 - 3 + 1 = 19 single square emitting patterns. However, +due to mirror symmetry, there are really only 10 patterns. Clearing 3 +rows works for the majority of them. But, an exhaustive computer search +revealed that 2 of the patterns require more. The next possible option +is 7 rows since 21 * 7 + 1 = 148, requiring 37 tetriminos. +As the images below show, those patterns do exist.

+

+

+

Platforms

+

Before a row is constructed, the algorithm inspects the row below it. +If the row below fails to provide support for all of the squares to be +deposited above it, then a temporary platform is required. When that +platform is removed, the new row will drop, leaving some of the squares +apparently floating above empty space due to the way that gravity works +in the original Tetris.

+

The illustration below depicts the 10 platform patterns (really only +5 considering mirror symmetry). The construction of a platform begins by +dropping a T tetrimino on top one +of the squares of the last generated row. The remaining tetriminos +support each other down to that first T. Meaning, as long +as the previously generated row contains at least 1 square, like the red +square below, then it is possible to construct a flat platform above it +for the generation of the next row.

+

+

In the middle of platform construction, the bottom row gets completed +and cleared, leaving 3 rows above it. The final J or +L tetrimino that will +remove those rows is not inserted until the square emitters are done +generating the next row of the sprite on top of the platform. That final +piece precludes square emission in the first and last 2 columns. But, as +discussed above, the square emitters are limited to the 17 inner columns +due to the geometry of the J, T and +L tetriminos used in the process.

+

Also, of the 19 possible ways to start constructing a platform on top +of a T tetrimino, only the +10 patterns shown above exist.

+

Program Input

+

The input sprite is represented textually. Digit characters +0 to 7 correspond to pixels with colors from +the palette below.

+
+ANSI color palette + +
+

As discussed above, sprites are limited to a maximum of 3 colors from +this palette.

+

All other characters are interpreted as transparent pixels.

+

The maximum permissible size of the input text is 32 rows by 17 +columns. Row length can vary as long as no single row exceeds 17 +characters.

+

Every row must contain at least one palette digit character.

+

The *.txt files contain different sprites in this +textual format that can be fed into standard input. Several examples +take advantage of the Tetris play-field +background color. Instead of using character 0, internal +regions marked as transparent are effectively rendered as black.

+

Program Output

+

The program conceptually uses Tetris as an output +device similar to a line printer. It +restricts itself to those operations that can be performed on the Tetris +play-field: spawning, rotating, positioning and dropping tetriminos. This +process is visually represented using ANSI escape sequences.

+

ANSImation

+

The rate at which the program plays Tetris is completely +determined by the rate in which the terminal application receives and +displays the ANSI escape +sequences.

+

To slow down the output programmatically, introduce a delay +immediately after the call to fflush(3) (N.B: see birken.alt.c).

+

IOCCC Size Tool Bug

+

This program demonstrates how to exploit a bug in IOCCC size tool +version 2013-07-30-v17. The first line of the program is +reproduced below.

+
char*_ = "'""/*";
+

If that line is added to the top of any program, the tool will report +a size of 8.

+
$ ./iocccsize -i < prog.c
+8
+

When that line is deleted from this program, the tool properly +reports the secondary size limit of the program as 2048.

+
$ ./iocccsize -i < birken.c
+2048
+

Although this bug provides an easy means of circumventing contest +rule 2, as demonstrated from the size value, this entry is not +necessarily striving for a ‘worst abuse of the rules’ award.

+

Obfuscations

+

This program is almost, but not quite, entirely unlike a +demonstration of good programming practices. Contrary to other programs, +an inspection of this one will certainly reveal that it possesses tea, +not to mention an affinity for the constant 42.

+

Variables are named and ordered to spell out, "Tetris", +"ELORG", "DVK" and the aforementioned +"Tea". ELORG is +the abbreviation for Elektronorgtechnica, the former Soviet +state owned computer organization that handled the worldwide Tetris +intellectual property rights. DVK is the line of Soviet +PDP-11-compatible personal computers capable of running Alexey +Pajitnov’s original 1984 Tetris prototype.

+

Carefully selected variable names also yielded wonderful expressions +like l=0, O=0, O=1 and +while(O). "Tetris" also makes a second +appearance of sorts:

+
[T][e][t]--; while(R+i) { s
+

The source is formatted to resemble the Tetris play-field +mid-game. It is also an homage to all the past +IOCCC entries formatted as a compact block of text; the +T, orientated appropriately to reflect its name and the +first letter in the title of the game, is just a moment away from +producing such a text block.

+

Three tables are encoded as separate strings within the program:

+

The first string stores the coordinates of the squares of the 19 +distinct rotations of tetriminos (see +below). Since a tetrimino is a chain of 4 squares, all tetriminos fit +within a 4x4 matrix. To determine the coordinates of the squares, the +tetrimino is pushed to the upper-left of the matrix. Each coordinate +value requires 2 bits of storage. Consequentially, the four +x-coordinates and the four y-coordinates were packed into separate +octets. To convert the octets into valid ASCII characters, the squares +were sorted such that the least significant bits stored the largest +coordinate values. The results were offset by 35, the # +character, which is 1 beyond the ASCII value of ", making +it easier to pack into a string. None of the resultant values are beyond +ASCII 127. The coordinates for all 19 rotations fit in a string of +length 38.

+

+

The second string stores the single square emitter patterns and the +platform patterns. Each pattern is a sequence of pairs, +{ tetrimino index, drop x-coordinate }. As mentioned, there +are 19 distinct rotations, requiring 5 bits of storage for the tetrimino index. +Another 5 bits is required for the drop x-coordinate since there are 21 +columns in the play-field. Necessarily, the pair is stored as 2 separate +characters. By offsetting them by 40, the ( character, the +resultant string almost resembles a long and complex mathematical +expression. The program takes advantage of mirror symmetry by only +storing 10 single square emitter patterns and 5 platform patterns. The +pattern lengths are not encoded within the string. Rather, they are +embedded within the string decoding logic.

+

The third string conceptually stores the default colors of the 19 +rotations. A 3-bit value is assigned to each, covering the 7 possible +colors. In addition, when a mirrored pattern is executed, J +exchanges with L and S exchanges with +Z, necessitating a second list of 3-bit color values. Pairs +of color values (6 bits) fit comfortably into a character that is offset +by #. The result is a string of length 19.

+

Obfuscations

+

The program is full of subtle obfuscations:

+ +

Beyond Obfuscation

+

Due to the contest code size constraint, some optimizations +reluctantly had to be omitted. For example, multi-square emitters are +possible:

+

+

+

+

+

In fact, using dynamic programming and creative heuristics, real-time +search is possible, enabling patterns like this:

+

+

And, even this:

+

+

In addition, it is possible to extend the algorithm to 6 colors +instead of just 3. This is achieved using I, S +and Z to produce the protruding square. A series of +rectangular regions are constructed above those tetriminos to erode +them down to a single emitted square.

+

The details of these enhancements are left as an exercise to the +reader.

+

Example Files

+

The following example files were created by the program author. They +can be freely used and distributed.

+ +

The following files are based on graphics from non-free, copyrighted +video games. The use of a limited number of textual representations of +the graphics for the demonstration of this program qualifies as fair use +as such files do not significantly impede the right of the copyright +holder to sell the copyrighted material and it is not being used to +generate profit in this context. The origin of each file is detailed +below (character, game, company, year).

+ +
    +
  1. +
+ +
    +
  1. +
+ +

The origin of the remaining files are described below:

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2013/birken

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2013/cable1/index.html b/2013/cable1/index.html index 3d2c528d8..8abbb82eb 100644 --- a/2013/cable1/index.html +++ b/2013/cable1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,257 @@ - - + + + + + + - - -2013 cable1 - - + + + +2013/cable1 + + + + + -

2013 cable1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2013/cable1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2013/cable1/index.html

- +
+ ← birken + ↑ 2013 ↑ + cable2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Adrian Cable
+Location: US

+ + +

To build:

+
make
+

To use:

+
./cable1 name group1 group2
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Partisan may be defined as a strong supporter of a cause, party or +person. We need not limit ourselves to the two major political parties +in the US today.

+

Let us consider:

+
./cable1 Cooper Mac PC
+

Simon works for Apple, so you would expect Mac. :-) Landon is a long +time Mac user:

+
./cable1 Noll Mac PC
+

That works too! Now Leo brings PCs to the IOCCC judging for +cross-platform testing:

+
./cable1 Broukhis Mac PC
+

We can test other people. The late Steve Jobs:

+
./cable1 Jobs Mac PC
+

That works! How about Bill?

+
./cable1 Gates Mac PC
+

A PC guy as expected. What about that other Steve?

+
./cable1 Ballmer Mac PC
+

Humm .. maybe there is a hidden reason he is leaving the late +Micro$oft? :-) Why late? Because:

+
+tweet about M$ being dead + +
+

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- An important 2023 +update about twitter:

+

The IOCCC no longer uses twitter. Today the IOCCC uses Mastodon. For +more information and to see our IOCCC Mastodon posts, see:

+
https://fosstodon.org/@ioccc
+

End of important 2023 update to this historic note. +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

+

So how does a one line C source know so much? Hint: it doesn’t.

+

Author’s remarks:

+

Presidents of the +United States of America!

+

Politics is full of memorable one-liners. +Without wishing to misunderestimate +the taste of the judges, nor prejudge the past, the author hopes you +enjoy this contribution to the genre.

+

This one-line C program accepts as a first command-line argument the +last name of any of the last 31 US Presidents (from Franklin Pierce +onwards), in lower case, and prints out their political affiliation.

+

Use republican as the 2nd command-line argument, and +democrat as the 3rd (or equivalent strings of your +choice).

+

Why is this entry +obfuscated/interesting?

+

The program looks up the name supplied on the command line against a +list of Presidents’ names, and matches names to political affiliations +using a look-up table. But where in the source is the list of names, and +where is the look-up table?

+

Notes

+ +

Compiler warnings

+

clang warns about a missing type specifier for +main(), and that implicit function declarations are invalid +in C99 (but still accepts them).

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2013/cable1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2013/cable2/index.html b/2013/cable2/index.html index 7016fc939..4843c4ae7 100644 --- a/2013/cable2/index.html +++ b/2013/cable2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,313 @@ - - + + + + + + - - -2013 cable2 - - + + + +2013/cable2 + + + + + -

2013 cable2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2013/cable2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2013/cable2/index.html

- +
+ ← cable1 + ↑ 2013 ↑ + cable3 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Adrian Cable
+Location: US

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2013 +cable2 in bugs.md.

+

To use:

+
./cable2 file.bmp [color]
+

Try:

+

For different OCR examples:

+
./try.sh
+

Judges’ remarks:

+

We can confirm that this is the first time the IOCCC has been used to +peer-review a new research. We had quite a bit of fun with a sharpie and +a scanner.

+

Author’s remarks:

+

OCR +- Obfuscated Character Recognition of Handwritten Text

+

This entry takes a BMP image file of hand-drawn (mouse-drawn?) text, +specified as the first command-line parameter, and converts it to an +ASCII text document. Magic!

+

BMP files created by most paint programs should work. The author +recommends Paint.NET.

+

Features

+ +

Why is this entry +obfuscated/interesting?

+ +

Other notes

+ +

Bugs/features

+ +

Compiler warnings

+

clang warns about unused expression results, missing +type specifiers, and incompatible pointer conversions - all just a fun +consequence of the obfuscations.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2013/cable2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2013/cable3/index.html b/2013/cable3/index.html index 41f1a2a4b..492688072 100644 --- a/2013/cable3/index.html +++ b/2013/cable3/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,634 @@ - - + + + + + + - - -2013 cable3 - - + + + +2013/cable3 + + + + + -

2013 cable3

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2013/cable3

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2013/cable3/index.html

- +
+ ← cable2 + ↑ 2013 ↑ + dlowe → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Adrian Cable
+Location: US

+ + +

To build:

+
make
+

An alternate version that should compile in Windows/MS Visual Studio +is available. See the Alternate code +section below.

+

To use:

+
./cable3 bios-image-file floppy-image-file [harddisk-image-file]
+

Try:

+
./runme
+

NOTE: to quit the program type QUITEMU. You might have +to be at the top level directory of the drive, A: or +C:.

+

To send an Alt+XXX key combination, press +(^A / Ctrl+A) then the key, so for example to +type Alt+F, press (^A / Ctrl+A) +then F.

+

To send an Fxx key, press ^F / +Ctrl+F then a number key. For example, to get the +F4 key, press ^F / Ctrl+F then +4. To get F10, press ^F / +Ctrl+F then 0.

+

To send a Page Down key, press ^F / +Ctrl+F then O (letter O, not digit zero). To +send a Page Up key, press ^F / +Ctrl+F then E. Other key combinations are left +for the discovery of the user.

+

Alternate code:

+

An alternate version, which should compile in Windows, is +provided.

+

Alternate build:

+

Assuming make is available and will function:

+
make alt
+

Alternate use:

+

Use cable3.alt as you would cable3 +above.

+

Judges’ remarks:

+

This entry weighs in at a magical 4043 bytes (8086 nibbles, 28,301 +bits). It manages to implement most of the hardware in a 1980’s era +IBM-PC using a few hundred fewer bits than the total number of +transistors used to implement the original 8086 CPU.

+

If you are using macOS, the included sc-ioccc.terminal configuration file will +correctly display console applications that use ANSI graphics.

+

NOTE: the author remarked that in some systems one might need to +#include <unistd.h>. This has been done in the entry +but not the alternate version. This should not affect the usability of +the program but will trigger a warning which we have disabled in the +Makefile.

+

Update: This entry now has its own website: https://github.com/adriancable/8086tiny

+

Author’s remarks:

+

A tiny +but highly functional PC emulator/virtual machine

+

The author hereby presents, for the delectation (?) of the judges, a +portable PC emulator/VM written specifically for the IOCCC which runs +DOS, Windows 3.0, Excel, MS Flight Simulator, AutoCAD, Lotus 1-2-3 …

+

In just 4043 bytes of C source, you get a complete mid-late 1980s-era +IBM-compatible PC, consisting of:

+ +

The emulator uses the SDL graphics +library for portability, and compiles for Windows, macOS, Linux and +probably most other 32-bit/64-bit systems too.

+

If you like living on the edge you can try building the emulator on a +big endian machine, and you will get an emulation of a big endian 8086, +a rather bizarre and somewhat useless beast. For everyone else, please +run the emulator on a little endian machine.

+

RULE 2 ABUSE DISCLAIMER

+ +

Why is this entry +obfuscated/interesting?

+ +

Compiling on different +platforms

+

This entry has been tested on Windows (compiled with MS Visual Studio +2010 and 2013), Mac OS X (clang and gcc), and Linux (clang and gcc). The +Makefile supplied is good for Mac OS X, Linux and probably other Unices. +I have received reports that the emulator works on Raspberry +Pi/Android/ARM (you will need to compile with +-fsigned-char) and iOS. You will need to adjust the Makefile if your system lacks +sdl-config to correctly point to the SDL libraries and +header files.

+

On UNIX-based systems we can get raw keystrokes using +stty. However Windows has no stty. Therefore +the Makefile includes a -D option to define a “keyboard +driver” KB which as it stands is suitable for Unices, but +maybe not non-UNIX platforms. For example, for Windows/MS Visual Studio, +instead of the Makefile definition of KB, use something slightly +different - add the following entry to the Preprocessor Definitions list +in the Project Properties page:

+
KB=(kb=H(8),kbhit())&&(r[1190]=getch(),H(7))
+

NOTE: this is done in the Alternate +code.

+

POSIX portability note

+

The code as supplied uses implicit function declarations for POSIX +file I/O and in doing so assumes that file offsets are the same bit +width as your architecture. For some systems (e.g. 32-bit Mac OS X, +which uses 64-bit file offsets) this is not the case, and to run +successfully on these systems, you will need to explicitly declare these +functions by adding the appropriate include to the top of the +source:

+
#include <unistd.h>
+

NOTE: this has been done in cable3.c.

+

Usage

+
./cable3 bios-image-file floppy-image-file [harddisk-image-file]
+

PLEASE NOTE that under Unices the keyboard must be in raw mode for +the emulator to work properly. Therefore the emulator is best run from a +shell script that looks something like:

+
stty cbreak raw -echo min 0
+./cable3 bios floppy.img harddisk.img
+stty cooked echo
+

See the runme script.

+

To use the emulator - +floppy mode only

+

The simplest use of the emulator is with a single floppy boot disk +image, like the fd.img provided, which is a FreeDOS boot +disk.

+

Before running the emulator on a Unix-type system, stty +needs to be used to put the keyboard into raw mode (and afterwards it +needs to be put back to cooked). So, run the emulator using something +like this script (provided as runme):

+
stty cbreak raw -echo min 0
+./cable3 bios fd.img
+stty cooked echo
+

To use the emulator - +floppy + HD mode

+

Easiest to start with is to try a ready-made 40MB hard disk image +containing a whole bunch of software which is in the included file +hd.img.

+

For the more adventurous, you can start off with (for example) a +blank 40MB image file called hd.img made using e.g. Makefile. Then +use:

+
stty cbreak raw -echo min 0
+./cable3 bios fd.img hd.img
+stty cooked echo
+

Preparing the hard disk for use in the emulator is done just like a +real PC. Boot the emulator, and use FDISK to partition the +hard disk. When it’s done FDISK will reboot the emulator. +Then you can use FORMAT C: and you are done. The resulting +disk image is in the right format to be mounted on a real Windows PC +using e.g. OSFMount (Windows), hdiutil +(macOS), or mount (linux/unix), providing an easy way to +copy files and programs to and from the disk image. Or, you can install +programs from regular floppy disk images (see Floppy disk support below).

+

Keyboard emulation

+

The emulator emulates an XT-style keyboard controlled by an Intel +8042 chip on I/O port 0x60, generating IRQ1 and then interrupt 9 on each +key press. This is harder than it sounds because a real 8042 returns +scan codes rather than the ASCII characters which the C standard I/O +functions return. Rather than make the emulator less portable and use +ioctl(2) or platform-dependent equivalents to obtain real +scan codes from the keyboard, the emulator BIOS does the reverse of a +real PC BIOS and converts ASCII characters to scan codes, simulating +depress/release of the modifier keys (e.g. shift) as necessary to work +like a “real” keyboard. The OS (DOS/Windows) then converts them back to +ASCII characters and although this process normally works seamlessly +don’t be surprised if there are issues, for example, with non-QWERTY +e.g. international keyboards.

+

Most of the time you can just type normally, but there are special +sequences to get Alt+xxx and Fxxx.

+

To send an Alt+XXX key combination, press +(^A / Ctrl+A) then the key, so for example to +type Alt+F, press (^A / Ctrl+A) +then F.

+

To send an Fxx key, press ^F / +Ctrl+F then a number key. For example, to get the +F4 key, press ^F / Ctrl+F then +4. To get F10, press ^F / +Ctrl+F then 0.

+

To send a Page Down key, press ^F / +Ctrl+F then O (letter O, not digit zero). To +send a Page Up key, press ^F / +Ctrl+F then E. Other key combinations are left +for the discovery of the user.

+

Text mode support

+

The emulator supports both text output via the standard BIOS +interrupt 0x10 interface, and also direct video memory access (one page, +4KB video RAM at segment B800) in +80x25 CGA 16-color text mode.

+

BIOS text output calls are converted to simple writes to +stdout. Direct video memory accesses for the +80x25 CGA color text mode are converted to ANSI terminal +escape sequences. If you are using a terminal which does not support +ANSI (e.g. you are compiling the emulator with MS VC++ and +running in a Windows console window) then PC applications that directly +write to video memory in text mode might be unusable.

+

Most CGA I/O ports are not supported except for the +CGA refresh register at 0x3DA, which some +applications use for timing or synchronisation.

+

The regular PC character code page (437) includes +various extended ASCII characters for things like line drawing. You +might want to set the font in your terminal program to something that +includes these (e.g. on Mac OS X there is a freeware font called Perfect DOS VGA +437 which does the trick).

+

Occasionally a DOS application on exit will leave the video hardware +in an odd state which confuses the emulator, resulting in subsequent +text output being invisible. If this happens, just use the DOS +CLS command to clear the screen and all will be well +again.

+

Graphics mode support

+

Hercules +720x348 monochrome graphics mode emulation is implemented using SDL. +Most Hercules features are supported via the normal I/O interface on +ports 0x3B8 and 0x3BA including video memory +bank switching (segments B000/B800), which +some games use for double-buffered graphics. CGA graphics modes are not +supported.

+

When an application enters graphics mode, the emulator will open an +SDL window (which will be closed when the application goes back to text +mode). Including code to redirect keystrokes from the SDL window to the +main terminal window would have busted the IOCCC size limits, so you +need to keep the main emulator terminal window in focus at all times +even when you are doing graphics (sounds a little odd but you will get +used to it).

+

On Unices, SDL will automatically output graphics via X11 if the +DISPLAY environment variable is set up.

+

Dual graphics card support

+

Some applications (e.g. AutoCAD) support a PC configuration with a +CGA card and a Hercules card, for simultaneous text and graphics output +on different displays. The emulator simulates this configuration, too, +using separate windows for the (terminal) text and (SDL) graphics +displays.

+

BIOS

+

Like a real PC, the emulator needs a BIOS to do anything useful. Here +we use a custom BIOS, written from scratch specifically for the +emulator. Source code for the BIOS (written in 8086 assembly language) +which compiles with the freely-available NASM x86 assembler is in bios.asm.

+

The BIOS implements the standard interrupt interfaces for video, +disk, timer, clock and so on, much as a “real” PC BIOS does, and also a +small timer-controlled video driver to convert video memory formatting +into ANSI escape sequences when the emulator is in text mode.

+

CPU and memory emulation

+

Memory map is largely as per a real PC, with interrupt vector table +at 0:0, BIOS data area including keyboard buffer at +40:0, CGA text video memory at B800:0, +Hercules dual-bank graphics memory at +B000/B800:0, and BIOS at +F000:100. Unlike a real PC, in the emulator the CPU +registers are memory-mapped (at F000:0), which enables +considerable optimisation of the emulator’s instruction execution unit +by permitting the unification of memory and register operations, while +remaining invisible to the running software.

+

The CPU supports the full 8086/186 instruction set. Due to the +complexities of the 8086’s arbitrary-length instruction decoding and +flags, 8086 instructions are first converted to a simpler intermediate +format before being executed. This conversion, along with instruction +lengths and how each instruction modifies the flags, is assisted by some +lookup tables which form part of the BIOS binary.

+

The CPU also implements some “special” two-byte opcodes to help the +emulator talk with the outside world. These are:

+ +

Emulator exit is triggered if CS:IP == 0:0 (which would +be nonsensical in real software since this is where the interrupt vector +table lives). The supplied fd.img disk includes a small +program QUITEMU.COM which contains a single +JMP 0:0 instruction, to allow the user to easily quit the +emulator without shutting down the terminal.

+

Floppy disk support

+

Emulates a 3.5” high-density floppy drive. Can read, write and format +1.44MB disks (18 sectors per track, 2 heads) and 720KB disks (9 sectors +per track, 2 heads).

+

If you want to install your own software from floppy images +(downloaded from e.g. Vetusware), +the easiest way to “change disks” is to copy each disk image in turn +over the floppy image file you specify on the command line. Don’t forget +to put your original boot disk back at the end!

+

Hard disk support

+

Supports up to 1023 cylinders, 63 sectors per track, 63 heads for +disks up to 528MB.

+

Disk image format used is a subset of the standard “raw” format used +by most disk image mount tools. In general, disk images prepared by the +emulator will work with disk image tools and other emulators, but not +the other way around.

+

The emulator uses a particularly dumb algorithm to derive a simulated +cylinder/sector/head geometry from the disk image file’s size. This +algorithm often results in not all the space in the image file being +available for disk partitions. For example, creating a 40,000,000 byte +image file results in DOS FDISK seeing only 31.9MB as the +volume size.

+

Note that unlike a real PC, the emulator cannot boot from a hard disk +(image). Therefore, you will always need to use a bootable floppy image, +even if after boot everything runs from the HD.

+

Mouse

+

No mouse is emulated.

+

Real-time clock

+

Reading the RTC (both time +and date) is emulated via the standard BIOS clock interface, pulling the +time/date from the host computer. Setting the time or date is not +supported.

+

Timers

+

A countdown timer on I/O port 0x40 is simulated in a +broken way which is good enough for most software. On a real PC this has +a default period of 55ms and is programmable. No programmability is +supported in the emulator and the period may be about right or +completely wrong depending on the actual speed of your computer.

+

On a real PC, IRQ 0 and interrupt 8 are fired every 55ms. The +emulator tries to do the same but again, the delay period is not +calibrated so you get what you get.

+

PC speaker

+

Beeps only, through the console.

+

Software supported

+

The emulator will run practically any software a real PC (of the spec +listed at the top of this file) can. The author has tested a number of +OSes/GUIs (MS-DOS 6.22, FreeDOS 0.82pl3, Windows 3.0, DESQview 2.8), +professional software (Lotus 1-2-3 2.4 and AsEasyAs 5.7 for DOS, Excel +2.1 for Windows, AutoCAD 2.5, WordStar 4), programming languages +(QBASIC, GWBASIC, Turbo C++), games (Carrier Command, Police Quest, and +a bunch of freeware Windows games), and diagnostic/benchmark software +(Manifest, Microsoft MSD, InfoSpot, CheckIt) and all of them run +well.

+

Screenshots of some of these applications running (on Mac OS X) are +provided for the impatient.

+
+AutoCAD + +
+
+Flight Simulator 4 + +
+
+Lotus 123 + +
+
+QBASIC + +
+
+SimCity + +
+
+Windows 3 on macOS + +
+

Compiler warnings

+

A lot of compiler warnings are produced by clang. Missing type +specifiers, control reaching the end of functions without returning +values, incompatible pointer type assignments, and some precedence +warnings, all necessary to keep the source size down. Other compilers +are likely to produce similar warnings.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2013/cable3

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2013/dlowe/index.html b/2013/dlowe/index.html index 3dc93d47f..f3b169273 100644 --- a/2013/dlowe/index.html +++ b/2013/dlowe/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,283 @@ - - + + + + + + - - -2013 dlowe - - + + + +2013/dlowe + + + + + -

2013 dlowe

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2013/dlowe

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2013/dlowe/index.html

- +
+ ← cable3 + ↑ 2013 ↑ + endoh1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: J. David Lowe
+Location: US

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2013 +dlowe in bugs.md.

+

To use:

+
./dlowe [number...]
+

where [number...] is one or more number, space +separated.

+

Try:

+
./try.sh
+

What is different about the above if you do something like:

+
echo 'IOCCC winning entry 2013/dlowe' > ioccc.txt
+./try.sh
+rm -f ioccc.txt
+

?

+

To make it simpler to see try showing just the different line +like:

+
./diff.sh
+

Judges’ remarks:

+

We liked how this entry used Unicode, specifically UTF-8, in a +somewhat obfuscated way.

+

Also, why doesn’t it crash but instead produces a correct output when +called with one argument or when all arguments are equal?

+

For extra fun, compile and run fun.c:

+
#include <stdio.h>
+int main() {
+    printf("%d %d %d\n", (int)(-1.0/0.0), (int)(0.0/0.0), (int)(1.0/0.0));
+}
+

with gcc and clang.

+

With GCC (4.7.2), we get

+
-2147483648 -2147483648 -2147483648
+

and with clang (3.3), we get

+
-2147483648 0 2147483647
+

and with Apple clang version 15.0.0 (clang-1500.0.40.1) in 2023, we +get:

+
1840985120 -2033041452 35979112
+

Which one is correct? :)

+

NOTE: make all will compile fun.c +but to provide a different compiler you can do something like:

+
make CC=clang fun
+

Author’s remarks:

+

sparkl

+

A tiny implementation of command-line sparkline data +visualization.

+

Synopsis

+
$ ./sparkl 0 1 2 3 4 5 6 7
+▁▂▃▄▅▆▇▉
+
+$ echo "sparkline of file lengths: $(wc -c * | awk '{print $1}' | xargs ./sparkl)"
+sparkline of file sizes: ▁▁▁▃▃▂▁▂▁▁▉
+

NOTE: this has been provided in slflen.sh so +you can try:

+
./slflen.sh
+

instead (which try.sh also uses).

+

Description

+

This is a handy little tool for visualizing numeric series from the +command line, using sparklines. Pass it a numeric series as arguments, +and sparkl will display a sparkline graph, which you can +use to very quickly get a sense of the shape of your data.

+

Limitations

+ +

Obfuscation

+

The code is very terse. I was torn between submitting this version, +and a one-line version compressed using a couple more -D +flags.

+

Hand-rolled UTF-8 sequence, magic numbers (what’s that 7 for?), +meaningless variable names, reused variables, and so on.

+

Acknowledgements

+

Edward Tufte invented sparklines (among other things.) Brilliant.

+

Zach Holman’s ‘spark’ +utility was absolutely an inspiration.

+

As I was writing up this description, I discovered I’m not the first +person to write an obfuscated C sparkline utility! Vicent Martí created +this one years (!) +ago. (My implementation is completely independent.)

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2013/dlowe

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2013/endoh1/index.html b/2013/endoh1/index.html index b22cc70c9..74935d3c3 100644 --- a/2013/endoh1/index.html +++ b/2013/endoh1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,354 @@ - - + + + + + + - - -2013 endoh1 - - + + + +2013/endoh1 + + + + + -

2013 endoh1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2013/endoh1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2013/endoh1/index.html

- +
+ ← dlowe + ↑ 2013 ↑ + endoh2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yusuke Endoh
+Location: JP

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2013 +endoh1 in bugs.md.

+

To use:

+
./endoh1 [file.lazy]
+

Try:

+
./try.sh
+

You might also enjoy running:

+
cc -E endoh1.c | less
+

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 remarks:

+

Remarks

+
less endoh1.c
+gcc -o endoh1 endoh1.c
+./endoh1
+

… Isn’t there any more to it?

+

Yes, of course.

+

This is a tool for C programmers to play the SKI +combinator calculus, especially, Lazy K.

+

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. At the same time, hello.lazy is a valid C program that uses +endoh1.c as a library.

+
$ gcc -o hello -xc hello.lazy
+$ ./hello
+Hello, world!
+

In other words, this program is a kind of polyglot.

+

The usage is simple: you just have to wrap Lazy K program with +#include "endoh1.c". Note that # is a comment +in Lazy K.

+

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.

+ +

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 would only matter when you run the attached +programs.

+

Portability

+

I confirmed that the program successfully worked with the following +compilers:

+ +

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:

+ +

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 extension, 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

+

The whole program is interpreted by macro expansion. For example, +S (K I) is translated to a normal C code, +(s)((k)(i)), or simply s(k(i)).

+

This expression returns an abstract syntax tree, and endoh1.c evaluates it.

+

This program uses a very simple “term rewriting” approach for +evaluating SKI combinator calculus. The rewriting rules are shown in the +shape of the code.

+

Abuse of function pointers

+

Consider a sequence of function applications in C:

+
s(x)(x)(x)(x)...
+

What type should s have? Unfortunately, C does +not provide a “recursive type”, such as +typedef f (*f)();.

+

So, I used a heavily nested function pointer type:

+
typedef void *(*(*(*...(*(f))()...)())())
+

This limits how many arguments one function can be consecutively +applied to. But you can increase the number by tweaking the definition +of macro p.

+

Code duplication by macros

+

Next, we need to encode “closures”. A closure is a function together +with an environment which is a reference to non-local variable.

+

In this case, we need something that meets all of the following +criteria:

+ +

However, no type in C is callable and has a reference at the same +time. (It is feasible by dynamic code generation, but it is far from +portable.)

+

So, I addressed this issue by generating many function definitions +statically by (ab)using macros:

+
void *x1; void f1(void *y) { return apply(x1, y); }
+void *x2; void f2(void *y) { return apply(x2, y); }
+void *x3; void f3(void *y) { return apply(x3, y); }
+...
+void *(h[]) = { f1, f2, f3, ... }
+

and by allotting each of them when a closure is needed.

+

This leads to another limitation: the number of pre-defined closures +limits how many identifiers (S K +I) one program can use.

+

But you can increase this number by tweaking the definition of macro +A B C and D. (Note +that closures are allotted only when parsing; after the evaluation +starts, “out of closure” cannot occur.)

+

Short cording

+

This margin is too narrow to contain a detailed explanation. Instead, +I just ask you one question. Can you tell what +v s[]={0,0,s+6,s+2,s+4,s,s+3,s+5,s+1}; is? I found this by +using an SMT +solver.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2013/endoh1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2013/endoh2/index.html b/2013/endoh2/index.html index 41dce236b..8380fc293 100644 --- a/2013/endoh2/index.html +++ b/2013/endoh2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,253 @@ - - + + + + + + - - -2013 endoh2 - - + + + +2013/endoh2 + + + + + -

2013 endoh2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2013/endoh2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2013/endoh2/index.html

- +
+ ← endoh1 + ↑ 2013 ↑ + endoh3 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yusuke Endoh
+Location: JP

+ + +

To build:

+
make
+

To use:

+
make check
+

You’ll need to have both Ruby +and ImageMagick installed to run +all the automated checks.

+

If you do not have both, however, you can still do the below in the +try section to enjoy the entry. The Makefile check rule will check if you +have both and if either is not found it will report it and tell you +where to download one or both before exiting.

+

Try:

+
cat jpeg.c
+

Next look at jpeg.jpg in an image viewer program.

+

Judges’ remarks:

+

This is a program which, when fed its own source, generates a program +that almost is its whitespace inverse, which, in its order, generates a +JPEG file (speaking of file size abuse, that is about 16.4 times larger +than a PBM file with the same image, but the source was also abusing the +size counting program…)

+

Don’t pay attention to the OCR behind the ruby curtain — +it’s a straightforward bitmap comparison.

+

Author’s remarks:

+

Highlights

+ +

Notes

+

I picked JPEG instead of PNG, GIF, or BMP because it is the most +difficult to generate. I believe that the JPEG encoder is the world’s +smallest ever.

+

Nevertheless, the program was too big to meet the IOCCC’s size rule. +So I created a smaller bootstrap program that generates the main +program. endoh2.c contains fragments of the main program +as a comment which iocccsize -i does not +count. I gratefully thank the judges for spoiling the size rule this +year.

+

I think the program will work on any major platforms and +compilers.

+ +

This program uses (a part of) Proggy Tiny Fonts which is distributed +in MIT License:

+
Copyright (c) 2004, 2005 Tristan Grimmer
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2013/endoh2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2013/endoh3/index.html b/2013/endoh3/index.html index 806265f59..69bf0683f 100644 --- a/2013/endoh3/index.html +++ b/2013/endoh3/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,365 @@ - - + + + + + + - - -2013 endoh3 - - + + + +2013/endoh3 + + + + + -

2013 endoh3

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2013/endoh3

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2013/endoh3/index.html

- +
+ ← endoh2 + ↑ 2013 ↑ + endoh4 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yusuke Endoh
+Location: JP

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2013 +endoh3 in bugs.md.

+

To use:

+
./endoh3
+

Try:

+

Trying this out will depend on how your system can play sounds. The +author’s remarks include some options for different operating +systems.

+

The simplest way is to create a .wav file and have your system play +that.

+
echo 'CDEFGABc' | ./endoh3 | ruby wavify.rb > cde.wav
+

Observe how you will need ruby installed.

+

There are also some other musical samples, twinkle.abc and +menuet.abc.

+

Judges’ remarks:

+

This program can toot out a tune that is small enough to posted to +most social media platforms that have small message length limits.

+

This endoh3ram can toot out a tune that is small enough.

+

A +modern day (2023) note about the award ‘Most tweetable 1-liner’ and +twitter:

+

The IOCCC no longer endorses the use of what was once twitter, or +whatever it might be called today. We recommend that you pick a +responsible social media platform to post the program’s output on. +Nevertheless the award of this entry will remain the same for historical +purposes.

+

Author’s remarks:

+

Remarks

+

This is a sound synthesizer for a subset of ABC music +notation.

+

Try:

+
cc -o endoh3 endoh3.c
+echo "CDEFGABc" | ./endoh3 > /dev/dsp
+

If /dev/dsp is not available on your system, use an OSS +sound wrapper such as padsp or aoss:

+
echo "CDEFGABc" | ./endoh3 | padsp tee /dev/dsp > /dev/null
+

If you are using Mac OS X, try sox like so:

+
echo "CDEFGABc" | ./endoh3 | sox -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio
+

If that does not work, use the attached script to convert the output +into a wave file format:

+
echo "CDEFGABc" | ./endoh3 | ruby wavify.rb > cde.wav
+

and play cde.wav.

+

You can also enjoy some music scores that I attached. With +/dev/dsp you can do so like:

+
cat twinkle.abc | ./endoh3 > /dev/dsp
+cat menuet.abc | ./endoh3 > /dev/dsp
+

but you should be able to modify it a way to meet your system +requirements as described above.

+

Obfuscation

+

The following sequence of questions may be helpful to understand the +endoh3ram program:

+ +

Limitation

+

The following features are supported:

+ +

The following features are NOT supported:

+ +

Known Bugs

+

You can NOT write a note length immediately followed by a +note E, such as C2E2.

+

Can you figure out why?

+

A workaround is inserting a whitespace: C2 E2.

+

Portability

+

I tested it on:

+ + +

I believe that all the scores that I attached are +out-of-copyright.

+

I did write a score of the Happy Birthday song too. (It does not +matter because the song is out-of-copyright in my country.) But I do not +attach it to protect you from W****r.

+

For the same reason, do not post a score that contains only +z1092. You know, it is “the famous +song”.

+

Spoiler

+

Here is a magical expression which I found by brute-force:

+
(c % 32 + 5) * 9 / 5 % 13 + n / 32 * 12 - 22
+

Interestingly, it converts an ASCII number of ABC notes to the +corresponding tone number.

+
'C' (ASCII  67) =>  3
+'D' (ASCII  68) =>  5
+'E' (ASCII  69) =>  7
+'F' (ASCII  70) =>  9
+'G' (ASCII  71) => 10
+'A' (ASCII  65) => 12
+'B' (ASCII  66) => 14
+'c' (ASCII  99) => 15
+'d' (ASCII 100) => 17
+'e' (ASCII 101) => 19
+'f' (ASCII 102) => 20
+'g' (ASCII 103) => 22
+'a' (ASCII  97) => 24
+'b' (ASCII  98) => 26
+

By the way, you can write a half-tone by the following +characters.

+
'K' =>  4 (= C#)
+'L' =>  6 (= D#)
+'U' =>  8 (= F#)
+'V' => 11 (= G#)
+'P' => 13 (= A#)
+

Note that the tone numbers simply enumerate the semi-tone steps. So +we can calculate the frequency easily: pow(2, n / 12.0). +Then, how can we calculate pow without math.h? +pow(2, 1.0 / 12.0) is approximated by 89/84.. +(I found this approximation by using the Stern-Brocot +tree.) We can gain the frequency by multiplying the value by +n times.

+

Finally, the following code generates a saw wave:

+
for(c = 0; c < len; c++) putchar(a = n * D);
+

where D is a frequency and a is a variable +whose type is char. By assigning float to +char variable, the implicit type conversion is performed +from float to char (modulo 256).

+

(Strictly speaking, this behavior is undefined according to 6.3.1.4 +in C99; you can replace it with (long)(n*D) if you are +pedantic.)

+

All that was left was to combine and condense the components. The key +is squashing them into just one for-loop.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2013/endoh3

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2013/endoh4/index.html b/2013/endoh4/index.html index faf20b657..13b8b7564 100644 --- a/2013/endoh4/index.html +++ b/2013/endoh4/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,715 @@ - - + + + + + + - - -2013 endoh4 - - + + + +2013/endoh4 + + + + + -

2013 endoh4

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2013/endoh4

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2013/endoh4/index.html

- +
+ ← endoh3 + ↑ 2013 ↑ + hou → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yusuke Endoh
+Location: JP

+ + +

To build:

+
make
+

To use:

+
./endoh4 < file
+./run.sh file
+

The second form is preferable as it will temporarily make the cursor +invisible as recommended by the author. If no file is specified in +run.sh command line it will feed to the program endoh4.c.

+

Try:

+
./run.sh cube.txt
+

Hit ctrl-c to end the program.

+

The author recommends the use of xterm.

+

For an example, if you are a football/soccer fan, try:

+
./run.sh solids/archimedian-solid/a11-truncated-icosahedron.txt
+

Judges’ remarks:

+

This program is formatted as the net for a tetrahedron (hint: try +feeding the program it’s own source code like ./run.sh). +When it runs there is an animation for the computation to work out the +convex hull.

+

Author’s remarks:

+

Spec

+

This is a convex polyhedron viewer, which:

+
    +
  1. reads three-dimensional vertices (3N float values) from +stdin,
  2. +
  3. calculates a convex hull of them, and
  4. +
  5. renders it.
  6. +
+

This simple spec involves many details.

+ +

(Note that this program does not use math.h.)

+

Portability

+

I think it conforms with both C89 and C99. I confirmed that it worked +on gcc, clang, and tcc. It should not be warned with +-pedantic and -Wextra.

+

Tips

+

You may want to use tput to hide the terminal +cursor.

+
tput civis
+./endoh4 < cube.txt
+tput cnorm
+

or

+
./run.sh cube.txt
+

Bonuses

+

You can change the screen size. Let the aspect ratio be about +3:1.

+
cc -DS=120,40 -o endoh4 endoh4.c
+

The shape of this code is the geometric net of a regular tetrahedron. +So, try:

+
./endoh4 < endoh4.c # or ./run.sh
+

The solids/ directory includes various solid +data:

+ +

I created the files by using the POV-Ray scripts (1 and 2) in +Wikipedia. They are copyrighted in CC BY-SA 3.0 by “User:Cyp” and +“User:AndrewKepert”.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2013/endoh4

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2013/hou/index.html b/2013/hou/index.html index 3d1f5aacf..d96a162d4 100644 --- a/2013/hou/index.html +++ b/2013/hou/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,435 @@ - - + + + + + + - - -2013 hou - - + + + +2013/hou + + + + + -

2013 hou

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2013/hou

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2013/hou/index.html

- +
+ ← endoh4 + ↑ 2013 ↑ + mills → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Qiming HOU
+Location: CN

+ + +

To build:

+
make all
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2013 +hou in bugs.md.

+

To use:

+
./hou [scene-file-name] [options]
+

Follow the instructions in stdout, preferably with an +auto-refreshing PPM image viewer ready. Refresh the image every time the +output refreshes, all effects should be more or less recognizable when +you see 16.

+

Try:

+
./hou BIG
+./hou old_default.scene BIG
+./hou otherroom.scene
+./hou otherroom.scene NAIVE
+

Try opening the file and then let the program run a while and every +so often reopen the file, to see how it changes. The author suggests +that you leave the program running overnight to see what happens. If +however you do not have all night :-) then the following JPEG files +should show you what happens with some of the invocations above:

+
+./hou BIG - Luna + +
+
+ + +
+
+./hou otherroom.scene - Other room + +
+

This program does not terminate by itself: you must kill +hou (but not Qiming Hou :-) ) in order to end the +program.

+

Judges’ remarks:

+

You could consider that this program violates the source code size +limit. This is because the first compilation of this program is really +just a decompressor to generate the real source code of the program.

+

This program will loop infinitely while progressively refining a raytraced +image.

+

NOTE: the author refers to a.c, placed in a gzipped +file a.c.gz. We do not include it but it can be generated +like:

+
cc -Wall hou.c -o hou -lm
+./hou > a.c
+

but there is no need to do this as the Makefile takes care of it +without even needing to create a temporary file.

+

Author’s remarks:

+

Using hou

+

This program is a programmable rendering engine with a built-in +default scene. The standard command line is:

+
./hou [scene-file-name] [options]
+

As hou runs, it writes a progressively refining image to +a ppm file specified in the scene. The initialization may take a while, +but once it’s done, a rough preview should be available in seconds. +Leave hou running for the night, and you get a high quality +result like the attached *.jpg files. Kill hou +manually after you’re satisfied with the image quality.

+

To save time and energy for the judges, rendered images for all +provided scenes are provided as attached files.

+

Features

+ +

Abuse of the rules

+ +

Self-imposed restrictions

+ +

Comments and why obfuscated

+ +

Spoiler

+
 3225  3225  3225  9  9    3225  3225
+ 1     1  1  1  1  1  1    1     1  1
+ 4225  1226  1  1  1  1    1222  1226
+    1  1     1  1  1  1    1     1 1
+ 4226  1     4226  8  4222 4226  1  1
+

The program consists of a recursive-descent interpreter, a +3DDDA (3D Discrete Differential Analysis) ray tracer, a +PSSMLT (Primary Sample Space Metropolis Light Transport) +light path sampler, all squeezed into the size limit using a +PPM compressor (Prediction by Partial Matching, and yes, +the output format is chosen for the pun..).

+

PSSMLT uses the Metropolis-Hasting algorithm to sample a +32D unit hypercube. Each point in the hypercube is interpreted as a +sequence of random numbers, and is sent to a path tracer to generate a +light path. The point’s Metropolis-Hasting energy is then defined as the +corresponding path’s contribution value to the final image. Since each +path is sampled with a probability proportional to its energy, the +sample distribution directly corresponds to the final image, which can +then be produced as a simple per-pixel histogram of all generated paths. +The robustness comes from a state mutation strategy that actively tries +to explore the neighborhood of high energy peaks (e.g. paths that happen +to hit the light source in otherroom.scene). In addition, a rudimentary +form of lens path stratification is added to balance the attention each +pixel receives. The Metropolis-Hasting process completely avoids the +tell-tale pixel sampling loop required in most other image generation +methods.

+

The 3DDDA tracer is chosen for scalability: its +performance doesn’t get much worse as scene complexity increases. +Another benefit is that with the DDA code in place one can +naturally use hierarchical grids as an acceleration structure. The +downside, of course, is that the setup involves quite a few divisions, +which naturally turns into divisions-by-zero. Fortunately, the IEEE754 +standard has a nice set of rules just for this purpose and the +arithmetics are organized in a specific way to take advantage of this. +The shader interpreter component is relatively straightforward, just an +expression evaluator stripped to the bare minimum – it doesn’t even +support numerical constants natively. A final little bit is a +just-good-enough PRNG (Pseudo Random Number Generator) to replace the +low precision Windows rand() and the non-C99 Unix +drand48(3). An overnight session would run through its +short period many times, but that doesn’t necessarily map to the same +set of paths in PSSMLT. After all, Metropolis-Hasting used +an even worse PRNG in their 1953 paper.

+

The PPM compressor uses statically weighted fixed order +contexts with an arithmetic encoder tweaked for iocccsize.c. The encoder emits octet-space +pairs where each octet encodes ~6.5 bits of information and each space +encodes 2 bits (thanks to the generous definition of “space” in iocccsize.c). The compressor actively shuffles +the variable names around until the compressed string happens to contain +enough {};s to pass the final iocccsize.c test. There are a few other +tweaks:

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2013/hou

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2013/mills/index.html b/2013/mills/index.html index 522e58568..a498c2e27 100644 --- a/2013/mills/index.html +++ b/2013/mills/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,285 @@ - - + + + + + + - - -2013 mills - - + + + +2013/mills + + + + + -

2013 mills

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2013/mills

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2013/mills/index.html

- +
+ ← hou + ↑ 2013 ↑ + misaka → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Christopher +Mills
Location: US

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2013 +mills in bugs.md.

+

To use:

+
./mills
+

Try:

+
./mills &
+

While that is running, point your favorite browser at: http://localhost:8224.

+

Judges’ remarks:

+

Who will be the first to post an image rendered during a +leap-second?

+

Author’s remarks:

+

The Program

+

This program is a handy graphical clock. Simply run the program, +click OK to any annoying security dialog that pop up (aren’t +those annoying?), then fire up your web browser and type in the +following URL: http://localhost:8224.

+

You will soon be presented with a lovely dynamically rendered 3D +scene that also conveniently tells you the current time!

+

Usage Notes

+

The program will continue to give you the time of day as it changes +by reloading the page as often as it can render. If you grow tired of +watching your life slip by, hit Control-C in the original +window. Note that if you want to restart the program again, you should +wait a minute or two before doing so. For details as to why this is +necessary, feel free to Google "TIME_WAIT", +"SO_REUSEADDR" and "SO_REUSEPORT" (with the +quotes). And while you are there, click on an ad. They could use the +money.

+

It would be possible to fix this by adding

+
n=1,setsockopt(s,SOL_SOCKET,SO_REUSEADDR,&n,sizeof n),
+

at an appropriate spot in the code (an exercise left to the reader). +However, as this limitation is documented, it is not technically a +bug.

+

Details of Operation

+

The program wears many hats (not literally). It is

+ +

It replies to web requests with a PNG image that uses the Adam7 encoding +to return data progressively. Since the data is returned in Adam7 +format, the scene is displayed initially at a lower resolution and +allowed to be progressively refined as time goes on. The ray tracer is +integrally tied to the PNG encoder, casting rays in the Adam7 order. The +web server uses PNG primarily because of PNG’s ability to return data +progressively, and not as you might think it being because the PNG +standard is so obfuscated as to require both little and big-endian +encodings at different spec layers.

+

Since ray-tracing was an obvious choice to return to a web server, I +needed something to ray-trace. A static scene would be uninteresting. I +took inspiration (as I often do) from the IOCCC remarks file which +says

+
+

At least one judge prefers to maintain the use of the leap-second as +part of the world’s time standard.

+
+

Then it was obvious; the code should display the time. It is believed +(but not confirmed) that the code will, in fact, display leap seconds +correctly.

+

To display the time, of course we would need a font. This font is +encoded as a string, using only the C whitespace characters. Clearly, +the judges intended this use of whitespace for data compression, since +their tool doesn’t count whitespace in strings differently than +whitespace outside of them.

+

User-modifiable Features

+

The code can be user-modified simply by changing the build command +line. The following symbols are defined in the Makefile:

+ +

Other Build Flags

+

The original program bound the server to INADDR_ANY to +allow everyone to experience the server’s output. The Judges suggested +that I instead restrict the bind to INADDR_LOOPBACK to +reduce security alarms. As a compliant veteran of innumerable post-ship +late feature additions, I have modified the Makefile to inject the new code without destroying +the beautiful spherical symmetry of the source code. In addition, I have +altered the word sin_port to the more family-friendly +version win_port (via +-Dwin_port="sin_addr.s_addr=htonl(2130706433),R.sin_port") +to protect against curious impressionable youth trying to learn about +sockets on the Internet.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2013/mills

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2013/misaka/index.html b/2013/misaka/index.html index c638358c9..2750aed21 100644 --- a/2013/misaka/index.html +++ b/2013/misaka/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,394 @@ - - + + + + + + - - -2013 misaka - - + + + +2013/misaka + + + + + -

2013 misaka

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2013/misaka

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2013/misaka/index.html

- +
+ ← mills + ↑ 2013 ↑ + morgan1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Don Yang
Location: +US

+ + +

To build:

+
make
+

This will build a bunch of versions of the code. See the author’s +details for information on all of these builds.

+

To use:

+
./horizontal_cat [files...] > [output]
+./vertical_cat [files...] > [output]
+

Try:

+

To understand the various intermediate source files that are built, +try:

+
make understanding
+

Also try:

+
./try.sh
+

NOTE: Use - for standard input. For example:

+
./vertical_cat - -
+

Judges’ remarks:

+

There is more to cat than mere cats. Be they tall, +fat, long or squat, this source code is sure to amuse.

+

Slight diversion

+

While one of the judges was reviewing this entry on the stern of the +Island +Sky in the middle of the Atlantic Ocean waiting for the total +solar eclipse of 2013 the judge was struck by a flying fish. While +the result of the impact was that the Port from Portugal was +lost, the Grog +from Cape Verde and the laptop containing this entry was saved.

+

While I’m sure most cats would have +preferred otherwise, the flying fish was returned to swim with the +fishes. :-) No cats were harmed in the +process of judging this entry.

+

Author’s remarks:

+

Overview

+

Misaka is a file concatenation utility, with at least +two modes of operation:

+
cc misaka.c -o horizontal_cat
+./horizontal_cat [files...] > [output]
+
+./horizontal_cat misaka.c misaka.c > misaka2.c
+cc misaka2.c -o vertical_cat
+./vertical_cat [files...] > [output]
+

Where [files...] is a list of text file names. Use +- to read from stdin.

+

Details

+

Horizontal cat

+

One of my favorite unix utilities is cat. The best thing +about it was that it was named “cat”. That, and it’s +useful for quickly showing contents of a file. Though it was primary +meant for concatenating files, that function only seem to work if I +wanted to concatenate files vertically.

+

I thought the lack of horizontal concatenation must have been an +oversight, so I implemented this utility:

+
cc misaka.c -o horizontal_cat
+./horizontal_cat files...
+

horizontal_cat concatenates files horizontally and write +the output to stdout. Each input file is padded with spaces +on the right so that the original text alignments are preserved.

+

If - is specified as a file name, +horizontal_cat will read from stdin. Unlike +cat, horizontal_cat loads all input to memory +first. Thus you can specify - multiple times to get +stdin multiplied horizontally. For example, if you have +seq(1) in your shell, you can add line numbers to both +sides of misaka.c like this:

+
seq -f '  %.0f  ' 45 | ./horizontal_cat - misaka.c -
+

Vertical cat

+

Because horizontal_cat must know the maximum width of +all files before writing any output, all files must be processed at +least twice. To support stdin, file must be buffered to +memory. This lead to the feature that horizontal_cat can be +used to duplicate stdin.

+

Seems like the stdin doubling feature might be useful +even for concatenating files vertically, so I included a vertical mode. +But supporting vertical mode with command line options would be no fun. +Instead, vertical mode is enabled by concatenating the source code +horizontally:

+
./horizontal_cat misaka.c misaka.c > misaka2.c
+gcc misaka2.c -o vertical_cat
+./vertical_cat files...
+

vertical_cat works more or less like cat, +except you can use vertical_cat to duplicate +stdin:

+
./vertical_cat - -
+

Long cat

+

After horizontal_cat and vertical_cat, I +thought, maybe all I really wanted was just more cats. So I implemented +one more mode, this one is enabled by concatenating misaka.c vertically:

+
./vertical_cat misaka.c misaka.c > misaka3.c
+gcc misaka3.c -o long_cat
+./long_cat
+

long_cat outputs ASCII art of a cat to +stdout. You can make this cat exponentially longer by +concatenating more files vertically (up to 31 levels high, depending on +sizeof(int) for your compiler):

+
./vertical_cat misaka.c misaka.c misaka.c > misaka4.c
+gcc misaka4.c -o loong_cat
+
+./vertical_cat misaka.c misaka.c misaka.c misaka.c > misaka5.c
+gcc misaka5.c -o loooong_cat
+
+./vertical_cat misaka.c misaka.c misaka.c misaka.c misaka.c > misaka6.c
+gcc misaka6.c -o loooooooong_cat
+

If your terminal has really thin fonts, you can also make this output +fatter by concatenating files horizontally:

+
./vertical_cat misaka.c misaka.c | ./horizontal_cat - - > misaka7.c
+gcc misaka7.c -o long_fat_cat
+
+./vertical_cat misaka.c misaka.c | ./horizontal_cat - - - > misaka8.c
+gcc misaka8.c -o long_faat_cat
+

Output width is determined by the first level of stacked programs, so +a triangle like the following will not have horizontally expanded +output:

+
./horizontal_cat misaka.c misaka.c | ./vertical_cat misaka.c - > misaka9.c
+gcc misaka9.c -o same_as_long_cat
+

Finally, if you lost track of how many misaka.c you have stacked together, you can feed the +source to a brainfuck interpreter +to get an overview of how the programs are stacked. Example:

+
perl bf.pl misaka9.c
+

This outputs:

+
MISAKA
+MISAKA MISAKA
+

Return value

+

horizontal_cat and vertical_cat will exit +with zero status on success.

+

If any input file fails to open, horizontal_cat and +vertical_cat will report the offending file name to +stdout, and exit with nonzero status.

+

If horizontal_cat and vertical_cat ran out +of memory, they will exit with nonzero status without outputting +anything.

+

Compatibility

+

horizontal_cat makes the following assumptions about +input files:

+ +

Misaka has been verified to work on these following +compiler+OS combinations:

+ +

Misaka requires a C99 compiler due to the use of single +line comments. Misaka does not depend on any other C99 +features.

+

Obfuscation

+

Main obfuscation is in having a C program that compiles when tiled +horizontally and vertically, while using single line comments in less +than half of the lines and maintaining a meaningful layout +while doing that.

+

There are other challenges too, of course, like getting a Brainfuck +program to tile horizontally and vertically. Really, tiling code of any +sort horizontally is an interesting exercise, I encourage everyone to +try this once.

+

Other features to look for:

+ +

gcc -Wall should provide a hint to where the mode switch +happens, it does not output any irrelevant other warnings (verified on +4.6.3).

+

Extra files

+

Extra files included in my submission are informational only, they +are not needed for the program to work.

+ +

About Misaka

+

The name, layout, and functionality of Misaka is +inspired by a particular stackable figure:

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2013/misaka

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2013/morgan1/index.html b/2013/morgan1/index.html index 99bdb88e2..0cac00210 100644 --- a/2013/morgan1/index.html +++ b/2013/morgan1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,284 @@ - - + + + + + + - - -2013 morgan1 - - + + + +2013/morgan1 + + + + + -

2013 morgan1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2013/morgan1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2013/morgan1/index.html

- +
+ ← misaka + ↑ 2013 ↑ + morgan2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yves-Marie +Morgan
Location: FR

+ + +

To build:

+
make
+

To use:

+
echo "2013/10/03" | ./morgan1
+

Try:

+
echo "1985/10/28" | ./morgan1
+
+echo "1996/12/31" | ./morgan1
+
+echo "1986/03/31" | ./morgan1 # Comet Halley (look for 'Ha')
+
+echo "1997/04/01" | ./morgan1 # Comet Hale-Bopp (look for 'Hb')
+

Try pressing the arrow keys when your focus is in the window.

+

Judges’ remarks:

+

To verify the output, try echoing the date of an evening with a clear +sky. Use binoculars and/or telescope as needed. In some cases you may +need to wait for a better time of the evening. In a few cases, such as +the South Pole in the summer, you may need to move to a different +observing site.

+

Author’s remarks:

+

Instructions

+

It displays the position of the 8 planets of the solar system around +the Sun. The date given in the command line is in the format YYYY/MM/DD +(year, month and day). The direction keys can be used to move in time +:

+ +

It handles correctly all leap years and the switch between Julian calendar +and Gregorian +calendar (10 days missing between 1582/10/04 and 1582/10/15).

+

The scale is logarithmic to be able to display the 8 planets without +having Mercury, Venus, Earth and Mars squeezed around the Sun.

+

The size is not proportional either.

+

Bonus

+

It also displays the position of 2 famous comets during their last +approach:

+ +

Limitations

+ +

Obfuscation

+ +

Compilation warnings

+

With gcc 4.7.2 on Linux Ubuntu 12.10:

+
morgan1.c:38:3: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
+morgan1.c:40:34: warning: value computed is not used [-Wunused-value]
+morgan1.c:56:6: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
+morgan1.c:58:50: warning: value computed is not used [-Wunused-value]
+morgan1.c:61:5: warning: suggest parentheses around ‘-’ inside ‘>>’ [-Wparentheses]
+

With clang 3.1 on Linux Ubuntu 12.10 :

+
morgan1.c:38:49: warning: '&&' within '||' [-Wlogical-op-parentheses]
+morgan1.c:38:27: warning: '&&' within '||' [-Wlogical-op-parentheses]
+morgan1.c:55:13: warning: '&&' within '||' [-Wlogical-op-parentheses]
+morgan1.c:56:14: warning: '&&' within '||' [-Wlogical-op-parentheses]
+

This is due to most of the parentheses and braces being removed when +unnecessary.

+

To verify the display, you can look at one of these programs : * +xephem : https://web.archive.org/web/20130310133219/http://www.clearskyinstitute.com/xephem/ +* homeplanet : https://www.fourmilab.ch/homeplanet/ * https://www.theplanetstoday.com

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2013/morgan1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2013/morgan2/index.html b/2013/morgan2/index.html index 7c39f97e6..ce30d1f27 100644 --- a/2013/morgan2/index.html +++ b/2013/morgan2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,285 @@ - - + + + + + + - - -2013 morgan2 - - + + + +2013/morgan2 + + + + + -

2013 morgan2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2013/morgan2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2013/morgan2/index.html

- +
+ ← morgan1 + ↑ 2013 ↑ + robison → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yves-Marie +Morgan
Location: FR

+ + +

To build:

+
make
+

To use:

+

For the console version (ncurses):

+
./morgan2
+

For the graphical version (X11):

+
./morgan2 X
+

Judges’ remarks:

+

The judges enjoyed playing the game almost to completion; if we +remember correctly, we managed to place 59 or 60 dominoes. We wonder, +what would be faster: to play the game to completion or to write an +unobfuscated version of it?

+

Author’s remarks:

+

This program is a domino game. The goal is to place dominoes on the +8x8 grid. Each domino is made of 6 squares of the colour red or green. +To place a domino, at least one of its side shall match the other side +of another domino.

+

How to play

+

Start of the game

+

At the start of the game, the first domino is placed randomly on the +grid. You get another domino to place by selecting one empty position in +the stack on the right. You can have up to 8 dominoes pending at any +time.

+

Moving in the stack

+

Use Up and Down key to move the cursor in +the stack. Press Enter to either:

+ +

The currently selected domino is indicated on the top right.

+

Placing a domino

+

Once a domino has been selected, the cursor moves to the grid. Use +Up, Down, Left and +Right keys to move in the grid. Press Enter on +an empty position to place the domino.

+

To go back to selection mode, press Enter on an occupied +position.

+

The domino can be placed in an empty position if all its neighbours +have matching sides and the domino has at least one neighbour.

+

Scoring

+

First, depending on the number of dominoes pending in the stack, a +bonus is accorded:

+ +

Then the bonus is multiplied by the number of matching neighbours the +placed domino has (1, 2, 3 or 4). This is added to the score.

+

Finally, the total score is divided by the number of dominoes placed +(1 - 64).

+

The 3 numbers on display represent: the total score, the fill count +and the final score (total score divided by fill count).

+

End of the game

+

The game is finished when no more dominoes can be placed and if one +of the following occurs:

+ +

Note: There is no real end of game detection +implemented in the program, simply press q when you have +finished…

+

Strategy

+ +

Limitations

+ +

Obfuscation

+ +

Compilation warnings

+

With gcc 4.7.2 on Linux Ubuntu 12.10 :

+
morgan2.c:46:65: warning: value computed is not used [-Wunused-value]
+

With clang 3.1 on Linux Ubuntu 12.10 :

+
morgan2.c:23:24: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
+

!!!!! HAVE FUN !!!!!

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2013/morgan2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2013/robison/index.html b/2013/robison/index.html index 270be31a6..0da494e2c 100644 --- a/2013/robison/index.html +++ b/2013/robison/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,267 @@ - - + + + + + + - - -2013 robison - - + + + +2013/robison + + + + + -

2013 robison

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2013/robison

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2013/robison/index.html

- +
+ ← morgan2 + ↑ 2013 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Arch D. +Robison
Location: US

+ + +

To build:

+
make
+

To use:

+
./robison
+# enter an expression
+
+echo expression | ./robison
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Of integers this prog does a lot,
+plus minus, div times (and what not).

+

And modulus if remainders the needing,
+on standard input percent be feeding.

+

More than one line can thru give input,
+when interactive one values more than throughput.

+

With cut and paste and some time,
+one can compute M(23209).

+

Author’s remarks:

+

Oh, The Strings You Can C!

+

I love the C language; its terseness is tops.
+But the thing I abhor is numerical ops!

+

No shifting, division, remainder, or times.
+No increment, decrement, or subscripting blech,
+No addition, subtraction, or bitwise bool glop.
+As for pointer arithmetic – totally yech!

+

But I do have a pref’rence, for pointer deref’rence.
+I find NOTS are a bang, and relations a ball.
+I like calling routines, and recursions in essence.
+But the thing I like MOST is a string dot h CALL!

+

With mem copy I copy, and mem set I clear.
+Take string len of this, and string copy that.
+From my keyboard I pause, to hear subroutines dear:
+The bark of string chrr, and the purr of string CAT!

+

One tiny detail that could lead to defeat.
+From where an arg points: string calls only go forth,
+So how to go back, to be Turing complete?
+From standard dot H, to the rescue, q SORT!

+

My fixation might hint at a textual bent.
+Does my program compose a tattoo for your shin?
+Play crosswords or translate from Urdu to Tzouby?
+To give it a whirl, just punch 2 + 2 in.

+

You can add, do division, and multiply too.
+Take unary minus and also subtract.
+Summing hairs of a walrus? No longer a fuss.
+Parenthetical grouping – no pushing a stack!

+

Try dividing a googol by one forty +three,
+Subtract an octillion +- it’s simply divine.
+To compute a remainder, inscribe a percent.
+For the sign of the answer, see C ninety nine!

+

A hundred and twenty five digits or so,
+Are the lengthiest figures the program can gnash.
+Go over that limit, by even a digit:
+Risk incorrect answers, or witness a crash!

+

Say, say, does it have octal or binary zen?
+What about duodecimal, ternary, hex?
+Try the base as an option (of course in base ten)
+Any base two to twenty – for that is the specs.

+

Use lowercase in trans-decimal radix,
+Divide babbage (in base seventeen) by cafe –
+a nice fad, but avoid a division by nix:
+No errant result, but you could wait all day!

+

To grok the internals, ask Queen +Cleopatra,
+or King +Tutankhamun; for him it’s a romp.
+Addition by cats, and if given two figures,
+to tell which is bigger, sort down and string CMP!

+

Unlawful subtraction, a grade school infraction,
+starts at the left and works to the right.
+Yet more innovation: like Henry Ford’s +cars,
+With a pound and define, mass production of vars!

+

The moral is clear, for programmers out there:
+With the C lib for strings, you can hack with a flair.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2013/robison

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2014/birken/index.html b/2014/birken/index.html index 7f7e17477..d94a15b21 100644 --- a/2014/birken/index.html +++ b/2014/birken/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,376 @@ - - + + + + + + - - -2014 birken - - + + + +2014/birken + + + + + -

2014 birken

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2014/birken

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2014/birken/index.html

- +
+ first entry + ↑ 2014 ↑ + deak → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Authors:

Name: Alexander +Prishchepov
Location: US

Name: Michael +Birken
Location: US

+ + +

To build:

+
make
+

There is alternate code that lets you redefine the port to bind to, +in case there is a firewall issue, and also lets you redefine the timing +constant, STARDATE. See Alternate code below.

+

To use:

+
./prog < some_secret_or_something
+
+./prog http://host[:port]
+

Try:

+
./prog < README.md
+

or maybe:

+
echo "IOCCC 2014!" | ./prog
+

Next, try in another terminal, as the above one is running:

+
./prog http://127.0.0.1:1701
+

What happens if you specify instead of a regular file something like +/dev/null ?

+

But there’s more! Try opening in a browser the same address and then +see what happens. This is explained by the authors when explaining their +inspiration.

+

Alternate code:

+

This version allows you to redefine the port to bind to, should 1701 +be a problem for some reason, and it also allows you to change the +timing as described by the author. See configuration below.

+

Alternate build:

+

To specify the port to say, 31337, try:

+
make clobber PORT=31337 alt
+

To change the timing constant, STARDATE, try:

+
make clobber TIME=5000000 alt
+

You can combine them both of course.

+

Alternate use:

+

Use prog.alt as you would prog above. +Remember that ports < 1024 are privileged ports that unprivileged +users cannot use.

+

Judges’ remarks:

+

Port 1701? Well this is not the l2f registered TCP/1701 protocol. +Sniff the traffic to/from that port. You will see HTTP client and server +traffic. The HTML content you may see is static and immutable. Nothing +funny with the HTTP status codes. Even the timestamp cookie, once set, +remains static throughout the session. The data appears to not be +transmitted within the binary content communicated between client and +server.

+

So how does this program do it? A trek though the cloak of +obfuscation awaits the reader of the source!

+

Authors’ remarks:

+

Abstract

+

When launched in web server mode, this application appears to deliver +nothing more than a static HTML page. But, in actuality, it allows +covert file transfer over the Internet. This is demonstrated by starting +the application as a client-side downloader. The hidden transmitted data +cannot be reconstructed or even detected from the binary content of the +traffic between the client and the server.

+

To use web server

+
./prog < secret_file_to_be_downloaded
+

Try using the program’s source code as the secret file:

+
./prog < prog.c
+

To use client-side +downloader

+
./prog http://host[:port]
+

The optional port defaults to 1701. If the web server instance is +started on the same box, try:

+
./prog http://127.0.0.1:1701
+

It will incrementally display the contents of the hidden file at a +rate of approximately 1 baud.

+

The client-side downloader will automatically terminate if the web +server is bounced.

+

HTML content

+

Plug the URL into a browser to view a static HTML page containing +ASCII artwork.

+

Exploration

+

Studying the network traffic will reveal that the HTML content is +static and immutable, the HTTP request and response fields do not +contain anything remarkable, HTTP status and error codes are not +exploited, no unusual or deprecated features of HTTP are used, and while +the cookie is based on a timestamp, its value also remains unchanged +throughout the session. As mentioned in the abstract, the data is not +transmitted within the binary content communicated between the client +and the server. A full explanation of the protocol appears below, but +feel free to explore before reading further.

+

Inspiration

+

The inspiration for this program comes from Star +Trek VI: The Undiscovered Country, specifically the final +confrontation between the Enterprise +and the enhanced prototype Klingon +Bird of Prey. The definitive feature of the prototype was its +ability to fire while cloaked. But, perhaps even more impressive was its +ability to keep an open communication channel with the Enterprise +throughout the battle, enabling the antagonist Chang to +taunt Captain +Kirk with Shakespearian +quotes while he slowly pelted his ship with torpedoes. Normally, cloaked +vessels must maintain silent running to avoid detection.

+

The battle is commemorated in the form of ASCII artwork depicting the +ships faced head-to-head in the page delivered by the web server. Plus, +the program source code is formatted in the shape of a Klingon Bird of +Prey. The code itself includes a number of Star Trek references: the +registry number of the Enterprise (NCC-1701) is defined as a constant; +variable names spell out Cpt. James T. Kirk and Odo (the Deep +Space 9 character was played by René Auberjonois who also appeared +as Colonel West +in Star +Trek VI); the STARDATE constant makes timing +configurable; and, the constant k stands for Khan +(in the final engagement in Star +Trek II: The Wrath of Khan, the damaged Enterprise managed to +disable the USS Reliant’s +shield generator by accessing its prefix code: 16309).

+

Secondary size limit

+

As obligated by a program that employs 23rd century cloaking +technology, when the source is fed as input to IOCCC size tool version 2014-09-23-v19, and +the -i command line option is used, the value printed is +0.

+

Transmission protocol +revealed

+

The client-side downloader relies on the response time of the web +server rather than the binary content of the response. The server +transmits 1 nibble at a time by counting to the nibble value via a +sequence of rapid responses terminated by a long response. For instance, +the value 5 would be transmitted by making a series of requests that +result in 5 near instantaneous responses followed by a half-second +delayed response. The long delay is skipped in the case of 15, the +maximal nibble value. With the aid of an ASCII table, it is actually +possible to read the nibbles by repeatedly pressing the refresh button +within a browser and observing the page refresh delay.

+

Nibble Count Coding (file transfer protocol NCC-1701) is faster than +transmitting each individual bit as a short or long delay because it +sends each byte with 2 long delays whereas communicating individual bits +requires 8 long delays in the worst case scenario. In fact, Nibble Count +Coding is faster than applying Huffman Coding since that is designed to +produce compact codes under the assumption that the bit value does not +affect transmission time.

+

The server relies on the cookie to identify each client uniquely, +enabling it to transfer the sequence independently to each client.

+

Configuration

+

As with all network communication, accurate transmission of data +relies on the nature of hardware revealed through statistics and +timeouts set accordingly. The long delay is arbitrarily set to +0.5 seconds. This is microsecond tunable via the +STARDATE constant defined at the top of the source code. +Increase the value in the event of transmission errors. Decrease the +value to download faster and less reliably.

+

The NCC constant is the web server port number.

+

Obfuscations

+ +

Compiler warnings

+

For space considerations, the following include statements were +dropped resulting in compiler warnings:

+
#include <asm/byteorder.h>
+#include <ctype.h>
+#include <netinet/in.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/unistd.h>
+

It may be necessary to restore some of these under certain +environments.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2014/birken

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2014/deak/index.html b/2014/deak/index.html index 174577130..8ca15c28f 100644 --- a/2014/deak/index.html +++ b/2014/deak/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,270 @@ - - + + + + + + - - -2014 deak - - + + + +2014/deak + + + + + -

2014 deak

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2014/deak

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2014/deak/index.html

- +
+ ← birken + ↑ 2014 ↑ + endoh1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Ferenc Deak
+Location: unknown

+ + +

To build:

+
make
+

There is an alternate version that the author provided but fixed in +2023 to compile with modern systems and to allow one to reconfigure the +constants X1, X2, Y1 and +Y2 (which were magic numbers). See Alternate code below.

+

To use:

+
./prog
+

Try:

+
./prog
+

Try changing bounding box coordinates in the source to explore +various regions of the fractal.

+

Alternate code:

+

The alternate code is included as prog.alt.c +so you can more easily see the difference in what it might look like if +the C was more recognisable and also to let you reconfigure the +coordinates.

+

Alternate build:

+
make alt
+

If you wish to redefine the coordinates you can do so by defining +X1, X2, Y1 and/or +Y2, which default to: -2, 1, +-1.3 and 1.3 respectively. For instance:

+
make clobber X1=-3 X2=2 Y1=-2.3 Y2=2.3 alt
+

You may pick and choose which ones to redefine.

+

Alternate use:

+

Use prog.alt as you would prog.

+

Alternate try:

+
./try.alt.sh
+

Judges’ remarks:

+

We consider this entry a tribute to all “Abuse of the C preprocessor” +and Mandelbrot fractal drawing entries we’ve seen over the years.

+

We liked the use of unary notation facilitated by variadic +macros.

+

Author’s remarks:

+

Portability

+

The application was written on a standard Ubuntu 14.04 and tested +with gcc 4.9.1 and clang 3.5 on a 64 bit system (though this should not +matter). The application makes no assumption regarding any system +specific settings, and it only needs a console to run. The provided +Makefile is just to have an easy compilation. I don’t see any problems +porting it to different compiler/system as long as it supports the C99 +standard.

+

The application

+

The purpose of the application is mainly to illustrate the weird +possibilities of the C preprocessor, rather than to be a full featured +console mode Mandelbrot drawer. There are tools much better suited for +drawing fractals.

+

The usage of recognizable elements from the C programming language in +the application source code is intentionally kept to a bare minimum. If +this phrase would not be true, the application would be the +following:

+
double                                 _[]={-2
+,1,-1.3                ,1.3,  0,         0,0,0
+,0               ,0,50, 80,     0,0,0     ,255
+,               8,0};    int      main       (
+           int j) {if (j==  1 ){ if(
+       _[12]      >_[10]  )_[17]=1 ;}  if
+   (_[13] >_[11     ] ||_[17]==1)  return 1
+ ;_[6]   =  _ [13] / _[11]*(_[1]-_[   0])
++_[  0];  _ [7]=_[12]/_[10]*(_[3]-_[2] )+_
+[2];_[8]=_[9]=_[14]=0;l2:_[4]=_[8] * _ [8]
+;_[  5]=  _ [9]*_[9];_[9]=2*_[8]*_[9]+ _[7
+ ];_[8   ]  = _ [ 4 ]-_[5]+_[6];_[14   ]++
+   ;if((_ [14]<     _ [15])&&(_[4]+ _[ 5]
+       <_[16      ])) goto l2;  putchar(
+           " #@*+   "[( int)  _[14]%
+5             ]);_ [13   ] ++ ;   main       (
+0)               ;_[12]++;      _[13]       =0
+;if(_                [17]    !=1)      putchar
+(0xa);                               main(1);}
+

The application expects no parameters, the only way you can change +the behaviour is to modify the source code at the indicated location: +the line /* <-- Configure here: X1, X2, Y1, Y2 */ is +intentionally not obfuscated so that the adventurous programmer can +manually modify the coordinates of the fractal to be drawn on the +screen.

+

Compiler warnings

+

Yes, unfortunately there are compiler warnings of the kind +“initialization makes integer from pointer without a cast” but the +provided Makefile automatically disables them.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2014/deak

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2014/endoh1/index.html b/2014/endoh1/index.html index 044edad6f..73da36697 100644 --- a/2014/endoh1/index.html +++ b/2014/endoh1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,279 @@ - - + + + + + + - - -2014 endoh1 - - + + + +2014/endoh1 + + + + + -

2014 endoh1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2014/endoh1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2014/endoh1/index.html

- +
+ ← deak + ↑ 2014 ↑ + endoh2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yusuke Endoh
+Location: JP

+ + +

To build:

+
make
+

To use:

+
./prog > foo.c
+

Try:

+
./try.sh
+

The script will ask you if you wish to run make rake but +this is not necessary to fully enjoy the entry. make rake +will run the rake.sh script and then +prog if all is built okay. If rake is not +installed then it will check that gem is installed. If +gem is not installed it will tell you where to get it and +then tell you how to install rake. Otherwise, if +rake is installed it will try running rake and +if that fails to run it will tell you to run a gem command +as either root or via sudo and then to try running +make rake or ./rake.sh again. If +rake succeeds it will run ./prog which can be +used to build main.c.

+

What is the difference between running ./prog and +main?

+

Judges’ remarks:

+

Big terminals with tiny fonts have their uses in certain cases. One +of them is:

+
make treacl
+./treacl
+

which is shorthand for:

+
./prog < prog.c > treacle.c
+make treacle
+./treacle
+

When using a smartphone to read the output, you may need to step back +to see the bigger picture because that picture is worth more than 1000 +words.

+

Author’s remarks:

+

Remarks

+

You may want to use a large display with a very small terminal +font.

+

Spoiler

+

See spoilers.md.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2014/endoh1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2014/endoh2/index.html b/2014/endoh2/index.html index bf97de1d0..15deda0de 100644 --- a/2014/endoh2/index.html +++ b/2014/endoh2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,218 @@ - - + + + + + + - - -2014 endoh2 - - + + + +2014/endoh2 + + + + + -

2014 endoh2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2014/endoh2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2014/endoh2/index.html

- +
+ ← endoh1 + ↑ 2014 ↑ + maffiodo1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yusuke Endoh
+Location: JP

+ + +

To build:

+
make
+

To use:

+
./prog < input > output
+

Try:

+
echo Hello | ./prog
+
+echo Hello | ./prog > hello.c
+make hello
+./hello
+

Judges’ remarks:

+

If you look closely at the source, you will see code that appears to +puts C code that includes itself. How and why? Perhaps it is in the DNA +code of the code? Perhaps there are 23 reasons? :-)

+

Author’s remarks:

+

Remarks

+

This chromosome program synthesizes a double helix. The helix can +also be compiled as a C program.

+

Enjoy DNA programming!

+

For more information / +background reading:

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2014/endoh2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2014/maffiodo1/index.html b/2014/maffiodo1/index.html index 1be1f0445..ce65b1dd8 100644 --- a/2014/maffiodo1/index.html +++ b/2014/maffiodo1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,459 @@ - - + + + + + + - - -2014 maffiodo1 - - + + + +2014/maffiodo1 + + + + + -

2014 maffiodo1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2014/maffiodo1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2014/maffiodo1/index.html

- +
+ ← endoh2 + ↑ 2014 ↑ + maffiodo2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Sandro +Maffiodo
Location: IT

+ + +

To build:

+

This entry requires SDL to be installed. See FAQ 3.8 if you don’t know how to do this for +your system.

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2014 maffiodo1 in bugs.md.

+

To use:

+
cat game.level | ./prog 320 200 800 300 128 144 game.rgba game.wav 10343679
+

The parameters to the program are:

+
    +
  1. Window width.
  2. +
  3. Window height.
  4. +
  5. Level width.
  6. +
  7. Level height.
  8. +
  9. Sprites image width.
  10. +
  11. Sprites image height.
  12. +
  13. Filename of the sprites image (raw RGBA image).
  14. +
  15. Filename of the music (WAVE 8000 Hz 8bit Mono).
  16. +
  17. Sky color. This number depends on the system where you run the +program. See note on macOS.
  18. +
+

Try:

+
./giana.sh
+
+./mario.sh
+

If you end up telnetting to the server (feature of mario.sh) you can try:

+
ls # show files including games
+wumpus.bas # play Hunt the Wumpus
+advent.gam # you know what this is! :-)
+starwars # animated Star Wars 'film'
+

If you wish to change the width and height, defaulting at 640 x 480, +say to 800 x 800, try:

+
ROWS=800 COLS=800 ./mario.sh
+
+ROWS=800 COLS=800 ./giana.sh
+

Judges’ remarks:

+

A classic for a particular generation. Like all good programs, being +data driven means you can do fun things in small spaces.

+

NOTE: the author states to use tabsize=4 to see the +magic of the formatting of the code. In vim you can do:

+
:set tabstop=4
+

in command mode to see this effect. You don’t need to modify your +.vimrc file! You can also use expand as +described below by the author if your terminal has enough rows and you +don’t want to move about in the code. The vim command should immediately +take effect.

+

Author’s remarks:

+

Remarks

+

Use tabsize=4 to see the magic.

+
expand -t 4 prog.c
+

The program returns 0 if the player wins or non-zero if the +player loses so you can test it and make something useful (or not), like +this:

+
cat mario.level | ./prog 320 200 800 300 128 144 mario.rgba mario8.wav 10343679 && telnet telehack.com 23
+

and type in: starwars

+

This is an engine for platform game. It +can be used to create games like the legendary Super Mario +Bros.

+

With this simple and clear source code you can create all the games +you want, for free!

+

In my two tests I tried to create one level of Super Mario +Bros and one of The Great +Giana Sisters.

+

Both games are classic platform games +and both share the same fundamental rules:

+ +

Running under macOS

+

[NOTE: this seems to no longer be the case as of 2023 and most likely +much earlier. However one can change the look of the game doing this +anyway:]

+

The color of the sky is wrong on macOS. You need to flip some bytes +from the last parameter of the program:

+ +

Regarding how to compile

+

The code requires SDL1.

+

The build process will generate some warnings (~60 with clang) +about:

+ +

How it works

+

Parameters

+
    +
  1. Window width.
  2. +
  3. Window height.
  4. +
  5. Level width.
  6. +
  7. Level height.
  8. +
  9. Sprites image width.
  10. +
  11. Sprites image height.
  12. +
  13. Filename of the sprites image (raw RGBA image).
  14. +
  15. Filename of the music (WAVE 8000 Hz 8bit Mono).
  16. +
  17. Sky color. This number depends on the system where you run the +program. See note on macOS.
  18. +
+

Sprites

+

The program read a single image that contains all the game sprites. +The image must be a grid of 8xN sprites. The size of a single sprite +must be square. The program calculates the size in this way:

+
sprite_size = image_width / 8
+

Each sprite is identified by its position inside the grid, counting +line by line, from left to right (for example sprite 0 is the top left +sprite in the grid, sprite 8 is the first sprite of the second row of +the grid etc.).

+

Some positions of the grid have a predefined purpose:

+
Position          | Description
+:-----------------|:--------------
+0                 | Player standing right
+1                 | Player walking right frame 0
+2                 | Player walking right frame 1
+3                 | Player jumping right
+4                 | Player standing left
+5                 | Player walking left frame 0
+6                 | Player walking left frame 1
+7                 | Player jumping left
+8 *(second row)*  | Super player standing right
+9                 | Super player walking right frame 0
+10                | Super player walking right frame 1
+11                | Super player jumping right
+12                | Super player standing left
+13                | Super player walking left frame 0
+14                | Super player walking left frame 1
+15                | Super player jumping left
+24                | Player dead
+32                | Player won
+40                | Super player won
+

All the others sprites can be used as you want, depending on the game +you want to create.

+

Levels

+

The program reads the level description from stdin.

+

The level description is a sequence of rows where each row describe +an object. You can input as many objects as you want but the maximum +number of objects handled by the program is 333. You can modify this +value by editing the source here:

+
C[333*7],d=333;
+

Each row has six columns:

+
    +
  1. Screen X : x position of the object in the +level.
  2. +
  3. Screen Y : y position of the object in the +level.
  4. +
  5. Sprite : id of the sprite to be used for +the object.
  6. +
  7. CLASSFLAGS : a bitmask that describe how the object +behaves.
  8. +
  9. CLASSPARAM0: a parameter that depends on +CLASSFLAGS.
  10. +
  11. CLASSPARAM1: a parameter that depends on +CLASSFLAGS.
  12. +
+

CLASSFLAGS must be a combination (bitwise OR) of some of +these constants:

+ +

If CLASSFLAGS is 0 the object only has an +aesthetic function.

+

The last row of the level descriptor must have all its columns set +equal to -1.

+

Limitations

+

Some classical features are missing: throwing objects, shooting, +multiple lives, score tracking. You can add those features if you +want!

+

The program allows only one level. It’s easy to add a menu and +multiple levels but the size of the engine would too big for the +contest.

+

When the Super character becomes bigger +(ZOOM flag), the character can collide with blocks and get +stuck inside them. This is a KNOWN BUG. When your player become bigger, +stay away from blocks!

+

There’s only one audio track (game effects are missing).

+

Credits

+

Some of the sprites used in the examples are identical to those of +the original games; the others were designed by me.

+

The music used in the examples have been resampled, +starting from the original versions for the Commodore Amiga and Nintendo +NES.

+

Super Mario +Bros is a game created by Nintendo Co., Ltd. My +use of the sprites +does not intend to infringe the intellectual +property of Nintendo but only demonstrates the operation of the +program. From my point of view this is a tribute to the legendary game +Super Mario +Bros!

+

The +Great Giana Sisters is the game created by Time +Warp Productions and my justification for the sprites for Mario are +the same for this game. Long live The Great +Giana Sisters !! :)

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2014/maffiodo1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2014/maffiodo2/index.html b/2014/maffiodo2/index.html index b833ae876..9b15866fc 100644 --- a/2014/maffiodo2/index.html +++ b/2014/maffiodo2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,262 @@ - - + + + + + + - - -2014 maffiodo2 - - + + + +2014/maffiodo2 + + + + + -

2014 maffiodo2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2014/maffiodo2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2014/maffiodo2/index.html

- +
+ ← maffiodo1 + ↑ 2014 ↑ + morgan → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Sandro +Maffiodo
Location: IT

+ + +

To build:

+
make
+

There is a 121 byte version provided by the author. See Alternate code below.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2014 maffiodo2 in bugs.md.

+

To use:

+
./prog arg
+

Try:

+
./try.sh
+

Alternate code:

+

This shorter version is provided by the author. It has a fixed ramp +and so not as fun but it’s 121 bytes instead of 140.

+

Alternate build:

+
make alt
+

Alternate use:

+
cat image.rgb | ./prog.alt
+

Judges’ remarks:

+

On the face of it :-) given what this program does one might wonder +what makes this winner special. But when you realize the source is small +enough for posting to social media that has a small size limit.

+

Who will be the first to tweet this source? How many re-tweets will +such tweet get? And how many people will really understand the +tweet?

+

Judges’ 2023 update: Last year we would have referred to a toot, +as in a Mastodon +toot. This year we might have mentioned the term publish +although we remain fond of the historic +Mastodon term, toot.

+

Author’s remarks:

+

Remarks

+

This program convert an image to an ASCII ART. The program reads a +raw RGB image from stdin and print the ASCII ART to +stdout.

+

The build process will raise some warnings about:

+ +

The program will crash if run without parameters.

+

Screen size

+

If you have a terminal geometry than is different from the common +80x25 you can modify the output width by changing the value of +the first variable:

+
d=80,
+

Something to try

+

Type this:

+
cat image.rgb | ./prog "  .:;Y0"
+

You can use your own image. Convert the image to a raw RGB image. +Using ImageMagick it’s very simple:

+
convert -geometry 80x source.jpg image.rgb
+

This program require one parameter or it will crash. The parameter of +the program is the conversion ramp. You can use different ramps +or create your own (for example using some letters of your name).

+

These are some ramps you can try:

+
./prog " :1"
+./prog "  .:;Y0"
+./prog " .:-=+*#%@"
+./prog "   .,:!-iots&8%#@$"
+

121 byte version

+

An alternative version of this program is only 121bytes long:

+
d=80,e,j;g(){j+=getchar();}main(){for(;;){j=0;g();if(j<0)break;g(g());putchar(" .:#@"[j/3*5>>8]);if(!(++e%d))puts("");}}
+

This alternative version has a fixed ramp. It’s +smaller but it’s not so fun to use…

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2014/maffiodo2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2014/morgan/index.html b/2014/morgan/index.html index 6c0fb37d4..66aec45dd 100644 --- a/2014/morgan/index.html +++ b/2014/morgan/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,247 @@ - - + + + + + + - - -2014 morgan - - + + + +2014/morgan + + + + + -

2014 morgan

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2014/morgan

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2014/morgan/index.html

- +
+ ← maffiodo2 + ↑ 2014 ↑ + sinon → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yves-Marie +Morgan
Location: FR

+ + +

To build:

+
make
+

To use:

+
./prog [arg ..]
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Think of this as a Maker Faire’s make. :-)

+

It works reasonably well. While not super ultra-featured, it does +fair well with the Makefile we supplied. Not only that, it helped +uncover a bug we had in our special Makefile rules.

+

Author’s remarks:

+

Remarks

+

This program is a tiny make(1) clone.

+

It is able to parse a subset of the make(1) syntax and +will execute rules for goals given in arguments if they need to (based +on timestamp of dependencies of rule targets).

+

Supported features

+ +

It should be able to build programs of previous years with the +provided Makefile found in previous contest archives. +Simply use this program instead of make. It will +recursively use itself for sub-make (the MAKE= assignment +inside Makefile will be ignored to continue using +itself).

+

Limitations / Known issues

+ +

Compilation warnings

+

With gcc 4.8.2 on Linux Ubuntu 14.04 64-bit :

+
prog.c:22:15: warning: return makes integer from pointer without a cast [enabled by default]
+prog.c:23:72: warning: signed and unsigned type in conditional expression [-Wsign-compare]
+prog.c:12:11: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2014/morgan

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2014/sinon/index.html b/2014/sinon/index.html index e3a8f1721..be1248962 100644 --- a/2014/sinon/index.html +++ b/2014/sinon/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,270 @@ - - + + + + + + - - -2014 sinon - - + + + +2014/sinon + + + + + -

2014 sinon

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2014/sinon

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2014/sinon/index.html

- +
+ ← morgan + ↑ 2014 ↑ + skeggs → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Don Yang
Location: +US

+ + +

To build:

+
make
+

To use:

+
cp -f prog.c run.c; ./hecate.sh
+

Try:

+
./try.sh
+

This script will ask you if you wish to try again after each run. +Type in any character other than y or Y to +exit at this point.

+

Judges’ remarks:

+

Try to figure out how this entry determines the optimization level +with which it had been compiled. Is this an example of undefined +behavior or unspecified behavior?

+

Author’s remarks:

+

Summary

+

Sinon is a game of timing, the goal is to eliminate all enemies in +under one minute.

+

To start, compile and run the program. To resume, compile and run the +output repeatedly until you have won/lost the game. For example:

+
cp prog.c run.c
+gcc -O0 run.c -o run && ./run | tee run.c
+gcc -O2 run.c -o run && ./run | tee run.c
+...
+

Details

+

Sinon is played by compiling and running the output repeatedly. Two +factors determine what actions are taken:

+ +

If you fire too quickly, the weapon will jam. If you fire too slowly, +you will not be able to eliminate all the enemies in time. Thus the +primary objective of the game is to time your compilations just +right.

+

Sinon has two weapons that are selected based on compiler +optimization level:

+ +

Because the weapons cool off independently, the best strategy is to +alternate between the two weapons. It is fairly easy to win the game +with this strategy even with occasional jams.

+

If your compiler does not have the right optimizations, only Glock +18C would be available. It is still possible to win, but your timing +will need to be more precise. This is effectively playing the game on +“hard” mode. It is worth trying this mode even if you have the right +compilers.

+

Compatibility

+

Sinon has been tested and verified to work on these platforms:

+ +

Sinon is intended to be played in a 80x25 terminal.

+

Miscellaneous features

+

Sinon might be the first game that uses compiler optimization level +as a primary input.

+

Sinon has a demo mode that plays the game automatically. Make sure +that there are no files named “run” and “run.c” in current directory +(they will be overwritten) and run:

+
perl prog.c | bash
+

File size and CRC32 of prog.c are embedded in +line 7.

+

Process for making Sinon is included in spoiler.html.

+

Layout of this code is based on Asada Shino, also known as “Sinon”, +from Sword Art Online.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2014/sinon

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2014/skeggs/index.html b/2014/skeggs/index.html index 2aa66f93d..9cd0aca17 100644 --- a/2014/skeggs/index.html +++ b/2014/skeggs/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,364 @@ - - + + + + + + - - -2014 skeggs - - + + + +2014/skeggs + + + + + -

2014 skeggs

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2014/skeggs

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2014/skeggs/index.html

- +
+ ← sinon + ↑ 2014 ↑ + vik → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Cel Skeggs
+Location: US

+ + +

To build:

+
make
+

To use:

+
./prog
+

HINT: Try pressing the left and right arrow keys as needed. Also try +pressing space/enter to select options. Pressing Q or Escape may end the +fun before you are ready. :-)

+

Judges’ remarks:

+

When the code looks like lemons, it is probably because the +LEMONPEOPLE, or at least the LEMONLORD was involved. :-)

+

Look at some of the C pre-processor macros in the source code. Ask +yourself why C source is being passed as arguments to some of those +macros.

+

Now you may observe, while it is running, that some C source code is +being written to a file and then compiled. And yet that compiled code is +somehow executed from main(). But how? How is +main() able to call code that was written and compiled just +in time for execution?

+

Author’s remarks:

+

TABLE OF CONTENTS

+ +

BACKSTORY

+

It was ten yours ago when THE LEMONPEOPLE invaded, juicing all in +their path.

+

Attempting to free the Earth from their tyranny, you have endured +pulpy and sour battles.

+

This has now culminated in you reaching the throne room of THE +LEMONLORD.

+

Armed with your right-facing curly brace, you charge into battle.

+

(Use left and right arrow keys and space/enter to select options. +Press Q or Escape to quit.)

+

KNOWN COMPILER WARNINGS

+

Unfortunately, it became very difficult to get this entry to fit +within the size requirements. It’s currently at 2052 according to iocccsize, and 3994 according to +wc -c.

+

The current size is a third to a half of the original size before +compression.

+

Due to this, it does LOTS of things that subtly annoy compilers!

+ +

OBFUSCATION? +WHAT OBFUSCATION? THIS IS A PERFECTLY NORMAL C PROGRAM!

+

THE COOL PART

+

Take a close look at how it works. Notice that it’s passing C code to +certain macros…

+

Guess what? It’s a very simple kind of JIT compiler, though not used +as deeply as would be cool.

+

Essentially, it generates C code at runtime, dumps it to a file, and +then runs a C compiler on that file, telling the C compiler to generate +a shared library. Then it loads the shared library with +dlopen(3), and…

+

Ignores the result?

+

That can’t be right.

+

Well, it is. Instead of using dlsym(3) like a normal +programmer, I mark one of the generated functions with +__attribute__((constructor)). This means that it gets +called immediately on load, so it can make its functions available.

+

But wait - how can it link into the main program, either? It has no +way to reference anything in the main executable!

+

But it does: I’m injecting certain addresses into the generated code, +which it then casts to pointers and accesses! It uses this to make +certain functions available to the main program, so the main program’s +generated code will then enter itself where it’s needed.

+

THE NOT-SO-COOL PART

+

There are also lots of #defines.

+

No, these are not obfuscation. These are compression.

+

There is a little bit of obfuscation gained from using the +stringification operator. (I can never remember what it’s actually +called, but it’s the # operator in a preprocessor macro) - +this allows me to pass C code in arguments to the macros, meaning that +it gets interpreted as C code instead of a string by the iocccsize tool, so it gets counted as smaller! +:D

+

A SLIGHTLY COOL PART

+

As part of the JIT compiling, the program hides the fact that it +needs ncurses: it just links ncurses with one of the generated shared +libraries, and then can access the contents of the ncurses library!

+

WAIT WHAT

+

Also, note where functions start and end…

+

I’ve messed with the syntax so that it’s not actually formatted +properly. It almost looks like it is, but it isn’t.

+

This isn’t significant obfuscation as long as you run it through a C +source code beautifier.

+

But wait… if you aren’t careful, running it through a C source code +beautifier won’t work. Remember how I’m interlacing generated C code +with actual C code? Note that this WRECKS some beautifiers. I hope you +have a good one!

+

(There’s an obvious way around this but I’m not going to spell it out +for you. That’d be too easy!)

+

MISCELLANEOUS STUFF

+

Do note that there are some other miscellaneous obfuscations, but +they should be easy to understand once you figure out the ones +above.

+

TROUBLESHOOTING GUIDE

+

This program is a very easy program to cause to fail!

+

Some things to check

+ +

I’ve tested it on the following platforms, in case you need to try it +on one:

+ +

I ran out of time to test it on more systems.

+

Q&A

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2014/skeggs

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2014/vik/index.html b/2014/vik/index.html index 340ab6831..d91782d10 100644 --- a/2014/vik/index.html +++ b/2014/vik/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,254 @@ - - + + + + + + - - -2014 vik - - + + + +2014/vik + + + + + -

2014 vik

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2014/vik

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2014/vik/index.html

- +
+ ← skeggs + ↑ 2014 ↑ + wiedijk → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Daniel Vik
+Location: US

+ + +

To build:

+
make
+

There is an alternate version that will theoretically work with +Windows compilers (if anything in Windows works :-) ). See the Alternate code section below.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: known bug - please help us fix
+

For more detailed information see 2014 +vik in bugs.md.

+

To use:

+
./prog > foo.c
+

Try:

+
echo 'Want to hear me beep?' | ./prog > audio_file.raw
+
+echo 'No. I want chocolate!' | ./prog | mplayer -demuxer rawaudio -
+

Alternate code:

+

The alternate code, prog.alt.c, is based on +the author’s instructions on how to get it to work with Windows.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use prog.alt as you would prog above as +well as below.

+

Judges’ remarks:

+

This program sets a new tone for obfuscation. But do you understand +what it says about obfuscation? Perhaps:

+
./prog < prog.c > prog.raw
+

might speak to your coding style? If not, then perhaps:

+
./prog < README.md | mplayer -demuxer rawaudio -
+

might help? :-)

+

Author’s remarks:

+

Remarks

+

This program converts ASCII text to Morse audio file and vice versa. +As far as I can tell, there are at least six chocolate references in +this program.

+

This program can convert text to Morse to a raw 44.1kHz stereo audio +file. Via streaming to mplayer(1), you can listen to the +Morse audio.

+

Don’t forget the last ‘-’ as it makes +mplayer(1) read from stdin.

+

Convert audio +file with Morse signals to text

+
./prog e < audio_file.raw
+

or alternatively pass a .wav file as input.

+

The preferred input format 44.1kHz stereo, but it does a decent job +on mono input and different frequencies as well.

+

Portability

+

The program is portable to most platforms. The only system dependency +is that the program relies on writing binary data to +stdout.

+

Microsoft compilers add a carriage return to newlines, and to compile +the program with this platform, the following line can be added to +main() before any code in order for the program to run +correctly:

+
_setmode(_fileno(stdout), 0x8000);
+

NOTE: see the alternate code for this.

+

Known Issues

+

The program uses a quite simple algorithm for detecting tone on and +off events in the Morse signal. Hence the program does not work well +with noisy input signals. I have tested it with several samples of man +made Morse recordings as well as computer generated ones.

+

Generally, any recording from ham radio transmissions does not decode +due to noise and echoes. Other man made recordings may decode, but some +characters can be incorrect due to too big variation in length of tones +and pauses. However I found some man made recordings on that decode +reasonable well.

+

If a recording doesn’t decode, you could try to pre-process the input +with a narrow bandpass filter on the frequency of the transmission.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2014/vik

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2014/wiedijk/index.html b/2014/wiedijk/index.html index 09b769270..e61b3d44f 100644 --- a/2014/wiedijk/index.html +++ b/2014/wiedijk/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,241 @@ - - + + + + + + - - -2014 wiedijk - - + + + +2014/wiedijk + + + + + -

2014 wiedijk

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2014/wiedijk

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2014/wiedijk/index.html

- +
+ ← vik + ↑ 2014 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Freek Wiedijk
+Location: NL

+ + +

To build:

+
make
+

To use:

+
./prog
+

Try:

+
./try.sh
+

By default that will use indent(1) found by the shell +type -P indent and sed(1) found by the shell +type -P sed but if you want to change these, say to try a +different beautifier, you can do it like:

+
INDENT=bcpp ./try.sh
+

which would change it to use bcpp(1) instead of +indent(1). Do similar for sed(1) only use the +name SED.

+

Judges’ remarks:

+

C11 features definitely help this entry to be as concise as it +is.

+

The judges would like to think that they had almost understood how +this entry works.

+

If you win a bet by demonstrating this entry, please let us know.

+

Author’s remarks:

+

Remarks

+ +
W_f = \x.f(xx)
+Y = \f.W_f W_f
+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2014/wiedijk

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2015/burton/index.html b/2015/burton/index.html index 633aaef66..91401e214 100644 --- a/2015/burton/index.html +++ b/2015/burton/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,378 @@ - - + + + + + + - - -2015 burton - - + + + +2015/burton + + + + + -

2015 burton

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2015/burton

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2015/burton/index.html

- +
+ first entry + ↑ 2015 ↑ + dogon → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Dave Burton
+Location: US

+ + +

To build:

+
make
+

To use:

+
./prog "expression"
+

or:

+
./prog
+

Type in expressions on standard input.

+

Try:

+
./try.sh
+

Notice how the script reads in from a file. If you type just:

+
./prog
+

it will prompt you in the same way. Send ctrl-c to exit.

+

Finally, if you wish to read the man page:

+
man ./calc.1
+

Alternate code:

+

An alternate version of this entry, prog.alt.c, is provided. This alternate code is +discussed in the “prog.c vs prog.alt.c” section of the author’s remarks +below.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use prog.alt as you would prog above.

+

Judges’ remarks:

+

“Look, Ma, no hands digits!”

+

The place where some arithmetic operations are done, for example, +division or modulo, are easy to find. Where are addition and +subtraction?

+

We were impressed with the level of detail the author “blogged” the +obfuscation process.

+

Author’s remarks:

+

calc +- an integer expression calculator that outputs in both hex and +decimal

+

All useful tools should include sufficient documentation. See the +included man page. ;-)

+

Notes

+

This program is named calc. Onomatopoeia of sorts, in +the visual realm. The formatting was easier: Form Follows Function +(although Hou did this better). It was tempting to call it +iCalc, with i for integer (and it was written on an +iDevice), but sanity prevailed.

+

Printed in 8 pt Courier, it makes aesthetically pleasing 8.5 x 11 +wall art.

+

prog.c vs prog.alt.c

+

Dominik Muth observed a +syntax error on 1+1, 1-1, 1|1, +and 1^1 when using an ARM based computer, although +1*1 and others worked correctly. This occurs because some +platforms by default treat char as +unsigned char. The original code has this weakness, which +can be corrected by adding -fsigned-char to the compile +line.

+

The modified code is agnostic to char signedness.

+

Why is this entry +obfuscated/interesting?

+

Yes, this is another calculator program.

+

However, unlike any other calculator source code the author is aware +of, this one contains no digits. At all. Anywhere. As in

+
grep '[0-9]' prog.c || echo no digits!
+

Nor are the digits simply obfuscated. There are no character +constants. There is only one single, short string, and it does not +contain any obfuscated digits. And yet the output is in decimal and +hexadecimal, and it accepts octal, decimal, and hex input.

+

Flow control is by for and return. It is +if-less, switch-less, while-less, +and hopeless. Literally, if not figuratively. ;-)

+

The code size is intentionally 2015, as stated by +iocccsize -i, and can be reformatted without changes (as in +rule2.c) to exactly 4096 octets.

+

Finally, calc is interesting, if for no other reason +than it is practically useful: Hex/decimal conversion, arithmetic, +byte-swapping, bit-shifting, and logical operations with memory, on the +command line, or interactively.

+

But the +question is why is the entry obfuscated?

+

The code follows many industry best-practices:

+ +

Compiler warnings

+

calc is C99 compliant, and is ANSI/C90 compliant except +for wanting 64-bit long long. Changing the two +long long typedefs to long, and compiling with +gcc -m32 yields a program that operates on 32-bit values, +with wrap-around of shifts mod 32:

+
1<<48
+65536   0x00010000
+

gcc 4.2.1 without arguments compiles cleanly +(e.g. cc prog.c -o prog). This is my workaday compiler. gcc +is also clean with -ansi, and -std=c99.

+

clang 3.6.0 lives up to its namesake, resounding on non-problems. To +stifle these complaints:

+
-Wno-return-type -Wno-parentheses -Wno-empty-body
+

When invoked with -ansi -pedantic, there are two +warnings, which can be ignored:

+ +

With -Wall -std=c99, both are quite noisy, and all can +be ignored:

+ +

Test Suite:

+

If the program name begins with an e, it echoes +stdin to stdout. This allows for a convenient +test suite:

+
ln -sf prog eprog
+PATH=. eprog < test.in | diff - test.out
+

Spoilers:

+

If you do not want to puzzle out how it works, see spoilers.md.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2015/burton

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2015/dogon/index.html b/2015/dogon/index.html index 33481dccf..be5b8f95e 100644 --- a/2015/dogon/index.html +++ b/2015/dogon/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,358 @@ - - + + + + + + - - -2015 dogon - - + + + +2015/dogon + + + + + -

2015 dogon

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2015/dogon

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2015/dogon/index.html

- +
+ ← burton + ↑ 2015 ↑ + duble → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Gil Dogon
+Location: IL

+ + +

To build:

+
make
+

To change the dimensions you can use the WIDTH and +HEIGHT variables when compiling (default 1024 x 800):

+
make clobber WIDTH=640 HEIGHT=480
+

to make the game 640 x 480. Obviously changing it to non numbers or +negative numbers or too large numbers will cause problems.

+

There is an alternate version that is based on the author’s +suggestion to change a value in order to see a bug that they avoided in +their entry. See Alternate code below.

+

To use:

+
./prog
+

Try:

+
./prog
+

Press and hold the Left Arrow key until you turn 90-degrees to the +left.

+

When you see a long tunnel, press the function key F2.

+

Use the Up, Down, Left and Right keys to change your path.

+

Press function higher numbered function keys (F3, F4, …) to go +faster.

+

Press F1 to stop.

+

Turn 90-degrees to one side.

+

Press F4 to drill into some blocks for a bit.

+

Press F1 to stop.

+

Turn 180-degrees to face the way you came.

+

Press F2 and navigate back down the new hole until you reach the long +tunnel again.

+

Press F1 to stop.

+

etc.

+

Press the ESC key.

+

Alternate code:

+

The author suggested that one change q to +0x82000820000000 instead of 0x820008202625a0 +to see a bug that they avoided, writing:

+
To see this bug in action change the assignment above
+to q=0x82000820000000`, and look towards the negative
+direction of the main tunnel.
+

This alt version does this for you.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use prog.alt as you would prog above.

+

Alternate try:

+

Try locating the issue the author suggested exists.

+

Judges’ remarks:

+

You are in a twisty maze blocks, almost all alike.

+

Those blocks are generated by twisty maze of code blocks, almost all +different.

+

Can you find your way around either and understand where you are?

+

How many function keys does your keyboard have? Can you generate very +high number function keys such as F30 or F31? :-)

+

Textures? We don’t need no stinking textures.

+

Author’s remarks:

+

What is it?

+

Just run ./prog with no arguments on an X11-compatible +system. The scenery, though pseudo-randomly generated should be +strangely familiar, especially to those still in their teenage years. +You can navigate using the keyboard arrow keys and the function keys. +Your speed is a linear function of (n-1) where +Fn is the last function key you have pressed, and you +always move in the direction you are looking at. Be aware that you are +probably some kind of a Creeper as is obvious from looking at the +program, hence your movement is destructive to the environment. So after +pressing F12 for warp speed, and moving around randomly, you might find +yourself in a 3D maze of twisty little passages, from which there is +only one Esc(ape) key. Note that in theory if you have a specialty +keyboard with 32 function keys you may even press F31 to reach infinite +improbability drive speed, though the author had never tested this +feature. However a hidden comment in keysymdef.h suggests +the existence of a mythical Sun Keyboard with 35 function keys :)

+

Full disclosure:

+

This entry, though pretty thoroughly obfuscated, is not entirely +original, nor am I Notch. The inspiration for this entry is a demo code +written by the Notch himself, which was released with the following +license: “you may use the code in here for any purpose in any way you +want, at your own risk”. That version will henceforth be referred to as +the original. Though the original in itself was quite nice and rather +dense piece of code, it was not written in C, nor entirely and +meticulously obfuscated, a state of things I hopefully rectified.

+

Some extra features:

+

Basing it on the original which already had a wonderful simple and +concise ray casting through a generated voxel world rendering, I added a +few tweaks of my own device:

+ +

Portability issues:

+

This entry is rather portable I think on modern platforms. It assumes +of course basic X-windows availability. There are several other salient +assumptions though:

+ +
*(a&1?&C:&B)-=(.05 -a/2%2*.1)*!(a-1&4092^3920)
+

Precision issues:

+

The entry, on purpose, (see the section about SIMD below) does not +use enough bits of precision, so sometimes the ray will miss the +intersection of two voxel faces and push on through. That’s why you may +notice some noise along close up voxel edges. Fixing this issue would +have taken the entry over the size limit regrettably.

+

Obfuscations:

+

Well, of course you have all the usual suspects, used for extreme +compression, and such a nice layout: not very informative identifiers, +which are being reused all over the place, some rather gruesome looking +expressions, a whole load of magic constants with apparently no rhyme or +reason (including a Lagrange polynomial), and a message from our +friendly Cetaceans. However it also includes some clever and not so +obvious though instructive techniques, to subtly make the code more +magical and efficient, at the same time.

+

Those techniques are about the use of 64 bit integers in order to do +SIMD work, in a portable way without ever using any SSE/AVX or other +non-portable compiler inline functions! The irony though, is that when +compiling the program on modern X86 architectures indeed SSE/AVX is used +for the long longs. Following is some “Spoiler” information, So if you +want to play tough, stop reading at this point.

+

Portable SIMD programming:

+

So how is this done? Quite simply by using the whole +long long arithmetic’s capability. I think the C99 standard +assures us that long long has at least 64 bits. Most of +those bits are unused in normal programs, however here we use them more +wisely. For example, in the inner loop of the program you have the +innocent looking expression i+=d. What it does in fact, is +a SIMD addition of two vectors, each with three signed fixed point +coordinates, advancing our ray in 3D space!

+

To spell it out, the macro producing such vectors is P, +and the assignment q=0x820008202625a0 sets our creeper +original position to about (32.5, 32.5019, 2441.406).

+

Evidently when doing such arithmetics, care must me taken to avoid +overflow from one component to the other, but since our voxel world is a +torus of size 64 in each dimension this hardly matters. A subtle issue, +is how to deal with signed quantities. In the i+=d +expression above i has 3 positive components, but +d has arbitrary signed components, as our ray may face in +any direction. It seems things should not work, specially as we defined +both i and d as unsigned! However +notice that the T (and P) macros convert +float to signed long longs.

+

Once sign is extended from a least component into higher bits, it +seems at first to be recipe for disaster, however everything works +beautifully, and you get precise component results when the final +accumulation components in i are positive. This only gets +broken a bit when the final accumulation has a least significant +negative component. To see this bug in action change the assignment +above to q=0x82000820000000, and look towards the negative +direction of the main tunnel.

+

Similar technique is used on the RGB components so their brightness +can be adjusted simultaneously by the expression: +o=o*b>>8. Of course some spare bits are needed +between the components, so they are spread in the long long +and reordered as RBG.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2015/dogon

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2015/duble/index.html b/2015/duble/index.html index a130bf4a4..7b6779cf9 100644 --- a/2015/duble/index.html +++ b/2015/duble/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,333 @@ - - + + + + + + - - -2015 duble - - + + + +2015/duble + + + + + -

2015 duble

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2015/duble

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2015/duble/index.html

- +
+ ← dogon + ↑ 2015 ↑ + endoh1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Etienne Duble
+Location: FR

+ + +

To build:

+
make
+

There is an alternate version of this entry, discussed in the +author’s remarks. See Alternate code +below.

+

To use:

+
echo Some text | ./prog
+

Try:

+
./try.sh
+

Alternate code:

+

This alternate code, provided by the author, is discussed in more +detail by the author in the ‘prog.c vs prog.alt.c’ section of their remarks.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use prog.alt as you would prog above.

+

Judges’ remarks:

+

Beautiful penmanship! However, your fonts may vary.

+

How does this entry compress the font it uses? What’s the purpose of +lrand48(3)? Why does the program dump core, when it does :) +?

+

Author’s remarks:

+

Introduction

+

This program prints text in your terminal with an interesting +hand-writing effect.

+

It uses the Braille patterns range of the unicode standard: +this allows to consider each terminal character as a tiny 2x4 +bitmap.

+

Turning the Braille code into something visual might be considered +blasphemous. When I was fighting to make this program work, I started +wondering if it was not the reason for its very erratic behaviour.

+

prog.c vs prog.alt.c

+

The file prog.alt.c is the one I +submitted.

+

Gil Dogon noted a few unsafe +statements (statements whose behaviour is undefined in the C standard +and, as such, could cause issues with other compilers or optimization +levels). These have been fixed in prog.c.

+

After this fix, in order to remain rule-2-compliant, a variable name +has also been shortened in this file.

+

How to build

+

If you have clang:

+
CC=clang make -e
+

Otherwise (gcc):

+
make
+

(You will get a few warnings in this case.)

+

How to use it

+

You need a terminal configured to handle a UTF-8 encoding +and a font including Braille patterns.

+

This is the default on most modern GNU/Linux operating systems.

+

The default terminal application (gnome-terminal) or even a simple +xterm should render things properly.

+

I tested this on several Debian and Ubuntu systems, 32 and 64bits and +no configuration was needed.

+

I also tested it on FreeBSD 9.3 32bits (font and encoding +configuration was needed in this case).

+

Basic mode:

+
$ echo 'I am testing this thing.' | ./prog
+[... rendering ...]
+
+$ ./prog < lorem-ipsum.txt
+[... rendering ...]
+

Interactive mode:

+
$ ./prog
+> hello world!!!
+[... rendering ...]
+>
+

Obfuscation:

+

This entry is obfuscated in various ways:

+ +

On the other hand, the following may help:

+ +

Limitations:

+

Charset

+

In order to comply with the size rule, I encoded only a part of the +visible ASCII chars:

+
a-z, A-Z, '.' ':' ',' ';' '!' and '?'.
+

Uppercase and lowercase chars are rendered the same. The program also +understands space and linefeed (\n). Other chars are simply +ignored (most of the time ;)

+

Stack size

+

This limitation is due to the heavy use of recursion. After having +processed a large number of characters, the process may exceed the stack +size and crash. (However I did not experience this myself. The top-level +recursion might be removed by the compiler as part of its +optimizations.)

+

Line rendering

+

The program does its best to avoid cutting words at the end of lines, +but it could still happen in case of long words.

+

Subtleties and extra +features

+

Handling more than text docs?

+

Given the limited set of characters handled, the program is mostly +limited to simple text documents.

+

Thus, if you try for example:

+
$ ./prog < prog.c
+

You will not get something that looks like C code. (but you can still +try, if you are curious. :)

+

A ‘draft’ mode

+

Defining an environment variable called DRAFT will +enable the ‘draft-mode’. Try for example:

+
$ echo 'testing the draft mode' | DRAFT=1 ./prog
+

The program will run much faster but the rendering will be less +precise.

+

The subtle interactive mode

+

I saved the best for last: usually, programs that handle an +“interactive mode” have to check whether their standard input is a +terminal or not (by using isatty()). Did you notice that +this program does not perform any such detection, but still behaves (or +seems to behave) appropriately?

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2015/duble

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2015/endoh1/index.html b/2015/endoh1/index.html index 8f7dc143c..bc18992fd 100644 --- a/2015/endoh1/index.html +++ b/2015/endoh1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,399 @@ - - + + + + + + - - -2015 endoh1 - - + + + +2015/endoh1 + + + + + -

2015 endoh1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2015/endoh1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2015/endoh1/index.html

- +
+ ← duble + ↑ 2015 ↑ + endoh2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Authors:

Name: Anonymous +2015
Location: JP

Name: Yusuke Endoh
+Location: JP

+ + +

To build:

+
make
+

NOTE: this program requires the tool tcpserver to use. +If you do not have this program see FAQ 3.14 +- How do I compile and install tcpserver for entries that require +it.

+

To use:

+
tcpserver -v 127.0.0.1 10333 ./prog ioccc.txt
+

Then connect to http://localhost:10333 with your browser.

+

Judges’ remarks:

+

How did +the leopard get its spots? Why are a zebra’s stripes +unique?

+

In case you didn’t recognise the portrait of Alan Turing, there +are some pointers to his features like eyes with “stdeye-o” +and “<--mouth”. Can you find any other tributes?

+

Author’s remarks:

+

What does “Alan +Turing” remind you of? Cryptanalysis of +the Enigma +machine? Turing machine? +Turing test? +This program is also based on his work.

+

Whirlwind tour

+

Compile the program as follows:

+
cc -O3 -std=c99 \
+        -Wall -Wextra -pedantic -o prog prog.c \
+        -Delta_u="Du*laplacian(u)-u*v*v+F*(1-u)" \
+        -Delta_v="Dv*laplacian(v)+u*v*v-v*(F+K)" \
+        -DF=0.040 -DK=0.060 -DDu=0.200 -DDv=0.100 \
+        -DUV_BACKGROUND=1,0 -DUV_DROP=-0.5,0.5 \
+        -DTIMESTEP=1.0 -DSPEED=2 -DRGB=255:128:192
+

Then, run it with the tcpserver command in the ucspi-tcp package, which was +created by Daniel J. +Bernstein, IOCCC 1991 “Best +of Show” (README.md).

+
tcpserver -v 127.0.0.1 10333 ./prog ioccc.txt
+

Finally, open http://127.0.0.1:10333/ in a modern +browser supporting HTML5. You can use the mouse cursor to place drops +into the Petri +dish interactively.

+

Description

+

This is a simulator of reaction-diffusion +systems.

+

Reaction-diffusion systems, proposed by Alan Turing in 1, +are mathematical models in which two chemical substances are transformed +into each other (local chemical reactions) and spread out +(diffusion). Their interactions sometimes form non-trivial +patterns, such as spots, spiral, dappling, and labyrinths.

+

The systems are generally formulated as follows:

+
du/dt = F(u, v) + Du * laplacian(u)
+dv/dt = G(u, v) + Dv * laplacian(v)
+

The functions F(u, v) and G(u, v) represent +reactions of each substance, and the parameters Du and +Dv are diffusion coefficients. By changing the functions +and parameters, you can see a wide range of behaviors.

+

See the +Wikipedia article of “Reaction-diffusion system” in detail.

+

This program simulates the systems. The field consists of 128 x 128 +cells. Each cell includes information of an amount of the two +substances, and interacts with neighbor cells (in terms of von +Neumann neighborhood) in each frame.

+

Configuration

+

You can change the model, initial pattern, simulation speed, and +color via macro definition.

+

Model: +-Delta_u=<expression> -Delta_v=<expression>

+

The definitions represent the equations of reaction-diffusion system. +For example, the following is the +Gray-Scott model in TeX notation.

+
\frac{\partial u}{\partial t} = D_u \Delta u - u v^2 + F (1 - u)
+\frac{\partial v}{\partial t} = D_v \Delta v + u v^2 - v (F + K)
+

You can specify this model as follows:

+
-Delta_u="Du*laplacian(u)-u*v*v+F*(1-u)" \
+-Delta_v="Dv*laplacian(v)+u*v*v-v*(F+K)"
+

Du, Dv, F, and K +are parameters of that model.

+

Initial +pattern: +-DUV_BACKGROUND=<u0>,<v0> -DUV_DROP=<u1>,<v1>

+

The definitions specifies the initial amount of the two substances +u and v. All cells have (u0, v0) +by default.

+

You can specify a pattern file when the executable is invoked (not +compile-time). The file should include a sequence of points, see ioccc.txt, center.txt, or +line.txt as examples. Each amount in cells near +to the point included in the file, will be added by +(u1, v1).

+

Simulation speed: +-DTIMESTEP=ts -DSPEED=spd

+

The definitions are for changing the simulation speed.

+

TIMESTEP is a simulation time step. The bigger, the +faster but more unstable.

+

SPEED is a frame skip parameter. The bigger, the faster +but more sluggish.

+

Rendering color: +-DRGB=r:g:b

+

This specifies a color used for rendering.

+

Examples

+

Some interesting parameters are included in Makefile. Do +one of the following commands and open +http://127.0.0.1:10333.

+
make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 ioccc.txt
+make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 center.txt
+make gray-scott-1 && tcpserver -v 127.0.0.1 10333 ./gray-scott-1 line.txt
+make gray-scott-2 && tcpserver -v 127.0.0.1 10333 ./gray-scott-2 ioccc.txt
+make gray-scott-3 && tcpserver -v 127.0.0.1 10333 ./gray-scott-3 ioccc.txt
+make gray-scott-4 && tcpserver -v 127.0.0.1 10333 ./gray-scott-4 ioccc.txt
+make fitzhugh-nagumo-1 && tcpserver -v 127.0.0.1 10333 ./fitzhugh-nagumo-1 ioccc.txt
+make fitzhugh-nagumo-2 && tcpserver -v 127.0.0.1 10333 ./fitzhugh-nagumo-2 ioccc.txt
+make oregonator && tcpserver -v 127.0.0.1 10333 ./oregonator ioccc.txt
+

These examples are created by drawing (and modifying) the pattern +files of Ready, a +cross-platform implementation of various reaction-diffusion systems 2.

+

Compatibility

+

C part

+

This program compiles clean with no warnings under +-std=c99 -Wall -Wextra -pedantic. Since it uses +long long for 64bit integers, C99 is required.

+

Browser part

+

You must use a modern browser that supports the latest specification +of WebSocket 3. All the following browsers worked +for me:

+ +

I think Safari 6 will work but I haven’t tested. (I have no recent +macOS.)

+

NOTE from the judges in 2023: recent versions of Safari also +work.

+

tcpserver alternatives

+

I think you may use inetd and xinetd +instead of tcpserver. Here is an example inetd +configuration.

+
10333 stream tcp nowait nobody /path/to/prog /path/to/prog /path/to/initial-pattern.txt
+

But note that I didn’t test well.

+

Internal

+
    +
  1. The C program accepts HTTP connection from the browser, and sends a +HTML document.
  2. +
  3. The browser tries to upgrade the connection to WebSocket.
  4. +
  5. The C program accepts WebSocket upgrade. This negotiation process +requires SHA1 hash 4 and Base64 encoding 5. +The C program calculates them without the aid of any external +libraries.
  6. +
  7. The C program simulates the reaction-diffusion system, and then send +the field data to the browser on each frame.
  8. +
  9. The browser receives and renders the field data onto the HTML5 +canvas.
  10. +
+

References

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+
+
+
    +
  1. Turing, A. M., “The Chemical Basis of Morphogenesis”, +Philosophical Transactions of the Royal Society, 1952.↩︎

  2. +
  3. The Ready Bunch, “Ready”, A cross-platform +implementation of various reaction-diffusion systems, since 2011, https://github.com/GollyGang/ready.↩︎

  4. +
  5. Fette, I. and A. Melnikov, “The WebSocket Protocol”, RFC +6455, DOI 10.17487/RFC6455, December 2011, http://www.rfc-editor.org/info/rfc6455.↩︎

  6. +
  7. Eastlake 3rd, D. and P. Jones, “US Secure Hash Algorithm +1 (SHA1)”, RFC 3174, DOI 10.17487/RFC3174, September 2001, http://www.rfc-editor.org/info/rfc3174.↩︎

  8. +
  9. Josefsson, S., “The Base16, Base32, and Base64 Data +Encodings”, RFC 4648, DOI 10.17487/RFC4648, October 2006, http://www.rfc-editor.org/info/rfc4648.↩︎

  10. +
+
+ + +

Inventory for +2015/endoh1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2015/endoh2/index.html b/2015/endoh2/index.html index c4e4eee13..77ab66d34 100644 --- a/2015/endoh2/index.html +++ b/2015/endoh2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,221 @@ - - + + + + + + - - -2015 endoh2 - - + + + +2015/endoh2 + + + + + -

2015 endoh2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2015/endoh2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2015/endoh2/index.html

- +
+ ← endoh1 + ↑ 2015 ↑ + endoh3 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yusuke Endoh
+Location: JP

+ + +

To build:

+
make
+

To use:

+
./prog
+

Try:

+
./try.sh
+

Judges’ remarks:

+

At this point you might be wondering, WTF?*

+ +

How is this code obfuscated? Well look again:

+
less prog.c
+
+more prog.c
+

Where did those underscores come from? Well RTFS!**

+

** Read the Freaking Source (polite form) ** Read The Freaking Screen +(polite form)

+

If you are still puzzled, look at prog.c with +your favorite text editor.

+

Author’s remarks:

+

Follow these instructions literally!

+
cat prog.c
+gcc -w -o prog prog.c
+./prog
+

You will do a double take.

+

Hint 1: Do less prog.c. You will see an +emphasized string if your terminal supports bold.

+

Hint 2: Do wc -c prog.c. This is very long +one-liner.

+

Spoiler: Open the source with an editor like vim or +emacs.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2015/endoh2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2015/endoh3/index.html b/2015/endoh3/index.html index adb8c9b67..54e4c2905 100644 --- a/2015/endoh3/index.html +++ b/2015/endoh3/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,385 @@ - - + + + + + + - - -2015 endoh3 - - + + + +2015/endoh3 + + + + + -

2015 endoh3

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2015/endoh3

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2015/endoh3/index.html

- +
+ ← endoh2 + ↑ 2015 ↑ + endoh4 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yusuke Endoh
+Location: JP

+ + +

To build:

+
make
+

To use:

+
./prog
+

Try:

+

To see the original mullender in +action:

+
./try.sh
+

Observe what happens when you hit enter or another character! You +might even try typing out, one character at a time, +1984/mullender, and then see what it looks like at the end. +Send INTR to end the program.

+

More generally use:

+
cc -o prog prog.c foo.c
+./prog
+^C  # if necessary, where ^C is ctrl-C, interrrupt
+

to compile and run prog as whatever foo.c is in the joke +PDP-11 emulator.

+

Judges’ remarks:

+

Like Marty +and Doc, +something nostalgic from 1984 appears live in October of 2015!

+

The author of this gem is a true DeLorean!

+

A question for inquisitive readers: is the implemented subset of +PDP-11 instructions Turing-complete? +(For a clue, see the end of the author’s remarks.) If in doubt, use APOUT.

+

Author’s remarks:

+

Hint / Compatibility

+ +

Spoiler

+

This program is a joke PDP-11 emulator. (“ll-dpd” is embedded in the +code. Read it upside down.)

+

You got it? This program is supposed to be used in this way:

+
wget https://www.ioccc.org/1984/mullender.c
+clang -o prog prog.c mullender.c
+./prog
+

You can enjoy the legendary winner of the first IOCCC, again.

+

Internal

+

This program uses __attribute__((constructor)), which is +a GCC extension, to hijack the main() function call. And +then it interprets main() as an instruction sequence.

+

It supports the minimal subset of instructions and addressing modes +which are needed for mullender.c to work:

+ +

Limitations

+

Non-trivial combination of instruction and addressing mode may cause +undefined behavior (unsequenced modification), such as attempting to +auto-increment a destination register. Index addressing mode works well +only for R7 (PC register).

+

One more thing

+

Note: this program writes a binary file to stdout:

+
short main[]={5568,1,-30460,12,2782,0,-29921,2056,-4864,6873,770,30054,11886,
+24948,114,21716,-28851,14043,-8944,32691,-16187,-12247,22692,-9781,-20403,
+-11771,16546,18710,17873,9233,31304,-32215,-24382,-28247,-25916,10466,24988,
+-3404,-4177,-28528,-531,-3016,17300,-28552,-7708,-26180,-4297,-367,-2312,
+-25611,28535,-8533,24004,25421,-1224,-5354,-20807,-21589,-6761,-5203,-1055,
+-6715,-26673,-1433,-17732,-24198,14681,-3714,-6660,-14891,-25575,20349,-7701,
+-8336,31433,16695,-14773,26819,3096,-12584,-28808,17825,-21200,-32399,15877,
+-28890,-3728,-27126,21375,-32630,-7615,32004,-29230,-6611,-5508,-28921,12418,
+27204,-5725,9643,3520,26836,-29347,2101,-29311,9320,29287,-29990,-6593,29825,
+-29114,16232,25641,20672,-23501,-32127,-6546,-956,10474,-29647,1070,5516,13760,
+-27814,-32488,-28006,-17968,-3146,10963,19234,22132,23988,7142,5523,9639,-6888,
+-11428,7964,23099,-16822,16518,31109,-12958,10351,2434,3091,3625,2244,27512,
+-28559,-10724,-19377,23625,30056,11478,-21176,27660,26517,-29037,-9390,12297,
+-11903,5980,-21927,-7483,6671,11249,29638,-23827,-26358,-6856,-1063,-5303,
+26636,25797,31818,26798,-4243,-18772,-13266,27472,-12005,-10642,-22524,24373,
+-13111,-9062,6274,-20002,24150,22189,-14965,-31249,-13934,-6341,-18384,-32054,
+-29246,10622,-9260,19428,-15485,2724,23810,16447,11627,18604,2739,27812,30295,
+-21538,-31786,11355,-11308,-9006,-4987,25363,-18927,-21130,-31213,-27411,17231,
+-19608,20232,27754,16476,11213,-19803,-24048,30918,-25329,21233,-10160,13519,
+11828,26653,-6703,10893,6871,-12417,24471,20310,-12137,-19677,4457,-19530,
+10147,17724,533,-10055,27076,10264,11274,-10511,4809,25208,16065,-5105,-19953,
+3772,-12124,13475,-27559,-9955,26446,15133,15207,-23640,6425,-11010,28688,
+-20064,26353,-889,-25008,10380,-14449,-6894,18920,-23900,16902,-31018,16093,
+20875,-19576,4585,13126,18589,24789,19424,31274,-5059,-14538,-3125,-16527,
+-25070,-9013,26628,15756,-7652,30841,-1283,17707,25717,-18315,-6342,6880,
+-19176,6995,5672,2853,-9044,-3409,-14421,-7522,13108,20582,-25317,1376,-5648,
+13821,17300,1220,-29437,-25832,-8332,-15575,-9744,28297,31995,-1217,23852,
+14382,31059,9160,-3296,20287,-28357,24449,-10323,-21992,-4655,-32548,13237,
+-15083,-25226,-21121,2015,-8996,-20247,-27551,-14771,-16089,-6920,-9645,21578,
+7142,-5613,14029,24730,-29253,13931,-3862,-16634,-7388,16951,15771,31302,
+-22186,-6716,18416,1698,-26200,-16231,9821,-10886,-4994,-30527,-9448,-16923,
+29549,-11207,-14909,-3643,-27548,17865,28859,29753,17616,16874,-17733,9424,
+21435,-31715,24544,8666,30844,25075,-18267,12027,-5346,2717,19615,-4548,-21763,
+28514,11691,22268,-2338,1406,-27379,-23568,-24525,13633,11295,-14715,7877,
+-27669,3475,20345,7779,-17849,2184,7132,4079,-24937,11585,22740,5810,-10855,
+16203,-6371,23235,-7,-24828,-11205,-11006,-10,-17812,-14274,11504,-27517,463,
+4498,-32180,-9775,-3190,-22435,-18662,-30146,-31834,-26449,-19374,-12616,
+-10596,14341,-10089,-18449,-16535,21439,21191,-1651,7695,-30009,-23339,-8675,
+-20774,21588,-2793,8218,-14337,-10866,14060,-15343,31712,25247,-8539,18074,
+-28683,-7363,-7663,-3563,-30718,17771,28687,-30495,30584,14022,-28053,5292,
+-31576,-32486,-15470,-1330,23551,-2185,-10829,-13216,-4825,-2964,-14668,24559,
+-4930,23731,-1152,-11493,-2321,15987,-27073,-20305,-24065,-25048,32750,-27440,
+-1169,-25633,-4356,-24993,30439,-17165,-4580,8662,22655,-4588,-6162,-3122,
+31986,-2569,20371,-12320,-25613,-16133,-25644,23677,12254,5855,26325,-13425,
+-15903,-1930,-28488,31222,31153,17607,-2758,7594,-8868,30434,-2518,27956,
+-19424,7370,6199,-17602,17347,-14358,25588,11611,-25209,-23701,-27444,-29788,
+2680,-27406,9318,22483,-28356,28482,4577,-14891,17323,-30152,2507,2977,5004,
+-11696,-31623,-15149,13357,28938,-14048,19490,-19860,-26050,10842,-24922,
+-20986,8847,-31184,28519,-29168,32195,10516,25713,-3493,670,31283,-12769,
+-17461,11357,13180,26133,15944,18051,-32167,-27990,16813,17676,21787,-17578,
+11173,19093,2836,656,-15239,4632,23937,4106,-21655,-7494,-21575,-17647,-18465,
+-14654,-29990,-10707,-12440,21465,5822,26164,-1404,-14303,-26635,-6900,-23611,
+11998,-18551,971,27579,13325,4579,23059,29281,22291,29880,-17546,25664,-14990,
+-526,-35,28218,-3214,11965,11263,6633,30719,32400,-29,-3733,24383,32678,-27542,
+-4444,6196,5975,-19722,11902,16840,-11680,11146,-26391,-8980,21573,-9043,2349,
+-12887,5916,-2996,10410,-23374,26338,11867,-14518,18281,14450,-5815,13842,359,
+25450,27043,3355,13423,-20880,-26311,-30720,-2503,-6046,-18156,-18558,-14774,
+-15664,-29001,3365,-12689,10233,23608,24692,12039,15445,18411,-27469,3764,
+-10841,22672,23844,2282,-12443,2851,-27163,13651,13738,17201,-29819,27414,
+-29764,-5308,-16171,-32427,-26312,-7460,-27376,-6004,25717,29254,-15015,8754,
+15493,22232,-28513,-23355,23676,7736,10571,-8120,-16677,7696,32549,-2646,25538,
+3498,30960,-28459,24716,12655,-10496,402,26209,482,-16661,-20350,-3403,14015,
+32299,11262,-25886,4092,-7843,-100,-1975,-58,-3729,-19269,-23583,-6929,20000,
+-6089,17780,-3250,29830,19954,-29277,27896,10330,9277,-25358,31279,-14454,
+24203,-30170,12872,-21973,-25773,-10502,-6647,-26143,6394,-13479,-24559,23007,
+-21844,1505,24702,-23187,-24364,-20470,20765,-7107,15674,9404,17408,17964,
+19820,18952,2154,-26052,30056,-3227,17770,-8557,-31018,-27700,-25974,9003,
+18218,22730,-19981,6737,3532,1562,-23626,14990,28472,-5270,17358,-32204,-29197,
+-3647,4296,8588,25302,-23906,30328,-29119,-24392,8992,-16557,31530,-31216,
+14107,13041,-6976,7529,-8296,17865,-1462,8181,-21588,-131,-10177,-25931,-14627,
+8301,3708,-32097,20808,13892,-21179,1192,20853,3249,-8774,20843,3520,24954,
+-14215,-25170,-16170,2390,25964,-23923,-17464,-7177,-27568,-9880,-4647,-7323,
+15388,2113,-12338,-7737,26255,26818,-22156,-19610,-911,-17057,-556,29935,27647,
+31806,23676,-18132,-19234,-10869,-3715,24983,-10900,-29564,19856,-16392,-31860,
+-25826,24077,12080,15383,-29852,-2266,-27217,31931,-3183,17385,-14211,19050,
+-2449,-468,-2871,-11466,973,2866,649,1367,-8688,-24069,20992,25139,-25850,1184,
+15851,785,16951,12160,22337,-21851,1849,-18801,14247,-429,-12682,30881,-11273,
+-24819,-9794,8389,-27287,7525,16633,1328,-26650,32607,-8217,31912,7774,-16188,
+-3546,-6550,-16279,-32696,1940,2577,-23723,-6484,2009,-424,27833,-21763,-13902,
+7044,27360,-18450,27889,23987,3137,-7669,-5784,-7490,24946,32302,26464,-15513,
+28898,2493,-17645,-4615,-13434,-20884,-4058,-29951,-22281,24784,21083,-8536,
+22147,-11261,-15069,20659,2993,19029,21909,6748,-3263,1401,30960,11000,-16871,
+-30566,-14959,-26356,-2885,21526,-26531,31063,12857,4992,-5067,3130,-17602,
+-1732,-6593,30200,24679,3267,310,20733,24863,-15669,7875,-4577,-13821,-22325,
+15548,29744,3733,-14547,21459,22122,3854,-2572,30197,-24770,-21263,8793,-8316,
+1571,28191,-16143,-6446,31524,-26496,-17349,-29097,2806,11281,-7041,-683,14149,
+19689,-22094,-1657,-30904,183,-15226,-6358,25461,461,1495,28345,-10554,-4004,
+27119,13484,-21600,-12272,-7272,-14064,-299,10697,11280,19066,-9841,-7265,
+-18002,19906,-17247,21482,-10939,-5897,-22300,-13978,27575,-8684,-6222,-19041,
+5788,-30863,-10134,15142,2895,14705,-17713,12940,-21535,-11619,29416,18417,
+-24973,24867,-26462,-24910,-32556,-26705,-7187,-7750,-758,-14809,20289,9260,
+13778,-1422,30301,-1922,30646,27662,-15465,-912,29340,13846,-1263,28887,-20019,
+32421,-29411,-27632,-7495,-8368,29230,-6386,-19536,-5235,2054,1854,23563,12348,
+-15165,-2936,-28063,-15760,20126,-25531,4963,-5739,23182,16895,-17258,-10470,
+-3969,-7742,-140,4475,-24014,-31961,19231,27153,-18551,20157,26443,11530,
+-22214,2284,-24238,-31051,-26422,9088,29868,18458,8488,-9515,6799,-12507,54,
+-19441,-32665,12561,23560,4725,-28617,-14800,-10224,-13503,-17636,-16823,
+-24072,18735,-29798,-23658,-670,-21769,7489,-6468,-8961,-14785,22255,11582,
+-29831,16303,-19652,2922,-4362,22966,16173,-18446,-6148,27381,-8493,-32289,
+24005,-3027,-18665,-16472,-17793,-27027,-7443,17854,31365,-17726,-2510,-17546,
+14893,21773,-23634,21117,32533,6637,-1106,-8152,-3672,-113,-2149,-34,-22700,
+-4102,-28533,-14104,-10086,4378,13695,-15320,-28258,2246,7595,30021,13281,
+-11968,-29983,14274,27152,26713,19434,17058,1142,-3043,-16496,18630,-11976,
+29168,-3634,32746,27287,-268,16711,-8712,-471,12895,17406,-22548,-3969,-10733,
+13128,10530,-31667,7929,-32277,30926,-1983,8401,-7705,6790,4532,1442,26728,
+29600,-15358,21622,9744,11406,15989,-30741,-15044,29913,24534,6774,-3755,17623,
+19647,18762,10042,9653,-5889,2408,-32579,-6285,-28559,-30655,6294,-21175,4390,
+1668,25437,2821,21066,-13680,5274,-27253,-5248,-26307,29744,-26428,25358,17196,
+15199,-29784,-4604,25653,-8048,-23131,-28995,31340,-9558,26186,11268,27916,
+9646,-7389,-11384,-29116,-4100,160,18394,7856,738,-25920,12148,24713,-31664,
+8203,-25556,13494,30352,29161,30898,1432,-5991,25411,1344,-4019,22299,15685,
+-16401,-23136,-28110,11874,-18945,1879,2,0,-32256,-20996,-18169,29220,12,0,0,0,
+335,-27277,-30776,20480,0};
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2015/endoh3

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2015/endoh4/index.html b/2015/endoh4/index.html index 08e4208d5..43929f129 100644 --- a/2015/endoh4/index.html +++ b/2015/endoh4/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,228 @@ - - + + + + + + - - -2015 endoh4 - - + + + +2015/endoh4 + + + + + -

2015 endoh4

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2015/endoh4

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2015/endoh4/index.html

- +
+ ← endoh3 + ↑ 2015 ↑ + hou → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yusuke Endoh
+Location: JP

+ + +

To build:

+
make
+

There is an alt version which is the originally submitted entry. See +Alternate code below for details.

+

To use:

+
./prog <a number of arguments>
+

Try:

+
./try.sh
+

Alternate code:

+

An alternate version of this entry, prog.alt.c, is provided. This alternate code does +not contain improvements suggested by Gil Dogon; it is the author’s +original entry.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use prog.alt as you would prog above.

+

Judges’ remarks:

+

For this one liner it is best to avoid prime numbers. The output +groups factors in the x-y dimensions. How many factors can be +represented before you run out of command line argument space? How could +you modify the program to experiment with numbers that have more or +larger factors?

+

Author’s remarks:

+

Visual factorization 1-liner. Try:

+
gcc -o prog prog.c
+./prog @
+./prog @ @
+./prog @ @ @
+./prog @ @ @ @
+./prog @ @ @ @ @ @
+./prog @ @ @ @ @ @ @ @
+./prog @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
+

Inspired by Animated +Factorization Diagrams.

+

prog.alt.c is the original version that I +submitted. Gil Dogon kindly +improved it during the review. Thank you!

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2015/endoh4

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2015/hou/index.html b/2015/hou/index.html index 008a1c89a..b19e5c47c 100644 --- a/2015/hou/index.html +++ b/2015/hou/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,270 @@ - - + + + + + + - - -2015 hou - - + + + +2015/hou + + + + + -

2015 hou

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2015/hou

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2015/hou/index.html

- +
+ ← endoh4 + ↑ 2015 ↑ + howe → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Qiming HOU
+Location: CN

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2015 +hou in bugs.md.

+

To use:

+
echo something | ./prog
+./prog < file
+

Try:

+
echo "" | ./prog
+

Judges’ remarks:

+

A good start for understanding this entry might be rfc1321.txt. How does it compute this using only +a single looping construct? The original reference source code for this +algorithm is about 355 lines of code, yet this entry is only 199 lines +with one statement per line and it isn’t using lots of macro expansion +tricks like the reference code!

+

Some things that make you go, “huh?”

+
./prog < prog.c | cut -c-5
+./prog < Makefile | cut -c-4
+

How are those values magically returned?

+

What happens with a large file? Something over 256K.

+
./prog < large_file
+

Where does that message come from?

+

Author’s remarks:

+

This looks like a normal C program.

+

Almost everything is a double.

+

There are tell-tale signs like pow(2,(?/12)) and +exp(-?*?) (names redacted). You can also find a bunch of +cosines and polynomial evaluations.

+

It looks like a ????? ???????????, right?

+

Run and find out.

+

Why obfuscated

+

Some poor scripting folks only have access to doubles (Jav?script, +L?a, BA?IC, etc.).

+

As a C programmer, I feel obliged to show a gesture of sympathy, to +experience their pain and provide an answer.

+

Except when absolutely necessary (printf, +int main(), array indexing), there isn’t a single integer. +Even getchar() and EOF are immediately +converted.

+

Since bool counts as an integer type too, there is no +boolean either. No comparison, no if, no ?:, +no || &&. Everything is done in a +single loop that terminates on printf(3). Straight up +arithmetic.

+

floor(3) and ceil(3) are technically +double-to-double functions, but they feel like cheating. Yes +cos(3), no floor(3).

+

Limitations

+

Hard requirements:

+ +

Soft requirements:

+ +

Tested platforms:

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2015/hou

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2015/howe/index.html b/2015/howe/index.html index 2d87a5478..7063ba687 100644 --- a/2015/howe/index.html +++ b/2015/howe/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,335 @@ - - + + + + + + - - -2015 howe - - + + + +2015/howe + + + + + -

2015 howe

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2015/howe

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2015/howe/index.html

- +
+ ← hou + ↑ 2015 ↑ + mills1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Anthony C. +Howe
Location: CA

+ + +

To build:

+
make
+

There is an alternate version provided. See Alternate code below.

+

To use:

+
./prog file1 file2
+
+./prog -d file1 file2
+

Try:

+
./try.sh
+

Alternate code:

+

This alternate version does not use a 64-bit FNV hash. This was the +original entry but was changed to be the alt version.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use prog.alt as you would prog above.

+

Judges’ remarks:

+

This is the best use of the FNV that we have seen in the IOCCC so +far! The output, when used without -d, is compatible with +POSIX diff(1) and is suitable for use with +patch(1).

+

We welcome back Canada to the list of nations from where winning +entries have been submitted.

+

Is this code a bug or a feature? :-) Or is this an attempt to corrupt +the programming of our youth? Should we heed Kyle’s mom words that she +uttered during a South Park P.T.A. Meeting?

+

“We must stop dirty (C) language from getting to our children’s +ears!”

+

Blame +Canada

+

Or should we teach our youth to understand the intricacies of this +code? Ying Tong Iddle I Po! We suggest you read the source for yourself, +which might be easier than the academic papers it was inspired by.

+

NOTE: Unlike the original entry source, prog.alt.c, prog.c uses a 64 +bit FNV hash and fixes a function call warning.

+

Author’s remarks:

+

Features

+ +

Description

+

This is a functioning micro diff(1) tool using an O(NP) +algorithm, compared to the older O(ND) difference +algorithm used by some versions of diff(1). Its output +is based on the default diff(1) output described by POSIX +and the +Open Group Base Specifications. The output is suitable for use with +patch(1).

+

The -d option simply writes the edit distance between +file1 and file2.

+

Observations

+

The FNV1a hash is a little slow compared to the trivial hash GNU diff uses. I +downloaded a plain text copy of “War And Peace” from Project Gutenberg, used makeholes.c to make 1000 random changes, then +profiled and timed the program verses GNU diff(1). The +bottleneck appears to be in the file I/O and line hashing with an +average +0.05s slower. Using a huge file like “War And Peace” for +testing offsets the diff(1) optimised file I/O.

+

There is no hash collision checking, partly because FNV1a appears to +generate very few +collisions and an assumption that localised collisions within a +region of edits are highly unlikely.

+

Support Files

+ +

References

+

Wu, Manber, Myers, and Miller; August 1989;
+“An O(NP) Sequence Comparison Algorithm”;
+http://myerslab.mpi-cbg.de/wp-content/uploads/2014/06/np_diff.pdf

+

Fowler, Noll, Vo; 1994
+http://www.isthe.com/chongo/tech/comp/fnv/index.html

+

Fowler, Noll, Vo on Wikipedia
+https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function

+

“diff”, The Open Group Base Specifications Issue 7
+IEEE Std 1003.1, 2013 Edition
+http://pubs.opengroup.org/onlinepubs/9699919799/utilities/diff.html

+

Eugene W. Myers; “An O(ND) Difference Algorithm and Its +Variations”;
+Algorithmica, 1986, pages. 251-266
+http://www.xmailserver.org/diff2.pdf

+

Webb Miller and Eugene W. Myers; “A File Comparison Program”;
+Software-Practice And Experience, Vol. 15(11). 1025-1040 (November +1985)
+http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.189.70&rep=rep1&type=pdf

+

D.S. Hirschberg, “A linear space algorithm for computing maximal +common subsequence problem”;
+Comm. of ACM, Vol. 18, June 1975, pages 341-343
+http://www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/DynProg/Docs/Hirschberg-LCS-1975.pdf

+

Which hashing algorithm is best for uniqueness and speed?
+http://programmers.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2015/howe

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2015/mills1/index.html b/2015/mills1/index.html index 61c819443..6f4f1e91e 100644 --- a/2015/mills1/index.html +++ b/2015/mills1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,311 @@ - - + + + + + + - - -2015 mills1 - - + + + +2015/mills1 + + + + + -

2015 mills1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2015/mills1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2015/mills1/index.html

- +
+ ← howe + ↑ 2015 ↑ + mills2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Christopher +Mills
Location: US

+ + +

To build:

+
make
+

To use:

+
./prog
+

Try:

+
./prog
+

Press the up arrow and the down arrow at the right time.

+

Judges’ remarks:

+

Did you find that mobile application game a bit frustrating? Well you +can adjust the Makefile parameters to make life a bit easier for +you:

+
./try.sh
+

which runs:

+
make clobber all DW=199999 DW=22 DH=16 DA=50 DI=-150
+./prog
+

From the Makefile:

+
# Game parameters
+#
+DU=99999        # Time between steps in microseconds.
+        # Make it larger if the game is too fast for you.
+
+DW=28           # Pipe-to-pipe spacing, in columns.
+        # Farther apart is easier.
+
+DD=20           # Space between pipes.
+        # The difference between DD and DW is the width of a pipe.
+        # Narrow pipes are easier to fly though.
+
+DH=8            # Height of gap in pipe.
+        # Make this larger to make the game easier.
+
+DA=100          # Acceleration due to gravity (scaled by 256).
+        # Smaller values make you glide slower.
+
+DI=-200         # Impulse velocity of a flap (scaled by 256).
+        # Make larger if you want a less intense tapping experience!
+
+DB='"<o^="'     # Sprite for player when gliding.
+        # HINT: Try using various emojis.
+        # NOTE: The string MUST be enclosed inside double quotes.
+
+DF='"<ov="'     # Sprite for player when flapping.
+        # HINT: Try using various emojis.
+        # NOTE: The string MUST be enclosed inside double quotes.
+
+DG='"Tap to Flap!"'     # Instruction text.
+            # Change to your native tongue.
+        # NOTE: The string MUST be enclosed inside double quotes.
+

WARNING: if you have good eye-hand coordination and too much time on +your hands you might fall asleep while playing as you probably will +never die in this mode. We only stopped when a reminder came through and +we tried to mark it complete at the same time as playing and we almost +managed to survive that. At that point we already scored over 90.

+

Enjoy!

+
TAP!! TAP!! TAP!!
+FLAP! FLAP! FLAP!
+

Author’s remarks:

+

The Program

+

Better late than never to jump on the bandwagon of 2014’s most +successful mobile game. The game is called Tappy Bird, and has all the +sophisticated gameplay of the original, except with an exciting twist! +(you get to fly to the right instead of to the left).

+

In addition, the game features exciting new customization options! +Too hard? Ran into that damn wall too many times? Now you can change +physics! Change any of a number of parameters (speed, gravity, etc.) of +the game to suit your gameplay!

+

You can even make the game more challenging – resize the terminal +window to make the world taller or shorter. You’ll never be able to get +through the pipes when they are four times as tall!

+

Instructions

+

The instructions are printed at the start of the game: Tap to +Flap!

+

Hit any key to make your bird fly. Navigate her between the gaps in +the pipes. Your score is shown in the upper left, along with your +current high-score.

+

Customization options

+

To customize the gameplay, change any of the following options on the +compile command line:

+ +

Feel free to try out physics or play field options to make the game +more interesting. Try setting the player sprites to change the game +completely – maybe you can be a fish, or a pig – the options are +limitless! Try using emojis – you can be a flying beer mug!

+

Note that since the curses library on POSIX doesn’t +natively support wide characters (needed for UTF-8 support, which is +needed for emojis), you may need to make some changes to the +Makefile to get emojis to work on your system. To help you +get started, I’ve included some example substitutions for emojis sprites +and instruction text; for example, type

+
make EMOJI=beer LANGUAGE=spanish
+

or

+
make EMOJI=globe
+

for some examples (the full list of options is in the +Makefile). Don’t forget to make clobber first +(or use make -B). If the output doesn’t look right, you may +need to link with the “wide” version of ncurses. On MacOSX +10.11, it should work with the current -lcurses; on Linux, +you might need -lncursesw. See the Makefile to +make this change if you need to. Or buy a Mac.

+

You will also need a UTF-8 compatible terminal and an emoji font +installed, and you will need to have your LANG environment +variable set to use UTF-8. Again, if this is too complicated, maybe just +go and get that Mac.

+

Future additions

+

Future versions of the game will include monetization via the +freemium model with micropayments for customization options, play-to-win +and of course live-streamed targeted video advertising.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2015/mills1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2015/mills2/index.html b/2015/mills2/index.html index d23ecbdca..f30bd7e44 100644 --- a/2015/mills2/index.html +++ b/2015/mills2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,297 @@ - - + + + + + + - - -2015 mills2 - - + + + +2015/mills2 + + + + + -

2015 mills2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2015/mills2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2015/mills2/index.html

- +
+ ← mills1 + ↑ 2015 ↑ + muth → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Christopher +Mills
Location: US

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2015 +mills2 in bugs.md.

+

To use:

+
./prog compressed_file.Z
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Without ASCII art, the source code of this entry would have been +exactly 256 bytes. Compared to 1990/jaw, it is very +impressive, even taking into account the missing atob +functionality. Now we wish for a compress(1)-like +compressor using a similar idea.

+

Why is the sad smiley on line 12 in that particular place?

+
  c=0)              :( O
+

Author’s remarks:

+

The Program

+

This program is an implementation of the unix zcat(1) +command for printing compressed files that have been created by the +compress(1) command.

+

The adaptive LZW +compression employed by compress(1) usually requires a +fairly large amount of memory to build the decompression tables (in +fact, compress(1) has a command-line option to control the +size of the decompression tables, since some of the early systems to +which it was ported (*cough*MS-DOS*cough*) +did not have enough memory to use the full 16-bit codes). This version +has no large static or dynamic tables. It is able to decompress 16-bit +files using a single function and a few ints.

+

To run the program, take an existing compressed file and pass it to +the program on the command line. On the odd chance you don’t have +compress(1) hanging about on your system, I’ve provided +compressed copies of this year’s IOCCC rules and guidelines files. To +print them, just do

+
./prog ioccc_guidelines.txt.Z
+./prog ioccc_rules.txt.Z
+

The Details

+

The basic cleverness here comes from realizing that the compressed +data is itself an encoded version of the code dictionary. When the +encoder sees an input string that is not in its dictionary, it emits the +code corresponding to the longest prefix that is in the dictionary and +adds a new entry consisting of that code followed by the next input +character. This means that when the decoder wants to know how to decode +a code, it just needs to find the spot in the code-stream where the +encoder added that entry to the dictionary. The code at that spot is the +prefix, and the first character of the following code is the suffix. +Decoding then just becomes recursion, to follow the chain of prefixes +and suffix characters.

+

Of course, it’s not nearly that simple. Finding the code in the +stream is complicated by several issues:

+ +

Managing all the details involved added a lovely additional layer of +obfuscation to the otherwise elegant recursive decoder. Still, the code +manages it in a remarkably small amount of code.

+

Limitations

+

The decoder doesn’t look at the header. If you supply something that +is not compressed data, it’s likely to crash in an interesting +manner.

+

In particular, it doesn’t look at the third byte of the header, which +encodes the maximum code word size and whether “block mode” was used +when the encoder was run. If you use compress(1) in its +default mode, the maximum word size will be 16 bits and “block mode” +will be enabled. You are unlikely to find any files that don’t use +“block mode”, since all versions of compress(1) after 2.0 +(circa 1984) use it by default and have no documented way to disable it. +Reducing the bit depth is still possibly by using the -b +flag. Modern systems have no problem with the 200 KB or so needed for +16-bit decoder tables, so the need for reducing the table size has +passed, hence this program always assumes 16-bits… However, should you +find a file that needs a smaller table, feel free to change the +hard-coded 16 in the source into the appropriate number and +recompile.

+

In the event that you don’t supply an argument, or that argument +doesn’t name a readable file, the program will just silently exit. This +is a feature.

+

The program depends on having a little-endian system. On a big-endian +system you will get a weird big-endian version of +compress(1), which might have come to pass in an alternate +universe where the VAX +on which compress(1) was authored had been big-endian. +Luckily for us, it wasn’t, and neither are most of the systems you might +want to compile this for.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2015/mills2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2015/muth/index.html b/2015/muth/index.html index 1cbc3a0f3..8813d3d3d 100644 --- a/2015/muth/index.html +++ b/2015/muth/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,312 @@ - - + + + + + + - - -2015 muth - - + + + +2015/muth + + + + + -

2015 muth

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2015/muth

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2015/muth/index.html

- +
+ ← mills2 + ↑ 2015 ↑ + schweikhardt → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Dominik Muth
+Location: DE

+ + +

To build:

+
make
+

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:

+
./try.sh
+

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. Now +we have the proof!

+

Author’s remarks:

+

Preprocessor Turing Engine

+

Features

+ +

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..., (,))))
+ +

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

+ +

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)
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2015/muth

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2015/schweikhardt/index.html b/2015/schweikhardt/index.html index a553d77b6..53317ea48 100644 --- a/2015/schweikhardt/index.html +++ b/2015/schweikhardt/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,894 @@ - - + + + + + + - - -2015 schweikhardt - - + + + +2015/schweikhardt + + + + + -

2015 schweikhardt

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2015/schweikhardt

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2015/schweikhardt/index.html

- +
+ ← muth + ↑ 2015 ↑ + yang → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Jens +Schweikhardt
Location: DE

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2015 schweikhardt in bugs.md.

+

To use:

+
./prog n
+

where n is a base 16 number of any size.

+

NOTE: although it’s supposed to be a base 16 number nothing will stop +you from doing something else. The author explains this in more +details.

+

Try:

+
./try.sh
+

After running it once to see what commands are run, you might wish to +run it a second time and just hold down space to see a fun scroll of +numbers especially where zeroes move to the right.

+

Judges’ remarks:

+

This code is clean. When you compile with all warnings enabled, such +as with clang:

+
cc -Weverything -pedantic -std=c11 -Dtyp=uint64\_t -O3 prog.c -o prog
+

The code compiles without warnings on the systems that we tested!

+

Even more, the code was 100% clean when we ran it against various +static source checkers.

+

This tool references a problem that David I. Bell once +described as having one of the largest “yummo quotients” in number +theory:

+
             complexity of the solution
+yummo quotient = -----------------------------------
+         complexity of the problem statement
+

Erdős +privately told one of the IOCCC judges:

+
+

Solving the Generalized +Riemann hypothesis would be a good warm-up exercise for someone to +get ready to begin to work on the Collatz +conjecture.

+
+

You may explore this famous conjecture using this entry:

+
./prog 2410
+./prog abfff
+./prog 27f8cebf
+./prog 246f8fddf
+./prog 2e95ab51ffea9de
+./prog e6a5c22fd7bde9f
+./prog 1b7dd73a937485bf
+./prog 7d3237680d190a77e53751b
+./prog 302ab3d052fb87c06228d249581be0e4
+

NOTE: try.sh runs these for you, filtered +through less(1).

+

When you first look at the source, the code looks fairly +straightforward. But look again. Like the Collatz conjecture, simplicity +is deceptive! Oh, and the variable names? They are not simple single +letter variables, they are names of various Proteinogenic +amino acid: which is yet another simple building block that can be +used to build some very complex structures. :-)

+

p.s. We appreciated that apart from a few powers of 2, the source +code is magic number free.

+

Author’s remarks:

+

The TL;DR version

+

This is the cleanest program ever submitted. If for some input it +enters a non-terminating loop or runs out of memory you will be +insta-famous. It’s a bit like a lottery without the need to buy a ticket +and you can play as often as you like. One notable historic person has +even offered some prize money.

+

The program illustrates the bloat caused by adherence to too many +rules, each of which may sound sane in isolation, but in their entirety +lead to an obfuscated, hard to read and understand monster.

+

What this program does.

+

The program tests whether a given natural number satisfies the Collatz +Conjecture:

+

Take any natural number n. If n is even, +divide it by 2 to get n/2. If n +is odd, multiply it by 3 and add 1 to obtain +3n + 1. Repeat the process indefinitely.

+

The conjecture is that no matter what number you start with, you +eventually reach 1.

+

Paul Erdős said about the Collatz conjecture:

+
+

“Mathematics may not be ready for such problems.”

+
+

He also offered $500 for its solution.

+

For example, the sequence of numbers for n = 6 is

+
+

6, 3, 10, 5, 16, 8, 4, 2, 1.

+
+

Continuing past one leads to the cycle 1, 4, 2, 1, 4, 2, 1, +… Interesting factoid: if you allow negative start values, +there are a few more cycles, each of different length:

+
−1, −2, −1
+
+−5, −14, −7, −20, −10, −5
+
+−17, −50, −25, −74, −37, −110, −55, −164,
+−82, −41, −122, −61, −182, −91, −272, −136,
+−68, −34, −17
+

The program computes the sequence for a given positive natural number +and stops at 1. The number n is specified in +hexadecimal (without 0x prefix) as the first argument. The +program prints the given number in zero-padded hex and each iteration +along with a line count in decimal. The example above looks like this +(compiled with 64 bit word size):

+
$ ./prog 6
+0000000000000006
+0000000000000003 1
+000000000000000A 2
+0000000000000005 3
+0000000000000010 4
+0000000000000008 5
+0000000000000004 6
+0000000000000002 7
+0000000000000001 8
+

The size of n is only limited by the argument size limit +of your shell/OS (the program implements arbitrary size +bignums). To query this on your POSIX system, run

+
$ getconf ARG_MAX
+262144
+

which reports the limit in bytes, here 256KB. This allows to test +whether a Googol, +which is 10100, satisfies the conjecture. But what is a +googol in hex? Fear not, bc(1) +to the rescue:

+
$ printf 'obase=16;10^100\n' | bc
+1249AD2594C37CEB0B2784C4CE0BF38ACE408E211A7CAAB24308A82E8F1000000000\
+0000000000000000
+$ ./prog 1249AD2594C37CEB0B2784C4CE0BF38ACE408E211A7CAAB24308A82E8F10000000000000000000000000 \
+| less
+[...]
+

Observe how the first 100 iterations melt the zeros to the right. Can +you explain why?

+

For a given n the program behavior is one of the +following 3:

+
    +
  1. The sequence stops at 1. No fame. No money. Thanks for playing. +Computational mathematicians have tested all +n < 4FFDD776055A0000 (~1018) so don’t try +anything less than that.
  2. +
  3. The chosen n leads to a sequence with ever bigger +numbers, so that eventually the bignum cannot be stored in +memory. If this happens, the program outputs laugh (more +likely) or throw up (less likely) and stops. You +might have found a number for which the sequence +diverges. If confirmed, this disproves the conjecture.
  4. +
  5. The chosen n leads to a cycle not including 1 +(i.e. runs forever, repeating the same sequence over and over). You have +disproved the conjecture and should certainly submit a paper to the +nearest mathematical journal.
  6. +
+

Design objectives

+

I gave myself the following objectives. Like in real world +programming, not all of them can be met 100%. Think of them as a +multidimensional continuum, where trade-offs have to be made.

+
    +
  1. No arbitrary limits on the input number. 64 bits might be enough for +everybody, but is not enough for exploring new Collatz-territory. Thus +bignums are required.
  2. +
  3. Ultra-portable. Must run on C89 systems and self-adapt to C99 and +C11 features like exact width types.
  4. +
  5. Super-efficient. Must be able to run with the widest type as the +base of the bignums. Make the user select the widest type +supported by the implementation and then crunch away. If a non-standard +128bit type is available, it should be usable.
  6. +
  7. Pentagon level lint cleanliness and MISRA compliance.
  8. +
  9. Easy to understand, self-documenting clear code. A joy for +maintenance programmers. The epitome of best practice demonstration for +all future textbooks on C.
  10. +
+

Program Obfuscation

+

In the following I address all the tests as specified by +your honors in the guidelines.

+ +

Look at the original source

+

Using one letter identifiers is quite old. I decided to use TLI +(three letter identifiers). Not the random kind, rather with a +connection to the meaning of life, the universe and the rest. Enter +amino acids! Among the myriad of possible amino acids there are 23 from +which proteins are built. In biochemistry, each is assigned a TLI (see +Proteinogenic +amino acid):

+
    ala Alanine
+    cys Cysteine
+    asp Aspartic acid
+    glu Glutamic acid
+    phe Phenylalanine
+    gly Glycine
+    his Histidine
+    ile Isoleucine
+    lys Lysine
+    leu Leucine
+    met Methionine
+    asn Asparagine
+    pyl Pyrrolysine
+    pro Proline
+    gln Glutamine
+    arg Arginine
+    ser Serine
+    thr Threonine
+    sec Selenocysteine
+    val Valine
+    trp Tryptophan
+    tyr Tyrosine
+    asx Asparagine or Aspartic acid
+    glx Glutamic acid or Glutamine
+    xle Leucine or Isoleucine
+    unk Unknown
+

My own research results complete this list (not yet in Wikipedia due +to the rule “No +original research”):

+
and Androgynine
+xor Xenoricine
+not Notanamine
+tla Triletramine
+

Interestingly, the TLI are the perfect mnemonics for C language +source. For example, met is +“main()'s Exit Type” (int), ala +is “A Large Algebraic” (bignum), +ile an “Incremented Local Entity” (index +counter), gly means “Grow Larger memorY”, +gln is “Grown Larger Now” (after +realloc(3)), not is a +“Not Overflowing Type” (recursive!), unk is +the “UNit (Known as 1)”, trp is the +“Tabula Rasa Product” (zero), phe is +“Print HEx” and so on.

+

Convert ANSI trigraphs to +ASCII

+

Huh??!

+

C pre-process +the source ignoring #include lines

+

Wow, an identity operation (except for the +<stdint.h> and EOF + __STDC__ +trivialities). Did you gain any insight through this?

+

C +pre-process the source ignoring ‘#define’ and ‘#include’ lines

+

#define? Which #define directives? How many +4K source files do you see that don’t use a single #define +directive or abuse the build file? Even though the “no +#define” rule I submitted myself to made it hard, I could +use __LINE__ and stdio.h macros +EOF, L_tmpnam, BUFSIZ, +FILENAME_MAX, TMP_MAX to obfuscate at least +something.

+

Run it through a C +beautifier

+

Another identity operation. I’ve done it for you already. Use this +.indent.pro with FreeBSD indent:

+
$ cat .indent.pro
+    -bad   /* blank line after decls */
+    -bap   /* blank line after functions */
+    -br    /* braces on if line */
+    -i8    /* indent */
+    -l999  /* line length */
+    -npcs  /* no space after function call names */
+    -npsl  /* don't break procedure type */
+    -ut    /* use tabs */
+    -ce    /* cuddle else */
+    -nip   /* no parameter indentation */
+    -di1   /* declaration indent */
+    -Tand
+    -Tmet
+    -Tthr
+    -Tpro
+    -Tser
+    -Tala
+

It looks like a perfect program should have:

+ +

The program contains not a single magic number (only 0 and +powers of 2, each power from 1 to 512) which are obvious to competent +software engineers). How many programs have that property? The +check for __STDC_VERSION__ was a bit tough to arrive at, +since 199901L has too many bits set. But I realized that I only needed a +number larger than 199409 and less than 199901. 199680 has only 4 bits +set and writing it as (256 + 128 + 4 + 2) * 512 minimizes +the character count. That’s what judges get when they don’t like +programs that are longer than they need to be.

+

Examine the algorithm

+

Spoilers ahead. Duh!

+

Pseudocode, with comments matching those in the C source:

+
/* run */
+if (non-NULL and nonempty argv[1]) {
+   n = convert(argv[1])
+   print n                       /* 2hx */
+   while (n != 1) {              /* one */
+      if (n is odd) {            /* odd */
+     m = deep copy of n      /* cpy */
+     n <<= 1                 /* shl */
+     n += m                  /* add */
+     increment n             /* inc */
+      } else {                   /* eve */
+     n >>= 1                 /* shr */
+      }
+      print n                    /* 2hx */
+  }
+}
+

Bignums are represented as the two member +structs:

+
typedef struct {
+     size_t places;   /* number of places in base 2 to the power of (8*sizeof(type)) */
+     type  *number;   /* dynamically allocated memory for number */
+} bignum
+

Compile it (with +flags to enable all warnings)

+

Here’s where the program shines brighter than a gamma-ray +burst!

+

I challenge you to throw all kinds of compilers, lints, checkers and +analyzers at my program and make it find the slightest of issues.

+

Is +clang -Wall -Wextra -Weverything -Dtyp=uint32_t prog.c all +you can do? Clang has implemented a new warning? Bring it on!

+

Execute it

+

May you win the jackpot!

+

For least surprising results, the execution character set should be +ASCII. The program computes four bits from every character in +argv[1] and interprets them as a hex digit. In ASCII the +characters a-f, A-F and 0-9 are +converted as expected.

+

This means however, that the program accepts any +string, turns it into a starting number (which is output as the +first line), and starts crunching. Nothing stops you from executing

+
./prog "$(cat prog.c)"            # Kind of quine?
+./prog "$(cat rules guidelines)"  # A jackpot? Maybe next year...
+./prog "$(cat /bin/ls)"           # Number cut short at first NUL byte.
+

In a certain way, the program is character set and encoding +agnostic.

+

Assumptions made

+ +

While the program works best when bytes/characters are octets and the +number of bits in a type is sizeof(typ) << 3, it will +work correctly on 24-bit or 36-bit systems with 9 bits/byte, or systems +where sizeof(typ) is 1 even for int and so on. +On such systems, it will only use 8 * sizeof(typ) bits per +place. It does not work when CHAR_BIT <= 7.

+

Results of various checkers

+

cppcheck

+

The open source static checker cppcheck checks various +problems with respect to style, performance, portability and general +fishiness. To enable all checks, run

+
cppcheck --enable=all --force -I/usr/include -Dtyp=uint32_t prog.c
+

No issues found.

+

flawfinder

+

The open source static checker flawfinder checks various +problems with respect to security like buffer overflows, function +arguments to known troublemaker functions and more. It doesn’t need to +pre-process code, so can be run without the typ macro being +defined:

+
$ flawfinder prog.c
+Flawfinder version 1.31, (C) 2001-2014 David A. Wheeler.
+Number of rules (primarily dangerous function names) in C/C++ ruleset: 169
+Examining prog.c
+FINAL RESULTS:
+ANALYSIS SUMMARY:
+No hits found.
+

valgrind

+

The open source dynamic checker valgrind runs an executable and verifies +all memory accesses and (de)allocations for proper bounds and memory +leaks. Since the program frees all memory in all possible execution +paths, even when it must bail out, valgrind should be happy. An early +version of my program however reported this:

+
valgrind --leak-check=full --show-leak-kinds=all ./prog 6
+[...]
+==14615== HEAP SUMMARY:
+==14615==     in use at exit: 4,096 bytes in 1 blocks
+==14615==   total heap usage: 4 allocs, 3 frees, 4,108 bytes allocated
+==14615==
+==14615== 4,096 bytes in 1 blocks are still reachable in loss record 1 of 1
+==14615==    at 0x4C236C0: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so)
+==14615==    by 0x4F62175: ??? (in /lib/libc.so.7)
+==14615==    by 0x4F62073: ??? (in /lib/libc.so.7)
+==14615==    by 0x4F514EE: ??? (in /lib/libc.so.7)
+==14615==    by 0x4F51265: vfprintf_l (in /lib/libc.so.7)
+==14615==    by 0x4F3E001: printf (in /lib/libc.so.7)
+==14615==    by 0x40101E: phe (in ./prog)
+==14615==    by 0x400A9F: main (in ./prog)
+==14615==
+==14615== LEAK SUMMARY:
+==14615==    definitely lost: 0 bytes in 0 blocks
+==14615==    indirectly lost: 0 bytes in 0 blocks
+==14615==      possibly lost: 0 bytes in 0 blocks
+==14615==    still reachable: 4,096 bytes in 1 blocks
+==14615==         suppressed: 0 bytes in 0 blocks
+==14615==
+==14615== For counts of detected and suppressed errors, rerun with: -v
+==14615== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+

From which I concluded that printf(3) allocated a single +4K block for which no matching free(3) existed. But how to +free memory allocated deep down in the guts of the Standard I/O library? +After some serious head scratching it hit me. The only chance I have is +telling the system I no longer want to do I/O, maybe then it would free +that buffer. A reading of C99 7.19.5.1, “The fclose function”, was +encouraging:

+
+

Whether or not the call succeeds, the stream is disassociated from +the file and any buffer set by the setbuf or +setvbuf function is disassociated from the stream (and +deallocated if it was automatically allocated).

+
+

So I fclose(stdout) before returning and now:

+
valgrind --leak-check=full --show-leak-kinds=all ./prog 6
+==14571== Memcheck, a memory error detector
+==14571== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
+==14571== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
+==14571== Command: ./prog 6
+==14571==
+0000000000000006
+0000000000000003 1
+000000000000000A 2
+0000000000000005 3
+0000000000000010 4
+0000000000000008 5
+0000000000000004 6
+0000000000000002 7
+0000000000000001 8
+==14571==
+==14571== HEAP SUMMARY:
+==14571==     in use at exit: 0 bytes in 0 blocks
+==14571==   total heap usage: 4 allocs, 4 frees, 4,120 bytes allocated
+==14571==
+==14571== All heap blocks were freed -- no leaks are possible
+==14571==
+==14571== For counts of detected and suppressed errors, rerun with: -v
+==14571== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+

A squeaky clean valgrind result!

+

FlexeLint

+

FlexeLint is a commercial lint tool by Gimpel Software. It +supports nearly a thousand checks, broadly categorized into 4 +levels,

+
    +
  1. Syntax errors only (messages 1 to 399)
  2. +
  3. Warnings (messages 400 to 699)
  4. +
  5. Informational messages (700 to 899)
  6. +
  7. Elective notes (900 to 1000 and > 9000)
  8. +
+

There is an on-line +demonstrator you can use for checking your C programs and I highly +recommend trying it. For a start, paste the well know first program in +the form and press “Analyze Code”. Note the FlexeLint configuration +options in comments (no space between /* and +lint).

+
    /*lint -w4            turn on everything */
+    /*lint +esym(534,*)   no demonstrator defaults */
+    /*lint -e966          indirectly included header file not used */
+    /*lint -esym(9058,_*) tag not used outside typedef */
+    /*lint -misra(2)      */
+
+    #include <stdio.h>
+    int main(void)
+    {
+        printf("hello, world\n");
+        return 0;
+    }
+

Possible checks include those for MISRA 2004 compliance verification. +The Motor +Industry Software Reliability Association has produced a list of +121 required and 20 advisory rules for C programming. I am proud to +report that my program fulfills almost all rules. To assess the +few exceptions, one has to understand that MISRA rules are geared +towards embedded systems used in the automotive industry. That’s why +features like malloc(3) and printf(3) are +right out. But that’s too restrictive for an IOCCC hosted application, +so I ignored these:

+ +

I started out with enabling all messages using +FlexeLint’s -w4 option and disabling all noise +from system headers. Then I dealt with the remaining messages by +addressing them or suppressing them in such a way that the set of +suppressions was minimal. At the end of the day, this is what +remained:

+
    //  === Tested with FlexeLint 9.00L on FreeBSD 11 ===
+    //  Compiler:
+    //  "4.2.1 Compatible FreeBSD Clang 3.6.1 (tags/RELEASE_361/final 237755)"
+
+    -w4                          // Enable maximum pickiness
+    -passes(6)                   // Recommended in FlexeLint manual for torture testing
+    +fsc                         // Make string literals have type const char*
+    +fnr                         // ptr-returning functions may return NULL
+    -strong(AJX,and,pro,ser,ala) // strong types
+    -strong(AcJcm,thr)           // thr is strong, but most arithmetic is okay
+    -strong(AarJemorX,met)       // met is strong, but some use is okay
+    +libclass(angle)             // All <headers> are system headers
+    -wlib(1)                     // Only errors for system headers
+    -i/usr/include               // System headers
+    -i/usr/local/lib/supp/ansi   // Comes with FlexeLint
+    -d__GNUC__=4                 // Pretend...
+    -d__GNUC_MINOR__=2           // I'm...
+    -d__GNUC_PATCHLEVEL__=1      // someone else.
+    -d__builtin_va_list=char*    // Fake this compiler extension
+    -d__inline=                  // Delete this compiler extension
+    -d__attribute__(x)=          // Delete this compiler extension
+    +e900                        // Announce number of messages produced
+
+    //                   MISRA 2004 checking
+
+    /usr/local/lib/supp/lnt/au-misra2.lnt    // Enable all MISRA checking
+    -elib(960)       // Don't check FreeBSD system headers for required rules
+    -elib(961)       // Don't check FreeBSD system headers for advisory rules
+    -e829            // stdio.h used
+    -e522            // MISRA 14.2 Highest operation, lacks side-effects
+    -esym(960,17.4)  // pointer arithmetic other than array indexing used
+    -e971            // char without signed/unsigned
+    -e974            // stack usage report
+    // Use verboten functions, Req. Rules 20.4 malloc() et al., 20.11, exit()
+    -esym(586,malloc,realloc,calloc,free,exit)
+
+    -e911            // implicit promotion of smaller than int to int
+    -e921            // cast from integral to integral
+    -e925            // cast from pointer to pointer
+    -e958            // padding required in struct
+
+    +e9???           // Enable all 9xxx informational messages, except:
+    -e9079           // conversion from pointer to void to pointer to other type
+    -e9087           // cast performed between a pointer to object type and a
+                     // pointer to a different object type
+    -e9141           // global declaration of symbol
+
+    //    Messages due to code in FreeBSD headers.
+    //
+    -dlint           // The "lint" macro is tested in x86/_types.h
+    -elib(537)       // Repeated include file
+    -e793            // external identifiers > 6 chars
+    -e935            // (unsigned) int within struct (actually the size_t)
+    -estring(960,_*) // Could be defined at block scope
+    -e964            // Header file not directly used
+    -e966            // Indirectly included header file not used
+    -elib(970)       // int outside typedef
+    -esym(9003,_*)   // could be defined at block scope
+    -elib(9047)      // FILE pointer dereferenced
+    -esym(9058,__*)  // tag not used outside typedef
+    -e9092           // NULL does not expand to a pointer (but plain 0)
+

Compulsory obfuscations

+

Which of the rules cause which obfuscation?

+

MISRA 6.1: “The plain char type shall be used only for +the storage and use of character values.” This forbids using character +constants in expressions other than assignments to char +objects. A consequence is that printing digits with +'0' + digit is not allowed (even though '0' is +technically an int!) so I am forced to output hex digits +with

+
printf("%c", (met)tyr + 32 + 16 + ((8 + EOF) * ((met)tyr / (8 + 2))));
+

because of the “no magic numbers other than powers of two” rule. How +is this an improvement over +printf("%c", '0' + tyr + 7 * (tyr / 10), MISRA?

+

MISRA 6.3: “typedefs that indicate size and signedness +should be used in place of the basic types.” Well, if you can’t infer +the size and signedness from typedef int met, you’re not a +real C programmer.

+

MISRA 10.5: “If the bitwise operators ~ and +<< are applied to an operand of underlying type +unsigned char or unsigned short, the result +shall be immediately cast to the underlying type of the operand.” +Because the program must work for any unsigned type chosen for the +typ macro, including the narrow types enumerated in the +rule, a lot of redundant casting ensues. It gets worse with the next +rule…

+

MISRA 12.1: “Limited dependence should be placed on the C operator +precedence rules in expressions.” This requires parentheses for almost +all expressions involving more than one operator, especially those for +which a cast is required, leading to hard to understand expressions such +as

+
const ser glx = (ser)((asx > (ser)64u) ? (ser)((ser)asx + (ser)8u + (ser)1u) : (ser)asx);
+not.not[leu] = (and)((and)not.not[leu] | (and)(((and)glx % (and)16u) << (and)lys));
+

MISRA 14.7: “A function shall have a single point of exit at the end +of the function.” Sigh. Since I must use eloquent prototypes (8.1, 16.3, +16.4) and static functions (8.10, 8.11), I can only use a few functions. +Everything usually written with an early return now cause +another useless indent level. The first three if +statements in main() cause a silly 24 character indent. The +maximum indent is forced to 8, which is way too high for a sane +function.

+

MISRA 16.10: “If a function returns error information, then that +error information shall be tested.” A cast to void would +draw a lint warning, so I use the printf(3) result in +expressions,

+
lys -= 4 * printf("%c", (met)tyr + 32 + 16 + ((8 + EOF) * ((met)tyr / (8 + 2))));
+val += printf("\n") / ((__LINE__ * L_tmpnam) + TMP_MAX);
+val -= (printf(" %d\n", val) > BUFSIZ) ? FILENAME_MAX : EOF;
+

which are, in the absence of errors, equivalent to

+
lys -= 4;
+/*nop*/
+++val;
+

MISRA 13.1: “Assignment operators shall not be used in expressions +that yield a Boolean value.” Forbids the idiomatic +if ((p = malloc(n)) == NULL) and requires separate +statements, in other words, bloat.

+

MISRA 16.7: “A pointer parameter in a function prototype should be +declared as pointer to const if the pointer is not used to +modify the addressed object.” in conjunction with lint’s “Note 952: +Parameter could be declared const” causes +const-poisoning for all functions,

+
static void phe(const ala not);
+static void gly(ala *const not, const and his);
+met main(met val, const pro *const his[]);
+

and quite a number of automatic variables.

+

Why the “laugh” and “throw +up” messages?

+

The guidelines state “We like programs that: make us laugh and/or +throw up :-) (humor really helps!)”

+

If you have a 128 bit type

+

If your compiler supports a 128 bit wide type (e.g. clang, gcc) then +you can use it via the typ macro:

+
clang -Dtyp=__uint128_t -o prog prog.c
+

Indeed, the program can use (and lints clean for) all of

+
clang -Dtyp=uint8_t  -o prog8  prog.c
+clang -Dtyp=uint16_t -o prog16 prog.c
+clang -Dtyp=uint32_t -o prog32 prog.c
+clang -Dtyp=uint64_t -o prog64 prog.c
+clang -std=c89 -Dtyp="unsigned long" -o prog89 prog.c
+

This works because the program has no need for corresponding +SCN or PRI macros to do the scanning and +printing of variables of these types. With a 128 bit type the program +can represent numbers up to 340282366920938463463374607431768211457 +(3.4 * 1000000000000000000000000000000000000000) as a +single “place”, enough to explore yet untested numbers for the rest of +your life.

+

How big a number +can I test with 4 GB of RAM?

+

The number of hex digits in the start number is limited by +ARG_MAX, probably minus some overhead for the environment +variables (use env(1) +to trim your environment). In bits this leaves you with +2 to the power of (4 * ARG_MAX).

+

The algorithm requires two bignums in memory for +addition. If you hit a divergent number, this will cause out-of-memory +(“laugh”) somewhere near 216,000,000,000 +(4GB/2 * 8bits/byte). Sadly, I don’t have a test case +:-)

+

How long would it take to overflow the Not Overflowing Type? +Lets assume we’re processing 2GB numbers. The program copies, shifts by +one, adds and increments 2GB long bit strings, each time completely +thrashing the data cache – at all levels. We have a fast +machine that can do an iteration in one second, on average. To make +things easy, we round up 3*n* + 1 to 4*n, and +assume we never need to divide by two (which is quite optimistic). Then +each iteration shifts left by 2. This would take 8 billion seconds, or +about 250 years. If you want to get famous, you better remove +some of the RAM, use an ancient box, or reduce available memory +resources with the ulimit(1) built-in of your shell.

+

For all intents and purposes, the Not Overflowing Type keeps +the promise!

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2015/schweikhardt

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2015/yang/index.html b/2015/yang/index.html index 86f6d6444..0f16a390f 100644 --- a/2015/yang/index.html +++ b/2015/yang/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,274 @@ - - + + + + + + - - -2015 yang - - + + + +2015/yang + + + + + -

2015 yang

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2015/yang

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2015/yang/index.html

- +
+ ← schweikhardt + ↑ 2015 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Don Yang
Location: +US

+ + +

To build:

+
make
+

To use:

+
echo Some text | ./prog
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Before analysing the code in detail we were able to guess two out of +four tests this entry uses to tell the 5 languages/flavors apart. Can +you find all four?

+

The way the text is encoded in the output doesn’t cease to amaze. Can +you tell why an array of 512 elements is needed?

+

NOTE: the author calls the program Fuuko and so the +source file referred to in their remarks uses fuuko.c. The +Makefile will compile everything so you need not +worry about this.

+

Author’s remarks:

+

Fuuko is a sea star generator. +Feed her some input through stdin to get lots of sea star +patterns on stdout.

+
cc -O3 -std=c90 fuuko.c -lm -o fuuko_c90
+echo IOCCC | ./fuuko_c90 > output_c90.c
+

If you compile with a C99 compiler instead of C90, the sea stars will +have eyes.

+
cc -O3 -std=c99 fuuko.c -lm -o fuuko_c99
+echo IOCCC | ./fuuko_c99 > output_c99.c
+

Don’t like sea +stars? Use a C++98 compiler to get a dango instead.

+
g++ -O3 -std=c++98 fuuko.c -lm -o fuuko_cpp98
+echo IOCCC | ./fuuko_cpp98 > output_cpp98.c
+

Don’t like dango +either? Use a C++11 compiler to get just circles (or Swiss +cheese, if you prefer that).

+
g++ -O3 -std=c++11 fuuko.c -lm -o fuuko_cpp11
+echo IOCCC | ./fuuko_cpp11 > output_cpp11.c
+

Don’t like any of these patterns? Use a C11 compiler and there will +be no extra pattern.

+
cc -O3 -std=c11 fuuko.c -lm -o fuuko_c11
+echo IOCCC | ./fuuko_c11 > output_c11.c
+

Regardless of which of these C/C++ dialects you choose, the output +will all be valid C90 code that reproduces original input on +stdout, filled with pointer dereferences (C stars).

+

Next time people ask you for a few pointers on C, you can run their +question through Fuuko and give them pointers all day +long.

+

Compatibility

+

Fuuko has been tested under these environments:

+ +

Features

+

The most obscure parts are in detecting the subtle differences in +different dialects. The standard committees put a lot of effort into +avoiding “quiet changes”, but Fuuko is still able to +exploit a few of those. It should be an interesting exercise for the +reader to figure how she did it.

+

Output patterns are usually random (except for C11). The built-in +random number generator is seeded using ASLR. +On systems where ASLR is not so random (such as cygwin), you can +introduce randomness by changing number of command line arguments to +Fuuko.

+

Output is somewhat robust: corruption on most of the lines will +usually result in a compiler warning. This is because the output is +vastly redundant: For ~1K of input, expect output to be on the order of +~1MB, and take ~500MB of RAM to compile.

+

CRC32 +of source code is embedded in the source code itself.

+

The process of writing this program can be seen by opening spoiler.html in a browser that supports +JavaScript.

+

Code layout is inspired by Ibuki Fuuko, for +her love of sea stars.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2015/yang

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2018/algmyr/index.html b/2018/algmyr/index.html index 65026f137..bbc913667 100644 --- a/2018/algmyr/index.html +++ b/2018/algmyr/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,319 @@ - - + + + + + + - - -2018 algmyr - - + + + +2018/algmyr + + + + + -

2018 algmyr

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2018/algmyr

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2018/algmyr/index.html

- +
+ ← anderson + ↑ 2018 ↑ + bellard → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Anton Älgmyr
+Location: SE

+ + +

To build:

+
make
+

To use this entry requires, in some invocations, a sound processing +program. This can be ALSA or SoX but we recommend the latter. See FAQ 3.10 - How do I compile and use an IOCCC +winner that requires sound?.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2018 +algmyr in bugs.md.

+

To use:

+
cat prog.c | ./prog           # Print garbage: might mess up your terminal
+./prog <file1> <file2> > out.raw
+./prog -d 2 0 out.raw         # Decode the first (0th) channel out of two
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Be warned, this is not your garden variety text-to-speech program! +Earplugs are advised, or at least a handy and well-tested volume +knob.

+

Pixels are numbered, amplitudes are weighed, frequencies are divided, +and the message can be displayed in fiery letters, but don’t be +alarmed.

+

How does decoding of the waveform work? Can you encode an arbitrary +text in a sound sample?

+

Author’s remarks:

+

What is this?

+

To put it brief, this entry is akin to a sound based cat. It takes +characters as input and outputs them into frequency space as audio. The +entry also supports decoding the produced waveforms using the +-d flag. Usage instructions is output if run with the +-h flag, albeit not in an immediately legible format.

+

Details

+

In normal operation, the entry reads characters from one or more +sources. If the -h flag is given, usage instructions is +used as a source. Else if file paths are present as arguments those will +be used. Else stdin is used.

+

If a character is part of the supported subset of ASCII +{10, 32-126} then that character is output into frequency +space of an audio signal (44.1 kHz single precision float, endianness +should depend on system endianness) through stdout. Any +other character will be interpreted and outputted as a space.

+

Characters are printed using a (slightly modified) pixel font based +on gohufont. Pixels +are drawn using crosses in frequency space, achieved by simultaneous up +and down chirps.

+

Each input source is designated its own channel in the output (one +float per channel per time step in the output) so if you have a surround +sound system you could listen to a cacophony of chirpy characters.

+

Interestingly, with training you might actually be able to tell +characters just from hearing. But even without training you can easily +read along with the printed characters and have the sound make sense +with the look of the characters.

+

See image spoiler.png for an example +spectrogram.

+

Limitations

+

There is no error checking done when opening files, so expect +segfaults if you provide the wrong path to a file.

+

This program is bound to misbehave if int is less than +32 bits.

+

Flags will only be interpreted correctly if they are the first +argument. Reading a file named -d or -h is +fully possible if it is not the first file provided, even though I am +not sure why you would want to do that.

+

Providing invalid/unexpected arguments to the decode flag will result +in odd behavior. Some erroneous arguments cause segfaults (negative +number of channels, channel id outside valid range). One argument in +particular causes an infinite loop printing whitespace.

+

Obfuscation:

+

A lot of the obfuscations done came naturally from trying to appease +the size tool. To name some:

+ +

On the intersection of size and obfuscation is the data encoding, +which was quite fun to design.

+

Some additional obfuscation was done to mathematical formulas. +Somewhat known expressions were transformed into equivalent but less +recognizable counterparts.

+

I have tried to avoid intentional red herrings in the code, although +fishy statements are plentiful.

+

Data encoding:

+

The large string in the beginning of the source file contains font +data, encoded in base64 using characters in the range ' ' +to '_'. The space was chosen as zero because the data +contains a lot of zeroes, and quite helpfully the size tool ignores +whitespace even in strings. Without this fact the program would have +been too large and the decoding feature would have had to go. +Fortunately this hole in the size spec was readily available. :)

+

Characters in the font (5x8 pixels, 40 bits) are packed into 7 base64 +digits (which was a pain to decode in minimal code).

+

Math:

+

Note that even though floats are used for the waveforms, +the standard math library is not used at all! Most arithmetic is done +purely on integers. The only major exception is generating a table of +sine values which are interpolated to give high resolution waveforms. +Can you see when the generation is triggered, and how it is done?

+

A critical issue encountered was that having abrupt starts and ends +of signals cause a lot of problems with spectral leakage which makes +spectrograms hard to read and audio painful to listen to. To reduce +spectral leakage a windowing function was used. Although the one used is +quite well known, it is not in a form that should be familiar to anyone. +What looks like a polynomial and quacks like a polynomial might not +actually be a polynomial, at least not deep inside.

+

Printing a string:

+

The program was written to deal exclusively with file descriptors, so +how would one go about printing a char array not from a +file descriptor without adding additional logic? Answer: +ungetc(3) into stdin, one char at +a time (to be standards compliant). This is used to print the usage +instructions.

+

Compilation warnings

+

Compiling using

+
gcc -Wall -Wextra -pedantic
+

gives only -Wmisleading-indentation which is sensible +considering the source code. While

+
clang -Wall -Wextra -pedantic
+

is a bit more pessimistic and gives -Wempty-body (I like +loops without bodies), -Wstring-plus-int (since apparently +some people think string+int is a concatenation) and one of +the weirder warnings I have seen from me splitting a negative constant +with whitespace. Compiling using

+
clang -Wall -Wextra -pedantic -Weverything
+

produces a few page faults of warnings and makes me feel generally +bad about myself. :(

+

Misc

+

The reported size of the source code using the size tool is very +intentionally 2018.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2018/algmyr

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2018/anderson/index.html b/2018/anderson/index.html index 3e409587b..514c234d6 100644 --- a/2018/anderson/index.html +++ b/2018/anderson/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,247 @@ - - + + + + + + - - -2018 anderson - - + + + +2018/anderson + + + + + -

2018 anderson

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2018/anderson

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2018/anderson/index.html

- +
+ first entry + ↑ 2018 ↑ + algmyr → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Derek +Anderson
Location: US

+ + +

To build:

+
make
+

There is an alternate version of this entry. See Alternate code below for more details.

+

To use:

+
./prog < textfile
+

Try:

+
./try.sh
+

Alternate code:

+

Compare prog.c and prog.alt.c and find out why we had to modify the +entry, and what confused the author (see the author’s remarks). No, it +was not the shape of the Roman V that we, or the compiler, didn’t +like.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use prog.alt as you would prog above.

+

Judges’ remarks:

+

With this entry, you won’t need to turn your monitor upside +down!

+

Author’s remarks:

+

Compiling the program:

+
cc -Wall -Wextra -Wpedantic -O3 -std=c11 prog.c -o prog
+

Also works with a standard of C99, but C90/C89 will not compile due +to for loop initial declarations, along with additional +warnings about variable length arrays and lack of a return +statement.

+

Additional info:

+

This small program, when given text on stdin, will +produce a pattern of squiggly lines. This pattern is deterministic, and +it shouldn’t be too difficult to determine from whence they come. There +is even a comment that describes the highlighted phenomena in the +source, for those that require a small nudge. With denser text blocks, +such as an essay or similar prose, the output can be rather pretty, in +an chaotic emergence sort of way. Try using this file, or the source +file as inputs.

+

In its current form, this program can handle lines of length 255; to +adjust this limit, change the variable a at the top of the +source. Other adjustments, such as the exact printed characters, are +rather easy, once sufficient reverse engineering has occurred. +Improvements such as proper handling of tabs are left as an exercise to +the reader.

+

In developing this program, the author found a potentially +interesting bug. If the expression (j=k,j) (near the middle +of the source) is changed to (j=k,k), the program produces +different output. The author used gcc 5.4.0, compiled for +x86_64-linux-gnu. Enabling or disabling optimization +produces the same results. The author is not sure who is the culprit, +but instead shrugged and moved on with life. Of course, YMMV with your +own environment.

+

The structure of this program, as you may have deduced, is two +for loops, one nested in the other. There are also a bunch +of direct variable assignments, such as j=k. There is some +filler fluff, such as 0-0+0, but all that sort should be +rather easy to spot. It was mostly added for the purpose of making +certain things line up right, and only secondarily to obfuscate.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2018/anderson

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2018/bellard/index.html b/2018/bellard/index.html index 225310924..3600ecd8b 100644 --- a/2018/bellard/index.html +++ b/2018/bellard/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,268 @@ - - + + + + + + - - -2018 bellard - - + + + +2018/bellard + + + + + -

2018 bellard

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2018/bellard

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2018/bellard/index.html

- +
+ ← algmyr + ↑ 2018 ↑ + burton1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Fabrice +Bellard
Location: FR

+ + +

To build:

+
make
+

There is an alternate version that should work with Windows. See Alternate code below.

+

To use:

+
./prog > lena.ppm
+

Try:

+
eog lena.ppm # On Linux
+open -a Preview lena.ppm # On macOS
+
+pngtopam < Lenna.png | pnmscale 0.25 | cjpeg -arithmetic -dct float -quality 14 > small.jpg
+

NOTE: pngtopam(1) (or pngtopnm(1) for older +versions) and pnmscale come from the netpbm project and +cjpeg(1) comes from libjpeg-turbo. If you +don’t have these tools already see FAQ 3.15 - +How do I compile and install netpbm for entries that require it? and +FAQ 3.16 - How do I compile and install +libjpeg-turbo for entries that require it?.

+

NOTE: Lenna.png is from https://upload.wikimedia.org/wikipedia/en/7/7d/Lenna_%28test_image%29.png.

+

Alternate code:

+

The prog.alt.c is based on the author’s +remarks and it should work for Windows.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use prog.alt as you would prog.

+

Judges’ remarks:

+

The file small.jpg will be approximately of the same +size as the raw image data in the program. Compare the level of the +detail and the artifacts of small.jpg and +lena.ppm.

+

Compressing images is just a matter of simple arithmetic and some +magic, isn’t it?

+

We could understand some of the arithmetic but none of the magic.

+

Deciphering the mechanism used for data encoding to make use of +whitespace, braces and semicolons should be a slightly easier task.

+

Author’s remarks:

+

Warning: the program is not protected against invalid input.

+

This program outputs a 128x128 RGB image file to the standard output +using the portable pixmap file format (PPM). It contains the famous +“Lena” image which is used in many image compression tests.

+

The uncompressed image is 12 times larger than the source code of the +program which includes the image data and the complete decoder. The +actual image data is 1220 byte long, which gives a compression ratio of +40. Using a JPEG-like algorithm would not be enough to reach this level +of compression (the Lena image would be barely recognizable). So the +algorithm is based on the latest advances in image compression. It +includes the following features:

+ +

The image data is encoded to a C string with some tricks to make the +best use of the IOCCC size constraints. The identifiers were shortened +to a single letter to save space. No specific obfuscation was needed as +the algorithms already have a significant complexity.

+

Although the program was optimized to decompress its built-in image, +it accepts to decompress image files from its standard input. +Examples:

+
./prog d < lena512.bin > lena512.ppm
+./prog d < fruits.bin > fruits.ppm
+./prog d < vintage_cars.bin > vintage_cars.ppm
+

The original images for fruits +and vintage +cars come from Wikipedia and were resized to a width of 1024 +pixels.

+

The program should be portable on any Unix system. On Windows the +line _setmode(0, 32768); _setmode(1, 32768); must be added +at the start of the main() function to avoid unwanted carriage return +characters in the output.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2018/bellard

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2018/burton1/README.md b/2018/burton1/README.md index 545d1e5b4..4c086d58d 100644 --- a/2018/burton1/README.md +++ b/2018/burton1/README.md @@ -210,7 +210,7 @@ not yet written for UNIX). [1]: http://minnie.tuhs.org/cgi-bin/utree.pl [2]: http://ioccc.org/all/README -[2]: https://web.archive.org/web/20180521074522/http://www.computerworld.com.au/article/279011/a-z_programming_languages_bourne_shell_sh/?pp=4 +[3]: https://web.archive.org/web/20180521074522/http://www.computerworld.com.au/article/279011/a-z_programming_languages_bourne_shell_sh/?pp=4 More significant is that v7 `printf(3)` does not report the number of characters written, and therefore 111 compiles but does not work correctly; 113 is the diff --git a/2018/burton1/index.html b/2018/burton1/index.html index 51acc178f..4e7f56f3b 100644 --- a/2018/burton1/index.html +++ b/2018/burton1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,406 @@ - - + + + + + + - - -2018 burton1 - - + + + +2018/burton1 + + + + + -

2018 burton1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2018/burton1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2018/burton1/index.html

- +
+ ← bellard + ↑ 2018 ↑ + burton2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Dave Burton
+Location: US

+ + +

To build:

+
make
+

There is an alternate version of this entry. See Alternate code below.

+

To use:

+
./prog < any-file
+

Try:

+
./try.sh
+

Alternate code:

+

An alternate version of this entry, prog.alt.c, is provided This alternate code was +supposed to compile without warnings, however with modern compilers this +is no longer the case so it will only cleanly compile with +-Wno- options.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use prog.alt as you would prog.

+

Judges’ remarks:

+

One line, one array, one loop and one statement but it prints many +bytes. It won.

+

Author’s remarks:

+

Feed this anything on stdin.

+

The included script.sh may be used as a +driver program for this entry. It adds several nice-to-have features, +and allows salt-to-taste customizability.

+

This code has been compiled and tested on:

+ +
+Spoiler below; scroll down. +
+

SPOILER:

+

This started life as a personal challenge: write the shortest hex +dump utility in C.

+

The self-imposed ground rules in the hunt for shortest:

+ +

E.g:

+
main(){system("hd");}   // it's turtles all the way down!
+

is not acceptable.

+

And, “output correctly” is the output format of this entry. QED.

+

Early attempts ended up at a reasonably short 157 characters. This +was too long for a one-liner, so it had to be formatted as something +more interesting. This solution is pleasing, but a true one-liner was +the hoped-for goal. Here is the 157 character version in it’s +entirety:

+
char     O,o[  20];L(O){
+putchar  ( O+  48+39  *(9<
+O));}    I(O)  {L(~     15);
+O|| puts(o);}  main     (l){
+for(;~(l=getchar())     ;I(O
+&=15     ))o[  O++      ]=4<
+(4^l     >>5)  ?l:     46,L
+(l>>     4),L  (l&15);O&&
+I(o[     O]=0  );}//157c
+

While thinking about this in the shower (you are not the only one +that does this!) came the idea which reduced the code to just 119 chars. +This dramatic reduction started to feel close to minimal, and the hunt +resumed. The progression to the present size is interesting, and it is +interesting that the same algorithm can be expressed so differently by +slight rearrangement of its parts.

+
// 119
+char O,o[20];main(l){for(;~(l=getchar());O||puts(o))o[O++]=isprint(l)?l:46,O&=15,printf("%02x ",l);O[o]=0;O&&puts(o);}
+// 116
+char O,o[20];main(l){for(;O++[o]=~(l=getchar())?4<(4^l>>5)?l:46:0;(O&=15)||puts(o))printf("%02x ",l);O>1&&puts(o);}
+// 115
+char O,o[20];main(l){for(;O[o]=~(l=getchar())?4<(4^l>>5)?l:46:0;(O=-~O&15)||puts(o))printf("%02x ",l);O&&puts(o);}
+// 113
+char O,o[20];main(l){for(;~l;(O=~l?printf("%02x ",l),-~O&15:!O)||puts(o))O[o]=~(l=getchar())?4<(4^l>>5)?l:46:0;}
+// 112
+char O,o[20];main(l){for(;~l;(O=~l?-~O&printf("%02x ",l)*5:!O)||puts(o))O[o]=~(l=getchar())?4<(4^l>>5)?l:46:0;}
+// 111
+char O,o[20];main(l){for(;~l;O||puts(o))O=(O[o]=~(l=getchar())?4<(4^l>>5)?l:46:0)?-~O&printf("%02x ",l)*5:!O;}
+// 110
+char O,o[0];main(l){for(;~l;O||puts(o))O=(O[o]=~(l=getchar())?4<(4^l>>5)?l:46:0)?-~O&printf("%02x ",l)*5:!O;}
+// 109
+char O,o[];main(l){for(;~l;O||puts(o))O=(O[o]=~(l=getchar())?4<(4^l>>5)?l:46:0)?-~O&printf("%02x ",l)*5:!O;}
+

There are solutions without the ASCII sidebar that are significantly +shorter. These do not compete in the same category, since their output +is materially different. They are derived from the solutions above, but +are still fascinating as concise utilities, so here is their +progression, for the curious:

+
// 102
+I;O(O){putchar(O+48+39*(9<O));}main(l){for(;~(l=getchar());O(++I&15?~15:~37))O(l>>4),O(l&15);O(-38);}
+// 80
+O;main(l){while(~(l=getchar()))printf("%02x%c",l,++O&15?32:10);O&15&&puts("");}
+// 78
+O;main(l){for(;~l;(O=~(l=getchar())?printf("%02x ",l),-~O&15:!O)||puts(""));}
+// 77
+O;main(l){for(;~l;(O=~(l=getchar())?-~O&printf("%02x ",l)*5:!O)||puts(""));}
+// 76
+O;main(l){for(;~l;O||puts(&O))O=~(l=getchar())?-~O&printf("%02x ",l)*5:!O;}
+

It is possible to reduce the size of each of these by one by eliding +the trailing newline. This was not reported above since the newline kept +getting appended by processing software, and it is more interesting to +remove characters by changing code than by filtering:

+
$ tr -d '\012' < 109.c | wc -c
+108
+$ tr -d '\012' < 76.c | wc -c
+75
+$ tr -d '\012' < 109.c | cc -o 108 -xc -
+$ verify 108
+$
+

An obfuscated hex dump has been done before: 1986/bright is similar in function, +but it uses more characters in just setting up its obfuscation than this +entire solution!

+

BIGGER SPOILER:

+

If you are unhappy with the way DEL (character 127) is handled, +replace the cryptic expression 4<(4^l>>5)?l:46 +with 32>l|l>126?46:l. Both take the same number of +characters, but the former is a bit more interesting. Bonus question: +how does the first expression work?

+

BIGGEST SPOILER (and some +history):

+

Technically, char o[0]; is illegal (SS 6.7.6.2) +according to ISO (N1570). And char o[]; is a conditionally +supported feature (SS 6.7.6.2, 6.10.8.3). However, it works in modern C +implementations as an extension, including GCC, Clang and TCC, for X86 +and ARM, on multiple operating systems (Linux, OSX/macOS, FreeBSD), so +it is functionally correct. MicroSoft Visual C++ does not allow +char o[] or char o[0], and implements its +close relative char o[1] such that writing more than a +single char will cause a fault, which is technically +correct.

+

But how does this work at all, even as an extension? o[] +allocates one(!) byte in a zero-filled data area (formerly BSS). The UNIX-derived +systems this code was run upon all place the storage of O +and o into a zero-filled VM page with nothing following: +thus, there are plenty of available and unused zero bytes following +O, addressed via o, and this code only needs +17. This is undefined behavior, but as shown, it is widely +available.

+

The 1979 Seventh +Edition UNIX (v7) system pre-dates the IOCCC by several years, and +the source code to sh(1) was a significant inspiration for this contest. +There are two C compilers present: cc written by Dennis +Ritchie, and pcc written by Steven Johnson. The nested +conditional expressions in 116 and smaller are too complex for +cc (“Illegal conditional”) but pcc handles +them correctly, and neither compiler accepts char o[] or +char o[0] and neither put the bytes in a zero-filled page +(as a paged VM was not yet written for UNIX).

+

More significant is that v7 printf(3) does not report +the number of characters written, and therefore 111 compiles but does +not work correctly; 113 is the shortest code that compiles and runs +correctly in Ancient UNIX.

+

Interesting digression: v7 printf (_doprnt) +was written in PDP-11 assembly. It pre-dates varargs.h, and +assembly was the only way to gain access to the variable argument types. +The first edition The C Programming Language, 1978, page 71, +remarks:

+
+

By the way, there is no entirely satisfactory way to write a portable +function that accepts a variable number of arguments, because there is +no portable way for the called function to determine how many arguments +where actually passed to it in a given call. …
+printf, the most common C function with a variable number +of arguments, … is also non-portable and must be modified for different +environments.

+
+

It is fascinating to explore the roots of C through the history of +the operating system it was birthed within. C is often criticized as a +difficult, inscrutable language, but as this contest demonstrates, this +is in parody. Shell-gol is one of those instances where someone +preferred a different +language, and (ab)used the preprocessor to re-mold C into something +they found comfortable. Most of the rest of the system, especially in +the kernel, are models of clarity and efficient expression.

+

TL;DR:

+

So which version is the shortest, portable hex dump?

+ +

Coda:

+

Clearly, the smallest possible program violates modern best practice. +It is not even possible to compile cleanly, but it will compile +correctly.

+

Included is prog.alt.c, a modern C +implementation that is – perhaps – the smallest, clean-compiling version +using clang or gcc with +-Wall -pedantic. Note that while this is larger than all +but the original attempt, it will not work with the original +Ritchie PDP-11 C compiler, since the expression within the ternary +remains too complex.

+

Try:

+
cat prog.c prog.alt.c
+

or

+
cmp -b prog.c prog.alt.c
+

to compare the differences (diff is not helpful on a +one-liner).

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2018/burton1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2018/burton2/index.html b/2018/burton2/index.html index eb8de3888..274c1836a 100644 --- a/2018/burton2/index.html +++ b/2018/burton2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,725 @@ - - + + + + + + - - -2018 burton2 - - + + + +2018/burton2 + + + + + -

2018 burton2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2018/burton2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2018/burton2/index.html

- +
+ ← burton1 + ↑ 2018 ↑ + ciura → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Dave Burton
+Location: US

+ + +

To build:

+
make
+

To use:

+
./prog [-tcksri] < file.c
+

Try:

+
./try.sh
+

If you get really stuck, try:

+
man ./tac.1
+

Judges’ remarks:

+

They say size isn’t everything, and in the case of IOCCC iocccsize.c that is +saying something! What is this program weighing and how much does it +weigh?

+

Author’s remarks:

+

tac - +tokenize and count C and derivative languages:

+

tac computes C program size
+(obfuscated / otherwise)
+by splitting code as tokens small,
+ignoring space, then counting all.
+

+

It tries quite hard to act the same
+as counting tool of I-OCCC fame.
+Some bugs were fixed, it’s faster too,
+and does more things, just add some glue!
+

+

It does far more than print the size:
+the token part’s a better prize!
+With each upon on a single line,
+how many things can you design?
+

+

Included is a keyword sorter,
+de-obfuscator, freq reporter.
+With code produced as little parts,
+just add your own creative arts.
+

+

But first you have to figure out
+the braces part, without a doubt!
+And then the code - it isn’t easy:
+for as else? That’s rather cheesy!
+

+

The rest of it is standard fare:
+expressions strange, the globals bare,
+confusing symbols one and oh,
+and precedence you have to know.
+

+

The keyword list was made external,
+because of standards change eternal.
+Thus other languages can now,
+be counted just like C, somehow!
+

+

I hope you find this code obscure
+enough to win, and thus procure
+a public place for all to see
+how badly I can butcher C!
+

+

Said another way….

+

tac is the inverse of cat(1): it +un-concatenates its input into C tokens, writing the token stream to +stdout. There are options to suppress the token ids, +summarize the token counts, and several options to allow it to be +compatible with iocccsize.

+

The token-based output is quite useful in analyzing source code (see +below), and the counter is more accurate than iocccsize +(see below); but this can be fixed by using the -c +compatibility flag, restoring the following problems as in the official +tool:

+ +

The following bugs are always corrected:

+ +

There is one (known) remaining problem with detection:

+ +
#/*this will not be counted*/include/*correctly*/<stdio.h>
+

Fixing this properly hampers backwards compatibility in counting. +This requires eliding comments during the translation phases (ISO +5.1.1.2, phase 3), and yet still counting words correctly absent +-k.

+

Backwards Compatibility:

+

tac was run over all 366 previous IOCCC winning +entries:

+
find ~/src/obc -type f -name \*.c | wc
+

The discrepancies found are documented and explained in the file discrepancies.md.

+
find ~/src/obc -type f -a -name "*.c" | xargs ./spotcheck.sh ./prog | ./spotdiff.sh |
+    grep -v keep | diff -bw - discrep* | grep "[<>] cl "
+

In summary, there are only 6 unique entries out of 366 that have any +variation in Rule 2 counts; in all cases, the differences are due to +bugs within iocccsize, described in detail in the file discrepancies.md. There are only 40 files +(40/366, ~11%, including originals and variations) that differ at all, +31 only in word count; most word count differences appear related to +comment block detection, weighted more towards recent entries (2011 and +onward = 20/40 ~50%).

+

This (minor) variation in word count values has not been addressed +since it is not a qualifying metric, nor is it very useful in a +programming context: whitespace surrounds English words, not necessarily +C tokens, as in a+=1;.

+

Accuracy (versus compatibility) is demonstrated through a series of +small test cases designed to allow exhaustive, hand-counted values for +comparison with the tool values. These test cases were vital in +debugging and regression testing, and provided a way to determine which +tool was correct when there were differences.

+
+

A version of this tool in more clearly written C (tac.c) is presented for the Judge’s consideration as a +more accurate replacement for iocccsize. This obfuscated +entry is derived from (and compatible with) that code, but due to +obfuscation, has had some significant, deep changes for the contest. +Nevertheless, the more clearly written code remains a spoiler for this +entry.

+
+

NB: iocccsize gets a different answer from +tac on its own (iocccsize.c) source code; tac +gets the correct answer. This is due to the aforementioned bugs within +iocccsize, proved by fixing iocccsize.c with the included patch, so +iocccsize reports the correct answer for itself.

+

But wait… There’s More!

+

There is no limit on line length, file length, comment length, or +identifier length.

+

tac features an accurate tokenizer; which presents each +C token on a line by itself. This feature enables interesting analyses +of C (and C++) code that’s hard to get any other way.

+

For instance, here is a simple token counter, useful in finding +repeated long tokens, or operator frequency, or counting the references +to identifiers, constants, or breadth of use of the language:

+
#!/usr/bin/env bash
+cat $* | ./prog -t | sort | uniq -c | sort -k1nr
+

And here is a C keyword frequency counter:

+
#!/usr/bin/env bash
+function iskeyword {
+   awk 'BEGIN{f="c11";while(getline<f)k[$1]=0} {if($1 in k)k[$1]++}END{for(i in k)print k[i],i}'
+}
+cat $* | ./prog -t | iskeyword | sort -k1nr
+

This script was used to “optimize” the reserved word order so the +most frequent IOCCC winning entry keywords are checked first.

+

An interesting aside: as might be expected, obfuscation has changed +the frequency of keyword distribution over time. The top five for the +decades:

+
1980s       1990s       2000s       2010s
+-----       -----       -----       -----
+94 if       532 char    375 if      254 int
+69 for      524 if      372 char    217 for
+59 while    417 int     332 int     198 if
+48 char     223 for     184 for     121 return
+43 int      223 void    165 return  104 char
+

The keyword list is external to the program, and is easily changed, +sorted, checked, verified. This allows such additional programs in +concert with the tool’s primary operation.

+

A poor-man’s de-obfuscator can be based upon the output of +tac -t and a handful of simple rules (and another use of +the external keyword file). A more refined version of this is included +in the file unob.sh, but the simple code below is +a serviceable obfuscated C de-obfuscator in a scripting +language. It really is this easy with tac:

+
#!/usr/bin/env bash
+script='
+BEGIN {
+    last=nl="\n";
+    f="c11"; while(getline <f > 0) kw[$0]++; close(f);
+}
+
+function iskw(a)   { return a in kw }
+function indent(a) { return sprintf("%*s", n*3, " ") }
+function newline() { if (!infor && last != nl) printf last=nl; }
+function show(a) {
+    if (last==nl) printf "%s", indent()
+    printf "%s%s", space(), a
+    last=a
+}
+function space() {
+    return iskw(last) ||
+      (last ~ /[A-Za-z0-9_+-\/%^[&\]\)=:<>;]$/ && $0 !~ /[:;()\[\],]/) ? " " : ""
+}
+
+/^\(/   { ++paren }
+/^\)/   { --paren }
+
+/^for/          { newline(); infor=1 }
+infor && /^;/       { ++infor; show($0 " "); next }
+infor==1 && /^:/    { ++infor }
+infor>1 && paren==0 { infor=0 }
+
+/^\?/       { tern++; n++; newline(); show($0 " "); next }
+tern && /^:/    { newline(); show($0); --tern; --n; next }
+
+/^#/    { newline(); show($0); newline(); next }
+/^;/    { show($0); newline(); next }
+/^{/    { show($0); ++n; newline(); next }
+/^}/    { n--; newline(); show($0); newline(); next }
+
+{ show($0) }
+'
+cat $* | sed 's/#include/##include/' | cpp -E -trigraphs |
+sed 's/^# .*$//' | sed 's/^#//' |
+./prog -t | awk "$script"
+

On the question of +obfuscation:

+ +

Rule 2:

+

The keyword list is externalized as an include file. This presents a +useful feature for the source code: not only can the reserved word +script above be produced, but the tool can be rebuilt with any set of +reserved words, just by using a different list. For instance: removing +all the secondary keywords; removing all the C11 keywords; trying just +K&R C. Since C++ and Java share the same operators as C, just change +the keyword list and tac will correctly tokenize both of +these; the tokens >>> and :: can be +handled with a short post-filter (tokenfix.sh, +included).

+

I believe this entry may also satisfy the request for gratuitous use +of all the C11 keywords? Whether this context satisfies “intended C +language context” is a matter of interpretation. ;-) And +tac is ready for the IOCCC++ contest. And the IOJCC trash +can.

+

The following reserved word files are included:

+ +

NB: The keyword file used in this code is derived from the list in iocccsize.c, which is +neither complete (#define, #ifndef, +#undef are missing – yes, Virginia knows about +#define omitted on purpose), nor correct (many more are +added: I, true, bool, +compl, …):

+
(sed -n '1p' c11; sed -n '2,$p' ioccc.kw.freq | sort) | comm -3 - c11
+

That is an obfuscated way to say “diff”. But it also more clearly +shows the, um, diffs.

+

The usage string is similarly externalized, providing a better +usability string than the limits would otherwise allow. If this is +considered bending the rules too far, just -DU=O to get a +passible, if cryptic, usage message using no additional octets than +without the define. This also allows the builder to configure the amount +of help a utility should provide (you want +a manpage? Because that’s how you get a manpage.) – a rather +significant point of contention made moot.

+

There is definitely abuse of the Rule2 counter, exploiting a +“feature” of iocccsize: iocccsize does not +Rule2 count {, } and ; when +followed by whitespace – even within a string! Thus: Freecode, a simple, +uncounted, highly obfuscated encoding of a central part of this program. +(The reserved word list is not Freecoded, both because it is useful +apart from the program, and because Freecode is not entirely free.)

+ +

Compilation:

+

The code is ANSI compliant, but it does have a string longer than 509 +characters. It has been tested on OSX and Linux, Clang and GCC.

+

The code uses trigraphs, ironically: it parses trigraphs with +trigraph code. Because that’s funny. And it remains obscure after, so +trigraphs are not used for obfuscation. Thus +-trigraphs -Wno-trigraphs (which is also humorous).

+

It’s obfuscated C. Thus +-Wno-parentheses -Wno-empty-body -Wno-char-subscripts.

+

The code uses unsigned chars, but C strings are +signed. Thus -Wno-pointer-sign. NB: This is +not a portability concern, the one string holds only printable +ASCII characters.

+

Thus:

+
cc -ansi -Wall -trigraphs -Wno-trigraphs -Wno-parentheses -Wno-empty-body -Wno-char-subscripts -Wno-pointer-sign -DU=O -DW=\"keywords\" -o prog prog.c
+

Coda:

+

Cody Boone Ferguson +was relentless in his pursuit of bugs. Thanks to his reports, the +version of unob.sh is stronger, tac +groks digraphs, tokenfix.sh corrects for +missing digraphs in prog.c, and the program manpage.sh was added to the corpus.

+

manpage.sh is a useful program that turns +ASCII versions of man pages (e.g. tac.man) into +real man pages. It works for C and C-like languages, command lines, and +was designed to handle man page sections 1-8. It works well on most +inputs, but tends to need some raw nroff for more fancy constructions, +such as combined arguments (e.g. the -r and -s +arguments to tac are not recognised when written as -rs in +prose).

+

Try:

+
./manpage.sh tac
+
+./manpage.sh -h
+./manpage.sh -h | ./manpage.sh
+./manpage.sh -h | ./manpage.sh -R | less
+./manpage.sh -h | ./manpage.sh -P | lpr
+

NOTE: in 2023 the tac.man was updated to proper man +format and renamed tac.1.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2018/burton2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2018/ciura/index.html b/2018/ciura/index.html index 335e062f3..ac6cba9d6 100644 --- a/2018/ciura/index.html +++ b/2018/ciura/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,442 @@ - - + + + + + + - - -2018 ciura - - + + + +2018/ciura + + + + + -

2018 ciura

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2018/ciura

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2018/ciura/index.html

- +
+ ← burton2 + ↑ 2018 ↑ + endoh1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Marcin Ciura
+Location: PL

+ + +

To build:

+
make
+

There is an alternate version that lacks a useful bug fix. See Alternate code and the author’s remarks (remarks section) below for more details.

+

To use:

+
./prog < text
+

Try:

+
./prog < Makefile
+./prog < README.md
+

Alternate code:

+

An alternate version of this entry, prog.alt.c, is provided. As mentioned in the +author’s remarks, the alternate version lacks a +useful bug fix.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use prog.alt as you would prog above.

+

Judges’ remarks:

+

This text was processed by prog. You may get confused. +We’re not really sure: prog.c wasn’t commented. Who +has been thoroughly puzzled by prog? Also how obfuscated is +prog? Having been written in C, how large of a vocabulary +has it?

+

Author’s remarks:

+

The Program:

+

“The Elements of Style” by Prof. William Strunk, Jr. and E. B. White +is well known for its dislike of the passive voice. Direct, vigorous, +active constructions were instead recommended by the authors. The +development of this program has been driven by this tenet.

+

Only passive sentences from the standard input are output. The +offending part(s) of each sentence will be highlighted. Several kinds of +passive constructions are recognized:

+ +

Sentences are never broken by periods that follow abbreviations and +initials. Both regular and irregular past participles are properly dealt +with. Note that some words are red herrings: even though their ending is +-ed, they are not past participles.

+

The Big String:

+

Here is the purpose of every byte inside the c[] +string:

+ +

The State Machines:

+

I heard you don’t like state machines so I put a state machine in +your state machine so you can reject this entry while you reject this +entry.

+

Both types of state machines in the program are Mealy machines: we +can think of their transitions as triples +(transition_label, next_state, +output).

+

Type A:

+

A state of type A state machine consists of eight transitions whose +representations occupy consecutive bytes. The byte +c[3 + 8*state + transition_label] contains +(unsigned char)(30 + 5*next_state + output).

+

The transition_label is either one of character +classes:

+ +

or one of word classes:

+ +

The output is either one of:

+ +

or one of

+ +

Type A state machines run continuously. Their state is kept in +k[2] and k[3].

+

Below are sample steps of scanning a sequence of characters with +classes uppercase, lowercase, +period, space, and uppercase.

+ +

And here are sample steps of scanning tokens with classes +to_be, adverb, +past_participle.

+ +

Type B:

+

Type B state machines are built by a variant of the algorithm +described in the paper How to squeeze a lexicon +(PDF). Their states are represented as interlaced sparse arrays of +transitions.

+

The transition_label is one of:

+ +

The output is either one of word classes:

+ +

or

+ +

The byte c[186 + (state + transition_label)] = +(unsigned char)(2 + transition_label + 28 * output).

+

The byte c[836 + 2*(state + transition_label)] =

+ +

The byte c[837 + 2*(state + transition_label)] =

+ +

The byte c[2136 + (state + transition_label)] = +(unsigned char)(32 + next_state % 94).

+

A type B state machine starts in a given state with +output set to ignore. It scans a word +backwards, converting character by character to +transition_label. When it meets word_start, it +returns, leaving the most recently stored output in +v.

+

It also returns when +c[186 + (state + transition_label)] != (unsigned char)(2 + transition_label + 28 * output), +i.e. when the transition_label in the byte mismatches the +transition_label used to compute the index. Otherwise, if +the output in this byte differs from ignore, +the state machine stores it in v. Regardless of the value +of the output, it also assigns next_state to +state and proceeds to scan the previous character. The +state machine that determines the word class is set up so that it never +returns ignore.

+

Below are sample steps of scanning the word “chiefly”.

+ +

And here are sample steps of scanning the string “i.e.”:

+ +

Remarks:

+

The judges found a bug in the handling of contractions: prog.alt.c outputs “foo wasn’[t +bazzed]”. I fixed the bug in prog.c, +making it output “foo [wasn’t bazzed]” instead, and +took the liberty to merge one statement into a for loop +inside its main() function.

+

The program uses a 9,437,187-byte buffer so it probably will not run +on 16-bit and smaller machines without changing the size of array +C[] and the expression 9<<20 inside the +call to read(2).

+

I have tested it on:

+ +

For a clean compile under C89 and C90, add +-Woverlength-strings to CSILENCE.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2018/ciura

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2018/endoh1/index.html b/2018/endoh1/index.html index dce2b285d..1b47472ca 100644 --- a/2018/endoh1/index.html +++ b/2018/endoh1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,225 @@ - - + + + + + + - - -2018 endoh1 - - + + + +2018/endoh1 + + + + + -

2018 endoh1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2018/endoh1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2018/endoh1/index.html

- +
+ ← ciura + ↑ 2018 ↑ + endoh2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yusuke Endoh
+Location: JP

+ + +

To build:

+
make
+

To use:

+
./prog < textfile > output.gif
+

Try:

+

To see the input files and feed them to the program, redirecting to +GIF files:

+
./try.sh
+

Judges’ remarks:

+

To get the best experience, use a GIF viewer that can handle animated +GIFs. With macOS you can use Safari using +open -a Safari smily.gif.

+

Some things to consider are that this 2.5KiB gem encodes a 96 +character 8x8 font (naively this could already take 6144 bytes) and a +GIF encoder. But how does it know which characters are closed?

+

You should only give this program printable ASCII characters.

+

Unfortunately this won’t run on your PDP8, if you had one, as it +needs at least 2MiB of memory to run in.

+

Author’s remarks:

+

This program generates an animated GIF from a plain text. Run:

+
cc -o prog prog.c
+./prog < invisible.txt > invisible.gif
+

Open invisible.gif with a GIF viewer that can show +animated GIFs and then wait a minute. You will see a hidden message. Can +you tell the difference between letters that leave the mark and ones +that do not?

+

Other examples:

+
./prog < golem.txt > golem.gif
+./prog < smily.txt > smily.gif
+

The program itself has a hidden message.

+
./prog < prog.c > prog.gif
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2018/endoh1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2018/endoh2/index.html b/2018/endoh2/index.html index a1c5c9255..682ded9b4 100644 --- a/2018/endoh2/index.html +++ b/2018/endoh2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,256 @@ - - + + + + + + - - -2018 endoh2 - - + + + +2018/endoh2 + + + + + -

2018 endoh2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2018/endoh2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2018/endoh2/index.html

- +
+ ← endoh1 + ↑ 2018 ↑ + ferguson → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yusuke Endoh
+Location: JP

+ + +

To build:

+
make
+

To use:

+
./prog
+

Try:

+
./try.sh
+

NOTE: to interrupt the loops send intr (typically ctrl-C).

+

Judges’ remarks:

+

And now for something completely different: A program whose metabolic +processes are a matter of interest only to historians. It has kicked the +bucket and departed to that mysterious country from whose bourne no +traveller returns! This is an EX-tremely obfuscated program!

+

Author’s remarks:

+

A high-context work that combines parrots that new hackers like and +parrots that old hackers like. One is an internet meme called Party Parrot (WARNING: has +flashing lights). The other is a sketch comté called “Dead +Parrot” from the British sitcom “Monty +Python’s Flying Circus” The “Python” in the award name +refers to Monty Python, not the [programming language +Python](https://en.wikipedia.org/wiki/Python_(programming_language) (the +name of the programming language Python is derived from Monty +Python).

+

The shape of prog.c is “Undead Parrot” based on +“dead parrot”. The message that appears in the bottom line of the output +source code is the subject of the dialogue that appears in “Dead Parrot” +and explains in various expressions that the parrot died. Also, the +second **__<-_Source_of_Parrots__** line from the bottom of http://cultofthepartyparrot.com/ (WARNING: has flashing +lights) has a hidden URL (hidden by the parrot’s body).

+

Although it is a boring Quine story, it is quite difficult to have 10 +parrot pictures and 10 lines of data. Only the outline data of the +parrot picture is saved, and the body is filled in at runtime. These +data are probably compressed with byte pair +encoding.

+

The parrot ASCII art below is the opening line of the Monty Python +show. The judge’s comment “And +now for something completely different” is also used in the +opening.

+
                             ___-----__
+                          _--          --__
+                        _-        _--_     \
+                      _-    /\  +-.:.:-+ /\ \
+                     /      \/  |.:.:.:| \/  |
+                    /           |:.:.:.|     |
+                   /            |.:.:.:|      |       ___-----___
+                  |              |.:.:|       |      /           \
+                  |              |:.:.|       |     <   It's ...  |
+                  \               |:.|       |       \           /
+                   \               ||        |        ---_____---
+                 _--\                       |
+               _-    -__                    |
+            __-         --___               |
+          _-                                |
+         /                                   |
+        |                                     |
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2018/endoh2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2018/ferguson/index.html b/2018/ferguson/index.html index 26faedcc4..89c9c2be6 100644 --- a/2018/ferguson/index.html +++ b/2018/ferguson/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,1297 @@ - - + + + + + + - - -2018 ferguson - - + + + +2018/ferguson + + + + + -

2018 ferguson

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2018/ferguson

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2018/ferguson/index.html

- +
+ ← endoh2 + ↑ 2018 ↑ + giles → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Cody Boone +Ferguson
Location: US

+ + +

To build:

+
make
+

The author provided an alternate version which has a simpler keyboard +for the monkey Eric. See Alternate code +below.

+

To use:

+
./weasel
+

Try:

+
./try.sh
+

Alternate code:

+

This version has a simpler keyboard (fewer characters). The author +wrote more about this under the keyboards +section, briefly referred to in the what it is +section.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use weasel.alt as you would weasel +above.

+

Alternate try:

+
./try.alt.sh
+

Judges’ remarks:

+

Looking back over the strata of past IOCCC entries, this program +marks a new mutation on our understanding of sequencing of code. In +adaptation of the modern scientific that the C language has evolved, +this mutant of a program may stress your understanding of taxonomy of +the C syntax tree.

+

The phenotype of the source suggests a veritable sea of primordial +ASCII soup. The encoded logic of the watchmaker suggests a variation of +thought experiment formulated by Richard Dawkins: but without the need +for feeding too many evolutionary relatives of the primate order in +which us Homo sapiens hang from the phylogenetic tree of life.

+

If you wish your computer to maintain one branch in the Cretaceous C +code era, while using more Cenozoic minded code migration, read +rpm.md.

+

If you find yourself in an evolutionary dead end, try:

+
man ./weasel.1
+

Author’s remarks:

+
    +
  1. Preface
  2. +
  3. What it is
  4. +
  5. How it works
  6. +
  7. Hints (Keyboards, Options, Spoilers, Example Invocations)
  8. +
  9. Obfuscation (Techniques, Beauty)
  10. +
  11. How to build (S and N Constants, Compilation, Portability, +Installing)
  12. +
  13. Final thoughts
  14. +
  15. Winning comments, thanks, dedications, links, etc.
  16. +
+

0. Preface

+

SPOILER WARNING: A great deal of this document and the man +page is full of spoilers of different types; as such I would recommend +that you try running the judges suggested invocations as well as running +make test before you get into the document or the man page, +unless you don’t mind any spoilers. I don’t reveal much in the way of +obfuscation however so if you just want documentation on the program, +how to compile, etc. then there isn’t need to heed this +note.

+

I was at a loss on how to present my remarks; on the one hand I +wanted to give everything to the judges so they didn’t miss anything. +But on the other hand I didn’t want to reveal as much publicly and many +people don’t like to read long texts. To resolve this I think the best +way is referencing the judges’ remarks: if you want a quick rundown of +the entry try what they suggest and view the man page (it explains all +the options and describes the program briefly):

+
man ./weasel.man
+

If that isn’t sufficient I would recommend reading this +section (and possibly the next) where I attempt to +give a brief explanation of the sections to make reading it easier and +faster. In addition I want to point out a few things. If you want +more details read this document more thoroughly (or just the sections +that seem relevant to what you’re after). The FILES file is a quick list of files and respective +summaries in this entry. Because several sections are quite long I have +added a skip to link to skip to the next subsection or section at the +beginning of each section (and subsection).

+

What it is: This is a brief +summary of the program; the man page is more thorough than this.

+

How it works: Explain some of the +basic concepts and terms of the program; if you’re familiar with genetic +algorithms there won’t be any problem following this section but it +might be of some value to read anyway. There is a randomised mode that +doesn’t use a genetic algorithm; it can be triggered a number of ways +but the -m option enables it specially (I discuss this +thoroughly in Hints).

+

Hints: Perhaps the longest part +of this document because in it I document the keyboards, options, +subtleties (including features that might appear to be bugs but aren’t - +including an input error), an Easter egg spoiler and quite a few example invocations. If you’ve read the man page +you probably don’t need this unless there is something specific you’re +after.

+

Obfuscation: Some of the +techniques that might not be used.

+

How to build: Here I describe +briefly the constants that can be redefined +S and N: the maximum size of the chromosome +(target string; the maximum length is S - 1 but it must be +>= the default 38) and the number of offspring, respectively. I also +give example compiler invocations, portability notes, an more +portability notes and a note on rpm.md.

+

On the subject of S and N: As the judges’ +suggested runs imply you can change the target string at runtime; +make test runs a script test.sh which reads +from the file test-strings.txt, running the program for +each string in the file, waiting approximately two seconds before +continuing. I explain how to pass options to the script in part of +Hints.

+

Final thoughts: You might +enjoy what I included; they’re humorous pieces by Dennis +Ritchie and Ken Thompson themselves from the +infamous UNIX-HATERS Handbook.

+

Winning thoughts: What it +means to me to win as well as some dedications and thanks. Here too I +include a link to a website which will be dedicated to this entry beyond +what will be published on the IOCCC website.

+

1. What it +is

+

Skip to How it works.

+

It is an implementation of Richard Dawkins’ Weasel program +(Wikipedia). According to Wikipedia in chapter three of his book The Blind +Watchmaker Dawkins wrote:

+
+

I don’t know who it was first pointed out that, given enough time, a +monkey bashing away at random on a typewriter could produce all the +works of Shakespeare. The operative phrase is, of course, given +enough time. Let us limit the task facing our monkey somewhat. +Suppose that he has to produce, not the complete works of Shakespeare +but just the short sentence ‘Methinks it is like a weasel’, and we shall +make it relatively easy by giving him a typewriter with a restricted +keyboard, one with just the 26 (capital) letters, and a space bar. How +long will he take to write this one little sentence?

+
+

He refers to the Infinite +Monkey Theorem (Wikipedia). As he points out the operative phrase is +given enough time; but even if it’s extremely unlikely +technically the probability is greater than 0. He simplified it +for the monkey; I thought the monkey had it too easy: unlike his limited +keyboard I have (besides space) every character in the ASCII range +0<=126 that isprint() returns non-zero +except that only capital letters are included; the file prog.alt.c has a slightly smaller keyboard. There +are some additional features I have added (including two Easter eggs); +amongst others: ability to change the target string and maximum length. +See
+How it works, Hints and How to +build for more details.

+

In its simplest invocation this program will work its way (using a +genetic algorithm) towards the solution of the string +METHINKS IT IS LIKE A WEASEL (note that I use +toupper() so it doesn’t matter what case the input is the +comparison and output will always be capitalised).

+

2. How it +works

+

Skip to Hints.

+

Here you can find a general explanation of a genetic +algorithm as well as a brief history. Although the link +provides more information (including images to try and show the way they +work) for those interested I will cite the summary:

+
+

Genetic Algorithms (GAs) are adaptive heuristic search algorithm +based on the evolutionary ideas of natural selection and genetics. As +such they represent an intelligent exploitation of a random search used +to solve optimization problems. Although randomised, GAs are by no means +random, instead they exploit historical information to direct the search +into the region of better performance within the search space. The basic +techniques of the GAs are designed to simulate processes in natural +systems necessary for evolution, specially those follow the principles +first laid down by Charles Darwin of “survival of the fittest.”. Since +in nature, competition among individuals for scanty resources results in +the fittest individuals dominating over the weaker ones.

+
+

SPOILER WARNING: Some of the below might help you follow the +code more easily.

+

For each generation there is a total of N +offspring; generation 0 is the pseudo-randomly initialised +array without parents. Each offspring has its own +chromosome to be compared to the target string and a +fitness score; the higher the fitness score the more likely it +will be a parent of the next generation (randomised mode +notwithstanding) as part of the selection process (As the +generations go by the fitness of the offspring should be higher; when +the fitness matches that of the target it will be printed and the loop +will be broken out of).

+

After determining the two parents crossover occurs: each new +offspring inherits DNA from the parents; every character in the +chromosome string is pseudorandomly selected from one of the parents’ +respective character. Next, based on the mutation rate, perform +mutation of the chromosome of each offspring; in other words +some of the characters in the chromosome will be assigned a +pseudo-random value from the keyboard (in normal mode; in random mode +every character will be assigned a value). Before mutation the +offspring chromosome will be printed; after mutation it will show what +it was mutated to (on the same output line). After the new generation +has been sequenced the loop goes back to the top and it starts all over +until the maximum number of generations SIZE_MAX - 1 is +reached or the target chromosome has been found.

+

Note that the generation is checked before the scoring takes +place by a prefix increment equality check; when the generation is +SIZE_MAX - 1 the fitness test loop will not be entered; +instead the outer loop will end after printing:

+
+

Too many attempts, blaming the monkey Eric even if he isn’t typing or +doesn’t exist. Bye.

+
+

Why ‘Eric’? Because the judges stated in the 2018 guidelines that +when there is a user input error the program should insult the pet fish +Eric even if such a fish (no, weasels do not equate monkeys to fish but +see below) doesn’t exist. The second to last example limitation example +note (it’s improved in the final but this is relevant) they give is:

+
+

The judges might not have a pet fish named Eric, so might want to +state:

+

This entry factors integers between 1 and +2305567963945518424753102147331756070. Attempting to factor anything +else will cause the program to insult your pet fish Eric, or in the case +that you lack such a pet, will insult the pet that you do not have.

+
+

After the final message they ask:

+
+

BTW: What is so special about +2305567963945518424753102147331756070? You tell us!

+
+

The answer is this: it is the primorial prime of 97: +the product of all prime numbers less than or equal to N; and +the primorial prime of N == 97 is +2305567963945518424753102147331756070. There is no +reference to this number in my entry but it’s nonetheless possible to +change the default target to it without modifying the source +code**; there are two hints in this very paragraph; the first sentence +in fact: the answer to the judges’ question and the definition. Can you +get the program to search the primorial prime of 97 without passing in +specially?

+

I was quite proud that when the next contest came the judges removed +that question. Later 2018 and all of 2019 was difficult for me so it was +like I won a second time for the same entry.

+

On user monkey errors

+

If the generation reaches SIZE_MAX - 1 I consider it a +monkey (or if you insist: user) error; if the user insists on being so +petulant enough as to try such a ridiculous set of parameters in an +attempt to make it be no more successful than a monkey typing then +it shouldn’t be any more successful than a monkey; if it by chance +reaches the target it’s because a monkey could too! Either way +unless the number reaches SIZE_MAX - 1 the monkey Eric +won’t be blamed. It should be noted that depending on the parameters +(size of chromosome, number of offspring, the string itself) the program +could take quite a lot of system resources; and whether the OS kills it, +Eric the monkey falls asleep or the typewriter is taken from him the +result could very well be not found without blaming him. Of course the +judges were talking about fish not monkeys. But since this program is +inspired by the Weasel program which was inspired by the Infinite +Monkey Theorem I opted instead to target the monkey Eric even +if such a monkey isn’t typing or even doesn’t exist (because it’s not +the Infinite Fish Theorem). So although the user might not be a +monkey the program makes the assumption that the user could in +fact be a monkey called Eric although it isn’t insolent +enough to say the user is a monkey for certain!

+

3. Hints

+

Skip to Obfuscation.

+

I noted that there are a number of additional features and here I +will document some of them.

+

Keyboards

+

Skip to Options.

+

The keyboard, as noted, has more than just the alphabet and space. To +be precise the following characters are acceptable; it equates to this +in C (note it includes a literal space ' ' but it doesn’t +include other isspace() characters) and this is why some of +the characters are escaped:

+
    const char keyboard[]=" !\"#$<%:>&'()*+,-./0123456789;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`{|}~";
+

The simpler keyboard looks like:

+
    const char keyboard[]=" !\"&'(),.0123456789;?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+

The program makes sure that the target string only has characters the +keyboard can actually produce but there is a certain type of input error +that might appear to be a bug; see specifically Input Error Example.

+

Options

+

Skip to Spoilers.

+

There are a number of options you can pass to the program besides the +target string; some I will document here (the summary being in the man +page). You can join options but there is a caveat with spaces and +-r option as well as the target string (see below).

+

Enable quiet output:

+
    -q
+

This means don’t print the generation and offspring output; only +print (some) of the options set (this is always done but wouldn’t +usually be seen due to verbose output) and the final answer.

+

Change the mutation rate to +<rate>:

+
    -r<num>
+

Please note that there cannot be a space between the -r +and the number. This is to simplify the parsing of options. As for +combining options you can do any of the following (amongst others):

+
    -r5q
+    -qr5
+    -qr
+    -q -r5
+

The third invocation will set quiet output and have no valid value to +parse for the mutation rate and strtol() in this case +returns 0. strtol() can legitimately return 0 but in no +instance is it valid input in this program: the valid mutation rate is +>= 1 && <= 100.

+

When the mutation rate is out of range it does something interesting: +take a look at the output and compare it to the output when the range is +valid. Can you figure out another way to trigger this? In fact there are +two more ways (one is an option I’ve mentioned and the other one is to +do with the number of offspring)! If you want something of a walk +through I suggest you follow the following:

+
    +
  1. Enable quiet mode and set an invalid mutation range; for example +specify:

    +
    -qr101
  2. +
  3. Take a look at the first few lines. Kill the program and try +invoking it with the following options:

    +
    -qr5
    +


    +

  4. +
  5. Look at the first few lines again and compare it to the output of +step #1. With the default string most modern systems shouldn’t take much +time to - given decent parameters - come to an answer here but if +necessary kill the program.

  6. +
  7. Repeat the steps only this time don’t enable quiet mode. Look at +the offspring output. If you still don’t see what it is and want to know +see Spoilers below.

  8. +
+

Finally any argument that doesn’t start with a - passed +into the program will become the target string. The same rule applies to +the number for -r: it must be a single parameter which +means you’ll need to quote the string if it has more than one word (that +is it contains spaces) or anything else interpreted specially by your +shell e.g. parentheses. For instance if you just want to find +METHINKS you could do one of:

+
./weasel METHINKS
+./weasel "METHINKS"
+./weasel 'METHINKS'
+

If you wanted YOU ARE A MONKEY:

+
./weasel "YOU ARE A MONKEY"
+./weasel 'YOU ARE A MONKEY'
+

If you do one of:

+
./weasel "METHINKS IT IS A" "MONKEY"
+./weasel METHINKS IT IS A MONKEY
+


+It will search for MONKEY in both cases; in other words +it’s the last one. If the string is too long given the value of +S (see
+How to build) it will be +truncated.

+

If you actually do want to search for a string starting with a +- you must disable further parsing of options by using the +- option itself; for example if you were to do any of:

+
./weasel -q- -- -test
+./weasel -q- -test
+./weasel -q -- -test
+

The target string will be: -TEST. This means though that +here:

+
./weasel -q -- -test -r5
+

The string to be searched would actually be -r5 and the +mutation rate will remain the default because after the - +option is seen it will no longer parse additional options: only target +strings if anything left on the command line. Because of the joining of +arguments this means that the first two examples of the last set of +three above are equivalent i.e. the following two are equivalent:

+
    -q-\
+    -q --
+


+As for the caveat I referenced what does the following do?

+
./weasel -qr 5
+

In fact it will set quiet output and set the target string to be ‘5’. +So the mutation rate will be out of range, thus enabling that Easter +egg, but it will likely come to an answer fairly quickly because it’s +just a single character. A note on the parsing of the - +option; if the program is currently parsing argv[N], for +example, and it encounters a -- then depending on where the +other options are in the command line it might still parse the options. +Thus you have:

+
$ ./weasel -qr-r5
+quiet output
+mutation rate out of range
+target 'METHINKS IT IS LIKE A WEASEL'
+mutation rate 5
+Generation  440 Offspring 20: METHINKS IT IS LIKE A WEASEL
+

Similarly this would set quiet output, then an invalid mutation rate +and then a mutation rate of 5:

+
./weasel --qrr5
+

If you were instead to do one of (for example):

+
./weasel -q -- -r
+./weasel -q -q- -r
+

Then it would set quiet output then see the -- +(the - option itself) and then the target string would +literally be set to -r because it no longer cares +about the - for option parsing. In other words options are +only parsed if the first character is - and if the parser +hasn’t seen the - - in an earlier element of +argv. This is not a bug!

+

Spoilers

+

Skip to Example Invocations.

+

The Easter egg: Since Dawkins references the Infinite +Monkey Theorem it simulates a monkey using a typewriter! This mode +has the following changes:

+

Selection is omitted; this means no sorting by fitness score +(each offspring is initially set to be the first two in the +list) but do pseudo-randomly select characters for every character +in the target string; that is to say if the string is of length 28 (the +default) then all 28 characters in each offspring of each generation +will be assigned a pseudo-randomly positioned character in the keyboard. +If you want to enable this specially you can use the -m +option (-m for monkey).

+

Example +Invocations

+

Skip to Input Error Example.

+

The following examples are used to demonstrate better the command +line parsing. In order to do that though I had to first document the +-m option because if the mutation rate is out of range +monkey mode is activated (that’s the first Easter egg). But what happens +if you later set a valid mutation rate? Should monkey mode be disabled? +If yes how do we know if monkey mode was specially requested? There are +at least two ways to go about it: I took the monkey safe (‘fool safe’) +method; *if you explicitly request monkey mode you cannot disable it in +the same invocation of weasel!

+
$ ./weasel -qr101r5r101r1r test
+quiet output
+mutation rate out of range
+mutation rate out of range
+mutation rate out of range
+target 'test'
+mutation rate 0
+monkey at typewriter
+Generation 16844        Offspring 22: TEST
+

So in this case I joined the options in the following order:

+
    +
  1. -q

    +

    Quiet output.

  2. +
  3. -r101

    +

    Mutation rate 101 (out of range).

  4. +
  5. -r5

    +

    Mutation rate of 5 but note that during parsing I only print invalid +mutation rate (only after parsing do I print the final mutation rate +whatever it ends up being); so while it appears there is a bug, showing +mutation rate out of range three times, this is expected (given the next +one, -r101). This means here the typewriter was taken from +Eric the monkey.

  6. +
  7. -r101

    +

    Mutation rate to 101: this too is out of range (this is the second +mutation rate out of range message). The typewriter returns to +Eric.

  8. +
  9. -r1

    +

    Set mutation rate to 1. Take that typewriter away!

  10. +
  11. -r

    +

    Set mutation rate to 0; when there are no valid characters passed to +strtol() it should return 0: this is the third message +about being out of range. Note here that rand() returns an +int and strtol() returns a long +but I compare the return value of rand() to the mutation +rate; if there are any systems where the widths differ this +shouldn’t matter because of truncation but I do in any case +specifically check for R < 0 || R > 100. Either way +the invalid range returns the typewriter to Eric.

  12. +
  13. test

    +

    Finally I requested it find the string test (will search +for TEST).

  14. +
+

Given that it was a short string it did find the answer relatively +quickly, even in monkey mode.

+

Another example:

+
$ ./weasel -q -r101 test -r5
+quiet output
+mutation rate out of range
+target 'test'
+mutation rate 5
+Generation  109 Offspring 13: TEST
+

In this case I also enabled quiet mode but I didn’t join the options; +the -r101 reports that it’s out of range and sets monkey +mode. I then specify the target string and then set a valid mutation +rate. This disabled monkey mode which means that it’ll use the genetic +algorithm.

+

One more example of monkey mode:

+
$ ./weasel -q -mr101 test -r5
+quiet output
+mutation rate out of range
+target 'test'
+mutation rate 5
+monkey at typewriter
+Generation 465298       Offspring 10: TEST
+

Here I also requested quiet output and then explicitly requested +that Eric the monkey types. After this I set the mutation rate to +be 101 which would have set monkey mode (in this case only +temporarily as I later set it to a valid number) but since I have +also requested monkey mode that won’t matter. Then I set the string to +test and then set a valid mutation rate of 5. Now note that +it is actually set to 5 but also note that monkey mode remains active: +it also took a lot longer to come to a conclusion for even four +characters. This example does demonstrate one other thing in a subtle +way though.

+

When the program prints out each iteration (I’ll give an example +next) it goes a lot slower; this makes sense because it’s an expensive +operation. Here are the times for the same but without quiet output +enabled:

+
    real    0m17.065s
+    user    0m1.245s
+    sys     0m2.402s
+

Whereas with quiet output:

+
    real    0m0.127s
+    user    0m0.125s
+    sys     0m0.001s
+

Of course it isn’t only down to the printing but the point is it +slows it down significantly. Adding an option to print every X lines +would go over the limit (iocccsize -i reports 2052!).

+

Finally I’ll show a default example in normal output (I omit many +lines showing instead […]). Note that the real/user/sys +times are from the time bash shell built-in utility: that +isn’t output from my entry.

+
    target 'METHINKS IT IS LIKE A WEASEL'
+    mutation rate 1
+    Generation    0 Offspring  1: 4V YGY.GH/}_|>Q1M.R8;KD[=(05
+    Generation    0 Offspring  2: Y_^S0_HZ399^/|9,MP%^{817"XX#
+    Generation    0 Offspring  3: F%88H1&[V1P>QOI}- U]0[V-Y%*[
+    [...]
+    Generation    1 Offspring 23: AHA#.\=ZT'0>?~-S.;1A L|1<S:^ -> AHA#.\=ZT'0>?~-S.;1A L|1<S:| (mutation)
+    Generation    1 Offspring 24: AHA#.\=ZT'0>?~-S.;1A L|1<S:^ -> AHA#.\=ZT'0>?~-S.;1A L|1<S:^ (mutation)
+    Generation    1 Offspring 25: AHA#.\=ZT'0>?~-S.;1A L|1<S:^ -> AHA#1\=ZT'0>?~-S.;1A L|1<S:^ (mutation)
+    **
+    Generation    2 Offspring  1: AHA#.\=ZT'0>?~-S.;1A L|1<S:^ -> AHA#.\=ZT'0>?~-S.;1A L|1<S:^ (mutation)
+    Generation    2 Offspring  2: AHA#.\=ZT'0>?~-S.;1A L|1<S:^ -> AHA#.\=ZT'O>?~-S.;1A L|1<S:^ (mutation)
+    [...]
+    Generation  979 Offspring  1: METHINKS ITZIS LIKE A WEASEL -> METHINKS IT IS LIKE A WEASEL (mutation)
+    [...]
+    **
+    Generation  979 Offspring  1: METHINKS IT IS LIKE A WEASEL
+
+    real    0m0.074s
+    user    0m0.040s
+    sys     0m0.001s
+

Keep in mind the way I display the generations and the fact that +generation 0 has no parents; it is generation 1 that starts working +towards the goal. You’ll see also (mutation) at the end +of the line at this point (if you enable monkey mode you’ll find that it +shows something else). The lines that only have +are separators: you won't see this between generation 0 and 1 but you will between future generations - as well as the final answer (if the answer is in generation 0 you won't see the).

+

One final thing to consider is that the +program doesn’t directly read from a file. This combined with +the way the shell works could possibly confuse some people. Take the +following invocations:

+
    (1) $ echo test > test
+    (2) $ ./weasel test
+    (3) $ ./weasel < test
+    (4) $ cat test | ./weasel\
+    (5) $ < test-strings.txt ./weasel
+    (6) $ cat | ./weasel
+

Only the first invocation of ./weasel will search for +TEST because the string test was explicitly +passed to the program (If the file test wasn’t found by +that path it would still have searched for TEST).

+

The second invocation will search for the default string if there is +a file or directory called test; else you will get an error +about no such file or directory (unless your shell for some reason +doesn’t consider it an error; bash most certainly does consider it an +error and halts).

+

The third invocation would if there exists a file test +cat that file and pipe the output to ./weasel; however +it will search for the default string. If there is no such file to +cat then an error will be reported but without quiet mode you’d probably +not even see the error.

+

The fourth invocation will also search for the default string unless +the file doesn’t exist in which case you’d get an error like in the +second invocation.

+

The fifth invocation will actually search for the default string even +with the file test-strings.txt existing. As far as I am +aware it’s equivalent to the third invocation except that the file +exists in this case.

+

The final invocation will search for the default and then read from +stdin; it won’t do anything with it however.

+

What this amounts to is if you want input from a file you have to +read from the file and pass each string to the program itself. I’ve +included a script test.sh and a file of sample input +test-strings.txt that you can play with.

+

Try:

+
make test
+

This will essentially make sure the program is compiled and then +do:

+
chmod +x test.sh
+./test.sh
+

The script will first try compiling the program (if necessary) and if +it fails for any reason it will exit; else it will read each line in the +file test-strings.txt (if the file doesn’t exist or can’t +be read the script will exit with return status of 1) and pass it to the +program. After finding the string it’ll sleep approximately 2 seconds +and then read the next string (passing it to the program, continuing +until all the strings have been read and processed).

+

You can pass additional options directly to the script but remember +that it stops when there are no more strings in the file - so if you +try:

+
./test.sh -q test
+

The final string test won’t be searched for; it will +however run the program in all invocations with quiet output enabled. +The following are some notes about how the shell and the program +interact with each other:

+

Because the script quotes the strings that it reads from the file if +you were to put in the file: -q STRING quiet mode would be +enabled; however the default string would be searched for. If the quotes +were removed from the script it would print the final word specified. To +be specific with the quotes: if in the file you had the line +-q STRING -m TEST it would enable quiet output and monkey +typewriter mode; but it would search for the default string. Without the +quotes on the other hand it would enable quiet output, monkey typewriter +and search for TEST. In other words if you want to +pass options to the script you will have to directly pass the options to +the script like the above example shows (but the strings will +still only be read from the test-strings.txt file).

+

Input Error +Example

+

Skip to Obfuscation.

+

There is a type of input error, as I said, that might appear to be a +bug. What actually is going on though is due to a technicality on how +spaces are printed and the fact the program does not accept spaces other +than a literal space
+; when a character in the string to be found isn’t in the +keyboard the program prints an error message and then exits (returning +1). But since the keyboard doesn’t have '\n' if you were to +type a ' and send a '\n' before the closing +' you might see something like:

+
$ ./weasel '!!
+> '
+
+'
+' not in keyboard " !"#$<%:>&'()*+,-./0123456789;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`{|}~"
+

I showed that ' is in the keyboard already; however the +user sent a \n (hence the secondary prompt +> on line two) before literally typing the closing +' (also line two). But in order to make it clear what +character is invalid I surround the character with 's so +what you actually see after typing the closing ' and +hitting Enter (or however you send the '\n') there is the +third blank line; but then the program prints ' +followed by the invalid character ('\n' itself which means +another line break) and then finally the closing '. +Specifically isspace() characters aren’t distinctly seen +like a letter, digit or symbol is: +isprint('\n') == 0 && isspace('\n') == 1. You can +add these characters but the output will be rather confusing and hard to +read.

+

4. +Obfuscation

+

Techniques

+

Skip to Beauty.

+

The following might be some of the techniques used in this entry:

+
    +
  1. Helpful and descriptive names for all variables and constants +(like S) as well as some C keywords.

  2. +
  3. The way main() is declared is:

  4. +
+
/* Special C main() handler (encapsulation): */
+#define r(main) main
+r(k main(k a, E **V)) {
+
It appears to be recursively defined but is it? And is it truly
+

encapsulation? And is it executing code of any kind? It mightn’t seem +like it isn’t encapsulation and also isn’t executing code but assuming +it’s encapsulation and executing code is it actually nothing? And if +it’s nothing why is it there? If it is something what is it doing? Could +it be both? Or maybe it really isn’t nothing or nothing? :)

+
    +
  1. A special C parser called H(). It might help to +observe that there might be recursive calls and much of the program +might use it. Or so it seems. Then again it might not help to not notice +it.

  2. +
  3. Digraphs. In their simplest form it’s probably not a big deal but +consider: some source code formatters don’t like them at all (neither, +incidentally, does splint, which completely baulks). There +also is a trick; if you try translating them then depending upon how you +do it there can be functional changes in the program!

  4. +
  5. The fact the program can by default print the primorial prime of +97 (but that default isn’t the default - except when it IS the +default!) and yet that number isn’t seen at all. See also technique +#7.

  6. +
  7. Another usual suspect: the source is formatted in a beautiful +design that could be described artistic; on the other hand some might +suggest it’s just a blob of octets but I disprove this when +discussing beauty later on in the next section.

  8. +
  9. The string METHINKS IT IS LIKE A WEASEL is +searched for by default (except when it’s not searched by default) but +it’s nowhere to be found in the source file in that form. Why? Because +anyone familiar with the Weasel program won’t recognise the string and +put together what it is by looking at the source code.

  10. +
+

In case you wondered deciphering #5 won’t decipher #7 (neither will +deciphering #7 help you decipher #5).

+

Beauty

+

Skip to How to build.

+

On the subject of beauty: the judges stated in the guidelines the +following:

+
+

We want to get away from source that is simply a compact blob +of octets. Really try to be more creative than blob +coding. HINT!

+
+

And if you’ll notice that although it might look like a compact +blob of octets at first glance if you look throughout the file +you’ll see two statements to set your thinking straight:

+
+

NO BLOB CODING

+
+
+

THIS IS NOT A COMPACT BLOB OF OCTETS

+
+

So you see even if your eyes are trying to deceive you they’re quite +wrong. Yes some of it might look like a blob but this is clearly false; +as all good programmers know if something is potentially confusing +or misleading it should be made clear in the comments! :)

+

5. How to +build

+

S and N +Constants

+

Skip to Compilation.

+

These two #defined constants can be redefined at +compilation to modify the behaviour of the program in a number of ways +(see the Compilation +subsection for example invocations). Both are capped to be no greater +than SIZE_MAX - 1. This is handled by the C +preprocessor.

+

S

+

This determines the maximum size of the target string but it +must be at least 38; this is because +38 >= 29 and because +strlen("METHINKS IT IS LIKE A WEASEL") == 28 (which is the +default target string - it would hardly be an implementation of the +Weasel program otherwise).

+

There is obviously a reason 38 is the chosen size but +the only hints I provide are those in How it +works and specifically an Easter egg I referenced there +(it’s not the only Easter egg but it’s the only Easter egg I +won’t spoil; yes this ironically and amusingly means I’ve left a rotten +egg somewhere!).

+

N

+

This is the number of offspring per generation. Anything less than 4 +will be set to 3 (that’s not a typo!) and this is part of an Easter +egg.

+

Be aware that depending on the size of S and +N (individually and together) the program will use varying +amounts of memory and the larger the values the more memory it’ll +require.

+

Compilation

+

Skip to Portability.

+

The following options must always be passed to the +compiler:

+
-DQ='typedef' -D'g(o)'='goto o;' -D'w(x)'="x:" -D'H(main)'='r(main)'
+

If you want to increase the number of offspring to 50 +and the size of the chromosome to 75 you would pass to the +compiler:

+
-DQ='typedef' -D'g(o)'='goto o;' -D'w(x)'="x:" -D'H(main)'='r(main)' -DN=50 -DS=75
+

If you wanted to change N to 3:

+
-DQ='typedef' -D'g(o)'='goto o;' -D'w(x)'="x:" -D'H(main)'='r(main)' -DN=3
+

Remember that it cannot be less than 3; more +correctly if it’s less than 4 it’s redefined to 3 so you could have +passed in -DN=2 and have the same result. Remember too that +S cannot be less than 38. Both S +and N are capped at SIZE_MAX - 1.

+

Portability

+

Skip to An aside on bugs.

+

This entry requires at least C99 even if you translate digraphs. The +program doesn’t require third-party libraries and should work on any +Unix based system. It works on both 64-bit and 32-bit (but inevitably +some data type sizes will be smaller and this I believe includes +SIZE_MAX). I don’t think Windows gcc ports would have many +issues (if any) either but I have no way to test this. Originally I +tested it on the below systems.

+

Fedora 26:

+
$ clang --version|head -n1
+clang version 4.0.1 (tags/RELEASE_401/final)
+$ gcc --version|head -n1
+gcc (GCC) 7.3.1 20180130 (Red Hat 7.3.1-2)
+$ /lib64/libc-2.25.so |head -n1|cut -d',' -f1-1
+GNU C Library (GNU libc) stable release version 2.25
+$ lscpu |grep Endian
+Byte Order:          Little Endian
+

CentOS Linux release +7.4.1708 (Core)

+
$ clang --version|head -n1
+clang version 3.4.2 (tags/RELEASE_34/dot2-final)
+$ gcc --version|head -n1
+gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16)
+$ /lib64/libc-2.17.so |head -n1 |cut -d, -f1-1
+GNU C Library (GNU libc) stable release version 2.17
+$ lscpu |grep Endian
+Byte Order:            Little Endian
+

Fedora 27:

+
$ clang --version|head -n1
+clang version 5.0.1 (tags/RELEASE_501/final)
+$ gcc --version|head -n1
+gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
+$ /lib64/libc-2.26.so |head -n1|cut -d, -f1-1
+GNU C Library (GNU libc) stable release version 2.26
+$ lscpu |grep Endian
+Byte Order:          Little Endian
+

macOS:

+

System Version: macOS 10.13.4 (17E199) Kernel Version: Darwin +17.5.0

+
$ gcc -v
+Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
+Apple LLVM version 9.1.0 (clang-902.0.39.1)
+Target: x86_64-apple-darwin17.5.0
+Thread model: posix
+InstalledDir: /Library/Developer/CommandLineTools/usr/bin
+$ uname -srmv
+Darwin 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar  5 22:24:32 PST 2018; root:xnu-4570.51.1~1/RELEASE_X86_64 x86_64
+

An aside

+

Skip to Installing.

+

Any undocumented bugs are the result of insolent monkeys tampering +with any number of things. That includes but is not limited to running +the program on a non-ASCII system; non little-endian; meddling with +S or N too much, changing the references to +SIZE_MAX to be larger than SIZE_MAX or a +signed value (size_t is unsigned) or too small of a value; +changing data types or variables; expecting really long strings - +including but not limited to the complete works of Shakespeare (hint: +isprint('\n') == 0 so it won’t ever find any string with +'\n') - to be found by the program in a quick and easy +fashion if ever; or any other meddling including being petulant and/or +unreasonable monkeys. I will say though that there is at least one place +I see after having won that could be slightly more efficient (can you +find it?); I am however leaving it as it is because this is what +won.

+

Installing

+

Skip to Final thoughts.

+

I have included a RPM spec file for those with a Red Hat based Linux +distribution; see rpm.md for details (including why +I implemented this) if for some (strange or maybe even mad) reason +you’re interested.

+

6. Final +thoughts

+

Skip to Winning comments.

+

The judges suggested that making them laugh helps entries chance of +winning. Well laughter helps everything so in case you haven’t +seen - and even if you have seen - Dennis Ritchie’s +anti-foreword to the ghastly UNIX-HATERS Handbook or Ken +Thompson’s revelation that C and Unix are a hoax (at the end of that +book) I include it below; because I agree that looking at a lot of +twisted code must be quite difficult (though maybe not as much as if you +were to have to look at Microsoft Windows code or code for Windows in +any case ? :)) and these two things I think are rather amusing (in order +of least to most):

+

Dennis Ritchie’s Anti-Foreword:

+
+

Anti-Foreword

+
+
+

By Dennis Ritchie From: dmr@plan9.research.att.com Date: Tue, 15 Mar +1994 00:38:07 EST Subject: anti-foreword

+
+
+

To the contributers to this book:

+
+
+

I have succumbed to the temptation you offered in your preface: I do +write you off as envious malcontents and romantic keepers of memories. +The systems you remember so fondly (TOPS-20, ITS, Multics, Lisp Machine, +Cedar/Mesa, the Dorado) are not just out to pasture, they are +fertilizing it from below.

+
+
+

Your judgments are not keen, they are intoxicated by metaphor. In the +Preface you suffer first from heat, lice, and malnourishment, then +become prisoners in a Gulag. In Chapter 1 you are in turn infected by a +virus, racked by drug addiction, and addled by puffiness of the +genome.

+
+
+

Yet your prison without coherent design continues to imprison you. +How can this be, if it has no strong places? The rational prisoner +exploits the weak places, creates order from chaos: instead, collectives +like the FSF vindicate their jailers by building cells almost compatible +with the existing ones, albeit with more features. The journalist with +three undergraduate degrees from MIT, the researcher at Microsoft, and +the senior scientist at Apple might volunteer a few words about the +regulations of the prisons to which they have been transferred.

+
+
+

Your sense of the possible is in no sense pure: sometimes you want +the same thing you have, but wish you had done it yourselves; other +times you want something different, but can’t seem to get people to use +it; sometimes one wonders why you just don’t shut up and tell people to +buy a PC with Windows or a Mac. No Gulag or lice, just a future whose +intellectual tone and interaction style is set by Sonic the Hedgehog. +You claim to seek progress, but you succeed mainly in whining.

+
+
+

Here is my metaphor: your book is a pudding stuffed with apposite +observations, many well-conceived. Like excrement, it contains enough +undigested nuggets of nutrition to sustain life for some. But it is not +a tasty pie: it reeks too much of contempt and of envy.

+
+
+

Bon appetit!

+
+

Yes he misspelt ‘contributors’! But then again we’re talking +about obfuscation and since it doesn’t break his message it’s not broken +- it’s just obfuscated albeit not very much (and it still +‘compiles’!); and isn’t that what this contest is about? :)

+

Ken Thompson’s ending:

+
+

Creators Admit C, Unix Were Hoax

+
+
+

FOR IMMEDIATE RELEASE

+
+
+

In an announcement that has stunned the computer industry, Ken +Thompson, Dennis Ritchie, and Brian Kernighan admitted that the Unix +operating system and C programming language created by them is an +elaborate April Fools prank kept alive for more than 20 years. Speaking +at the recent UnixWorld Software Development Forum, Thompson revealed +the following:

+
+
+

“In 1969, AT&T had just terminated their work with the +GE/AT&T Multics project. Brian and I had just started working with +an early release of Pascal from Professor Nichlaus Wirth’s ETH labs in +Switzerland, and we were impressed with its elegant simplicity and +power. Dennis had just finished reading Bored of the Rings, a hilarious +National Lampoon parody of the great Tolkien Lord of the Rings trilogy. +As a lark, we decided to do parodies of the Multics environment and +Pascal. Dennis and I were responsible for the operating environment. We +looked at Multics and designed the new system to be as complex and +cryptic as possible to maximize casual users’ frustration levels, +calling it Unix as a parody of Multics, as well as other more risque +allusions.

+
+
+

“Then Dennis and Brian worked on a truly warped version of Pascal, +called”A.” When we found others were actually trying to programs with A, +we quickly added additional cryptic features and evolved into B, BCPL, +and finally C. We stopped when we got a clean compile on the following +syntax:

+
+
for(;P("\n"),R=;P("|"))for(e=C;e=P("_"+(*u++/
+8)%2))P("|"+(*u/4)%2);
+
+

“To think that modern programmers would try to use a language that +allowed such a statement was beyond our comprehension! We actually +thought of selling this to the Soviets to set their computer science +progress back 20 or more years. Imagine our surprise when AT&T and +other U.S. corporations actually began trying to use Unix and C! It has +taken them 20 years to develop enough expertise to generate even +marginally useful applications using this 1960s technological parody, +but we are impressed with the tenacity (if not common sense) of the +general Unix and C programmer.

+
+
+

“In any event, Brian, Dennis, and I have been working exclusively in +Lisp on the Apple Macintosh for the past few years and feel really +guilty about the chaos, confusion, and truly bad programming that has +resulted from our silly prank so long ago.”

+
+
+

Major Unix and C vendors and customers, including AT&T, +Microsoft, Hewlett-Packard, GTE, NCR, and DEC have refused comment at +this time. Borland International, a leading vendor of Pascal and C +tools, including the popular Turbo Pascal, Turbo C, and Turbo C++, +stated they had suspected this for a number of years and would continue +to enhance their Pascal products and halt further efforts to develop C. +An IBM spokesman broke into uncontrolled laughter and had to postpone a +hastily convened news conference concerning the fate of the RS/6000, +merely stating “Workplace OS will be available Real Soon Now.” In a +cryptic statement, Professor Wirth of the ETH Institute and father of +the Pascal, Modula 2, and Oberon structured languages, merely stated +that P. T. Barnum was correct.

+
+

So is it a hoax about a non-hoax, a non-hoax about a hoax, a +non-hoax about a non-hoax or is it a hoax about a hoax ? :) And if it’s +any of those what does it mean about Unix and C? And if a hoax +is involved what is the hoax? The pedant and Tolkienist that I +am has to state that Tolkien didn’t consider The Lord of the +Rings a trilogy (and he made that very clear) but that +doesn’t take away from the humour by any stretch (if anyone wants me +to elaborate or debate the matter do send me an email - I love Tolkien’s +legendarium and having another person to talk about it with is more than +welcome!). Ken suggested that there is a lack of common sense but +since he was part of its creation I don’t think it’s a bad thing; +on the contrary it makes all of us C programmers even more +talented! :) I do wonder if he tested that bit of C code +though:

+
for(;P("\n"),R=;P("|"))for(e=C;e=P("_"+(*u++/
+8)%2))P("|"+(*u/4)%2);
+


+How is R=; valid? Since I don’t have the context maybe +there is something I’m missing but either way it’s a funny piece. It +could also be for irony itself (actually I had previously thought of +somehow implementing something like that for the contest but decided for +the message by itself in the end). I would prefer believing that whether +true or not.

+ +

I feel incredibly honoured, privileged and I am extremely happy and +proud to have won! I am more proud and happy about this than anything I +have ever done in my life and I don’t think there can be anything else I +can be more proud of in the future (except winning again should I find +or think of another interesting thing to try and implement in an +obfuscated way). Because winning is one thing; but to be included +amongst very clever and talented veterans whom I highly respect is an +incredible badge of honour that I will proudly wear (literally too as I +hope to get my entry on a shirt) for the rest of my life. This type of +badge is something I feel most only dream of but never come close to +earning. That I did is by far the best feeling I can think of.

+

Thank you Simon Cooper, Landon Curt Noll and Leonid A. Broukhis, and +thank you to everyone who has been an important and special part of my +life. I want to specially name some:

+

I dedicated this program to my beloved but recently late dog Venus; +instead of drowning in grief I channelled it to creativity. And to have +won a contest requiring creativity, cleverness and novelty is a tribute +to an equally creative, clever and unique dog that she was. I miss you +terribly Venus but I’m so happy to have had you in my life.

+

But I want to also dedicate it to (and thank) my dear friend Martijn Schoemaker whom provided me +with the spark a very long time ago (and whom has stood by me and helped +me in more ways than he can know - #including C); if it +wasn’t for you Martijn I wouldn’t have been able to win so consider this +a recursive thank you thank you! :)

+

I would also like to give thanks and much love to my dear friend +Vicky Wilmore who means the absolute world to me; thank you for being +such a wonderfully beautiful person and friend - that truly is what +‘just you’ means, sweetheart, and don’t you forget it! <3

+

Finally I would like to thank my mother for being the best mum anyone +could ask for, who’s always been here for me and whom I also inherit the +keen analytical mind from. I love you all!

+

I want to also thank Dave Burton +for acknowledging me in his [README.md]((../burton2/README.md) for his +2018/burton2 entry for as he put it +‘being relentless with pursuit of bugs’. To think that it was +circumstantial to my entry too makes it all the more unlikely but that +doesn’t take away the significance of it; for I am a very symbolic +person and being acknowledged for this type of thing is great but to be +acknowledged for it by someone who has won more than once is even more +special to me: thank you Dave! It means a great deal to me and I am glad +I could help! :)

+

I would also like to say to the judges about their commentary as well +as the category title: they’re all very dear to me and that includes not +just the remarks but the example invocations. They fit my views +precisely. As for the test-strings.txt file modifications: very amusing +and I certainly do not object. Thank you again for such an honour and +privilege! That this isn’t a dream is the best reality imaginable! +:)

+

Congratulations to one and all for winning; it’s an honour to win +such a wonderful contest requiring creativity, cleverness, uniqueness +and inventiveness but to win beside all the other wonderful entries is +truly special!

+

I have more information on the winning entry at https://ioccc.xexyl.net/2018/weasel +including how to contact me (besides what’s already published on the +IOCCC website). I have commentary on the other winning entries as +well.

+

If you wish to contact me please do so. Please contact via mastodon. +You can try email but I’m more likely to respond to mastodon +messages.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2018/ferguson

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2018/giles/index.html b/2018/giles/index.html index 512892988..054c9990c 100644 --- a/2018/giles/index.html +++ b/2018/giles/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,238 @@ - - + + + + + + - - -2018 giles - - + + + +2018/giles + + + + + -

2018 giles

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2018/giles

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2018/giles/index.html

- +
+ ← ferguson + ↑ 2018 ↑ + hou → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Edward Giles
+Location: AU

+ + +

To build:

+

This entry requires SDL2 to be installed. See FAQ 3.8: How do I compile an IOCCC winner that +requires SDL1 or SDL2? if you don’t have it installed and don’t know +how to do so.

+
make
+

To use:

+
./prog
+

Try:

+
./prog ioccc.txt
+./prog prog.c
+./prog sand.txt
+./prog sand.alt.txt
+

Judges’ remarks:

+

Can you explain the behavior of the program when ioccc.txt is given to it as input?

+

How would the description of the state machine look like when +translated from Polynomish to English?

+

Author’s remarks:

+

Remarks

+

This entry graphically displays a simulation of sand falling. It uses +SDL to draw the interface.

+

The code makes the following assumptions about the underlying +system:

+ +

In order to simulate the motion of the sand, a cellular automaton is +used. The state transition table is not stored directly. Instead, the +program stores the coefficients of a polynomial that map each state to +the correct one. These coefficients are stored as raw hexadecimal in the +V[] array, and they are reinterpreted as +doubles when used. This allows more numeric precision in +fewer characters (base 16 > base 10), and makes the purpose of the +array less clear.

+

The code is laid out graphically as a bucket pouring sand, and it is +far easier to observe this high-level layout than the code’s actual +function.

+

The preprocessor is used to both obfuscate the code as a whole and +abbreviate the calls to SDL. Additionally, throughout the code, the +variables were named so that they are short and easily confused with +each other.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2018/giles

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2018/hou/index.html b/2018/hou/index.html index f8bac857e..c0e1ef8d5 100644 --- a/2018/hou/index.html +++ b/2018/hou/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,223 @@ - - + + + + + + - - -2018 hou - - + + + +2018/hou + + + + + -

2018 hou

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2018/hou

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2018/hou/index.html

- +
+ ← giles + ↑ 2018 ↑ + mills → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Qiming HOU
+Location: CN

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2018 +hou in bugs.md.

+

To use:

+
./prog < input.json > output.html
+

View output.html in a browser.

+

Try:

+
./try.sh
+

As the script says, open output.html in a browser.

+

What’s not right with the output? How can one fix it?

+

Judges’ remarks:

+

This entry exhibits a way of obfuscation we haven’t seen before, we +think. The rulez of programming in an imperative language +are violated, aren’t they?

+

Try figuring out how to increase the number of different colors, if +you can.

+

Author’s remarks:

+

Nowadays almost every programmer needs to do some Web chore. With all +the open source stuff readily available, often we just need to call a +bunch of libraries to generate an HTML page from a JSON feed.

+

This entry takes such decadence to an extreme. It just calls a bunch +of libraries to generate an HTML page from a JSON feed, literally. There +is no variable (function parameters included), no operator, no flow +control statements except a few decorative returns. In +compliance to production coding standards, the code is littered with +fashionable jargon, doxygen comment, and license text.

+

As one would expect from such an approach, this program is much more +resource intensive than it should be. And one needs a C99-compatible +libc (with the common UNIX stuff) to build this and an HTML5-compatible +browser to open the result. And it terminates with an assertion failure, +but who cares if the web page is already generated?

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2018/hou

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2018/mills/index.html b/2018/mills/index.html index 843c71fcb..4d3ff99c0 100644 --- a/2018/mills/index.html +++ b/2018/mills/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,909 @@ - - + + + + + + - - -2018 mills - - + + + +2018/mills + + + + + -

2018 mills

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2018/mills

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2018/mills/index.html

- +
+ ← hou + ↑ 2018 ↑ + poikola → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Christopher +Mills
Location: US

+ + +

To build:

+
make
+

If you wish to save state so that you can run the program and keep +files changed (for instance you don’t want to compile +mullender.c again) you can compile it like:

+
make clobber SAVE=1 all
+

Make sure that if you do add a file (including by compiling code) +that before you exit (ctrl-e) you type in sync! Otherwise +the file might not exist or it will be corrupt if it does.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: known bug - please help us fix
+STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2018 +mills in bugs.md.

+

To use:

+
./prog
+

Try:

+
./prog
+

At the >boot prompt, type return.

+

At the : prompt, type rk(0,0)rkunix and +wait for it to initialise itself. Now try typing:

+
cat > prog.c
+main(){ printf("Hello, world!\n"); }
+^D
+cc prog.c
+a.out
+

where ^D is EOF.

+

Next try:

+
cc mullender.c
+a.out
+

… and enjoy the classic 1984/mullender entry as it would +have been in 1984 with a VAX-11/PDP-11! Once it reaches the end of the +line, hit enter and see what happens again. When you’re tired of it hit +ctrl-c.

+

But there is much more to this entry! See below.

+

NOTE: To quit, press Control-E.

+

Judges’ remarks:

+

Do small machines only need small programs? This program weighs in at +just 3636 bytes, which is considerably lighter than the original machine +it can replace.

+

This program can take you back to the start of everything, it is +possible to run v0. Just type:

+
./v0
+

NOTE: To quit v0, press Control-E.

+

You will be greeted with a familiar prompt of “login”. The username +and password are “dmr” and “dmr”. To make things more familiar you’ll +need to create ‘.’ as it hasn’t been invented yet on this image!

+
@ ln dd dmr .
+

An ls will reveal that C hasn’t been invented yet! IOBCC +anyone? The compiler is bc. It produces assembly, which +will then need to be assembled together like +ops.s bl.s hello.s bi.s (in that order) to produce +a.out!

+

But wait, we said this was the start of it all! This program can also +run a program that replaces an even larger machine that can run BSD 2.9. +To start this,

+
./prog
+

At the >boot prompt, type return.

+

At the “:” prompt, type rk(0,0)rkunix.

+

NOTE: To quit prog, press Control-E.

+

This should now be very familiar and it is possible to compile and +run one of the very first IOCCC entries mullender.c, as shown +earlier.

+

But wait, there is even more! Try:

+
./v6
+

At the @ prompt, type rkunix. You might +want to type stty -lcase as otherwise the output will be in +all caps.

+

NOTE: To quit v6, press Control-E.

+

Author’s remarks:

+

This +IOCCC entry is dedicated to the late Dennis M. Ritchie

+

The Program:

+

Since this is the 25th “annual” IOCCC, I thought I should mark the +occasion with a look back to its earliest roots. At the same time the +contest enters its 34th year of providing a safe forum for poor C code, +the C language itself is fast approaching its 50th anniversary, along +with the UNIX operating system whose history is so entwined with.

+

The program delivered here is both a full machine emulation of the +original PDP-7 that Ken Thompson used to write the first version of UNIX +and a full machine emulation of the PDP-11/40 used by subsequent UNICES. +The Makefile can build versions that can run each of the +following:

+
    +
  1. UNIX v0 for the PDP-7 (circa 1969)
  2. +
  3. Research UNIX Version 6 (circa 1975)
  4. +
  5. BSD 2.9 (circa 1983)
  6. +
+

For reasons to be described in a bit, the last (BSD 2.9) is the +default.

+

Building and Running BSD 2.9:

+

To run BSD 2.9, do make to build prog and +then ./prog to run it.

+

You should see a prompt from the first-stage bootloader that looks +like

+
>boot
+

Hit enter/return at this point and you will get to the second-stage +boot loader that looks like

+
40Boot
+:
+

The 40 in the prompt indicates that the bootloader has correctly +determined that we are running on a PDP-11/40.

+

At this point, type the rather cryptic command +rk(0,0)rkunix – this tells the system to look at the first +partition on the first RK05 fixed disk, find the +rkunix file and load it. You should eventually see the +following:

+
>boot
+
+40Boot
+: rk(0,0)rkunix
+
+Berkeley UNIX (Rev. 2.9.1) Sun Nov 20 14:55:50 PST 1983
+mem = 135872
+
+CONFIGURE SYSTEM:
+xp ? csr 176700 vector 254 skipped:  No CSR
+rk 0 csr 177400 vector 220 attached
+hk ? csr 177440 vector 210 skipped:  No CSR
+rl ? csr 174400 vector 160 skipped:  No CSR
+rp ? csr 176700 vector 254 skipped:  No CSR
+ht 0 csr 172440 vector 224 skipped:  No CSR
+tm 0 csr 172520 vector 224 skipped:  No CSR
+ts 0 csr 172520 vector 224 skipped:  No CSR
+dh ? csr 160020 vector 370 skipped:  No CSR
+dm ? csr 170500 vector 360 skipped:  No autoconfig routines
+dz ? csr 160110 vector 320 skipped:  No CSR
+dz ? csr 160110 vector 320 skipped:  No CSR
+dn 0 csr 175200 vector 300 skipped:  No autoconfig routines
+vp ? csr 177500 vector 174 skipped:  No autoconfig routines
+lp ? csr 177514 vector 200 skipped:  No CSR
+Erase=^?, kill=^U, intr=^C
+#
+

Congratulations, you are running BSD UNIX 2.9 in single-user mode as +root.

+

On the other hand, if you did a typo somewhere, the boot loader has +probably crashed and halted – if so, type Control-E to quit the emulator +and try again. If you did really badly, you might have corrupted the +virtual disk. If so, consider a make clean to start from +scratch.

+

Assuming you managed to type 15 characters correctly, you should be +at the root prompt. Most of the commands you are familiar with work here +(this was only a quarter of a century ago – how much could things have +changed?). Let’s try some:

+
# ls
+.cshrc       .profile     boot         hkunix       mnt          tmp
+.login       2.9stamp     dev          lib          mullender.c  unix
+.msgsrc      bin          etc          lost+found   rkunix       usr
+# df
+Filesystem  Mounted on  kbytes    used    free  % used
+/dev/rk0    /             1958    1688     270     86%
+# bin/cc mullender.c
+# ./a.out
+

The program you’ve just run was the [winner of the first IOCCC +contest from 1984] 1 (or was it 1894?), a personal favorite of +mine. It is rather tightly bound to running on either a PDP-11 or a +VAX-11. Now you have one.

+

Hitting Control-C will return you to the BSD UNIX prompt. Hitting +Control-D will log you out of the single-user session and get you back +to the :login: prompt. Here you can log in as +root and get a full time-sharing session. Feel free to try +things like vi. I’ve taken the liberty of editing the +.login and .profile files to set the console +to a less traditional setup so that you don’t have to wait for the Model +33 KSR teletype to move its carriage. I’ve also predefined +TERM to vt100, which will probably work well +enough with whatever sort of ANSI terminal emulation you are using.

+

Note that I have not mounted the /usr disk here, so some +commands from /usr/bin will be missing, along with all of +the man pages. They are [available online] 2 if you need them. Adding a second RK05 disk was +possible, but I didn’t get around to it… As the Judges can no doubt +attest, “Mid 2017” creeps up on you quicker than you expect. :)

+

Once you’ve had enough fun in BSD 2.9, type Control-E to exit the +emulation.

+

Building and Running +Research UNIX v6:

+

Research UNIX v6 and BSD 2.9 use the same executable, but require a +different disk image. Type make v6 to build it, then type +./prog to run it.

+

You should see the boot loader prompt which is a single +@:

+
@
+

At this point, you again must type a special incantation: +rkunix. After that you should see:

+
@rkunix
+mem = 1035
+RESTRICTED RIGHTS
+
+Use, duplication or disclosure is subject to
+restrictions stated in Contract with Western
+Electric Company, Inc.
+#
+

You are now running a single-user session of v6 UNIX. You might want +to start with stty -lcase because otherwise everything will +be IN ALL CAPS.

+

Again, if you failed typing seven characters without making a +mistake, you may need to use Control-E to quit the emulation.

+

Assuming you’re more careful than that, we can try a few +commands:

+
@rkunix
+mem = 1035
+RESTRICTED RIGHTS
+
+Use, duplication or disclosure is subject to
+restrictions stated in Contract with Western
+Electric Company, Inc.
+# STTY -LCASE
+# ls
+bin
+dev
+etc
+hpunix
+lib
+mnt
+rkunix
+rpunix
+tmp
+unix
+usr
+# cat > foo.c
+main()
+{
+    printf("Hello, World!\n");
+}
+^D
+# cc foo.c
+# ./a.out
+Hello, World!
+

Why is Version 6 interesting? Well, it was the oldest version that I +could find a boot image of that had a C compiler… This C compiler is +recognizably C, but not quite the same syntax as we have today. It’s +much closer to the [B language] 3 from which it is derived. In particular, this C +compiler would not be able to compile mullender.c (as +simple as it is), because the following syntax features don’t exist +yet:

+ +

It can still compile “Hello World!” (note that you must type a +Control-D after you finish entering the code, to let cat +see an end-of-file).

+

This version of UNIX doesn’t go into multi-user mode if you do a +Control-D. Single-user mode was entered because the front-panel console +switches were set to the magic number 0173030 (this can be changed with +a recompile).

+

Once you are done with Version 6, Type Control-E to exit the +emulation.

+

Note that since both BSD 2.9 and UNIX v6 use the same PDP-11/40 +emulation code, and they use the same name for the disk +(rk05.fs), if you want to go back to the BSD emulation, you +should either delete rk05.fs or do a +make clean before you do a make.

+

Building and Running UNIX v0:

+

We now set the Wayback Machine to the very start of it all, 1969.

+

[The story] 4 here is interesting and well worth a read. +Bell Labs was pulling out of the Multics project and Ken Thompson and +his colleagues had become accustomed to the relatively nice programming +environment. They also enjoyed the early computer game [Space +Travel] 5 and wanted another system to run it on. They +found a PDP-7 which was already obsolete at the time to port Space +Travel to. The primitive programming environment influenced +Thompson to recreate parts of the Multics experience in the much more +hardware-constrained PDP-7 environment. In the summer of 1969, with his +wife out on a month-long vacation, Thompson rewrote a filesystem +emulation he had been experimenting with to include an assembler, a +shell, an editor and an operating system kernel and hence created the +first version of UNIX (although it hadn’t been named that yet).

+

You can try out this version by typing make v0. Since +this version is a native PDP-7 emulation, it gets its own binary. Type +./v0 to run it. You should see the login prompt.

+
login:
+

There are two user accounts ken and dmr, +with the passwords ken and dmr respectively. +Let’s try the Dennis Richie’s dmr account:

+
login: dmr
+password: dmr
+@ ls
+.       ?
+

Even though this is not Ken’s doing, I feel this gives me licence to +include this quote from the BSD fortune program:

+
+

Ken Thompson has an automobile which he helped design. Unlike most +automobiles, it has neither speedometer, nor gas gauge, nor any of the +numerous idiot lights which plague the modern driver. Rather, if the +driver makes any mistake, a giant “?” lights up in the center of the +dashboard. “The experienced driver”, he says, “will usually know what’s +wrong.”

+
+

What’s the deal here? Well, that’s a slightly long story. The short +version is we have gone so far back in the history of UNIX that we +don’t have filesystem paths yet. In other words, we can’t say +something like /bin/ls yet, and the shell can’t store that +path in $PATH to search for it. We also haven’t invented +. or .. yet. In fact, the filesystem isn’t +even the traditional UNIX tree structure, it’s a directed graph of hard +links…

+

ls needs to be able to read ., the current +directory. dmr’s home directory doesn’t have that yet, but +we can make it, because the home directory has a hard link to +dd, which is the directory that holds all of the user home +directories (this will eventually become /, the root path). +We can do

+
@ ln dd dmr .
+

To make the new link (note that ln doesn’t support paths +either, so you have to give it three arguments – a directory in the +current dir, a file in that directory, and the new name).

+

Now ls will work, and we can try some other things while +we are here:

+
login: dmr
+password: dmr
+@ ln dd dmr .
+@ ls
+dd
+system
+as.s
+b_readme
+bi.s
+bl.s
+db.s
+hello.b
+ops.s
+.
+@ cat b_readme
+Here is how to compile and run hello.b:
+
+@ bc hello.b hello.s
+@ as ops.s bl.s hello.s bi.s
+I
+II
+ops.s
+bl.s
+hello.s
+bi.s
+@ a.out
+Hello, World!
+
+
+@ bc hello.b hello.s
+@ as ops.s bl.s hello.s bi.s
+I
+II
+ops.s
+bl.s
+hello.s
+bi.s
+@ a.out
+Hello, World!
+@
+

The last command is invoking the compiler for an extremely early +version of the [B programming language] 3, the predecessor to C. Thompson missed the +convenience of writing code in a high-level language – Multics was +written in a version of PL/1 – and wanted the same convenience in UNIX. +He preferred BCPL (a typeless language) to PL/1. As Dennis Ritchie +[wrote] 6:

+
+

B can be thought of as C without types; more accurately, it is BCPL +squeezed into 8K bytes of memory and filtered through Thompson’s +brain.

+
+

A look at the B reference manual will show the strong correlation +with C, and shows the source of a lot of C’s mysteriousness – some of +which is preserved simply so that C could compile the dozens of +lines of existing B code…

+

Thompson’s assembler was also extremely simple. It didn’t even know +about opcodes – these need to be defined in the first assembly file, +with the assembler OR-ing the opcode fields together (space was the +“operator” for logical OR). There is no link step – all files are +provided to the assembler on the command line, concatenated together and +assembled, producing a single a.out (assembler output) +file. Even after UNIX got a linker, a.out remained the +default name of the binary generated by the linker (and hence also by +cc).

+

This system still has the familiarity of UNIX, with all the two and +three letter commands, device files, shell redirection and the same core +system calls (read(2), write(2), +open(2), close(2), creat(2), +fork(2), etc.). There are a number of differences +still:

+ +

As usual, when you are done exploring UNIX v0, type Control-E to exit +the emulator.

+

About the Program:

+

The program came about when I was looking for something to honor the +pending 50th anniversary of the C language (because of the mercurial +nature of IOCCC contest scheduling, I chose not to wait for the actual +50th anniversary). I had thought of writing self-hosting compilers for a +stripped-down version of C, or maybe even a version of the B language… +At the same time, I was obsessed with the idea of allowing mullender.c from 1984 to run. +Although that was still a possibility on an interpreted version of B or +a stripped-down version of C, it felt cheap, as it would be mullender.c only in spirit.

+

It was during this time that I discovered that in 2016, members of +the Unix Heritage Society got access to [printouts of assembly-language +source for the original version of UNIX] 7. With what was a [huge amount of work] 8, they scanned in the printouts, fixed up the OCR +translations, built assembler and file system tools from scratch and +made an accurate emulation of Thompson’s PDP-7 that allowed them to get +the system up and running. Although source for the entire kernel and +about half of the user-space commands were present (including the +runtime and libraries for the B compiler), the remainder needed to be +written from scratch, including the shell. The final results of the +project are [available on GitHub] 9.

+

None of this was remotely easy (as I was to discover myself). The +PDP-7 is long gone, and the documentation for it is less complete than +one would like. In addition, the devices attached for it were a bit of a +mystery. The disk system is referenced only in an old price list. It was +a RB09 fixed disk, probably made by Burroughs. It is close to what was +called the RC10 for the PDP-10, but with a different interface. And the +system also included a custom display device called Graphics-2, which +had been built in-house by AT&T. It can’t be completely ignored, +because the kernel itself pokes at it (the UNIX crew used it as a second +terminal – a “glass TTY”).

+

I decided that implementing this PDP-7 would be possible as an IOCCC +entry.

+

The emulator emulates the full machine:

+ +

The [PDP-7] 10 is an odd duck by modern computer +standards:

+ +

The emulation handles everything I was able to discover about the +PDP-7, even things that the UNIX code itself doesn’t use. For instance, +it correctly implements the “trap mode” feature (a primitive form of +supervisor mode) even though the kernel does not enable it. It also +implements the microcoding of the EAE instructions even though the UNIX +environment uses only the standard encodings. If you wanted to do a +11-bit multiply instead of an 18-bit one, it will probably work.

+

The emulation starts by loading a boot program off of the virtualized +paper tape, which is in a modified version of the RIM boot loader +format. The RIM format encodes each 18-bit word as three six-bit +characters, using one bit to denote the final word (which is executed +directly and is usually a JMP or HLT +instruction). The load address comes from the console address switches. +Both of these are controlled by compile-time flags.

+

The emulator continues emulating instructions until it sees a +HLT instruction which will cause it to exit. Console I/O is +emulated by setting the terminal into raw mode and polling via +read(2). Line-clock ticks (at 60 Hz) are done by polling +gettimeofday(2). Dynamic frequency code arranges to reduce +the polling interval to a few polls per tick, so that emulation remains +responsive. Since we use the real wall-clock time, this means that the +emulated system will see time advance at the correct rate.

+

Licencing Fun

+

So now I have a system that can run UNIX v0. One problem remains… I +don’t have permission to submit UNIX v0 to the IOCCC. It is not my code +and the copyright for it remains the property of whoever owns that part +of what was once Bell Labs – I believe it is Nokia at this point. I have +worked around this problem in two ways:

+

First, I didn’t submit the source code or binary image for v0 UNIX as +part of my IOCCC entry. I merely submitted a Makefile that +can issue a curl command to fetch a pre-built v0 disk image +from the GitHub repository. I am hoping this is considered part of +“Legal abuse of the rules” which is supposed to be “somewhat +encouraged”. As per RULE 12, I am justifying said abuse here, in the +remarks file.

+

Secondly, the choice to run the UNIX v0 code is optional. If you are +worried about Nokia’s lawyers running you to the ground for running a +50-year old copy of a binary image for a machine that is almost +completely non-existent, you can just not do so. Delete the lines from +the Makefile and sleep well. You still have two other +UNICES to play with.

+

What about the other two UNIX variants? These are both covered by +licences that allow me to use them. Back in 2002, Caldera International +released Research Unix versions 1-7 and 32V under a [permissive BSD-like +license] 12. BSD UNIX is based off of v7 UNIX, and of +course has its own permissive BSD licence. And in 2017, Nokia also +released versions 8-10 under the condition that it will not assert +copyright rights for non-commercial use.

+

So the newer UNICES are in the clear. I doubt anyone actually cares +about version 0 either, but technically it’s still under copyright.

+

PDP-11/40

+

So if I have a PDP-7 emulator, how do I run operating systems that +expect a PDP-11? Simple… I emulate a PDP-11/40 on the PDP-7. I +have written PDP-7 assembler code to emulate a PDP-11/40 with the +following equipment:

+ +

This required a few tweaks to the emulator. The first problem is that +the RK05 disk is about 2.5 MB, but the RB09 is only about 2 MB. That’s +easily solvable – just add more tracks to the RB09. UNIX v0 is unlikely +to notice (although the number of tracks is a compile time parameter, +and the v0 build commands set it to the correct value).

+

The second problem is that we are emulating a system that can have up +to 124K words of memory on a system with only 8K words total. That meant +I needed to virtualize the PDP-11/40’s physical memory (and add a few +more tracks to the disk to hold the virtualization).

+

A large amount of time was spent tuning this code to be efficient. +The memory virtualization uses part of the 8 Kword memory as an LRU +cache, and uses a number of first-level microcaches to avoid having to +do the LRU updates. This also serves to offload the complexity of the +PDP-11’s segmentation logic from a large number of memory accesses (the +PDP-11 does as many as eight accesses per instruction). Despite the +super fast emulated disk, the PDP-7 code in the emulator is slow, mostly +because it has to do a bunch of divides to convert the linear disk +offset into a BCD-coded track and sector for the emulated RB09. I/O +polling is again used, except this time it uses the PDP-7’s “skip on +flag set” I/O instructions. As with the PDP-7 emulator itself, the +PDP-11 emulator dynamically measures the instruction throughput relative +to the line-clock tick, so that it only polls for I/O a few times per +tick.

+

The one remaining problem is building the disk images themselves. +Since the PDP-11’s disk is 16-bit, but the PDP-7’s is 18-bit (which the +emulator stores in 32-bit ints), a conversion program is +needed to unpack the binary disk images from 16 bits per word to 32. +This in turn needs to be done in the Makefile using standard POSIX +tools, which aren’t exactly good with binary. I had a weirdly clever way +to do this with od(1), awk(1) and +uudecode(1) that I will leave as an exercise for the +curious, but I decided it would be easier to do it with the PDP-7 +emulator itself, feeding a simple program in on its boot tape. This +required an additional tweak to the emulator, since by default its +console TTY is not eight-bit clean (in fact, UNIX v0 expects to see the +MSB set on the terminal reads, and sets it on writes, what is called +“mark” parity). This is also enabled by a compile-time setting (used +only for the builddisk program).

+

Despite the complexity of the PDP-11 instruction set and its emulated +I/O devices and the corresponding primitiveness of the PDP-7’s +instruction set, the emulation itself is a surprisingly small amount of +code, not really taxing the 8K word memory, with about 2.25 Kwords of +actual code and a similar amount of space for the memory virtualization +cache and disk block buffer, leaving nearly half (3.5 Kwords) of the +memory unused. The simulator executes somewhere around 250 PDP-7 +instructions per PDP-11 instruction. On my laptop, the PDP-7 is running +somewhere in the neighborhood of 70 MIPS, which means the PDP-11 is +running at about 0.3 MIPS, which is probably not too far off of its +actual speed (the cycle time of an 11/40 was around a microsecond for +simple instructions, but could be proportionally larger for instructions +that did multiple memory accesses, which many did).

+

As an aside, although the idea of emulating the PDP-11 on an emulated +PDP-7 came about from the realization that I needed a response to the +late-discovered licence issue, I’m quite pleased with the result – it +enables an interesting window on the dawn of the UNIX era. I feel that +someone should complete the circle here by emulating a VAX 780 on the +PDP-11 and run 4.2BSD on it, so that we can get the [original runtime +environment used for the first IOCCC] 13.

+

Compile-time Options:

+

The following command flags control the compilation:

+ +

What is the ASCII art +supposed to be?

+

The ASCII art represents a torn piece of [paper tape] 14.

+

Acknowledgements

+

None of this could have been possible without the hard work of

+ +

Finally, thanks to my spouse for putting up with the many hours I +spent on this nonsense, and treating “I’m working on my IOCCC entry” as +an acceptable answer to queries about how I was spending my free time. +Similarly, I apologise to those friends and coworkers who had to listen +to me complain about obscure corner-case bugs in my code. The obsession +is over, at least until next time…

+
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2018/mills

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2018/poikola/index.html b/2018/poikola/index.html index 1f58f2c3a..77b17a314 100644 --- a/2018/poikola/index.html +++ b/2018/poikola/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,319 @@ - - + + + + + + - - -2018 poikola - - + + + +2018/poikola + + + + + -

2018 poikola

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2018/poikola

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2018/poikola/index.html

- +
+ ← mills + ↑ 2018 ↑ + vokes → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Timo Poikola
+Location: FI

+ + +

To build:

+
make
+

To use:

+
./prog
+

Try:

+

On a terminal that supports 24 bit color, has black background, and +size at least 125x38, try:

+
./try.sh
+

Judges’ remarks:

+

It is said by some students of Astronomy:

+
Oh, Be A Fine Gal, Kiss Me!
+Oh, Be A Fine Gentleman, Kiss Me!
+

Many Mnemonic +variations exist. You might wish, on a star, to better understand +the colors being displayed. And those in the deep south might wish to go +north for a better view.

+

Author’s remarks:

+

How to build:

+
cc -o prog -std=gnu11 -O3 prog.c
+

or

+
make
+

Poster:

+

You can generate an A3 sized poster by make docs. This +command creates a pdf file poikola.pdf.

+

Introduction:

+

It was a starry night when my wife pointed her finger up and asked: +“What is this star and may I have some Easter eggs?”

+

So I had to sit down and solve those tricky questions with Nano and a +C compiler.

+

Little spoilers:

+

Basically, the program draws animated ASCII art of the Big Dipper +using Annie Jump Cannon’s spectral classification system of stars and I +think the colors of the output are as accurate as possible.

+

This program also tells once in a year if it is correct time to find +and eat some Easter eggs.

+

The program has also at least three other functions, obvious and not +so obvious.

+

Technical jargon

+

This program has been tested on xterm and Konsole and also Linux +virtual terminal. Color support in the terminal is not necessary, but +the effect is better with it.

+

This entry has partial support for terminals with a white background +but the best viewing experience is achieved when the terminal in use +supports 24-bit colors, has a black background and the size is at least +125x38.

+

Special note for Mac users: Terminal.app does not work +as expected; you might need xterm from XQuartz (see FAQ 3.7: How do I compile and use on macOS, an +IOCCC winner that requires X11?) or some other working terminal. +Thanks to Dave Burton for +spotting this problem.

+

The main reason for the header unistd.h is +getdelim(3) but once I included it I also abused other +functions and #defines. This header is mutually exclusive +with -std=c11.

+

The program was developed with little-endian machines; I tried to +support big-endian too, but this support is somewhat limited.

+

This program has been compiled with:

+
    +
  1. i386 (Debian Stretch) with gcc and clang
  2. +
  3. amd64 (Debian Buster) with gcc and clang
  4. +
  5. Raspberry Pi 3 (Debian stretch) with gcc and clang
  6. +
  7. Lego Mindstorms EV3 Intelligent Brick (Debian Jessie) with gcc and +clang (in this case, compiling time with clang-3.5 12 seconds and with +gcc 27 seconds)
  8. +
+

Extra +notes from the judges on the macOS Terminal.app problems:

+

Depending on the settings of the terminal in Terminal.app the program +might not show anything at all. In other cases it won’t show all the +colours right but mostly is okay. YMMV, as they say.

+

Warnings and +restrictions required by law:

+

Please do not feed little babies chocolate.

+

Major spoilers:

+

I incorporated the Fletcher 16 +checksum algorithm into the source for security reasons; it might be +challenging to make changes without breaking the main functionality of +the code.

+

The space after #define p return is necessary.

+

The computus (method to determine the date of Easter) uses an +algorithm described in the journal Nature in 1876. It should be valid +for Gregorian calendars.

+

Some obfuscation techniques +used:

+
    +
  1. I tried to use meaningless or misleading variable names. For +example, this program draws the Big Dipper with the correct colors, but +variables like o, b, and a are +used in totally unrelated tasks.
  2. +
  3. I reused and recycled variables almost every time when +possible.
  4. +
  5. Unnecessary use of predefined stuff like +__ATOMIC_SEQ_CST.
  6. +
  7. When I was a kid, my favorite programming language was Pascal. In +Pascal, there are things like begin; and end; +instead of curly brackets. They are used also in my code, but I had to +shorten them to meet size requirements.
  8. +
  9. I also have strong Perl background, and therefore I added some +dollar signs to the code. One of the first ideas was to write all +variables with prefixed $, but then I rejected it.
  10. +
+

If you think you understand how this program works, can you answer +these questions:

+
    +
  1. What is the value of aI_ after line 21?
  2. +
  3. Why are there some big numbers on line 47?
  4. +
  5. How is the scaling effect created?
  6. +
  7. How do you change a single bit, without changing the +functionality?
  8. +
+

Rot18 part

+

Because the rot13 is too easy to decode with the plain eyes, I +decided to use the Caesar cipher +with the key 18:

+
Lzw xajkl tsffwj ak wfugvwv mkafy AWWW 754 xdgslk gf dafw 47. Al ak hjaflwv
+gfdq gf dalldw-wfvasf esuzafwk.
+

If you want to or must know and don’t know how to decipher this, you +might look at the Caesar +cipher decoder. Find the text that says:

+
Manual decryption and parameters
+Shift/Key (number)
+

and enter 18 and then click the button that says: +DECRYPT (BRUTEFORCE).

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2018/poikola

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2018/vokes/index.html b/2018/vokes/index.html index b532e2599..b1df17720 100644 --- a/2018/vokes/index.html +++ b/2018/vokes/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,382 @@ - - + + + + + + - - -2018 vokes - - + + + +2018/vokes + + + + + -

2018 vokes

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2018/vokes

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2018/vokes/index.html

- +
+ ← poikola + ↑ 2018 ↑ + yang → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Scott Vokes
+Location: US

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2018 +vokes in bugs.md.

+

To use:

+
./prog < file.txt
+

Try:

+
./try.sh
+

Judges’ remarks:

+

What this program does is not witchcraft and there are no spectres, +but you might have a meltdown trying to work it all out (look at the +source code to understand this better).

+

This entry is designed to mislead in many ways. However, if you find +yourself wanting to know the possibilities for navigating a graph, you +will get the answer you seek with no hocus pocus.

+

Author’s remarks:

+

Introduction:

+

This program reads a directed graph (as lines with integer node IDs), +and prints the graph’s nodes in reverse-topologically sorted order, +grouped into strongly connected components. Given a set of nodes +representing targets and edges representing dependencies between them, +it produces a build order with any dependency cycles gathered.

+

For example, the following input (provided as example-1.txt):

+
0 4 8
+1 0
+2 1 3
+3 2
+4 1
+5 4 6
+6 5 2
+7 3 6 7
+

would be interpreted as:

+
0 -> 4, 8
+1 -> 0
+2 -> 1, 3
+3 -> 2
+4 -> 1
+5 -> 4, 6
+6 -> 5, 2
+7 -> 3, 6, 7
+

So, node 0 has edges to / depends on nodes 4 and 8, node 1 depends on +node 0, and so on. Then, it groups the graph’s nodes into strongly +connected components and prints them in reverse-topologically sorted +order:

+
0: 8
+1: 0 1 4
+2: 2 3
+3: 5 6
+4: 7
+

It uses Tarjan’s +strongly connected components algorithm for the grouping and +reverse-topological sorting, along with a bonus hidden implementation of +counting sort, which sorts each group.

+

For other details about the input format, see Issues and Limitations.

+

Building:

+

To build:

+
    ${CC} -o prog prog.c -std=c11 -O3 \
+        -Wall -Wextra -pedantic -Wno-missing-prototypes
+

-Wno-missing-prototypes is necessary because there +aren’t any prototypes. (They would put the program well over the size +limit.)

+

Note: The program can also be built with -std=c99 or +-std=c89.

+

If building with -Weverything, then +-Wno-strict-prototypes may also be necessary – the function +pointer declarations for _ and B may get +warnings otherwise, for reasons described next in Obfuscations.

+

Obfuscations:

+ +

Issues and Limitations:

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2018/vokes

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2018/yang/index.html b/2018/yang/index.html index 0ae9baa4f..3eeef15fd 100644 --- a/2018/yang/index.html +++ b/2018/yang/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,303 @@ - - + + + + + + - - -2018 yang - - + + + +2018/yang + + + + + -

2018 yang

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2018/yang

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2018/yang/index.html

- +
+ ← vokes + ↑ 2018 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Don Yang
Location: +US

+ + +

To build:

+
make
+

To use:

+

The author suggested that after compilation one should look at the +generated files. For instance:

+
less generated1.c
+less generated2.c
+less generated3.c
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Code should be readable in any direction! This tool will help you +rotate your code so you don’t have to stare at it sideways or even +upside down. Rotating this program left and recompiling will reveal +other tools including a right rotate and a shift program.

+

Strange things happen when the +world is upside down! It is entirely possible that this remark is +completely misleading.

+

What exactly does the shift program do?

+

Like a great sliding puzzle (hint) this entry has six more programs +that will reveal messages and one more tool that can be used to reveal +the final message hidden in the original source. All of these can be +created using combinations of ./left, ./right +and ./shift and the additionally generated programs.

+

The final message can be revealed using

+
./msg9 < prog.c
+

But what combinations will generate ./msg3, +./msg4, ./msg5, ./msg6, +./msg7, ./msg8 and finally +./msg9?

+

Author’s remarks:

+

Tools’ usage:

+

Nuko is a text rotator: given some text in +stdin, Nuko will write the same text to +stdout, but rotated 90 degrees counterclockwise.

+
cc prog.c -o left
+./left < input.txt > rotated_counterclockwise.txt
+

Due to static memory allocation, only the first 1K columns by 1K rows +are rotated, the rest are silently ignored. But fear not, a separate +tool with dynamic memory allocation is included:

+
./left < prog.c > r1.c
+cc r1.c -o right
+./right < input.txt > rotated_clockwise.txt
+

For variety, this second tool rotates clockwise instead of +counterclockwise. Also, it can handle files larger than 1024x1024, +depending on how much memory you have.

+

Of course we wouldn’t stop with just two rotations, if we continue to +rotate counterclockwise once more, we get another program. This program +outputs a single message to stdout, which is the name of +the series that Nuko came from.

+
./left < prog.c | ./left > r2.c
+cc r2.c -o msg0
+./msg0
+

There is one final rotation, which produces a tool that removes +leading whitespaces:

+
./left < prog.c | ./left | ./left > r3.c
+cc r3.c -o shift
+./shift < input.txt > no_leading_space.txt
+

Where this might be useful, besides ruining the formatting of certain +files, is that it completes the set of tools needed to solve the puzzle +that is embedded in prog.c.

+

Puzzle box:

+

Notice how the edges of prog.c contain two +notches. By rotating prog.c and removing leading +space, the code would be shifted one space toward one of those notches +(and create a new notch on the other side). This shifted code behaves +slightly different from the original program. For example, here are two +more messages that can be produced:

+
./shift < prog.c | ./right > msg1.c && gcc msg1.c -o msg1 && ./msg1
+./shift < prog.c | ./left > msg2.c && gcc msg2.c -o msg2 && ./msg2
+

In total, there are 9 embedded strings that can be produced via a +sequence of rotates and shifts, one of which can be used to extract the +10th final string from prog.c. The intent is to +simulate those wooden puzzle boxes that can be opened by pushing and +shifting various well-concealed seams. Thus, finding the correct +sequence of rotates and shifts is left as an exercise to the reader (but +if you are really lazy, just read the Makefile).

+

Source code for all the tools needed to solve this puzzle are +embedded in prog.c, all you need is a C +compiler.

+

Features

+ +

Compatibility:

+

Nuko and the rotated tools accept only ASCII files where +each character maps to exactly one byte. Also, end-of-line sequence is +assumed to be LF only, as opposed to CR-LF. All control characters are +treated like normal printable characters, so files containing tabs will +look weird after rotation, for example.

+

Nuko has been verified to work with these compiler / OS +combinations:

+ +

Nuko compiles without warnings with all compilers above, +even with -Wall -Wextra -pedantic for gcc and clang.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2018/yang

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2019/adamovsky/index.html b/2019/adamovsky/index.html index bcf577d0a..732a36d80 100644 --- a/2019/adamovsky/index.html +++ b/2019/adamovsky/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,456 @@ - - + + + + + + - - -2019 adamovsky - - + + + +2019/adamovsky + + + + + -

2019 adamovsky

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2019/adamovsky

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2019/adamovsky/index.html

- +
+ ← duble + ↑ 2019 ↑ + last entry + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Ondřej +Adamovský
Location: CZ

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2019 adamovsky in bugs.md.

+

To use:

+
./prog file.unl
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Even after pre-processing and indenting, the C code of this entry it +is about as understandable as the Unlambda code.

+

Pretending that we don’t know a bit of functional programming :) and +lacking a better way to understand the entry but to fuzz it, we stumbled +on a string of bytes which crashed it:

+
````.0`.0`.0`c.0``sssss
+

Functional programming is not a panacea against core dumps, after +all.

+

This can be demonstrated by:

+
./prog crash.unl
+

Author’s remarks:

+

A highly structured +state state machine

+

Purpose:

+

The purpose of this program is to allow you to play Colossal Cave +Adventure as implemented by Kunihiko Sakamoto. As that was written in Unlambda programming language +designed by David Alexander Madore it has to be an Unlambda +interpreter.

+

Aesthetics:

+

The program grew a bit too long so I had to use several macros to +downsize it. That unfortunately reduced my options for program layout. I +decided to separate it into two portions: the initial macro section +where I had limited resources which you should disregard its shape, +unless you like it, and the rest, which is a separator in the form of a +single line followed by a section signifying the function of the +program, a block with removed shape of lambda character. Even the +official IOCCC size tool acknowledges this: When you call +./iocccsize -i <prog.c, using the 2019 version of iocccsize, iocccsize +returns 955, which is the Unicode codepoint of the +λ character.

+

It might be a surprise for you that according to the IOCCC size tool +the program is actually a one-liner. It certainly was for +me. I like to think the tool is overwhelmed by the sheer length of the +dividing line and totally overlooks the rest of the program.

+

Usage:

+

When built directly using

+
make
+

the program (prog) accepts a single parameter with the +name of an Unlambda program. You can download the Colossal Cave Adventure (the advent.unl file) and run it like this:

+
./prog advent.unl
+
+

NOTE: the file was added to the entry so there is no need to download +it.

+
+

You can also try other programs from the Web. Many example programs +are in the official Unlambda distribution on the +Unlambda homepage. The most complex programs there are entries from quine contest.

+

There is an alternative build path that requires the 2018 IOCCC size +tool to complete. Put the tool source iocccsize_2018.c in the project directory +and call

+
make identify
+

It will build the tool and use it to build an alternative program +prog2, which in turn will produce an Unlambda program +identify.unl. make identify runs this program +to identify itself.

+

The base program (prog) implements an interpreter of +Unlambda 2.0. It recognises all its builtins (k, +s, i, v, c, +d, .x, e, @, +?x and |) including the syntactic sugar +function r and formatting properties in the form of +ignoring whitespace and comments to the end of line introduced by the +# character.

+

In case of wrong usage (missing Unlambda program file or missing +parameter) or use of an unseekable (fseek(3)) Unlambda +program source if it uses the c function, the program +returns the message fail. It also informs you about +syntactic errors in the Unlambda program should there be any (but only +when the execution reaches them).

+

The Unlambda source file may contain several Unlambda programs. The +interpreter will run them all in sequence.

+

Unlambda

+

If you want to familiarise yourself with the language, visit its Wikipedia page for a brief +introduction or its homepage for an in depth +discussion. For further reading you can visit Wikipedia pages on Lambda Calculus and Combinatory Logic.

+

You can also play with an online interpreter by GitHub +user inazz. There you can debug one of the example programs provided or +try your wits in writing your own.

+

Hints:

+

Here are some pointers where to start when trying to understand the +interpreter:

+ +

Obfuscation sources

+ +

More on this in the Spoilers section.

+

Build notes:

+

The program does not require any special treatment by compilers. Some +warnings had to be suppressed when compiling with +-Wall -Wextra -pedantic. Those were produced because of the +formatting of the source code, not any programming technique. +Compilation with clang -Weverything produced many more +warnings, but those are only relevant for multi-source-file projects and +some are really questionable +(e.g. -Wdisabled-macro-expansion).

+

Portability:

+

Development was done on Debian 9 on x86-64 architecture using mainly +Clang 3.8.1-24 and GCC 6.3.0. The source is C11 compliant and does not +use any special properties except the following:

+ +

Spoilers:

+ +

Identification spoiler:

+

The alternative build path make identify output +commemorates a previous IOCCC winner which uses +similar methods to mess with the size tool.

+

Judges’ spoilers:

+

It is not a bug, it is a feature. :)

+

The crash is caused by a stack overflow. Conventional Unlabmda +interpreters implement the Unlambda execution stack using data +structures on the heap. This interpreter uses the C call stack for this +purpose. In a conventional interpreter, the judges’ program would +consume memory until the user (or the operating system) would lose +patience. The C call stack is usually of a limited size and protected, +so this interpreter crashes, when the judges’ program depletes the +stack. You can always increase the maximal stack size through the system +settings (on Linux) or compiler options (on Windows) if your Unlambda +program needs it. Nevertheless, it will not help the judges’ program +which quickly depletes any limit you define.

+

The judges, pretending to not know what they are doing, created a +program that grows Unlambda execution stack indefinitely. You may +consider it an Unlambda anti-pattern. Normally, infinite cycles in +Unlambda work by creating two functions and applying one to the other +which creates further functions to apply. The application of the +function frees its position on the stack. This program builds one ever +growing function that will never be complete and be able to be +applied.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2019/adamovsky

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2019/burton/index.html b/2019/burton/index.html index 0bf4cd72d..02b185b6c 100644 --- a/2019/burton/index.html +++ b/2019/burton/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,258 @@ - - + + + + + + - - -2019 burton - - + + + +2019/burton + + + + + -

2019 burton

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2019/burton

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2019/burton/index.html

- +
+ ← lynn + ↑ 2019 ↑ + dogon → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Dave Burton
+Location: US

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2019 +burton in bugs.md.

+

To use:

+
./prog < file
+
+./cow file
+

Try:

+
./try.sh
+

Judges’ remarks:

+

A tiny, but punctually correct way of POSIX counting for text files. +This one line, one word, 127 character beauty continues to expand the +number of classic unix utilities available as winning entries.

+

You might find the author’s commentary on +one liners interesting.

+

Author’s remarks:

+

Synopsis:

+

Feed it anything on stdin. The output should look +familiar.

+

Compiles cleanly with:

+
WARN="-Wno-implicit-int -Wno-missing-variable-declarations -Wno-parentheses"
+cc -Wall -Wextra -Weverything -pedantic $WARN -include stdio.h -o prog prog.c
+

Description:

+

Included is a test script, useful for the corner cases. As in all +good Unix programs, it is silent upon success; any output demonstrates +an error. Instead of checking correctness, the check.sh script can simply output the results: (The +Makefile contains the spoiler):

+
out=cat ./check.sh ./prog
+

Interestingly, and a spoiler here: macOS and FreeBSD implement the +common utility “correctly”. CentOS and Ubuntu both share a “flawed” +utility that changes output format based upon input redirection or +pipeline(!). As well, the latter two also behave slightly differently on +what they count as whitespace: \a and \b are +both counted whitespace(!), even though the relevant man pages on these +systems omit these characters from the description.

+

This program follows FreeBSD and macOS, the arbiters of correct for +these purposes.

+

Limits:

+

Requires the C locale and ASCII character set. Input should be less +than ten million octets “toavoidthisproblem”.

+

See Also:

+

You can enjoy this code from beginning to end. No whitespace was +harmed in the creation of this program. All your base belong to us, but +the constants seem a bit … off?

+

Bonus

+

The script cow.sh provides a closer analog, and +perhaps a more useful interface.

+

Included is a version without compilation warnings:

+
cc -Wall -Wextra -Weverything -pedantic -include stdio.h -o prog.clean prog.clean.c
+

Bugs

+

The flags are not supported. Although they could easily be added into +cow.sh. This exercise left to the reader.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2019/burton

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2019/ciura/index.html b/2019/ciura/index.html index d5d5f974d..74aea88fd 100644 --- a/2019/ciura/index.html +++ b/2019/ciura/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,377 @@ - - + + + + + + - - -2019 ciura - - + + + +2019/ciura + + + + + -

2019 ciura

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2019/ciura

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2019/ciura/index.html

- +
+ ← mills + ↑ 2019 ↑ + diels-grabsch2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Marcin Ciura
+Location: PL

+ + +

To build:

+
make
+

There is an alternate version available. See Alternate code below.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2019 +ciura in bugs.md.

+

To use:

+
./getwords.sh en | grep .. | ./prog string
+

Try:

+
./try.sh
+

Alternate code:

+

There is an alternate version of this code that flushes +stdout after writing a newline. See the Author’s remarks +for more information.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use prog.alt as you would prog above.

+

Alternate try:

+
./try.alt.sh
+

Judges’ remarks:

+

A few letters, one at a time, with no repeats. How many different +ways can this be done?

+

While a quick brown fox might jump over the lazy dog, it has too many +repeat letters to allow this entry to repeat. It is better that Mr Jock, +TV quiz PhD, bags few lynx.

+

Speaking of jumping, can you rewrite the code to remove all of the +goto jumps in this code?

+

Author’s remarks:

+

What is this?

+

This entry reads from standard input a list of words in any language +written with an alphabet and outputs perfect pangrams composed of these +words. A perfect pangram is a series of words that contains every letter +of the alphabet exactly once.

+

Example execution:

+
$ grep .. /usr/share/dict/words | ./prog abcdefghijklmnopqrstuvwxyz
+qualm fjord wiz pyx vs beg kc nth
+quartz jinx vs fed kc womb glyph
+quid jamb fez vs pyx kc growl nth
+quiz fjord pyx vs bag kc mewl nth
+quiz fjord pyx vs gab kc mewl nth
+quiz fjord pyx vs gem bawl kc nth
+quiz fjord pyx vs meg bawl kc nth
+quiz fjord vex bawl kc gyp ms nth
+quiz jamb flex vs kc gyp word nth
+quiz jamb pyx vs kc flog drew nth
+quiz jamb pyx vs kc frog lewd nth
+quiz jamb pyx vs kc frog weld nth
+quiz jamb pyx vs kc golf drew nth
+quiz jamb pyx vs kc grew fold nth
+quiz jamb pyx vs kc grow nth fled
+quiz jamb pyx vs kc growl fed nth
+

Rearranging the words into more or less meaningful expressions is the +user’s duty.

+

This entry implements Algorithm X (Exact cover via dancing +links) from Section 7.2.2.1 in fascicle 5C of The Art of +Computer Programming by Donald E. Knuth. As of June 2019, you can +download an incomplete draft of the fascicle from Knuth’s +website, converted to PDF as fasc5c.pdf for +your convenience.

+

Usage:

+

./prog LETTERS [N]

+

reads allowed words from standard input and writes perfect pangrams +with at most N words composed of LETTERS to +standard output, one per line. If N is not given, the +number of words in the pangrams is unlimited. The characters in +LETTERS must not repeat. The length of LETTERS +must not exceed 97 characters.

+

The exit status is 0 if no error occurred, 1 if the input word list +is too long, and 2 if the command-line arguments are missing.

+

Helper scripts:

+ +

Miscellaneous remarks:

+

I dare submit this entry to categories algorithms, +internationalization (I have not found active use of +<wchar.h> among the programs that won IOCCC in the +past), and obscure bugs (see the questions about Linux core +dumps below).

+

To a casual eye, this entry may look similar to 2005/klausler. However, +prog is internationalized and way faster. On my machine, +./klausler abcdefghijklmnopqrstuvwxyz printed only 3,965 +perfect pangrams until I killed it after 144 hours running, while the +equivalent +tr A-Z a-z < /usr/share/dict/words | egrep -v '^[^ais]$' | ./prog abcdefghijklmnopqrstuvwxyz | wc -l +finished in 62 minutes, reporting 1,640,569,315 perfect pangrams, and +the example from section What is this? finished in +1.35 seconds. On the other hand, prog can only output +series of words with non-repeating characters, unlike +klausler.

+

In contrast to prog.alt.c, prog.c does not call fflush(stdout) after +outputting each line, thus running faster. I am grateful to Witold +Jarnicki for suggesting this change. The original prog +finished the example above in 100 minutes instead of 62 minutes.

+

If your word list contains meaningless one-letter words, pipe +grep .. [FILE] through prog to eliminate the +pangrams that contain them.

+

According to prog and aspell, some +languages, e.g. Spanish, have no perfect pangrams.

+

Why does yes | ./prog y hang on Linux? Change +static int to int and +static wchar_t to wchar_t, and recompile +prog. Why does yes | ./prog y dump core now? +Change the line #define P 9<<23^1 to +#define P 9<<23 and recompile prog. Why +does yes | ./prog y exit gracefully?

+

Answer: As of June 2019, thus manifest bugs in glibc +2.22–2.29: 1 naq +2.

+

The source code uses goto three times. While it could +easily get by without goto M and goto H, I +challenge the adherents of structured programming to refactor +goto T, which jumps back into a nested if +block.

+

With the supplied Makefile, both +gcc and clang compile prog.c without warnings in C11 and C99 mode. For a +clean compilation with gcc -std=c90, add +-Wno-format to CSILENCE in +Makefile.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2019/ciura

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2019/diels-grabsch1/index.html b/2019/diels-grabsch1/index.html index 6ed0ec17a..a4183549a 100644 --- a/2019/diels-grabsch1/index.html +++ b/2019/diels-grabsch1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,231 @@ - - + + + + + + - - -2019 diels-grabsch1 - - + + + +2019/diels-grabsch1 + + + + + -

2019 diels-grabsch1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2019/diels-grabsch1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2019/diels-grabsch1/index.html

- +
+ ← giles + ↑ 2019 ↑ + poikola → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Volker +Diels-Grabsch
Location: DE

+ + +

To build:

+
make
+

To use:

+
./prog < file > file.Z
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Finally, IOCCC now has its own text compression program, and it is +short enough to qualify for the Best Short Program award! That said, can +you compress it down to a one-liner, still producing files in the UNIX +compress format, albeit sacrificing the compression ratio?

+

Can you explain why the /dev/zero file compresses +identically by the entry and the standard compress(1) tool +(see try.sh), but the text file compresses +differently? The judges know. :)

+

Author’s remarks:

+

A tiny “compress” tool:

+

Usage:

+
./prog < input.txt > input.txt.Z
+

Example:

+
./prog < guidelines.txt > guidelines.txt.Z
+

Check for correctness:

+
zcat guidelines.txt.Z > guidelines2.txt
+diff -s guidelines.txt guidelines2.txt
+

Of course you can also use 2015/mills2 instead of +zcat to verify the output file. The achieved compression +ratio roughly matches that of the classic Unix compress(1) +tool. And the source code is very compressed, too: It has exactly the +same size as the paragraph you are reading right now. And exactly the +same shape. Nevertheless, it is portable C99 code that runs on 32-bit +and 64-bit platforms. It compiles without warnings on both GCC and Clang +even with -Wextra and -Weverything.

+
+

2023 note: the above paragraph might not be true as far as number of +bytes goes.

+
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2019/diels-grabsch1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2019/diels-grabsch2/index.html b/2019/diels-grabsch2/index.html index 93cfacae5..791b06346 100644 --- a/2019/diels-grabsch2/index.html +++ b/2019/diels-grabsch2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,334 @@ - - + + + + + + - - -2019 diels-grabsch2 - - + + + +2019/diels-grabsch2 + + + + + -

2019 diels-grabsch2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2019/diels-grabsch2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2019/diels-grabsch2/index.html

- +
+ ← ciura + ↑ 2019 ↑ + endoh → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Volker +Diels-Grabsch
Location: DE

+ + +

To build:

+
make
+

To use:

+
./prog
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Before running this one, stay calm. Chill out, have a cup of tea. Is +this bad?

+

To understand what is going on here, please check if you are +dreaming, or are you dreaming that you are dreaming? Or is it, wake up +from the simulation?

+

Author’s remarks:

+

Almost a hash collision:

+

This program prints its own SHA-512 hash. To verify, run:

+
$ sha512sum prog.c; ./prog
+43bd0c4381a5078d2850fca9ae5e0647596bcc03cd67d8d973ad02ff35c316c728e7b347ca70abe6c74e745e63646cc7643cb0cffcd3d9a969cbf31a7ce5bf68  prog.c
+43bd0c4381a5078d2850fca9ae5e0647596bcc03cd67d8d973ad02ff35c316c728e7b347ca70abe6c74e745e63646cc7643cb0cffcd3d9a969cbf31a7ce5bf68
+

It started as a complicated “hello world” program that prints some +random hex digits instead of “hello world”. Then, the digits were +adjusted until the resulting program matched its own SHA-512 hash, via +brute force through all 2^512 possibilities. Just kidding.

+

This wasn’t brute force, but involved quite some math, using a +variant of Jane Doe’s algorithm for generating SHA-512 collisions +efficiently. If you still don’t believe me, you are right.

+

No crypto was broken in the making of this program!

+

The trick is that under the hood, this program is a quine! That is, +it is aware of its own source code in string representation. But instead +of printing that string (its own source), its SHA-512 hash is computed +and printed. So two major steps were needed to obfuscate this +program:

+
    +
  1. Hide the quine.
  2. +
  3. Hide the SHA-512 computation.
  4. +
+

Note that both steps were achieved mostly algorithmically. The code +is otherwise as short and as clean as possible. The implementation is +portable C99 code for 32-bit and 64-bit systems that compiles without +any warnings on current GCC and Clang versions even with +-Wextra -Weverything. The program is composed of mostly +pure functions, and the #defines are only used to shorten +redundant parts of the code, they are not meant to obfuscate much. +Having that out of the way, how are step 1 and step 2 achieved then?

+

Regarding step 1, note that the large string literal

+
"`x{bh}ndbq..."
+

in the last line doesn’t look like C code. Moreover, it is too short +to contain even a compressed representation of all preceding and +subsequent code. Instead, the preceding code including the +" character has already been run through the SHA-512 +computation by an external script. The internal state of the SHA-512 +computation at that point has been extracted and encoded into the +string. This works because the preceding code is exactly 1280 bytes, +which is a multiple of 1024 bits, the block size of SHA-512. The program +itself then just continues the SHA-512 computation from that point, +adding the last 1024-bit block, finalizing the hash and printing it. The +last block is taken directly from the string literal at runtime, plus +the subsequent code which consists of just ", +; and \n. Those 3 characters are short enough +to be hidden in … well, let’s leave this as an exercise for the +reader.

+

To summarize, the main trick here is to move the string constant to +the end, so the preceding code can be pre-calculated and the subsequent +code is short enough to be hidden anywhere.

+

Regarding step 2, almost all macros, functions and variables have +meaningless single-letter names. Moreover, the SHA-512 computation is +reduced to the special case of adding just one block and immediately +finalizing it, where the total size is known in advance.

+

But this is not enough! For SHA-512 we need 8 initial hash values and +80 round constants, which are very characteristic. If any of them +appeared in the source, a quick web search (e.g. for +0x428a2f98d728ae22) would tell the reader immediately +what’s going on. Because of the pre-computation, the 8 initial hash +values are not needed, but the 80 round constants are.

+

It is almost impossible to hide those 640 bytes in the source. +Luckily, the round constants where not chosen by fair dice rolls. They +are the fractional parts of certain irrational numbers, namely, the cube +roots of the first 80 primes. So the round constants are calculated at +runtime, which makes the program shorter and adds another layer of +obfuscation.

+

While this sounds like just iterating primes and executing +pow(3), this turned out to be harder than expected. If we +were computing SHA-256, it would have been as simple as that, because +the round constants would have been 32-bit values. However, SHA-512 +needs the cube roots at 64-bit precision, while double has +only 53-bit mantissa precision.

+

Using higher-precision floating point is no option here, because the +program is meant to be portable C99. And implementing +arbitrary-precision arithmetic would have been overkill and would have +increased the program size dramatically.

+

Instead, the program just multiplies. That is, it computes cubes +instead of cube roots. It steps through cube root candidates via +bisection, and calculates their cubes until those match the given prime. +Thus, we don’t need floating point and can use 64-bit integers instead. +But that still doesn’t solve the problem as it poses the following new +challenges:

+ +

The reason for challenge 1 is that in portable C99, the result must +fit into the same data type. To multiply two 64-bit integers we would +need a 128-bit integer for the result. So we can at most multiply two +32-bit integers to get the 64-bit product at full precision. While GCC +and Clang both support 128-bit arithmetics, that isn’t standard and +wouldn’t have been portable C99.

+

The reason for challenge 2 is that cube root of the 80th prime is +around 7, so we need to compute with 3 bits for the integral part and 64 +bits for the fractional part.

+

The reason for challenge 3 is that the cube of a 67-bit number is +3*67=201 bits, but fortunately we only need to check if it +is close enough to the actual prime. It won’t be exactly +409.0000... anyway, but must be accurate enough to +distinguish the correct cube root from its neighbours, e.g. the same +number with the 64th fractional digit increased.

+

The solution here is to split the 67-bit input into 3 integers of +24-bit each. Those are cubed using the multiplication formulas numbers +with 3 “digits” of base 2^24 each. During that calculation, +at most two values are multiplied at once, and the accuracy of +intermediate values is reduced using right-shifts as far as allowable +for the computation. Finding working right-shift values was mostly +trial-and-error, producing correct results for the first 80 primes, but +not much more. Moreover, for some terms it was possible to leave them +out entirely, especially higher-order terms of the last digits. Luckily, +in the end, all intermediate results did fit into 64-bit integer +addition and multiplication, but that was not obvious at the +beginning.

+

That’s it.

+

Well, I could continue with details about the encoding of the +internal state values into the string, how to avoid escaping issues, how +to find short notations for various loops, how to get rid of +if(), where the final "\";\n" is stored, how +to eliminate intermediate values and arrays by reordering of operations, +and so on. But those were all minor issues compared to the challenges +described above. What’s documented here is all you need to know to write +your own version of that program.

+

I’d like to finish with an open problem:

+

Is it possible for the cubing and bisection to be implemented with +just two parts instead of three? That would simplify the formulas a lot. +For example, one could split the 67-value into two 34-bit parts, but +whenever one multiplies two of them, one needs to right-shift one of +them by at least 4 bits, or both by 2. Or, one splits the 67 bits +asymmetrically? I was unable to make it work with 2 parts, but that +doesn’t have to mean anything.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2019/diels-grabsch2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2019/dogon/index.html b/2019/dogon/index.html index 49ba45ed1..b8a0b1b93 100644 --- a/2019/dogon/index.html +++ b/2019/dogon/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,449 @@ - - + + + + + + - - -2019 dogon - - + + + +2019/dogon + + + + + -

2019 dogon

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2019/dogon

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2019/dogon/index.html

- +
+ ← burton + ↑ 2019 ↑ + karns → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Gil Dogon
+Location: IL

+ + +

To build:

+
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 2019 +dogon in bugs.md.

+

To use:

+
./prog < pattern.mc
+

Try:

+
./try.sh
+

Make sure that you keep focus of windows in mind when going back and +forth to the program and the script.

+

Judges’ remarks:

+

1991/davidguy, 2011/blakely, …

+

…This entry likely concludes the IOCCC category “Cellular automata +simulators”; it would be very hard to beat it on its field.

+

FYI: The .mc extension stands for +Golly macrocell format.

+

We truly have not much more to add, except two things:

+ +

In the interest of saving lives, this entry was not fuzzed.

+

Author’s remarks:

+

What is it?

+

Just run with no arguments on an X11-compatible system using one of +the supplied input .mc files as standard input. Press +- several time to zoom out if necessary, then press space. +For acceleration press ] several times. That’s rather quick +don’t you think?

+

Historical Timeline

+ +

Which brings us to the present moment in time.

+

Full documentation and keys +UI

+

Yes, this program is a Conway’s Game of Life graphic simulator +implementing Bill Gosper’s hashlife algorithm. The entry’s UI is rather +terse and somewhat obfuscated, as it should be. Also, when you, +accidentally or not, press any of the keys not specified below, some +stuff will happen or not, there is no guarantee whatsoever.

+

The program should be used as follows:

+

The standard input should contain a Golly macrocell format file for a +two state automaton. See: http://golly.sourceforge.net/Help/formats.html. Of +course only Conway’s GOL rules are supported, so rules in the files are +ignored. The supplied input examples should be quite interesting. Except +one, all are taken from Golly’s standard distribution. Information and +credits to their designer are in the header comment of each.

+ +

Notice that when going backward in time we ignore the current time +step setting and just jump by the amount that was specified before. +However going forward is always using the current time step.

+

There is a minimal text printout by the program, so you can know what +Generation your are in (G:), Internal memory allocated till +now (M:), and then which Level is the current macrocell +(L) and which zoom Scale you are watching +(S).

+

Portability issues

+

This entry is quite portable hopefully on most modern platforms. It +assumes X Window support of course. More than 2GB of memory is +recommended. Configuration through Makefile is +provided for the display windows size and for the memory usage. The +Makefile provided configuration (Z=0x20000000) will need a +system with 4GB DRAM to run nicely. There are several other salient +assumptions though:

+ +

Limitations:

+

Foremost the entry is very strict, unsafe and picky regarding its +input. Anything straying from the standard Golly macrocell legal format +will result in undefined behavior, meaning mostly a very defined core +dump. Since aforementioned core is rather large by default (about 4GG) +it is highly recommended to set the core dump size limit to 0 in the +shell before playing with fire …

+

This entry needs quite a lot of memory to be effective, but by modern +standards that is not too much. It does not do any garbage collection, +so sooner or later memory will run out, resulting, surprise, surprise, +in a core dump. On the plus side, this enables the nice time reversal +feature… Anyway the amount of memory used can be controlled by the +Makefile -DZ=... argument. With the default Z, +the program will support in total about 240 million 64bit +longs for the internal memory, which should be sufficient +for about 100 million nodes+leafs, as each node is 3 longs +and each leaf is 2.

+

Important: Makefile Z define must be a power of +two!

+

Zooming out past about S58 scale will enter a buggy twilight zone as +only long integers are used in the drawing code. Reverting +to doubles could have remedied that, but then I’d need to +use a lot of ldexp()s which would take the program over the +size limit. Also the program will crash once the universe goes past +level 64, though this is simply fixed by modifying a single constant in +the program, can you find it ? Anyway 2^58 squared is quite +a big enough universe for such a tiny program to simulate, no ?

+

In case cell memory did not run out, or your pattern did not grow too +big, and you have had patience enough and did not increase speed too +much, you can run out of the history buffer after 33333 +steps.

+

If all of the above did not happen and result in the expected core +dump, you will encounter the final limitation, which is the absence of +an escape key. Just close the window or use ^C/intr to exit +….

+

Warnings

+

Oh don’t get me started on the torrent of litanies gcc emits when +used with -Wall! Does it think I have not memorized by +heart C’s precious operator precedence table (or at least have a cheat +sheet nearby) that it dares suggest extra parentheses that would take +the program over the limit ? And what if I do not use a variable here or +there, do I have to pay extra tax for every orphaned variable?

+

There is the reasonable warning about some longs printed +as ints but its OK too, trust me.

+

Then there’s the warning about gets(3) being unsafe, +which is indeed the only one that appears by default in some versions of +gcc linker. Yes Virginia, I know it is unsafe, and I would not recommend +anyone using this entry as part of a web daemon, or a spaceship, no, +seriously don’ do that.

+

Obfuscations:

+

Well almost none of the obfuscations are done on purpose, but mostly +out of necessity, so all identifiers possible to be one character, are, +and they are mercilessly reused. In the main() function +there’s even a nice little identifier first used as a global and then +reused (shadowed) in the same scope, and this did not produce +even a little squeak of a warning from the compiler! Macro compression +is rather sparingly used, however magic numbers abound everywhere, and +bit twiddling is magical too. Do you know for example why we have +unsigned F=-1 ? (No warning there of course :) Hint: Later +in the program you have F/=17. Did that make any sense? +Further hint: print the resulting F in hexadecimal…

+

And yes, the layout hint involves a mix of the most trendy +typographical character juxtaposed against a very ancient one, not to +mention the program includes some famous name dropping and documents +itself as usual.

+

Further +spoilers, engineering, and obfuscation galore:

+

Those wait for you, curious and intrepid reader, in the attached apholife.c file, which is a partially obfuscated +version of the program I wrote with a lot of helpful annotations and +comments for myself and posterity, revealing some of the magic under the +hood. This program is also a somewhat improved version which uses +ldexp()s in the draw routine and has bigger constants, so +it can zoom up to level 1024 if memory allows, and it tries its best to +avoid dumping core on the poor user when its memory runs out, rather it +enters freeze mode where you can still travel in calculated frozen +space-time. Well, it’s not nice and tame, it even has an escape key, +usage message, and to top it all it even avoids +gets(3)!

+

Special thanks:

+

To Tom Rockiki, the original co-writer of Golly, a personal friend +and hashlife master, who reviewed some earlier versions of the entry and +freely shared some of his vast knowledge regarding GOL programming and +hashlife. As a free bonus, Tom has allowed me to show his code which is +probably the most efficient yet most obfuscated way of calculating the +GOL function on a 64 bits 8*8 leaf:

+
unsigned long life8x8(long a) { unsigned long aw = a << 1, ae = a >> 1, s0 = aw
+^ ae, s1 = aw & ae, hs0 = s0 ^ a, hs1 = (s0 & a) | s1, hs0w8 = hs0 >> 8, hs0e8 =
+hs0 << 8, hs1w8 = hs1 >> 8, hs1e8 = hs1 << 8, ts0 = hs0w8 ^ hs0e8, ts1 = (hs0w8
+& hs0e8) | (ts0 & s0); return (hs1w8 ^ hs1e8 ^ ts1 ^ s1) & ((hs1w8 | hs1e8) ^
+(ts1 | s1)) & ((ts0 ^ s0) | a); }
+

This uses only 19 bitwise operations and six shifts to calculate the +inner 6x6 next generation bits of the input 8x8 !

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2019/dogon

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2019/duble/index.html b/2019/duble/index.html index eea38cbd5..0de3e8f15 100644 --- a/2019/duble/index.html +++ b/2019/duble/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,375 @@ - - + + + + + + - - -2019 duble - - + + + +2019/duble + + + + + -

2019 duble

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2019/duble

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2019/duble/index.html

- +
+ ← yang + ↑ 2019 ↑ + adamovsky → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Etienne Duble
+Location: FR

+ + +

To build:

+
make
+

There is an alternate version, the original, which does not work well +in macOS. See Alternate code below if you +are curious.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2019 +duble in bugs.md.

+

To use:

+
./prog file
+

Try:

+
./prog /tmp/drawing
+

Open another window / terminal.

+
./prog /tmp/drawing
+

Open more terminals and repeat…

+

You might also wish to try a full screen size. For this try:

+
make clobber fullscreen
+

Alternatively, if you want to change the size, do something like:

+
make clobber LINES=20 COLUMNS=20 all
+

The author provided us with the following table for use:

+
+ +

The mode and current color is indicated at the bottom left corner of +the editor.

+

After editing the file and quitting, try:

+
/tmp/drawing
+

i.e. execute the file.

+
+

WARNING: if the file is deleted it might lock any session still in +use. These will have to be killed from another shell session or by +closing the terminal tab (in other words don’t do this from the +console!). If the file cannot be opened in the beginning this will also +happen. This is discussed in 2019 duble in +bugs.md.

+

NOTE: this entry might leave sockets lying about in the current +working directory which you’ll have to delete manually. This is also +discussed in 2019 duble in +bugs.md.

+

Alternate code:

+

An alternate version of this entry, prog.alt.c, is provided. This alternate code might +not work as well in macOS.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use prog.alt as you would prog above.

+

Judges’ remarks:

+

After starting the program, use the cursor keys, then try some modes, +like p or l (they toggle).

+

Author’s remarks:

+

Introduction:

+

This program is a graphics editor, running in the +terminal.

+

It provides collaborative features: one can join the +drawing session of someone else by just opening the same file!

+

Getting started:

+

The program can run on Linux, FreeBSD, macOS, and in most terminals. +See section Limits, Portability for +more info.

+

To build, type make (assuming gcc) or +make CC=clang.

+

Then you can start the program. It expects a file path as its first +argument:

+
./prog /tmp/drawing
+

(If not started this way, with a file, prog will refuse +to start.)

+

If the file does not exist, you will start with a blank drawing.

+

If someone else (or another instance of yourself, maybe?) is +already editing this file, you will join the session!

+

Edit features:

+ +

The mode and current color is indicated at the bottom left corner of +the editor.

+

Bonus features:

+ +

Obfuscation:

+

You will probably have a hard time analyzing this entry, because:

+ +

A few more things:

+

Did you notice the enum declaration? Could it be just an +int or const int variable, instead? (spoiler: +http://c-faq.com/ansi/constasconst.html)

+

If your keyboard has no arrow keys, you can probably find alternate +keys by reading the source code.

+

Limits, Portability:

+

I tested the program on several Linux systems, on FreeBSD 12, and on +macOS (Mojave).

+

On Linux, the program uses an OS-specific detail to hide +communication artefacts, and avoids the need to remove them on exit. +Since this is Linux-specific, it was not possible on FreeBSD or macOS. +Its behavior is a little more dirty there.

+

The program should work on most terminals that support 8-bit colors, +inverse video mode, and movement escape codes, e.g. xterm, +gnome-terminal, terminator, etc.

+

Note: the drawing files prog generates are probably even +more portable than prog itself!

+

Drawing area size:

+

The drawing +area size is set at compilation time:

+

The default size is the one of my xterm (see top of Makefile). You +may set it to the full size of your terminal window by typing:

+
make clobber fullscreen
+

IMPORTANT NOTES:

+ +

prog.c vs prog.alt.c

+

The file prog.alt.c is the one I +submitted.

+

The judges proposed a small update: the program was using macro +FD_SET inside an expression, which breaks compilation on +macOS. Wrapping this macro into a function was enough to fix this +compilation issue.

+

However, that was not enough to make the program work on macOS. If +you analyse the program you will see that it heavily relies on OS +resources. And, for this first version of the program, you even needed +to increase default sysctl parameters to make it work on +FreeBSD (this was the purpose of file check-os.sh). I tried hard to tune macOS the +same, but failed.

+

The simple fact the Judges proposed this update meant they wish it +could work on Mac. And if the judges wish something, it has +to be done. ;) So I refactored a little more the program to +reduce OS resources consumption. Or maybe not reduce consumption, but +consume them differently… And I obtained prog.c. +With this version, no need to touch sysctl parameters, and +it works on macOS too! I must confess it was challenging to remain below +the size limit with this little change.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2019/duble

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2019/endoh/index.html b/2019/endoh/index.html index a6eff647d..f9c3110b5 100644 --- a/2019/endoh/index.html +++ b/2019/endoh/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,269 @@ - - + + + + + + - - -2019 endoh - - + + + +2019/endoh + + + + + -

2019 endoh

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2019/endoh

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2019/endoh/index.html

- +
+ ← diels-grabsch2 + ↑ 2019 ↑ + yang → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yusuke Endoh
+Location: JP

+ + +

To build:

+
make
+

NOTE: the use of the C compiler optimiser was disabled and +-g was enabled for this entry because it is SUPPOSED to +crash and it needs debugging symbols.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2019 +endoh in bugs.md.

+

To use:

+
./prog
+

Try:

+

If you have gdb(1) installed:

+
./try.sh
+

Note that in macOS installing gdb(1) takes multiple +steps - it’s not just a matter of installing gdb(1) and +that’s that. The try.sh script has only been tested +with linux.

+

You might also wish to try:

+
gdb ./prog || lldb ./prog
+

and then type in r (to run program) and then +bt (for backtrace).

+

Judges’ remarks:

+

The purpose of this program is to crash. You’ll want to have +memorized man 7 ascii when debugging it to reveal its +purpose.

+

Author’s remarks:

+

backtrace quine:

+

Compile prog.c with no optimization.

+
cc -g -O0 -o prog prog.c
+

Then, run it. You will see a segmentation fault.

+
$ ./prog
+Segmentation fault (core dumped)
+

Let’s debug. As usual, run it under gdb.

+
$ gdb ./prog
+(gdb) run
+Starting program: /home/.../prog
+
+Program received signal SIGSEGV, Segmentation fault.
+0x0000000000000000 in ?? ()
+

Okay, check the backtrace.

+
(gdb) backtrace
+#0  0x0000000000000000 in ?? ()
+#1  0x0000555555555201 in x23 () at prog.c:35
+#2  0x000055555555571a in x64 () at prog.c:100
+#3  0x0000555555555747 in x65 () at prog.c:101
+#4  0x0000555555555774 in x66 () at prog.c:102
+#5  0x00005555555557ce in x69 () at prog.c:105
+#6  0x0000555555555828 in x6e () at prog.c:110
+#7  0x0000555555555747 in x65 () at prog.c:101
+    ...
+

See the line numbers and lookup the ASCII table.

+
 35 = '#'
+100 = 'd'
+101 = 'e'
+102 = 'f'
+105 = 'i'
+110 = 'n'
+101 = 'e'
+...
+

One more thing:

+

The original program can be used as a GDB command file.

+
gdb -q -x prog.c ./prog | cat
+Reading symbols from ./prog...done.
+
+Program received signal SIGSEGV, Segmentation fault.
+0x0000000000000000 in ?? ()
+#0  0x0000000000000000 in ?? ()
+#1  0x0000555555555201 in x23 () at prog.c:35
+#2  0x000055555555571a in x64 () at prog.c:100
+#3  0x0000555555555747 in x65 () at prog.c:101
+#4  0x0000555555555774 in x66 () at prog.c:102
+#5  0x00005555555557ce in x69 () at prog.c:105
+#6  0x0000555555555828 in x6e () at prog.c:110
+#7  0x0000555555555747 in x65 () at prog.c:101
+...
+

By using this, you can confirm that it is actually a quine.

+
gdb -q -x prog.c ./prog | sed -n -r 's/#.*:([0-9]+)/\1/p' | awk '{printf "%c",$1}' > prog2.c
+diff prog.c prog2.c
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2019/endoh

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2019/giles/index.html b/2019/giles/index.html index 295cb1cfb..74f11e52b 100644 --- a/2019/giles/index.html +++ b/2019/giles/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,415 @@ - - + + + + + + - - -2019 giles - - + + + +2019/giles + + + + + -

2019 giles

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2019/giles

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2019/giles/index.html

- +
+ first entry + ↑ 2019 ↑ + diels-grabsch1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Edward Giles
+Location: AU

+ + +

To build:

+
make
+

To use:

+
./prog infile.wav outfile.wav
+

Try:

+
play MonodyVocals.wav
+./prog MonodyVocals.wav
+play out.wav
+

NOTE: play comes from SoX, the Swiss Army Knife of sound +processing programs. If you don’t have this installed, see FAQ 3.10: How do I compile and use an IOCCC +winner that requires sound.

+

Judges’ remarks:

+

Do you need to pretend enjoying a more spacious living environment +than you actually are in, or the great outdoors with mountains and +canyons, when recording your outgoing voicemail message? Then don’t +waste another minute! Record yourself, send the audio file through this +entry, and let your callers be surprised.

+

Author’s remarks:

+

Description:

+

This program takes a WAV audio file as input, and applies an +artificial reverberation effect to it. It works by feeding the audio +through a number of delay lines of various lengths, with various amounts +of feedback, to create a smooth echo that fades away over time. A number +of parameters of the effect can be altered, to change its sonic +characteristics.

+

BlockDiagram.png is a block-diagram of +the internal structure of the reverb algorithm, which is most likely +easier to understand than the source code.

+

MonodyVocals.wav is for testing the +program: It is an extract of the unprocessed vocals from Monody by TheFatRat, +featuring Laura Brehm. The track was published under a free +license.

+

This program has also been successfully compiled on Windows, with +both the Tiny C Compiler and +Microsoft’s C/C++ compiler. However, the latter reports warnings about +loss of information when converting floats, and that +void (*)() and void (*)(void) are not the same +thing.

+

Interesting fact: The size of the program from +./iocccsize -i is 2019.

+

How to use:

+
./prog input [output [size [dry [wet [damping]]]]]
+prog.exe input [output [size [dry [wet [damping]]]]]
+ +

The values size, dry, wet, and +damping can be specified either as decimal numbers +(e.g. 0.35) or as percentages (e.g. 35%).

+

The default settings are designed to make the effect obvious rather +than subtle, so it may be a good idea to adjust the ratio of “dry” to +“wet”, to give a more pleasant result:

+
./prog in.wav out.wav 1.8 80% 15%
+

The program only supports WAV files, and only mostly. Other audio +formats, such as MP3, are not supported because they are difficult to +decode, but there are free programs such as ffmpeg that can +perform the conversion. Some of the advanced features of the WAV file +format are also not supported, such as metadata, 3 or more channels, or +a bit depth other than 16 bits. Fortunately, WAV files that don’t use +these features are very common. The program validates the input file, so +passing it a file it can’t process will cause the program to print +Bad input file or +Wave file must be 16 bits,1-2 channels. depending on what +it thinks the problem is. If the output file cannot be opened, the +program will print Can't open output file.

+

Assumptions:

+
    +
  1. The code is compiled using the C99 or C11 standard.
  2. +
  3. Values are stored in memory in little-endian order.
  4. +
  5. float is a floating-point type of any size, such that +all zero bits represents the number zero.
  6. +
  7. int16_t and int32_t are 2’s-complement, +sizeof(int16_t) == 2 and +sizeof(int32_t) == 4.
  8. +
+

Obfuscations

+

The main obfuscation is that digital signal processing algorithms are +inherently opaque. They just consist of iterating through a list of +floating-point numbers and performing a series of arithmetic operations +on each value. Even if this entry were entirely cleaned of all other +obfuscation, it will appear to the average programmer to do the +following:

+ +

Note that no part of the above description of the code’s function had +anything to do with echoes in a room. The purpose of the code is +therefore hidden.

+

The source code, on cursory inspection, appears to be a jumbled +series of characters arranged into three arcs, representing sound waves. +The overall layout distracts people from the fact that it is source code +rather than only ASCII art, and the random appearance of the code +discourages people from trying to decipher it.

+

#defines are used to abbreviate the code, which has a +side effect of making it very slightly harder to read.

+ +

Every variable name is one letter long. This allows the code to fit +into the IOCCC size limit, and it also makes the purpose of a given +variable much less clear. For example, it is not evident from the name +of the variable t that it contains pointers to the +delay-line arrays.

+

As many values as possible have been crammed into arrays. +float w[] contains:

+ +

int32_t f[] is even more multi-purpose. It contains:

+ +

All of the strings are concatenated together and “encrypted” by +breaking the string into 4-byte chunks (by casting it to an +int32_t*), and then XORing the sequence of +ints with a known numeric sequence. The “decryption” is not +done in-place, to avoid writing over the string constant.

+

int32_t *c is a pointer that points into +f[], except that it is often incremented or decremented +when it is accessed. In order to determine which indices of +f[] are being accessed through c at any given +point in the code, you would have to locate the places where +c is modified.

+

In order for this program to read and write WAV files, it needs to +parse the header. The necessary information, such as the sample rate and +channel count, is defined by the standard to be in somewhat arbitrary +locations within the file. Therefore, even if you know which indices of +f[] are being accessed, it takes extra effort to look up +the WAV file format and determine which field that corresponds to.

+

Some array accesses (which make up most of the program) have been +replaced with harder-to-interpret equivalents, for example:

+ +

Assignments return the assigned value, allowing them to be included +into later expressions: +10[f]=f[13]<<2; f[1]=20+10[f]+k; is replaced with +f[1]=20+(10[f]=f[13]<<2)+k;.

+

This technique is used in conjunction with the comma operator to +further obscure where the data ends up. For example:

+ +

A few other miscellaneous obfuscations have also been done:

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2019/giles

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2019/karns/index.html b/2019/karns/index.html index 6f0b49b20..ae5875e16 100644 --- a/2019/karns/index.html +++ b/2019/karns/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,258 @@ - - + + + + + + - - -2019 karns - - + + + +2019/karns + + + + + -

2019 karns

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2019/karns

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2019/karns/index.html

- +
+ ← dogon + ↑ 2019 ↑ + mills → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Joshua Karns
+Location: US

+ + +

To build:

+
make
+

NOTE: we disable the optimiser because this program has problems with +it enabled.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2019 +karns in bugs.md.

+

To use:

+
./prog < textfile_that_fits_on_the_screen
+

You might want to type:

+
reset
+

after running the program to restore the terminal to its previous +state.

+

Try:

+
./try.sh
+

If you have more time you might want to try:

+
./prog < README.md
+

Judges’ remarks:

+

If you typically get lost in mazes, watching this program run might – +or might not, YMMV – teach you how to find your way in a maze. The +algorithm is well-known but the drawing is amazing!

+

Before running, make sure that your terminal can accommodate the +whole file. Before running make test, make it about 120x40 +to be safe, ensuring that you see the @ sign as well as the +exclamation mark.

+

…Oh, and the first M in YMMV stands for “mazing”.

+

A puzzle for the reader: Can you change the program to consider a +diagonal movement as one step?

+

Author’s remarks:

+

The Program:

+

This program is pretty simple! It performs a breadth first +search on the specified graph. The graph can be any ASCII text file +that has an ‘at’ (@) character, which is going to be the +starting location, and a ! character which will be the +destination.

+

The nodes on this graph that are spaces are connected with any +directly adjacent nodes that are also spaces. Nodes that aren’t spaces +are not connected with anything.

+

Compiling and Running:

+

This program usually compiles under both GCC and clang. Build +with:

+
$(CC) -std=c99 -o tbfs prog.c
+

where $(CC) is cc, gcc, clang, or some other C +compiler.

+

You can then run it with:

+
cat <input file> | ./tbfs
+

Examples:

+
./tbfs < maze
+./tbfs < prog.c
+

Issues

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2019/karns

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2019/lynn/index.html b/2019/lynn/index.html index 746623767..ebd03aaac 100644 --- a/2019/lynn/index.html +++ b/2019/lynn/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,443 @@ - - + + + + + + - - -2019 lynn - - + + + +2019/lynn + + + + + -

2019 lynn

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2019/lynn

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2019/lynn/index.html

- +
+ ← poikola + ↑ 2019 ↑ + burton → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Ben Lynn
Location: +US

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2019 +lynn in bugs.md.

+

To use:

+
./prog
+

Try:

+
./try.sh
+

Judges’ remarks:

+

A fully functional compiler. The example prints out the 30th Fibonacci +number.

+

Author’s remarks:

+

Remarks:

+

A Haskell compiler. Supports a subset of Haskell more than large +enough to self-host. Like GHC with custom language extensions:

+ +

Building:

+

Build the compiler:

+
cc -o prog prog.c
+

Demos:

+

Fibonacci numbers:

+

Test the compiler on fib.hs:

+
(./prog < fib.hs ; cat prog.c) > fib.c
+

Compiling the output produces a binary that prints the 30th Fibonacci +number.

+

The file ghcfib.hs includes fib.hs with some glue code, and shows GHC also accepts +our subset of Haskell:

+
ghc ghcfib.hs
+

Self-hosting compiler:

+

To avoid spoiling this entry by revealing the original Haskell +source, we instead provide hint.hs, the output of +a certain stage of the compiler when run on itself. This intermediate +output is hopefully difficult to understand, yet is accepted by our +compiler:

+
(./prog < hint.hs ; cat prog.c) > hint.c
+make hint
+./hint
+

The output program behaves like the compiler itself.

+

Unlike the original source from which it is derived, GHC fails to +compile hint.hs. This is because values have been +replaced with their Scott +encodings by this stage, which messes up type-checks; we’d need +equirecursive types for it to work.

+

Regexes:

+

The file lol.hs contains an adaptation of Doug McIlroy’s elegant +code from “Enumerating the strings of regular languages”. We +exercise it by showing the first entries of the length-ordered list of +all strings consisting of the characters a and +b that contain an even number of as.

+
(./prog < lol.hs ; cat prog.c) > lol.c
+make lol
+./lol
+

A GHC wrapper is provided:

+
ghc ghclol.hs
+

Strongly-connected +components:

+

See scc.hs (and its GHC wrapper ghcscc.hs) for an elegant way to print the +strongly-connected components of a graph in reverse topological +order.

+
(./prog < scc.hs ; cat prog.c) > scc.c
+

It expects the input to be in a similar format as a previous entry +(2018 vokes). For example:

+
make scc
+./scc < example-1.txt
+./scc < example-2.txt
+

The output should agree, though our program omits line numbers and +does not sort entries within a line. (Also, our program only treats +spaces as whitespace, and supports any non-space character in a vertex +name.)

+

Syntax

+

Some claim Haskell syntax is frightening because braces and +semicolons are optional. Some complain about a zoo of twisty little +operators, all alike. Our compiler addresses such concerns by making +braces and semicolons compulsory, disabling layout-based rules, making +every operator left-associative with same precedence, and only defining +6 primitive functions:

+
: + - * / <=
+

The arithmetic operations behave as they do in C on +unsigned ints, and (:) is Haskell’s +cons function. Like Haskell and unlike C, +(<=) returns a Bool (which are Church +booleans behind the scenes) and not an Int.

+

No ifs, ands, or buts. Define them yourself. No tuples. Who needs +them when algebraic data types delivers a better product? There is no +do. No where. No list comprehensions. No unary operators.

+

Let expressions and operator sections are supported.

+

Within global scope or a let expression, each definition can only +refer to itself or previous definitions. This implies we can only +achieve mutual recursion by having one function pass itself to +others.

+

Caveats

+

The only primitive type is Int. In particular, they +represent characters. To interoperate with GHC, our compiler treats any +undefined functions as the identity function, so that we +may freely use ord and chr (or +fromEnum and toEnum) to make our code +acceptable to both compilers.

+

The main function is the last function to successfully parse. It +should have type [Int] -> [Int], and our compiler treats +this like the function passed into Prelude.interact, that +is, the entire standard input is passed to this function, and the result +is printed to standard output.

+

Bool must be defined as:

+
data Bool = True | False;
+

so that it matches the Scott-encoded booleans internally used by the +primitive function (<=).

+

The alternatives in a case expressions must list every +data constructor in the order they are defined. For example, if we +have:

+
data Foo a b = Bar a | Baz | Qux Int [b]
+

then a case expression that examines a term of this type +must have the form:

+
case x of
+  { Bar a    -> ...
+  ; Baz      -> ...
+  ; Qux n bs -> ...
+  }
+

We stress braces and semicolons are required. Our fussy parser treats +semicolons as separators, not terminators.

+

The effect of erroneous input is undefined. It may be best to develop +with GHC, but even then, be mindful of changes needed because of issues +caused by the uniform operator precedence and the touchy format of +case alternatives.

+

Why?

+

One-letter variable names abound in IOCCC entries, and for good +reason. These tiny pieces of confetti are hard to read, and leave room +for more code. Then why not go further and use zero-letter variable +names? That is, tacit programming or point-free style.

+

I had been playing with an algorithm devised by Oleg Kiselyov that +effortlessly and efficiently eliminates those pesky variables, leaving +behind terms composed from a small set of combinators. No need for +lambda lifting or supercombinators.

+

By adding a handful of lines of mostly parsing code, we get a Haskell +compiler, or rather, a compiler that accepts a subset of Haskell +sufficiently large to self-host. You might say I wrote a tool for this +contest, then ran it on itself to make an entry for it.

+

Obfuscation techniques:

+

Even with Kiselyov’s algorithm and some term rewriting, the compiler +only fit after compression, which naturally obfuscates the code. More +tricks were needed to fit within the size limits.

+ +

Other obfuscation techniques are better appreciated after decoding +the compiler. See hint.hs.

+ +

Warnings:

+

On my system, it compiles cleanly with -Wall with older +standards, e.g. -std=c89, but less cleanly if +-pedantic is also supplied.

+

Compiling the compiler output with -Wall triggers a +warning about a strange-looking comment.

+

Behind-the-scenes commentary:

+

My +website reveals how this compiler works.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2019/lynn

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2019/mills/index.html b/2019/mills/index.html index c55e8c915..25d0d5c2c 100644 --- a/2019/mills/index.html +++ b/2019/mills/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,802 @@ - - + + + + + + - - -2019 mills - - + + + +2019/mills + + + + + -

2019 mills

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2019/mills

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2019/mills/index.html

- +
+ ← karns + ↑ 2019 ↑ + ciura → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Christopher +Mills
Location: US

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2019 +mills in bugs.md.

+

To use:

+
make cpclean
+# Let this run for about about an hour and then kill it:
+./prog Shakespeare.txt
+

Try:

+
./try.sh
+

However, as the binary model files used to produce the output are in +an implementation-specific format, your mileage may vary.

+

Judges’ remarks:

+

Can a machine learn?

+

Some say so.

+

But can a machine learn to write like Shakespeare? Can it write rules +and guidelines for the IOCCC?

+

You decide. :-)

+

Author’s remarks:

+

Welcome to OMLET! 🍳:

+

OMLET is the Obfuscated Machine Learning Environment +Toolkit, a micro-framework for experimenting with recurrent +neural networks (RNN). OMLET lets you build, train and evaluate deep neural +networks (DNN). Why invest hours reading documentation and megabytes +of disk space on a full-featured DNN framework like TensorFlow or Torch when you can have full RNN +functionality in less than 4 KB!

+

OMLET has the following features:

+ +

OMLET is based on Andrej Karpathy’s +character-level language +model as described in his blog post The +Unreasonable Effectiveness of Recurrent Neural Networks. I’ve +included a small sample dataset to use for training, but you can have +even more fun by downloading some larger datasets:

+ +

Getting started with OMLET

+

OMLET has three operating modes:

+ +

For your first OMLET experiment, we will try training a simple +single-level RNN to write some Shakespeare +plays. Start by typing

+
make
+

After it builds, train it using

+
./prog Shakespere.txt
+

This will immediately start outputting gibberish to the output, +e.g.

+
./prog Shakespere.txt
+

produces:

+
sins ohennAu
+T-teooclelp tiThoWy
+
+g
+nlakuafy
+e
+sselW usnsofueB Aoee pasfUsuslhe ooM ot Wou moy
+me neltAl -no IoyI mhuyakse  inT-l chu ghenn ffo? fnsoe yhyye
+ue nnfrlass heUthole saounlcesyee pee
+t,
+T0:0% 3.210888
+o',,vU
+ An ,hTf lnm  Far rur:s moilt WoEgrv wonds mith Aog thernw
+Rni So
+co Nnd :
+For an bImy pgafoun:
+Wf'r hom wortiverita
+int fod mous Eheledet,
+Tho he theket nonS wnu-ang dorlaMSp
+nrocWiSe tflg 'o.
+T0:0% 2.995950
+d whecedhencrysesil yr bn,
+we hh y thiwt
+
+
+hut fithlot,
+Fmdy s he alt
+Vh th no dh foud bobt werw:s Aotnf Fhwi't whe, eusu
+
+lhh thele wewcond ary soupfy wind tDont couc ths:
+er fucwald oncli hen bos, f
+T0:1% 2.878945
+

The gibberish is the networks attempt to write a play. So far, it’s +not very successful! Between the chunks of gibberish are training +progress reports that look like

+
T0:1% 2.878945
+

This tells you that we are 1% through training epoch 0, and that the +training loss +is about 2.88. As the training continues, the training loss will reduce +and the generated snippets will improve quickly:

+
ses, kuth
+LAs of the wish,
+As, I nos you,
+Yov not to nalll,
+Tr tot wonds.
+
+First Sondy, llt lrte, our, tw.
+
+First.
+
+BRUTUS:
+Helsting the kith gops of hoch Whay, fars surd what to,
+The cownens golt te.
+T0:12% 2.259114
+eplerrotrur tandans one wiok thy or thach and cullice ded yourssting
+And wours:
+Whed ur surt.
+
+SINENIUS:
+On we lain bith
+rerytund: tich lon hyivetetgor.
+
+VOLUONIA:
+He brich nom dove worthan then wise,
+T0:13% 2.254926
+

It’s already started to figure out things about Shakespeare plays – +how to spell short English words, how long lines tend to be, and that +characters take turns speaking with their names capitalized. The +training loss has dropped to 2.25 and the improvement is noticeable.

+

Eventually, we will finish with the training data set and move on to +a validation cycle:

+
y fath onother,
+I sucess,
+For I me the west crare.
+
+TRANIO:
+Whow and'd have not to had you you one in my lapteny she very ame come me a gut and shourd aghir you as ignested; shend to make I strem
+To h
+T0:99% 1.924063
+ notnce gaud and is nicked thou day, ha the dusing you disaid: in thim, you things in ere thee thus erile Iht that tare theme my hast thesp thou shay: thou not eaten-or-ho-bess resing: I the but had d
+T0:99% 1.923128
+V0:0% 1.678907
+V0:9% 1.700527
+V0:18% 1.733179
+V0:27% 1.714891
+V0:36% 1.716672
+V0:45% 1.782946
+V0:54% 1.835629
+V0:63% 1.876108
+V0:72% 1.906814
+V0:81% 1.924096
+V0:90% 1.954492
+V0:99% 1.969287
+serfs you'll alliencseard:
+We
+got you? before
+I say.
+
+Farstred dentlentecaly, sir, I it one bosticield
+All me the backnour mino,
+Whith capitaned mid! but stell the ifvemion
+Willerity.
+
+First Cumfol of
+T1:0% 1.885619
+

Validation cycles are used to test the network to see if it has +learned to generalize – how well it performs on data it hasn’t seen +before (as opposed to the training data that the network will see many +times as it trains). Progress on the validation set is also displayed +with a validation progress report that looks like

+
V0:36% 1.716672
+

which means we are 36% of the way through the validation for epoch 0, +and the validation loss is about 1.72. Comparing the validation loss and +the training loss will give you an idea of how well the network is +learning and can let you know if the network is overfitting or +underfitting.

+

As part of the training process, the data set (which for OMLET is the +Shakespeare.txt file you gave on the +command line) is divided into training +and validation sets (by default, 95% of the data is used for +training, but like most OMLET parameters, you can change this at +compile-time).

+

At the end of the validation run, OMLET writes out a checkpoint file +with a name like cp01_1.970. This saves the state of the +run at the start of the epoch 1, after computing a validation loss of +1.970. The checkpoint is helpful if you need to stop and restart +training. You can stop training by doing Control-C.

+

You can continue training from a previous checkpoint by providing the +checkpoint file name as the second parameter, for example:

+
./prog Shakespeare.txt cp01_1.970
+

After the validation cycle finishes, OMLET begins the next epoch by +restarting training at the beginning of the training set. Training +continues forever, until you quit it with Control-C. You +should monitor the checkpoints to see that the validation loss continues +to drop. If it rises, the network has probably started to overfit on the +training data.

+

Once you’ve trained the validation loss as low as it will go, you can +use OMLET to run the network in inference mode which uses the frozen +checkpoint parameters to generate data. Inference mode takes the +checkpoint file as standard input (not on the command line) and +hence must be run with a command like

+
./prog < cp55_1.807
+

Running it produces an infinite amount of generated output, until you +hit Control-C to stop it.

+

Note that if you decide to change networks or use a different input +file, you will want to delete all the checkpoint files because the +format depends on both the network and the input – using the wrong +checkpoint is likely to cause a crash.

+

Experimenting with +different networks

+

The default network for OMLET (the one you get if you type +make with the executable name prog) is the +simplest recurrent neural network. It looks like

+
h = tanh(Wxh * x + Whh * h' + Bh)
+y = Why * h + By
+

where

+ +

The W’s and B’s are the trainable +parameters of the network, and the process of training is optimizing the +values of these parameters to minimize the loss of the network across +the training set.

+

It is the presence of the hidden state vector that allows the RNN to +“remember” the past. We can see what would happen if we removed this +hidden state. If you type

+
make lin1
+

OMLET will create an ADALINE network that +does

+
y = Wxy * x + By
+

This is a simple linear feed-forward +network. You can run it with

+
./lin1 Shakespeare.txt
+

The linear network won’t be able to get past the gibberish stage, +because it lacks history:

+
./lin1 Shakespeare.txt
+

produces:

+
UERond w,
+
+
+Gir:
+KINof s, mesther s thouth.
+E:
+KINTret, at fu,
+GOMy t, as sth kesewit sooos atse ang k, ck,
+Sotheouserivesthecowhet been's, t he, h nre; t and, har wiread of pincer cedst sur has, ut:
+
+T14:67% 2.465115
+UKESpan,
+NGaromy soreate e m esewfoure pamitherarjulthengeoly tl.
+NG s at e! w.
+
+WAllinoully?
+Wamisw ofilem:
+I'delandinarrstath har aksubly s cath Whern t Is, weciss:
+
+GLat s; llde.
+Y aterit dsthence
+T14:67% 2.465404
+

It is able to guess at what character is likely to follow the current +one (by doing a linear +regression), but it lacks any history beyond that to guide it.

+

You might be wondering about the role of the tanh(3) +function in the RNN. tanh(3) acts as an activation +function which adds nonlinearity +to the network and allows it to solve complicated problems. Without +nonlinearity, all of the linear functions would fold together into a +single matrix-vector multiply and you’d effectively regress to the +linear network above. Alas, even adding a nonlinearity to the +feed-forward network (creating a perceptron) does not +improve the performance because we still lack the history provided by +the hidden state vector (although if you want to try it yourself, you +can do so with make per1 - note that’s not +perl the language but per with the digit +1).

+

Going deeper:

+

We can try to improve the RNN’s performance by stacking RNN modules +atop each other:

+
h1 = RNN(h1', x)
+h2 = RNN(h2', h1)
+y = Why * h2 + By
+

with RNN(h, x) defined as above. Each RNN module has its +own set of parameters and its own hidden state vector. This will improve +the network’s performance, at the cost of a much larger parameter +space.

+
+

IMPORTANT NOTE: Since OMLET uses the system stack +for network storage, larger networks may cause OMLET to crash (typically +with a message like Segmentation fault) unless the system +stack size is first increased. The exact command for doing so depends on +your shell and your system’s hard limits. On +sh/ksh/bash shells, you can view +the hard limit with ulimit -Hs and set it with +ulimit -s 65532 (replacing 65532 with the +actual hard limit). On csh/tcsh shells, you +can view the hard limit with limit -h stacksize and set it +with limit stacksize 65532 (replacing 65532 +with the actual hard limit).

+
+

You can try the deeper network by doing

+
make rnn2
+

(or even make rnn3 if you want a three-layer RNN) and +train it with

+
./rnn2 Shakespeare.txt
+

The additional depth should allow the network to make better +predictions (it can represent more complicated history), but it may take +a long time to train -- both because the network (being larger) now +requires more time to train and because of the vanishing +and exploding gradient problem, which might keep it from ever +reaching its potential.

+

LSTMs and GRUs

+

RNNs are particularly hard to train because they are trained using backpropagation +through time. The RNN is trained by effectively converting it into a +non-recurrent network by making many copies of it and propagating the +hidden state through the copies. During training, the backpropagation +through many clones of the network amplifies the gradient, worsening the +exploding and vanishing gradient problem.

+

Long +Short Term Memory networks (also called LSTMs) were developed to +solve this problem. Christopher Olah gives a good description of them at +his blog +posting. You can build a two-level LSTM by doing

+
make lstm2
+

and train with it with

+
./lstm2 Shakespeare.txt
+

The LSTM is much easier to train because it explicitly decides how to +update its hidden state via “gates”. These gates are called

+ +

The basic LSTM equations are

+
f = sigmoid(Wxf * x + Whf * h' + Bf)
+i = sigmoid(Wxi * x + Whi * h' + Bi)
+o = sigmoid(Wxo * x + Who * h' + Bo)
+c = f * c' + i * tanh(Wxc * x + Whc * h' + Bc)
+h = o * tanh(c)
+

Where

+ +

There are several LSTM variants (see C. +Olah’s blog post for more examples). One important one is the gated +recurrent unit. GRUs are simplified versions of an LSTM which +combine the gates together, meaning they require fewer learned +parameters. This allows them to train faster than a generic LSTM. You +can build a two-layer GRU with

+
make gru2
+

Building your own networks

+

The OMLET Makefile comes with one-, two- and three-layer +RNNs, LSTMs and GRUs, along with simpler feed-forward networks like +multi-layer perceptrons and a linear network. This isn’t the limit of +OMLET’s power – you can create your own networks by modifying the +Makefile. Networks are passed in on the compiler’s +command-line by using -D directives. The network is defined +by a -DNW='...' command which consists of a series of +comma-separated assignments. For example, the simple one-layer RNN could +be defined like

+
-DNW=' x  = I(n), hp = I(128),                  \
+       h  = C(hp, T(A(L(128, x), L(128, hp)))), \
+       y  = L(n, h)'
+

The network declares x as an input vector (there must be +a declaration for x). It is declared as I(n), +which is an input vector of size n, which is the number of +characters of the input alphabet (OMLET computes this from the input +file at the start of training). OMLET will arrange to present the input +character as a one-hot vector based on +the current input character.

+

The second declaration, hp, declares the previous hidden +state vector (what we called h' above). We declare this to +be of size 128 – an arbitrary choice. A larger state vector can +(theoretically) carry more state, but at a cost of larger parameter +matrices and longer training time. You can experiment with increasing +the hidden vector size and see.

+

The third line is the core of the RNN. It sets h, the +hidden vector output to be the sum of two linear elements specified by +L. The L function takes two parameters – the +output vector size (which must match the size of h) and the +input vector. L will compute y = W * x + B +where each L has its own W (weight) and +B (bias) training parameters. Both x and +hp are sent through L and the result passed +through the A function, which does vector addition. That +result is passed through T which does element-wise +tanh(3) activation.

+

Next, we wrap the whole thing with the C function. +C connects hp with h, causing the +new value of h to be passed to the hp vector +on the next iteration of the algorithm (allowing the RNN to retain state +in h).

+

Finally, the whole result is passed through another instance of +L, this time producing a vector of size n, +which will have the negative log likelihood +function. This is assigned to y, which is the output of the +network (and hence must also be declared).

+

OMLET will take the y result and pass it through the softmax +function, which converts the log probabilities into a probability +distribution. In inference mode, this is used to select the next +character to emit. In training mode, this is used to generate the loss +which is backpropagated.

+

As an example of a more complicated network, we can look at a +two-layer GRU network:

+
-DHS=128,                                 \
+-DNW=' x  = I(n),                         \
+       y  = L(n, MD(MD(x)))'              \
+-DBK=' hp = I(HS),                        \
+       z  = S(A(L(HS, x), L(HS, hp))),    \
+       r  = S(A(L(HS, x), L(HS, hp))),    \
+       c  = T(A(L(HS, x), L(HS, hp))),    \
+       zc = OG(1, -1, z),                 \
+       h  = C(hp, A(M(zc, hp), M(z, c))), \
+       y  = h'
+

We are using a few new tricks here – first, we are defining +HS as the size of the hidden and cell vectors. There’s +nothing special about this name, it’s just convenient to specify it so +we don’t have a bunch of constants in the code. Second, the network +itself is very simple – it declares x and has the matrix +that converts the HS-sized hidden vector back to the +n-sized alphabet vector… but it now calls MD, +which is the user-definable module (here we are using it twice, to have +two cascaded GRU blocks). The MD function performs the +sub-network defined by the BK compile-time parameter +(specified in the -DBK='...' setting). This sub-module +again takes an x parameter and produces a y +output. Inside it, we declare hp and h, the +previous and current state vector, plus equations for the various GRU +gates (these use S for the sigmoid activation function). +One final new call is OG which does offset and gain, +performing y = offset + gain * x where offset +(the first parameter) and gain (the second) are constants. +We are using this here to compute (1 - z) for the GRU’s +linear interpolator.

+

The full set of available function blocks follows:

+ +

Note: even if you don’t use MD in your network, you +should still define BK by adding -DBK='y=x' to +the command line, otherwise you will get a compile-time error.

+

Hyperparameters

+

OMLET has a large number of training and inference parameters which +can be changed by the user. All of these are set by -D on +the compile command line. The list of hyperparameters follows:

+ + +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2019/mills

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2019/poikola/index.html b/2019/poikola/index.html index 66e573a39..006a60e08 100644 --- a/2019/poikola/index.html +++ b/2019/poikola/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,408 @@ - - + + + + + + - - -2019 poikola - - + + + +2019/poikola + + + + + -

2019 poikola

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2019/poikola

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2019/poikola/index.html

- +
+ ← diels-grabsch1 + ↑ 2019 ↑ + lynn → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Timo Poikola
+Location: FI

+ + +

To build:

+
make
+

There is an alternate version of this program which changes the way +the output is displayed. See Alternate +code below.

+

NOTE: we disable the optimiser because the author stated that for GCC +optimiser level 0 gave correct output. With clang [0123s] works which +suggests that [123s] might or might not work with GCC. Likewise, we do +similar for the standard, forcing -std=gnu11.

+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2019 poikola in bugs.md.

+

To use:

+
./prog 512 ./prog
+
+sleep 86400; make clobber prog
+./prog 512 ./prog
+
+sleep 86400; make clobber prog
+./prog 512 ./prog
+

If you wish for some documentation:

+
make docs
+

This will create the file poikola.pdf for your +enjoyment.

+

Try:

+

If you don’t have a few days, try:

+
./try.sh
+

As the bugs.md says, this program +will not validate input so it might get stuck or fail if invoked +erroneously.

+

Alternate code:

+

This version prints a newline after each number for parsing in other +ways than what can be done with the original entry.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use prog.alt as you would prog above.

+

Alternate try:

+
./try.alt.sh
+

Judges’ remarks:

+

Do you have the time to see what this program does? Think again, come +back and try again.

+

Note that 2 can +be said to be the least odd prime because it +is the greatest even +prime. Moreover 2 can be also said to be the greatest odd +prime because it is the least even prime.

+

The source code layout and some of the variable names honors the ski +jumping accomplishments of Matti +Nykänen.

+

Author’s remarks:

+

How to build:

+
gcc -O0 -o prog prog.c
+

or

+
clang -O[0123s] -o prog prog.c
+

e.g.:

+
clang -O1 -o prog prog.c
+

Poster:

+

You can generate an A3 sized poster by make docs. This +command creates a pdf file poikola.pdf. This requires the +pdfTeX tool.

+

What this entry does:

+

An old wise man mumbled to me: > Implement a program, which can +calculate SHA-3 checksum for a file –

+

I thought it was easy, but the wizard didn’t stop yet:

+
+

and primes and Fibonacci numbers.

+
+

Still easy. But the Gandalf the Grey +impersonator was not ready:

+
+

But use only main(), and do not use math.h +nor predefined stuff at all. But wait, there are more rules: This work +should reflect the extraordinary mind of Matti Nykänen, the all-time +best ski +jumper and amateur +philosopher, who passed away on fourth of February 2019.

+
+

Oh boys:

+

So, I followed the rules given by Gandalf the +White and the Judges of the IOCCC.

+

Output of iocccsize, using the 2019 version of +iocccsize, is carefully selected. For the sake of clarity, I used +single letter variables in the code. I also avoided unnecessary use of +functions. Like a tripundra, this +program has three levels. In order to reveal all of them, you have to +compile this program on three consecutive days.

+

As this is a contest for obfuscated code, the program does not +perform unnecessary checks, but either fails or gets stuck if invoked +erroneously. The program is invoked in this way:

+
./prog <integer> <file>
+

where <integer> is 224, 256, 384, 512 or even +1024. Yes, I know 1024 is not a supported length of output, but as I +said, the program does not validate its input in any way. These same +parameters should be given in calculating a Fibonacci +sequence or prime numbers. +Please note that maximum file size is one gigabyte!

+

Obfuscation:

+

Matti Nykänen: Every time I jump, and I get that feeling of +bon voyage, the feeling that I’ve been here before.

+

Matti Nykänen: When you are about to jump, you are all alone +and have to make your own decisions. Up there, it’s all up +yours.

+

This code has some jumping too. I used some gotos +instead of longjmp(3). Some Finnish ski jumping sites +are used as labels, however, there is lahti instead of +salpausselkä.

+

SHA-3-512 Compatibility +chart

+

Tested against test +vectors.

+

Clang-4.0: For optimization levels [0123s], the program compiles and +produces correct output for every tested vector using the C standards +c11, c89, c90, c99, gnu11, gnu1x, gnu89, gnu90, gnu99, iso9899:1990, +iso9899:199409, iso9899:1999 and iso9899:2011 (argument of +-std=).

+

GCC-6: For optimization level 0, correct output using the C standards +c11, c99, gnu11, gnu1x, gnu89, gnu90, gnu99, iso9899:1999 and +iso9899:2011.

+

Missing a prime

+

For obvious reason, the oddest prime is +missing from output.

+

Observations

+

gcc and clang are very fragile compilers. I +spent numerous hours trying to achieve exactly the same output from +different optimization levels and compilers. Small change in code can +produce really unexpected results, i.e. the compiler can skip a few +expressions or statements without obvious reason.

+

Major spoilers

+

It is commonly believed that Mike Keith’s algorithm +published in Journal of Recreational Mathematics, Vol. 22, +No. 4, 1990, p. 280, is the shortest way to calculate the day of the +week for a given date.

+

Keith’s versus my algorithm

+

Kieth’s algorithm is +(d+=m<3?y--:y-2,23*m/9+d+4+y/4-y/100+y/400)%7. I noticed +that (23*m/9+(m<3?y--:y-2)+d+4+y/4-y/100+y/400)%7 is one +character shorter. In my solution, m<3?y--:y-2 is used +directly, instead of assigning a value to d.

+

Q is pronounced in Finnish exactly like +kuu, a word for month or the Moon. So, +Q = k is intended.

+

Last term of outputted Fibonacci +sequence is the last one smaller than 264. It is a plain +but funny coincidence that the value of ^ is 94 in ASCII.

+

For prime +calculations: I recycled code from my high school C-programming +course. Originally, I wrote it over 20 years ago. My teacher said that +it is (too) complicated to use bits stored in arrays, so I did it.

+

Other stuff

+

Cody Boone Ferguson: +I really like that you enjoyed my previous entry. I hope that you will +like this entry too. Because I did not want to give too many clues to the Judges, I tried to write this entry in a +different way than Most Stellar, +but in this code there is at least one recycled thing from it. By the +way, the answers to the questions I posed: (1) 255. (2) Try to compare +binary representations of those floats and binary +representation of the string “25th IOCCC!”. (3) I don’t +know. I used standard trigonometric +functions from math.h +for rotating the Big +Dipper and later replaced those functions with my own +implementations. But there was a bug in my code and the effect was more +beautiful than intended. I did not even debug this bug and now it works +as a feature. (4) It is not possible. If you change a single bit, the Fletcher’s +16 checksum does not match anymore and goto jumps to +the end of the code.

+

I see that one of the Volker Diels-Grabsch’s +winning entries is awarded the category Most self-aware. In last year, my +entry incorporates the Fletcher’s +16 algorithm to ensure integrity of code. One of my first ideas for +this year was to do the same thing, but with SHA-3. Using Fletcher 16, +calculating a checksum which matches +with sleeping time factor took about one minute. I realized +that SHA-3 even with 224-bit output could take too +much CPU +time.

+

I would like to say thanks to PSP, because there were not +too many interruptions during the coding phase.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2019/poikola

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2019/yang/index.html b/2019/yang/index.html index 58dbc3109..f18dd8203 100644 --- a/2019/yang/index.html +++ b/2019/yang/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,333 @@ - - + + + + + + - - -2019 yang - - + + + +2019/yang + + + + + -

2019 yang

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2019/yang

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2019/yang/index.html

- +
+ ← endoh + ↑ 2019 ↑ + duble → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Don Yang
Location: +US

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2019 +yang in bugs.md.

+

To use:

+
./prog sample_input.txt a b c d
+
+cat a
+
+cat b
+
+cat c
+
+cat d
+
+cat a b c d | ./prog
+

Try:

+
./try.sh
+

Judges’ remarks:

+

Do you understand how this program works? You may have to go over and +over the output again.

+

Author’s remarks:

+

Summary:

+

Scramble/unscramble to single file:

+
./prog original.txt > scrambled.txt
+
+./prog < scrambled.txt > unscrambled.txt
+

Scramble/unscramble to multiple files:

+
./prog input.txt output1.txt output2.txt ...
+
+cat output1.txt output2.txt ... | ./prog > unscrambled.txt
+

Re-scramble:

+
./prog original.txt | ./prog - > scrambled1.txt
+./prog original.txt | ./prog - | ./prog - > scrambled2.txt
+./prog original.txt | ./prog - | ./prog - | ... > scrambled3.txt
+

Scramble slowly:

+
./prog input.txt | ruby prog.c
+

Input must be in UTF-8 encoding.

+

Details:

+

This is a text scrambling utility. To scramble text, specify input +file name as the first argument:

+
./prog input.txt > output.txt
+

If original input file was small enough to fit in your terminal, you +can simply use cat to unscramble the output text.

+
cat output.txt
+

It might seem like nothing was scrambled, but you can try passing the +output through strings(1) and see that most of the original +strings are gone. What happened is that the original text has been +shuffled with ANSI cursor positioning codes inserted in such a way that +characters are printed in random order. This effect is more visible if +there is a delay after each character is printed. For convenience, a +utility is included in the source to output characters slowly:

+
./prog input.txt | ruby prog.c
+

Scrambling order is deterministic, but you can reshuffle the output +by piping it through the same utility again, by specifying +- as the first argument:

+
./prog input.txt | ./prog - | ./prog - | ...
+

You can also split the input to multiple files, each getting a subset +of the original input characters:

+
./prog input.txt output1.txt output2.txt ...
+cat output1.txt output2.txt ... > unscrambled.txt
+

You can only unscramble files with cat if the input fits +in a single terminal screen. If you don’t know what will be the terminal +size of the recipient, note that prog.c will fit in a 80x25 +terminal, so a good guideline is to pick files that have fewer rows and +columns than prog.c.

+

For files that are larger than your terminal window, cat +will not be sufficient for unscrambling because any scrolling causes the +character positions to be misaligned. But fear not, this utility also +includes unscrambling functionality. If no argument is specified, input +will be read through stdin and unscrambled to +stdout:

+
./prog < scrambled.txt > unscrambled.txt
+

Where this is useful is that if you scramble the input to multiple +files and unscramble each output file individually, those output files +can be printed on transparencies and distributed separately.

+
./prog input.txt output1.txt output2.txt output3.txt
+./prog < output1.txt > layer1.txt
+./prog < output2.txt > layer2.txt
+./prog < output3.txt > layer3.txt
+

In other words, this is a utility for facilitating visual +cryptography.

+

This utility can also be used just for removing trailing whitespaces +and expanding tabs to 8 spaces.

+
./prog input.txt | ./prog
+

Features:

+

UTF-8 support:

+

A simple text scrambling utility might not have required a screenful +of code, but this particular one natively supports UTF-8. Specifically: +individual UTF-8 byte sequences will not be split into broken ones, and +the utility is aware of full-width versus half-width differences such +that the cursor is positioned correctly for most CJK input. sample_input.txt demonstrates this feature +with a mix of Basic Latin and Japanese characters.

+

Output cursor positions will most definitely be wrong for inputs +containing combining characters and right-to-left text, but it should be +possible to unscramble those text back to the original using this same +utility, since the utility is self-consistent in how cursor positions +are handled.

+

Error handling

+

If any file can not be opened for reading or writing, an error is +printed to stderr, and the utility will exit with nonzero +status.

+

If there isn’t enough memory, the utility will likely crash.

+

If input contains CR-LF end of line sequences, those CRs +are silently dropped. In fact, most control codes are silently ignored +except line feeds (preserved) and tabs (expanded to 8 spaces).

+

Compatibility

+

Verified to work and compiles without warnings on these +environments:

+ +

Full version

+

I tried really hard to make prog.c fit in a 80x25 +terminal without wrapping. If I were not constrained by space, I would +have made an ASCII art out of it. violet.c is +that program, and also comes with the minor benefit of supporting lines +longer than a million columns depending on sizeof(int).

+

Violet is named after Violet +Evergarden in the story with the same name, the character who is +highly skilled in writing letters.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2019/yang

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2020/burton/index.html b/2020/burton/index.html index dc5980c92..e7ca6a8e8 100644 --- a/2020/burton/index.html +++ b/2020/burton/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,259 @@ - - + + + + + + - - -2020 burton - - + + + +2020/burton + + + + + -

2020 burton

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2020/burton

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2020/burton/index.html

- +
+ first entry + ↑ 2020 ↑ + carlini → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Dave Burton
+Location: US

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2020 +burton in bugs.md.

+

To use:

+
./prog arg ...
+

Try:

+
./try.sh
+

Alternate code:

+

By default, the program works for Little Endian machines. This +alternate build is for Big Endian machines (that works whether you have +LE or BE).

+

Alternate build:

+

Running make builds the alternate code by default.

+

Alternate use:

+

Use prog_be as you would prog above.

+

Judges’ remarks:

+

Can you determine why this shows strange output for +./prog 128 128 and ./prog 128 128 128 128 but +not ./prog 128 128 128?

+

Can you find a pattern here?

+

What happens if you specify different numbers?

+

This tiny one-liner is a bit-twiddler’s delight! It does all of the +work without looping.

+

To understand how it works, a good place to start is to look at the +hex value that results when the two magic constants are +XORed.

+

Once you’ve figured out what happens with one set of constants, how +can choosing new constants, but using the same computation generate a +reversed result?

+

This code may be tested by:

+
make test
+

Author’s remarks:

+

Invoke this with a single non-negative integer less than 256, and a +useful transformation occurs.

+

Rule 2-ish:

+

Exporting the constants +B,I,T,S to the Makefile allows the code to be compiled for either +LE (little-endian) or BE (big-endian) machines(!!), so they are truly +configuration parameters, not logic.

+

Notes:

+

One ping argument only. It will segfault on zero +arguments, and display strange results with more than one argument.

+

Small, non-negative integers only. Useful range is +0 .. 511, sorta, for LE; 0 .. 255 for BE. +Bonus points if you can explain why the limits work this way.

+

ASCII character set, 64-bit long longs are required.

+

v,a,r,i,a,b,l,e,s_NAME the operation.

+

No loops, no branches?!?

+

Compilation:

+

Compiles cleanly under +clang -Wall -Weverything -pedantic, but you need to add +--include stdio.h --include stdlib.h for the +printf(3) and atoi(3).

+

On a little-endian machine:

+
clang -include stdio.h -include stdlib.h -Wall -Weverything -pedantic -DB=6945503773712347754LL -DI=5859838231191962459LL -DT=0 -DS=7 -o prog prog.c
+

On a big-endian machine:

+
clang -include stdio.h -include stdlib.h -Wall -Weverything -pedantic -DB=7091606191627001958LL -DI=6006468689561538903LL -DT=1 -DS=0 -o prog_be prog.c
+

You might be interested to compile it both ways on the same host, and +try:

+
./prog 1; ./prog_be 1
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2020/burton

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2020/carlini/README.md b/2020/carlini/README.md index 91fa26cde..fdbe701e8 100644 --- a/2020/carlini/README.md +++ b/2020/carlini/README.md @@ -242,9 +242,9 @@ the following expression where argument 1 is a pointer to a temporary variable followed by a NUL byte. This works because if the current count is 0 mod 256, then `"%1$hhn"` will write -zero to argument 1 and then "%1$s" will never emit any text. If, on the other +zero to argument 1 and then "%1\$s" will never emit any text. If, on the other hand, the count is not 0 mod 256, a length-1 string will be written to argument -1, and then `"%1$s"` will increment the count by one. By repeating this 256 +1, and then `"%1\$s"` will increment the count by one. By repeating this 256 times we're eventually going to reach 0 mod 256. Checking if there has been an invalid move is achieved similarly. diff --git a/2020/carlini/index.html b/2020/carlini/index.html index 3b787d1c7..44aea07c2 100644 --- a/2020/carlini/index.html +++ b/2020/carlini/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,403 @@ - - + + + + + + - - -2020 carlini - - + + + +2020/carlini + + + + + -

2020 carlini

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2020/carlini

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2020/carlini/index.html

- +
+ ← burton + ↑ 2020 ↑ + endoh1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Nicholas +Carlini
Location: US

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2020 carlini in bugs.md.

+

To use:

+
./prog
+

Try:

+
./try.sh
+

Or if you actually want to play:

+
# Play with a friend, real or imagined, P1 and P2, squares are numbered 1..9
+./prog
+

Judges’ remarks:

+

This program consists of a single printf(3) statement +wrapped in a while loop. You would not think that this +would amount to much, but you would be very, very wrong. A clue to what +is happening and how this works is encoded in the ASCII art of the +program source.

+

Author’s remarks:

+

HOW ABOUT A NICE GAME OF CHESSTIC-TAC-TOE?

+

USAGE

+
cc -o prog prog.c
+./prog
+

Alternates between P1 and P2. Enter a digit [1-9] to move:

+
1 | 2 | 3
+---------
+4 | 5 | 6
+---------
+7 | 8 | 9
+

The game ends if:

+ +

LIMITATIONS

+

Bad things may happen if the entered move is outside of the range +[1..9]

+

While the game will stop if one player tries to overwrite another +player’s move, it will happily allow a player to move on top of +themself. However, given that this is an effective no-op and guarantees +a loss to a competent opponent, if you do this you probably deserve to +lose.

+

Your terminal may beep at you every turn. We’ll call this a feature +that … the program … is hard at work processing your move! That is! +Please be patient.

+

After macro expansion the format string is roughly 100K. This makes +some compilers unhappy, and others slow. (For example, passing GCC the +flags -Wall -Wextra -pedantic will result in a warning +about oversized strings.)

+

Under some terminals the program may exit early. The following should +always work:

+
echo "1 2 3 4 5 6 7" | ./prog
+

OBFUSCATION

+

The entirety of the program consists of a single iterated call to +printf(3).

+
int main() {
+    while(*d) printf(fmt, arg);
+}
+

Here, fmt is a single string, and arg is a +series of arguments to printf(3).

+

While its primary purpose is to serve as The One True Debugger, +printf(3) also happens to be Turing complete. (See +“Control-Flow Bending: On the Effectiveness of Control-Flow Integrity” +where we introduced this in an actual, published, academic paper. The +things you can get away with sometimes.)

+

We abuse this fact to implement the logic of +tic-tac-toe entirely within this one printf(3) call (and a +call to scanf(3) to read user input).

+

Here’s (briefly) how it works.

+

Preliminaries

+

This program uses three printf(3) format specifiers.

+ +

Okay, everyone probably knows this. Let’s get a bit more +advanced.

+

Format specifiers can take extra “arguments”.

+ +

For example, the following expression

+
printf("%1$.*2$d%3$hhn", 5, 10, &x)
+

will have the same effect as if we had written

+
x = 10;
+

because it will print out 0000000005 (5 padded to size +10) and then write the number of bytes written to x.

+

printf(3) Oriented +Programming

+

Alright, now we can get to the real fun.

+

We perform arbitrary computation with printf(3) treating +memory as a binary array–one bit per pair of bytes:

+ +

We can use format strings to compute the OR/NOT of arbitrary +“bits”.

+

We’ll start with the simplest, OR:

+
printf("%1$s%2$s%3$hhn", a, b, c)
+

will compute

+
*c = strlen(a) + strlen(b)
+

but given that strlen(x) is 1 for a 1-bit +and 0 for a 0-bit, we have

+
*c = a | b
+

Computing the NOT of a single value is also easy:

+
printf("%1$255d%1$s%hhn", a, b)
+

will compute

+
*b = (strlen(a)+255)%256 = strlen(a)-1
+

and again, because strlen(x) is either 1 or +0 we have

+
*c = !b
+

From here we can compute any binary circuit. Doing something +efficient, though, still takes work.

+

Tic-Tac-Toe

+

The game itself is represented as a board of 18 bits, 9 bits per +player, along with a turn counter that alternates between player 1 and +player 2.

+

To detect who has won, we implement the following logic. Let +A, B, and C be pointers to three +squares in a row to test, and D be where to save if there +is a win or not.

+
"%A$s%B$s%C$s%1$253d%11$hhn" // r11 = !(*A & *B & *C)
+ZERO
+"%11$s%1$255d%11hhn" // r11 = !r11
+ZERO
+"%11$s%D$s%D$hhn" // *D = *D | r11
+

That is, we set *D to 1 if there is a +three-in-a-row. We repeat this for all possible three-in-a-row +configurations, for both players.

+

The ZERO macro ensures that the number of bytes written out is 0 mod +256 with the following expression

+
"%1$hhn%1$s" (repeated 256 times)
+

where argument 1 is a pointer to a temporary variable followed by a +NUL byte.

+

This works because if the current count is 0 mod 256, then +"%1$hhn" will write zero to argument 1 and then “%1$s” will +never emit any text. If, on the other hand, the count is not 0 mod 256, +a length-1 string will be written to argument 1, and then +"%1\$s" will increment the count by one. By repeating this +256 times we’re eventually going to reach 0 mod 256.

+

Checking if there has been an invalid move is achieved similarly.

+

In order to decide what to print out, we have to cast the “in-memory” +array of bits to Xs and Os to print out. This is actually rather +straightforward. Given in 1$ the pointer to player 1’s +square, and 2$ the pointer to player 2’s, and in +3$ the pointer to the board string, we can compute

+
"%1$s" (repeated 47 times) "%2$s" (repeated 56 times) %1$32d%3$hhn"
+

which will, in effect, compute

+
*r3 = (*r1) * 47 + (*r2) * 56 + 32
+

which will output ' ' if neither are true, +'X' if r1 is true, or 'O' if +r2 is true.

+

Further Obfuscations

+

In order to be able to finally display the board, while still only +using one printf(3) statement, we finish the statement +with

+
"\n\033[2J\n%26$s"
+

which is the escape sequence to clear the screen, and then prints +argument 26. Argument 26 is a pointer to a char* in memory, +that initially is undefined, but within the printf(3) +statement we will construct this string to look like a tic-tac-toe +board.

+

After the board, we need to print one of the following strings:

+
P1>_
+P2>_
+P1 WINS
+P2 WINS
+P1 TIES
+P2 TIES
+

Depending on if it’s P1 or P2’s turn to move, the game is over and +someone won, or the game is over and it is a draw.

+

This turns out not to be as hard as it might look. Using the same +trick as before, we set byte four to be

+
*byte4 = is_win * 'W' + is_tie * 'T'
+

The byte 'I' and 'S' can always be the +same, and we do the same for 'E'/'N'.

+

We do this same on-the-fly creation of the scanf(3) +format string, but for a different reason. We first want to run +printf(3) to show the first board, and then alternate +between runs to scanf(3) and printf(3) reading +and then displaying moves. Importantly, we do not want a final +scanf(3) when the game ends. It should just exit.

+

One option would be to implement the logic as

+
printf()
+while (*ok) {
+    scanf();
+    printf();
+}
+

but this would DOUBLE the number of calls to printf(3) +we require. So instead we implement it like this

+
while (*ok) {
+    scanf();
+    printf();
+}
+

(In reality we actually pass scanf(3) as an argument to +avoid the extra statement, but it has the same effect.)

+

Notice there is now no initial printf(3). In order make +sure the program doesn’t block before the first printf(3), +we initialize the scanf(3) format to the NUL string so that +it returns right away without blocking. The first time the +printf(3) call runs, it writes out "%hhd" to +create the scanf(3) format string.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2020/carlini

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2020/endoh1/index.html b/2020/endoh1/index.html index e596d41ca..21965a0c7 100644 --- a/2020/endoh1/index.html +++ b/2020/endoh1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,357 @@ - - + + + + + + - - -2020 endoh1 - - + + + +2020/endoh1 + + + + + -

2020 endoh1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2020/endoh1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2020/endoh1/index.html

- +
+ ← carlini + ↑ 2020 ↑ + endoh2 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yusuke Endoh
+Location: JP

+ + +

To build:

+
make
+

There is an alternate version provided by the author. See Alternate code below.

+

To use:

+
# IMPORTANT for macOS: run under Terminal.app
+
+./prog
+

Try:

+
# IMPORTANT for macOS: run under Terminal.app
+
+# Try resizing the terminal window before the first click.
+
+# Try resizing the terminal window after the first click.
+
+./prog ioccc.txt
+
+./prog unwinnable.txt
+

Alternate code:

+

An alternate version of this entry, prog.alt.c, is provided. This alternate code lacks +the additional rule to flag all unprobed cells. See the Author’s remarks +for more details.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use prog.alt as you would prog above.

+

Judges’ remarks:

+

When playing Minesweeper, +a misclick might ruin a game, so why not leave the routine to the +computer? This program automatically uncovers mines according to several +rules, and leaves guessing (and applying the most straightforward of the +rules – just for fun, perhaps?) to the user.

+

Try creating your own input files according to the author’s remarks. +Did you encounter any problems?

+

The submission was in violation of the “2053” size rule by one +character, likely a late typo. It was easy to fix.

+

For macOS:

+

We observe that this entry may not work under macOS using iTerm2. +Users on macOS might want to run this entry under the macOS Terminal, +which is located in +/System/Applications/Utilities/Terminal.app.

+

Author’s remarks:

+

Semi-automatic Minesweeper:

+

Minesweeper is a game to sweep mines, as you know. The task consists +of two parts:

+
    +
  1. Choose a random cell based on your sixth sense.
  2. +
  3. Identify a non-mine cell based on logical inference.
  4. +
+

However, (1) is error-prone, and a waste of time. You must use a +computer to do such a boring task!

+

This program is a semi-automatic minesweeper which does part (1) +automatically. All you have to do is (0). You can test if you are lucky +or not.

+

How to use:

+

It uses ncurses:

+
gcc -o prog prog.c -lncurses
+./prog
+

You will see a terminal-wide field of a minesweeper. Probe a cell by +mouse click.

+

If a cell turns out to have a mine (or not), the program determines +whether its neighbors have a mine or not, and automatically probes (or +flags) the cell.

+

Keyboard commands:

+ +

Input is case-sensitive.

+

Internals:

+

The program uses four types of local inference:

+

Rule 1:

+

If the number of a cell is equal to the count of the flagged +neighbors, all the unprobed neighbors are probed.

+

Example:

+
? ? ?      . . .
+? 3 ?  =>  . 3 .
+! ! !      ! ! !
+

Note that ? is an unprobed cell (it is unknown whether +the cell has a mine or not); ! is a flagged cell (it is +already known that the cell has a mine); and . is a probed +cell (it is already known that the cell has no mine).

+

Rule 2:

+

If the number of a cell is equal to the count of the unprobed or +flagged neighbors, all the unprobed neighbors are flagged.

+

Example:

+
. ? ?      . ! !
+. 4 ?  =>  . 4 !
+. 2 !      . 2 !
+

Rule 3:

+

Consider two number cells A and B. If +A is equal to the difference of B and the +count of B’s unprobed and flagged neighbors that are not +A’s neighbors, all A’s unprobed neighbors that +are not B’s neighbors are probed.

+

Example:

+
? ? ?        . . .
+? 1 ? ?  =>  . 1 ? ?
+? ? 4 .      . ? 4 .
+  ? . !        ? . !
+

A and B are probed cells whose numbers are, +respectively, 1 and 4. The count of B’s unprobed and +flagged neighbors that are not A’s neighbors is three (one +! and two ?s). Since +A == B - count (1 == 4 - 3), the left and top +unprobed cells are probed.

+

Rule 4

+

Consider two number cells A and B. If +B is equal to the difference of A and the +count of A’s unprobed and flagged neighbors that are not +B’s neighbors, all of A’s unprobed neighbors +that are not B’s neighbors are flagged.

+
? ? ? ?      ! ? ? ?
+? 3 1 2  =>  ! 3 1 2
+2 2 . .      2 2 . .
+

A and B are probed cells whose numbers are, +respectively, 3 and 1. The count of A’s unprobed and +flagged neighbors that are not B’s neighbors is two (left +?s). Since B == A - count +(1 == 3 - 2), the left unprobed cells are flagged.

+

Note

+

Interestingly, these complex rules can be integrated to one simple +rule. Analyze the code.

+

One more thing

+

You can also play with a prepared map.

+
 ./prog ioccc.txt
+

The format of the text is:

+
width height number-of-mines priorities-of-each-cell...
+

There are mines in a cell whose “priorities-of-each-cell” is less +than “number-of-mines”. (But the mine in the first-clicked cell is +removed.)

+

Bug fixes and Credits

+

The judges pointed out a bug of the original version that I submitted +(prog.alt.c). Because this program does not +provide a feature to flag unprobed cells manually, we can do nothing if +the number of unprobed cells are equal to the number of mines remaining; +unwinnable.txt is an example for such a +case.

+

Thus, I implemented an additional rule to flag all unprobed cells in +such a case into the final version (prog.c).

+

Ilya Kurdyukov also +pointed out a warning “ignoring return value of ‘fscanf’” only when +-O3 is used. So I changed the code a little to pretend to +use the return value of fscanf(3).

+

Don Yang (omoikane) contributed +another example map megumin.txt which is the +Explosion Arch-Wizard from KonoSuba.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2020/endoh1

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2020/endoh2/index.html b/2020/endoh2/index.html index 915949f79..a4bdec246 100644 --- a/2020/endoh2/index.html +++ b/2020/endoh2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,239 @@ - - + + + + + + - - -2020 endoh2 - - + + + +2020/endoh2 + + + + + -

2020 endoh2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2020/endoh2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2020/endoh2/index.html

- +
+ ← endoh1 + ↑ 2020 ↑ + endoh3 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yusuke Endoh
+Location: JP

+ + +

To build:

+
make
+

To use:

+
./prog
+

Try:

+
./try.sh
+

What happens if you do

+
./prog prog.c
+

?

+

Judges’ remarks:

+

Clever use of the C99 complex data type. The spoiler directory contains clues as to how some +winning authors create / edit programs into ASCII shapes.

+

With the source from the spoiler directory +could you make the code render for a larger terminal window? How about +adding more glyphs?

+

Author’s remarks:

+

No! Try not. Do, or do not. There is no try.

+
cc -std=c99 prog.c
+./a.out
+./a.out hello.txt
+./a.out yoda.txt
+./a.out bear.txt
+

See spoiler.zip for the source code. The +16th most common password on the Internet in 2017 (according to Splash +Data) the password is.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2020/endoh2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2020/endoh3/index.html b/2020/endoh3/index.html index 4c0a02bff..e825125dd 100644 --- a/2020/endoh3/index.html +++ b/2020/endoh3/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,216 @@ - - + + + + + + - - -2020 endoh3 - - + + + +2020/endoh3 + + + + + -

2020 endoh3

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2020/endoh3

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2020/endoh3/index.html

- +
+ ← endoh2 + ↑ 2020 ↑ + ferguson1 → + Inventory +
+ + + + +
+ + + + +
+ + + + + +
+ +
+ +
+ +
+ +
+ + + + + +
+ + + + +
+ + + + + + + + + +

Author:

Name: Yusuke Endoh
+Location: JP

+ + +

To build:

+
make
+

An alternate version of this program exists. See Alternate code below.

+

To use:

+
./prog
+

Try:

+
./run_clock
+# And watch closely for 15-20 seconds
+

Alternate code:

+

An alternate version of this entry, prog.alt.c, is provided. This alternate code uses +Unicode letters.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use prog.alt as you would prog above.

+

Judges’ remarks:

+

You may be tempted to use a mirror. Resist the temptation! Try +figuring out how the clock hands are drawn. Can you change the program +to make it draw a familiar (non-mirrored) clock face? Can you add the +second hand?

+

When using the run_clock.sh shell script, +your perception of time might depend on what time it is.

+

Author’s remarks:

+

Prepare a mirror!

+
make clock
+

Note: You need to recompile it each run.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2020/endoh3

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2020/ferguson1/index.html b/2020/ferguson1/index.html index 975d3fdcf..ee2f72516 100644 --- a/2020/ferguson1/index.html +++ b/2020/ferguson1/index.html @@ -10,7 +10,7 @@ - + @@ -111,8 +111,7 @@ -

Author:

-

Name: Author:

Name: Cody Boone Ferguson
Location: US

@@ -182,7 +181,7 @@ in this game is a misnomer; see notes below.

whether you can go through the Snake or not. Default is 0 (cannot - die if you try).

-

Try:

+

Try:

make test
 
 WAIT=75 WALLS=1 CANNIBAL=1 ./prog
diff --git a/2020/ferguson2/index.html b/2020/ferguson2/index.html
index b30837a90..d74caee39 100644
--- a/2020/ferguson2/index.html
+++ b/2020/ferguson2/index.html
@@ -1,4 +1,6 @@
 
+
+
 
 
 
@@ -6,27 +8,1053 @@
 
 
 
-
-
+
+
+
+
+
+
 
-
-
-2020 ferguson2
-
-
+
+
+
+2020/ferguson2
+
+
 
 
+
+
+
 
 
-

2020 ferguson2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2020/ferguson2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2020/ferguson2/index.html

- + + + + + +
+ + + + + + + + + +
+ + + + + + + + + +

Author:

Name: Cody Boone +Ferguson
Location: US

+ + +

To build:

+
make
+

The author provided alternate code that prints the output one +character at a time to make it a bit more like the real thing in that it +isn’t dumped out all at once. See Alternate +code below.

+

To use:

+
./prog
+
+# get recode help:
+./recode -h
+
+# general syntax for recode passing to Enigma machine:
+./recode [options] | ./prog - 2>/dev/null
+# general syntax for recode without passing to Enigma machine:
+./recode [options]
+
+# recode prompts for settings; pass to Enigma machine:
+./recode | ./prog - 2>/dev/null
+
+# recode reads from input file, prompts for settings; passed to Enigma machine:
+./recode -finput | ./prog - 2>/dev/null
+
+# recode reads config from string or file; passed to Enigma machine after
+# prompting for input:
+./recode -R<string|file> | ./prog - 2>/dev/null
+
+# write config to output file; passed to Enigma machine after prompting for
+# input:
+./recode -o<config> | ./prog - 2>/dev/null
+
+# pseudo-randomly select settings
+./recode -r
+
+# show Enigma machine settings after selection / generation:
+./recode -v
+

NOTE: in recode no spaces +between options and option arguments are allowed.

+

Try:

+
./try.sh
+

What does:

+
echo | ./recode
+echo | ./recode -v
+

do?

+

Alternate code:

+

This version, prog.alt.c, writes a character +at a time, sleeping after each character, so that one can read it more +easily (for longer output) and to make it a bit more like the real +thing.

+

Alternate build:

+
make alt
+

The default time to sleep is 400000 microseconds but you can change +this by doing:

+
make clobber SLEEP=600000 alt
+

to change it to 600000 microseconds. It guards against negative +numbers.

+

Alternate use:

+

Use prog.alt as you would prog above.

+

Alternate try:

+
./try.alt.sh
+

Notice how only the last part should use the prog.alt. +Why? Try it and find out! Can you figure out why this works this +way?

+

Judges’ remarks:

+

This code is an enigma. +Try to decode it!

+

There is a good deal of useful documentation that is provided with +this entry:

+
    +
  • enigma.1 - A useful man page for this entry. +To render, try:
  • +
+
man ./enigma.1
+ +

Author’s remarks:

+

My remarks about my Heer +(army) and Luftwaffe (air force) +Enigma +machine simulator for the 27th IOCCC.

+

I want to dedicate this entry in part to the millions of poor souls +that were lost during the tragedy that is the Second World War. +There are so many people who are unknown, unloved, unclaimed and even +unidentified. And who knows what they might have gone on to do if their +lives weren’t - like it is with all other wars - needlessly taken from +them? When one considers it was all because the most powerful man in the +world at the time felt he should rule all others it makes it somehow +even more tragic: there wasn’t even a good reason for the war (is there +ever?).

+

If one were to write the name of every person who died in the +conflict in a book, it would take so many pages that the book would be +so heavy, so long, so expensive to print and it wouldn’t bring anyone +back to life nor would it erase the suffering. Nothing will. It’s +horrible.

+

There really are no words that can truly describe the tragedy but I +wish to with my Enigma +simulator honour each and every soul who was lost, or suffered, or +suffered the loss of friends or loved ones, as well as the world itself, +in and from one of the greatest tragedies in the history of mankind.

+

I have more information on this entry like the testing procedure at +https://ioccc.xexyl.net/2020/enigma.

+

- IOCCC: an Enigma?

+ +

IOCCC: an +Enigma?

+

Is there a better single word that could describe the code that is +IOCCC? I’m sure there are some other words that are equally as valid but +I believe ‘Enigma’ is a great word nonetheless.

+

However it’s curious that no winning entry has ever been a simulator +of the German +Enigma machine. I was actually quite surprised (though pleased as it +gave me the chance to learn about it and submit and win an entry) at +that because it’s such a brilliant piece of engineering of the time even +though it had a critical flaw: that no letter could be itself; this +combined with cribs (known or suspected plaintext) - which was down to +carelessness, capturing an Enigma and sometimes settings sheet, as well +as known messages the Germans started out with - allowed for cracking +the code.

+

Combining this entry with two of the Morse code entries +is particularly interesting because that’s what the Germans did: the +party sending the message would first set up the machine, write down the +letters and then transmit by Morse code the +encoded message. Then those picking up on the message would note the +Morse code, translate it to the alphabet and then input it into their +Enigma machine configured in the same way and thus have the original +message.

+

The 1998 ASCII +/ Morse code translator entry by Franz van Dorsselaer +prints the Morse code of text; and the 2014 Morse audio +transcoder by Daniel Vik can +be used to allow for the actual sound of it. With my entry we can +complete the loop!

+

The +1992 Nathan Sidwell entry

+

The author Nathan Sidwell +of the 1992 Worst +Abuse of the Rules had this to say about his program:

+
+

This program is a hello world text encrypter/decrypter. It uses an enigma +(I think) style encryption algorithm, where the encryption key character +is modified by a value, determined from the previous character. +Non-printable characters (those with ASCII values < ' ' +or > 0x7e) are passed unaltered, thus any kind of file +may be successfully processed, but if the original is printable, the +processed file will be too. The input is read from stdin, and the output +presented to stdout. The key, a text string, is presented as a command +argument. This is optional, and if omitted, the file is +self-{de,en}crypted. To specify decryption, a - should be +given before the key. (Actually encryption and decryption proper inverse +operations, so you can use decrypt to scramble and encrypt to +descramble, if you’re perverse.)

+
+

But the Enigma algorithm is more complex than that and my entry can +encipher (and by extension decipher) text in the manner of the Enigma +machines of the Heer +(army) and Luftwaffe (air +force); the Kriegsmarine +(navy; literally War Nazy) was more complex (see section Kriegsmarine support? for more information on +that.

+

My entry should also work as a non-military grade Enigma; they had no +plugboard +and by default mine is empty. I explain how to set up the simulator +later.

+

Yusuke Endoh asked the +judges and me if the real 1992 entry source was available. Simon Cooper +didn’t have access to it because it was before his time in the IOCCC; +but before the other judges could answer Ilya Kurdyukov sent a link to +the original 1992 code. As of 4 March 2023 the original before unseen +code was published but I leave this in for historical purposes.

+

Usage

+

If you run the program by itself it’ll use the default settings and +prompt you for input (end with EOF). At that point it’ll process the +input string and print the result (after finishing the enciphering).

+

If you run it like:

+
./prog -
+

It will prompt you for the settings of the machine (example +below).

+

The first group is in the order of rotor +(number), ring +setting (letter) and ring (starting) position (letter). It will do +this for the first, second and then third for each.

+

Then it will prompt you for the reflector +(by number). The first one is reflector B and the second is reflector +C.

+

Finally it’ll prompt you for the plugboard +pairs.

+

After that you can input the string and it’ll go from there.

+

Example run

+

BTW: There’s a much more entertaining (and delicious) challenge or +exercise in recode.html (if you’re reading +this on GitHub check the recode.md file +instead); this involves chocolate-cake.html (if on GitHub see here) though one might need a different +kind of exercise after taking up the challenge! :-) These however show +the general program as well as how to use the two winning entries of the +Morse code that I +referred to earlier:

+
$ ./prog -
+Ring 1: 3
+Setting 1: I
+Position 1: O
+Ring 2: 1
+Setting 2: C
+Position 2: C
+Ring 3: 5
+Setting 3: C
+Position 3: Z
+Reflector: 2
+Plugboard pair 1: CO
+Plugboard pair 2: DE
+Plugboard pair 3: SN
+Plugboard pair 4: XY
+Plugboard pair 5: MS
+Plugboard pair 6: AT
+Plugboard pair 7: VF
+Plugboard pair 8: UR
+Plugboard pair 9: KL
+Plugboard pair 10: BJ
+IOCCC
+^D
+CFDRG
+

Notice that all output except the deciphered/enciphered text is sent +to stdout.

+

If I didn’t specify the - by +e.g. echo IOCCC | ./prog then it will use the default +settings; as the judges suggest this invocation I will not show it +here.

+

But you can also type it out like this:

+
$ ./prog
+IOCCC
+UUMMX
+

The IOCCC comes from stdin; the UUMMX is written to +stdout.

+

If I compile the 2014 entry and copy it to my local directory as +vik I might do:

+
$ echo TEST|./prog |./vik | mplayer -demuxer rawaudio -
+

And you would hear Morse code of the Enigma +output of ‘TEST’ (i.e. KCWV)! Or perhaps not in this case. +I’m not sure: I discovered a bug in that entry (Fedora, CentOS and macOS +all affected).

+

For example I can use the syntax provided in the winning remarks +along with my entry to write it to a file. Say:

+
$ echo TEST|./prog |./vik > test.raw
+$ ./vik e < test.raw | ./prog
+LEST
+

Why did that happen? This shows more details:

+
$ ./vik e < test.raw
+SCWV
+

However as can be seen the first char is wrong:

+
$ echo TEST|./prog
+KCWV
+

And piping the original output to my entry itself you get the +original input:

+
$ echo TEST | ./prog  | ./prog
+TEST
+

I’m not sure what causes that or if there’s a way to fix it but +that’s the idea anyway. Neither do I know if the original transcoding is +correct.

+

What if I use the input string LEST instead? In that +case it worked fine:

+
$ echo LEST | ./prog | ./vik > lest.raw
+$ ./vik e < lest.raw | ./prog
+LEST
+

But there’s one obvious question, right? Let’s try the most important +one:

+
$ echo IOCCC | ./prog | ./vik > ioccc.raw
+$ ./vik e < ioccc.raw
+UUMMX
+$ ./vik e < ioccc.raw | ./prog
+IOCCC
+

Phew! The program redeemed itself after the test failure! :)

+

(Technically above it didn’t print a newline after the output and +this is how it is with some of the things I pasted in the other file and +maybe others here too. Notice also how it showed the same output that my +program gave it - UUMMX.)

+

What about the other Morse code +entry?

+
$ echo IOCCC | ./prog | ./dorssel
+..- ..- -- -- -..-
+

The +recode.c configurator

+

I have included a supplementary program recode.c that can do a number of things which acts +as a kind of wrapper and configurator to my entry. By default it prompts +you for the settings (rotors, rings +and ring settings and positions, reflector +and plugboard +pairs), validating input as you go.

+

After that it prompts for text that you can pass to the Enigma +simulator; alternatively you can specify a file to read in.

+

It has a randomise mode and it can save/read the settings to/from a +file to allow for duplicity (an archaic term for the state of being +double but obviously for Enigma it has to also mean deceitful).

+

I recommend using this in a pipeline instead of the simulator itself if you want to change the +configuration of the simulator because it offers a much richer +experience (and because you can reuse the configuration without having +to type it out again every time).

+

It does take the effort to try and prevent invalid input (as above) +though maybe I didn’t think of everything. My entry was meant to be a +simulator only as far as the ciphering goes but I thought this would +make it much more interesting: make it more flexible by a wrapper +program.

+

For examples using it (and a delicious challenge) see recode.html (or recode.md +if reading on GitHub). See also the recode.1 and +enigma.1 man pages.

+

A +parser subtlety that could cause confusion

+

The parser is in a sense rather rudimentary but allows for both +interactive and automatic (e.g. via the recode +program) input. This does mean that something like the following can +happen:

+
$ ./prog -
+Ring 1: 1AB
+Setting 1: Position 1: Ring 2: 2CD
+Setting 2: Position 2: Ring 3: 3
+Setting 3: A
+Position 3: B
+Reflector: 1A
+Plugboard pair 1: BC
+Plugboard pair 2: ..
+Plugboard pair 3: ..
+Plugboard pair 4: DE
+Plugboard pair 5: FG
+Plugboard pair 6: HI
+Plugboard pair 7: JK
+Plugboard pair 8: LM
+Plugboard pair 9: NO
+Plugboard pair 10: PQ
+IOCCC
+WD
+SIRDK
+

First of all: what is that WD? I didn’t type that but it +showed up hitting ctrl-d to end input.

+

If everything is input correctly it would show nothing except the +actual Enigma +machine output (maybe at times ^D - I have noticed this at least +when I don’t fill in all plugboard +pairs - which might or might not be possible with the Enigma machines +that had plugboards; I really do not know). I don’t view this as a bug +because the parsing of input is meant to be simple and in fact you can +expect the same output from the same input even if there are errors in +the input.

+

Anyway as you can see the first 1AB was the first ring, +setting and position. After this it wants Ring 2 and I did similar; for +ring 3 I did it each variable by itself. However for the reflector I did +1A but it only expects 1 char! So will that mean that the +plugboard pairs are off? Yes it does seem to be so. This is buffering at +play I believe but it’s useful for allowing the recode +program to easily configure the Enigma machine. In the recode.html file (or recode.md if reading on GitHub) file I give a hint +as to how this could be fixed but the caveat is it would necessitate a +need for rewriting recode.c.

+

There’s another thing to be aware of and that’s the way the ranges +are enforced. There are five rotors which obviously are in C 0-4 but in +‘natural language’ 1-5 (they were labelled I, II, III, IV and V +though).

+

There are two reflectors +and the same applies: in C 0-1 but in human it’s 1-2 (technically these +were reflectors B and C in the Enigma machine which I display by name in +recode.c just like with the rotors).

+

For more information see recode.html (or recode.md if viewing on GitHub).

+

BTW: If you need a reminder to go to the gym just do your Enigma ABCs +and it should help you remember (though not at this time in our world it +might help you later on?). This might become even more useful after the +challenge is accepted, accomplished and made use of! :)

+
$ echo ABC | ./prog
+GYM
+$ echo ABC | ./prog | ./prog
+ABC
+

On the +source code layout

+

The layout of recode.c isn’t too significant +(but see below) but I want to mention prog.c +especially:

+

I did think of a more artistic layout but reflecting +on it I think that the blankness of it can be another way of honouring +all the many people who died in - like all other wars - what was a +useless conflict because - again like all other wars - a powerful human +being decided that they should rule others.

+

The blankness is a reflection +of the millions of people who died unknown, uncared for, unloved, +without ever being acknowledged in their far too short lives, some even +unidentified; it’s the presence of absence.

+

I find it somehow fitting that the day I have finished this is 30 +April 2020, which was exactly 75 years from the day that the person +responsible for the Second World War, +Adolf Hitler, ended his life. (I later made a bug fix but I consider +this inconsequential).

+

As for recode.c though I really love this:

+
          /\
+    /          This is *not* what you think:
+

…because it seems so wrong in C code at first glance. Also what does +the ‘this’ refer to?

+

Obfuscation

+

It’s an Enigma +machine simulator! Isn’t that proof that it’s obfuscated itself?! :) +Silliness aside obfuscation.txt has some +of the ways I think this entry is obfuscated. To decipher try:

+
./recode -Robfuscation.key -fobfuscation.txt | ./prog - 2>/dev/null > obfuscation.md
+

To encipher:

+
./recode -Robfuscation.key -fobfuscation.md | ./prog - 2>/dev/null > obfuscation.txt
+

The file obfuscation.key is the key to +decipher/encipher obfuscation.txt.

+

For the lazy obfuscation.md has the +deciphered version. I am afraid I’m not so inclined to do that for the +cake recipe: the idea there is to make it a fun exercise that when +solved unlocks a wonderful double-layered chocolate fudge cake recipe. +But given that my ‘Don’t tread on me’ award +entry also has the recipe +(ferguson1/chocolate-cake.md if +reading on GitHub), not enciphered, one might just go there instead. +Still it’s a fun way to explore this entry.

+

As for the obfuscation.key file if you +observe the contents you’ll find the word OBFUSCATION:

+
2OB5FU1SC2ATIONCDEFGHJKLMPQRYZ
+ OB FU SC ATION
+

Bugs, +limitations, differences from the real Enigma machines and general +notes

+

Ways that my simulator differs from the real thing. Not all of these +are bugs and some could be considered features; others are just +differences.

+
    +
  • Does not check for using the same rotor +more than once. The real Enigma machines this would not work because +they had to choose from a set of rotors and there were no duplicates. +This shouldn’t be a problem here however except that it wouldn’t be a +possible configuration of the real Enigma machine. The +recode program however does validate this (except +when reading in settings via the -R option which I explain +in the recode.html file (recode.md on GitHub).

  • +
  • The way the plugboard +- for the machines that had them - is, if you connect A to B then no +other letters can connect to A or B. Earlier there wasn’t proper +detection and this caused invalid output.

    +

    Why only 10 pairs when the German alphabet has 26 letters (the Enigma +did not have the Eszett or the umlauts and in any case there is some +disagreement about these being part of the alphabet; anyway for umlauts +one can add an E after the letter and for the Eszett you can use ‘ss’ or +‘SS’ which is what they did)? It’s theoretically possible to have 13 but +the Enigma typically had 10 pairs. It’s easy enough to update my entry +to do this once you de-obfuscate it but I’m not helping there (and in +fact I don’t think I could any more even if I wanted to - at least not +easily).

  • +
  • It does not obviously have the clicking sound associated with the +moving parts of the real machine. I think it would be annoying to have +this as it processes each letter - but with the 2014 Morse audio +transcoder entry you can at least have the output played in Morse +code as the Germans did; I think that’s really cool (I think it’s really +cool even if there’s a bug in it). That it pays homage to that (and +another) entry is a bonus here.

  • +
  • The simulator doesn’t report errors but +tries to gracefully deal with them: if one chooses a value out of range +it moves it into the range (if > the max then the max, if < min +then the min). If invalid chars are input for the plugboard pairs then +it’s not added to the plugboard etc.

  • +
  • The real Enigma +machines had only letters: no digits, no punctuation. My entry +prints !isalpha() chars untouched. The Germans had +different systems for punctuations, numbers etc. (one of the documents I +link to has these details).

  • +
  • My entry preserves case of letters. The real Enigma had only one +case as it was just a keyboard and they didn’t need case-sensitivity. +Context would be important as some words in German have different +meanings depending on if capitalised or not (and all nouns are +capitalised).

  • +
  • Later models introduced a fourth rotor. The Kriegsmarine +procedures were also far more complex than the Heer +(army) and Luftwaffe (air force) +(though apparently the additional notch provided another flaw). I find +this particularly interesting because it was Hermann Goering who was the +Supreme Commander of the Luftwaffe and the intelligence agency +Forschungsamt (FA) was his; it provided Hitler with invaluable +information so one would think the Luftwaffe system would be more +complex! See Kriegsmarine support? for more +information.

  • +
  • I only include reflectors +B +and C. To have included more would have used too many bytes (each +reflector and rotor +is 26 characters!) and I could not include them for this reason; I +include five rotors and two reflectors and that’s a total of +(5 * 26 + 2 * 26 == 182 chars) but there are as you can see +many other strings too. It is however feasible to update the rotor and +reflectors options and you could even make your own versions if you +wanted to. Doing this is an exercise to the reader however (the idea of +trying this makes me cringe because of how I obfuscated things including +encrypting some of it with the Enigma itself).

  • +
+

There’s one thing I’m unsure of in my implementation. Because of all +the possible settings I used some other simulators as a starting point +and more importantly to validate that my code worked right. These other +simulators had bugs though and so one thing looked odd and I don’t know +if it is right or not. An online simulator appears correct but I don’t +see the option to change that part.

+

If you notice in the Q() function where I set up +specific pointers and other data there is a call to the macro +q but I only refer to the first ring setting (of which I no +longer even know which element it is! Or was it position? I don’t even +know that now for certain). That’s because the Python code did that +(though very differently of course) but I also had to bug-fix the Python +in another part.

+

I do not know if this is correct but as I show somewhere my entry +does match the online simulator so I presume it is correct. It might be +that the Germans tended to have it at A but again I do not know.

+

Kriegsmarine +support?

+

Is it possible to add Kriegsmarine +support? I thought so by adding the additional rotors but looking at it +again it appeared that it’s not as simple as adding the rotors to the +code and then updating the references to the array etc.

+

This is because it had three additional rotors - +VI, +VII and VII - and had two +notches and this changes the way things work. The Kriegsmarine +M4 also had an additional change which would complicate matters +more.

+

I looked into trying to do this for another version after winning but +some of the obfuscation techniques dramatically complicates even +attempting this so I haven’t even tried.

+

It is feasible that you could add your own rotors however but I leave +this as an exercise to the reader. I will say that the five rotors I, +II, III, IV and V can be found in the source code verbatim and you could +confirm it by looking them up; however much more would have to be done +in order to get them to work, than to just put the strings in. Again the +way I set things up complicates this greatly.

+

Portability

+

I have tested it under macOS, Fedora and CentOS Linux and all seems +okay under these platforms. When I was in the final stages of +obfuscation I made an error somehow (or else maybe the vim formatting +caused a problem - I have seen this before) and I had to go back and +undo some of the obfuscation to figure out what was going on (I had a +hunch where and I noted it in the obfuscation I believe) but this made +me wonder on if I made any other mistakes since it appeared to be +working before that.

+

I don’t know if EBCDIC will work but I think it might because it +appears that the alphabet is a contiguous sequence. I don’t believe +endianness matters but I no longer remember what I’ve done in full and +I’ve no way to test it.

+

If there are any inconsistencies in input/output one also has to be +certain that input was put in correctly because as soon as a letter +differs the entire sequence will be off.

+

The results of my test script (not included here but I will probably +have it on my website) are the same under Fedora, CentOS and macOS.

+

Resources

+

A +note on Wehrmacht, its branches and other agencies and their Enigma +machines

+

The Wehrmacht +was the defence force in full which included the Heer +(army), Luftwaffe +(air force) and Kriegsmarine +(navy). As I said the Kriegsmarine procedures were more complex: they +had additional rotors and one of their models had a different reflector +system (thin instead of thick - some of the documents below discuss +this). The military intelligence agency, the Abwehr, had their own +system too. Non-military grade Enigma machines didn’t have the plugboard. +And so on.

+

However one of the documents below distinguishes the Kriegsmarine +from the Wehrmacht; when you see this you can read it as the +Kriegsmarine versus the rest of the Wehrmacht rather than the Wehrmacht +and the Kriegsmarine.

+

Enigma +Message Procedures: The Heer, +Luftwaffe and Kriegsmarine) Enigma +procedures.

+

Interactive Enigma +Machine: Shows wiring of the Enigma machine +based on the settings and input (unfortunately uses Flash). This was +what I used to verify output (as best I could find). To set this up to +use the default settings in my simulator make sure to use Rotors +I, II and III and the starting positions at B, B and C respectively (as +in left, centre, right). To do this click the button at the top right +that looks like:

+
o->
+<-o
+

and then select the rotors. Next click the button again at the left +of the rotor selection ‘screen’. Then use the arrow buttons above each +rotor to set from left to right B, B and C. After this you can type your +message in the input field and watch the wiring of the rotors change and +show the path it takes.

+

If I made use of the Enigma code in the recode.c program I would maybe consider doing +something like that but I intentionally do not use it there: as cool as +it might be it would give a better idea of how the algorithm works +(unless I were to make it just as obscure as I do in prog.c but that’s +also a bit risky). I don’t believe I could do it now anyway.

+

I’m uncertain how to change the rotor setting itself in this +simulator to determine if the ring settings being different from +ABC would cause a problem (this is the thing I mention I’m +uncertain about in the bugs section).

+

Going back to the configuring the online simulator try inputting the +text IOCCC and you’ll see the resulting text being:

+
UUMMX
+

Which is exactly as my entry shows! So at least for the starting +position BBC and an empty plugboard +and the other defaults in my entry (which appear to be consistent with +the online simulator too) I can verify it works.

+

Tony +Sale’s pages on The Enigma cipher machine: This is many pages on the +Enigma machine by the late Tony Sale who was the original curator of the +Bletchley Park Museum. +There is a wealth of information in these pages on how the Enigma worked +and this includes some challenges to do to see how well you understand +the algorithm.

+

Fun fact: the abbreviation for the Signals +Intelligence is that of our wonderful SIGINT.

+

Technical +Details of the Enigma Machine: ‘This page provides the technical +details of the Wehrmacht and Luftwaffe Enigma, +and the Kriegsmarine Enigma M4.’ It is quite a nice document with +diagrams, pictures of actual Enigma rotors +and other parts and more.

+

The +German Enigma Cipher Machine: The history of Enigma, its +development, use during the war and cryptanalysis.

+

How the Enigma was Set +Up and Operated: This is the third page in a document series on the +Enigma that explains the initial set up of the Enigma machine for each +day. This is a good introduction to the set up. There is one thing that +I was not aware of (or if I was it did not register): the operator would +after setting the positions also put in three letters before the actual +message (there were several parts to each message but this was another +layer of complexity). I did not implement this in the recode program but +what would it be anyway? If the user here wants to they could add three +letters to their message beginning. I don’t think there need be any +addition to the recode program - at least not that.

+

Author’s dedication:

+

Winning +thoughts, dedications and thanks

+

Once again I’m honoured to win along with some of the other veterans +who I have a huge amount of respect for; there’s Don Yang, Dave Burton, Yusuke Endoh and Edward Giles all of whom are +amazing programmers. I’m especially proud to win besides Dave Burton and +Yusuke Endoh but Don Yang and Edward Giles too.

+

But there are some others who I don’t remember like Ilya +Kurdyukov (who’s offered a lot of interesting thoughts on Snake and who plans to have his own +version after the entries are published), Nathan Otterness, Nicholas Carlini (your entry +is an absolutely brilliant abuse of printf - and I totally +agree with the judges remarks that your entry is so novel that it’ll be +worth special mention in the future Best of IOCCC list!) and tsoj too.

+

Well done and congratulations to all of you again! Thank you for +submitting the wonderful entries and I’m honoured to have my two entries +beside yours!

+

To Yusuke Endoh, Dave Burton and Nicholas Carlini I very much +appreciate your wonderful comments on this program. Your comments Yusuke +on this entry specially and also Dave’s comments on my double-win are +both extremely special to me - it truly takes my pride to another +level!

+

I would like to dedicate this entry to my wonderful mum Dianne +Ferguson whom I love with all my heart and soul <3 Thank you for +being the best mother imaginable! You’ve been there for me in the +darkest of my hours without question without complaint and with all the +love, compassion, empathy, sympathy and devotion anyone could ever ask +for. Bless you again and again and again dear mother.

+

I also want to dedicate this to Vicky Wilmore who has given me a lot +of love the past few years and who was there for me in some very dark +times. Thank you Vicky sweetheart from the bottom of my heart and soul +xxx

+

Once more besides those two I want to also dedicate this to all the +many millions of people whose lives were taken from them in what amounts +to - like all other wars - a horrible, pointless conflict and an utter +waste of life, something precious that is far too often taken for +granted. As I noted before I found it fitting that I finished this on 30 +April 2020 - exactly 75 years after Adolf Hitler, he who started the Second World War, +ended his life. The blankness of the layout is another way of honouring +the poor souls who lost their lives, many of whom we will never know +even their name let alone what they might have accomplished if it wasn’t +for their tragic and pointless deaths. Always remember that life is +precious and never ever take it for granted! Believe in yourselves. +Everyone. Do not let anyone ruin that for you ever.

+

I would like to thank my dear friend Martijn Schoemaker for encouraging me +in my programming over the years and who I owe a great deal to. Thank +you for believing in me and my programming abilities (and other +abilities) even when I couldn’t believe in myself! Very much appreciated +especially coming from an amazing programmer who I have huge admiration +for!

+

Finally I want to thank Leo Broukhis, Simon Cooper and Landon Curt +Noll for continuing to hold the contest after all these years - and for +having selected my entries. It’s a huge honour; thank you! I also happen +to love your comments as well as the award titles. And yes indeed ‘most +of us could use Double-layered +Chocolate Fudge Cake!’

+

If you wish to contact me please do so. Please contact via mastodon. +You can try email but I’m more likely to respond to mastodon +messages.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2020/ferguson2

+

Primary files

+ +

Secondary files

+ + + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2020/giles/index.html b/2020/giles/index.html index 34abea3e6..e18e9213d 100644 --- a/2020/giles/index.html +++ b/2020/giles/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,320 @@ - - + + + + + + - - -2020 giles - - + + + +2020/giles + + + + + -

2020 giles

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2020/giles

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2020/giles/index.html

- + + + + + +
+ + + + + + + + + +
+ + + + + + + + + +

Author:

Name: Edward Giles
+Location: AU

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2020 +giles in bugs.md.

+

To use:

+
./prog < dtmf.wav
+
+./prog [digits] > digits.wav
+

where dtmf.wav is a WAV file of the dialling of a number +being dialled with DTMF +(Dual-tone multi frequency) (more commonly known as Touch-Tone) and +[digits] is a sequence of digits that will be converted to +the DTMF sound!

+

Try:

+
./try.sh
+./prog < pi.wav
+
+# See 
+./prog 867-5309 > jenny.wav
+

If the script try.sh did not play a WAV file, it +means you do not have SoX installed; see FAQ +3.10: How do I compile and use an IOCCC winner that requires +sound?). In this case install it and try it again or play the files +jenny.wav and ioccc28.wav in a program that +can play WAV files.

+

NOTE: the phone number of jenny.wav comes from https://en.wikipedia.org/wiki/867-5309/Jenny.

+

Judges’ remarks:

+

A cross platform utility for both encoding and decoding touch +tones.

+

Author’s remarks:

+

Introduction and Usage

+

This program encodes and decodes dual-tone +multiple frequency signals used in telephone systems, more commonly +known as Touch-Tones.

+

If the program is executed with no arguments, it will read a WAV file +from standard input, decode the touch-tones in the file, and output the +corresponding digits to standard output. This program only supports WAV +files that have exactly 16 bits per sample, but it allows any sample +rate and any number of audio channels.

+
$ ./prog < pi.wav
+31415926
+

If the program is executed with a command-line argument, it will +generate the tones corresponding to the specified characters, writing +them to standard output as a WAV file.

+
$ ./prog 867-5309 | aplay
+

Interesting Features

+
    +
  • When compiled with gcc -pedantic -Wall -Wextra there +are no compiler warnings.
  • +
  • This program can be successfully compiled and run on Windows, using +both Microsoft’s C compiler and TCC.
  • +
  • This program resamples the incoming audio, so that it can accept +audio data at any sample rate.
  • +
  • The code that generates the output sine-waves is the same as the +code that looks for sine-waves in the input. (see Algorithm Details for +roughly how this works).
  • +
  • Despite handling lots of sine waves, the program only uses basic +arithmetic operations. It does not depend on libm.
  • +
  • All type punning is done with memcpy(3) so there are no +strict-aliasing violations.
  • +
  • The size of the source code using the IOCCC size tool is 1963, the +year the first push-button telephones were made available to +customers.
  • +
  • The source code (not counting the C pre-processor) is roughly in the +shape of a telephone handset.
  • +
+

Assumptions

+
    +
  • Code is compiled using the C99 or C11 standard.
  • +
  • CHAR_BIT == 8.
  • +
  • Machine is little-endian.
  • +
  • int16_t, uint16_t, and +uint32_t exist.
  • +
  • int16_t is 2’s-complement.
  • +
  • double is an IEEE 754 binary64 floating-point +type.
  • +
  • sizeof(double) == 8.
  • +
+

Obfuscations

+
    +
  • DSP code is inherently somewhat difficult to understand.
  • +
  • Lots of identifier reuse. Each identifier is used for about 2.2 +different tasks, on average. For example, aa is both a +variable and a macro for error handling, and memcpy(3) is +both a library function and a oto label.
  • +
  • Most of the identifiers are only 1 or 2 characters long, and are +unrelated to their actual function.
  • +
  • The f macro is used to unroll some of the loops.
  • +
  • Some numerical constants are replaced with character literals, so +the actual value is unclear.
  • +
  • All of the strings used by the program have been combined into a +single string literal.
  • +
  • Most of the values used for the actual signal-processing all reside +in one array, named l. This array is usually accessed at +index z plus a constant. Accesses of this type have been +rewritten from, e.g. l[z+17] to 17[l+z]. +[l+z] ends up occurring quite often, so I created the macro +a as a shorthand.
  • +
+

Algorithm Details

+

Each tone in a DTMF signal is a combination of two frequencies. The +lower frequency determines which row the digit is in, and the higher +frequency determines the column. There are 4 possible row frequencies +and 4 possible column frequencies.

+
|            | **1209 Hz** | **1336 Hz** | **1477 Hz** | **1633 Hz** |
+|------------|-------------|-------------|-------------|-------------|
+| **697 Hz** | 1           | 2 abc       | 3 def       | A           |
+| **770 Hz** | 4 ghi       | 5 jkl       | 6 mno       | B           |
+| **852 Hz** | 7 pqrs      | 8 tuv       | 9 wxyz      | C           |
+| **941 Hz** | *           | 0           | #           | D           |
+

This program determines which frequencies are present in the input by +passing it through a set of 8 virtual resonators, each tuned to one of +the frequencies used for DTMF. These can be implemented using only basic +arithmetic, and they are able to ‘select’ a specific frequency from the +input sound, blocking all other frequencies from reaching the output. +The loudness of the sound output from each resonator can therefore be +used as a measure of how much of a particular frequency was present in +the input. The program then decides, over the course of one tone, which +row frequency and which column frequency were most prominent.

+

Tones are generated using those same resonators by providing an +impulse as input. An impulse can be thought of as consisting of +sine-waves at all frequencies, and when it is put through one of the +resonators, the result is a single pure sine wave.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2020/giles

+

Primary files

+ +

Secondary files

+
    +
  • .gitignore +- list of files that should not be committed under git
  • +
  • .path - directory path from top directory
  • +
  • .winner.json +- description of winner in JSON
  • +
  • README.md +- markdown source for index.html
  • +
  • dtmf.bin - binary support file
  • +
+ + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2020/kurdyukov1/index.html b/2020/kurdyukov1/index.html index 750dd14f5..40b9d8d10 100644 --- a/2020/kurdyukov1/index.html +++ b/2020/kurdyukov1/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,279 @@ - - + + + + + + - - -2020 kurdyukov1 - - + + + +2020/kurdyukov1 + + + + + -

2020 kurdyukov1

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2020/kurdyukov1

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2020/kurdyukov1/index.html

- + + + + + +
+ + + + + + + + + +
+ + + + + + + + + +

Author:

Name: Ilya +Kurdyukov
Location: RU

+ + +

To build:

+
make
+

There are alternate versions of this entry. See Alternate code below for more details.

+

To use:

+
./prog
+# input some text
+
+echo text | ./prog
+
+./prog < file
+

Try:

+
./try.sh
+

Alternate code:

+

There are a number of alternate versions for this program, some in C +and some in assembly.

+

The file prog.alt.c is smaller and does not +contain any headers or any workaround for WIN32 based platforms.

+

The file prog.extra.c has a number of +layouts including some for different social media profile covers as well +as different shapes.

+

The files prog.x86_64.asm and prog.x86.asm are the program in assembly for +x86_64 linux and x86 linux respectively.

+

Alternate build:

+

To build prog.alt.c:

+
make alt
+

Alternate use:

+

Use prog.alt as you would prog above.

+

Judges’ remarks:

+

This hash of a C code makes a hash out of input. Do you understand +how? You should get a-round-to-it figuring it out!

+

Author’s remarks:

+

MD5 with integers

+

Just a tiny MD5 checksum utility. Prints hash string of data from +stdin. Works the same as +openssl md5 | cut -d' ' -f2 command.

+

My objectives

+
    +
  1. Reduce code size as much as possible.
  2. +
  3. Avoid warnings from gcc/clang +-Wall -Wextra -pedantic.
  4. +
  5. Portable (regardless of register size and endianness).
  6. +
  7. Fit code in a round shape.
  8. +
  9. Mo macro defines.
  10. +
  11. No floating-point arithmetics.
  12. +
+

Notes

+

The main difficulty of making MD5 code smaller is a 64x4 bytes long +table with constants which will take more than 512 bytes in hex +encoding. This table is a results of a sine function, so can be +generated dynamically, but merging floating-point arithmetics with +precise integer calculations is not a great idea, because it can cause +portability issues.

+

Attempts to satisfy clang -Weverything will ruin comma +magic, that is so great for obfuscation, so I don’t want to care about +that.

+

Probably, should work correctly on any machines, but I have nothing +exotic (like BE or not 32/64) to try it.

+

Added a macro hack to make stdin work in binary mode +under Windows (tested under mingw64), otherwise the hashes can be +incorrect.

+

Bonus

+
    +
  • prog.extra.c is the same with the sine +function (so smaller), and in different shapes.

  • +
  • prog.x86_64.asm contains the same +program, but written in assembly for x86_64 Linux, for the sake of +smaller executable size which is 500 bytes long (where 120 is for the +ELF headers) after compilation. Algorithm details is slightly different +(like constants packing), just to make smaller binary code. It’s +interesting to compare density of binary code and obfuscated

  • +
+
    +
  1. +
+
    +
  • prog.x86.asm is for x86, although the +headers are smaller, but the binary code is larger due to fewer +registers and lack of 64-bit multiply.
  • +
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2020/kurdyukov1

+

Primary files

+ +

Secondary files

+
    +
  • .gitignore +- list of files that should not be committed under git
  • +
  • .path - directory path from top directory
  • +
  • .winner.json +- description of winner in JSON
  • +
  • README.md +- markdown source for index.html
  • +
+ + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2020/kurdyukov2/index.html b/2020/kurdyukov2/index.html index cace4e7f5..b48baa880 100644 --- a/2020/kurdyukov2/index.html +++ b/2020/kurdyukov2/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,278 @@ - - + + + + + + - - -2020 kurdyukov2 - - + + + +2020/kurdyukov2 + + + + + -

2020 kurdyukov2

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2020/kurdyukov2

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2020/kurdyukov2/index.html

- + + + + + +
+ + + + + + + + + +
+ + + + + + + + + +

Author:

Name: Ilya +Kurdyukov
Location: RU

+ + +

To build:

+
make
+

To use:

+
./prog
+

Try:

+
# Take a selfie
+./prog 1000 selfie.jpg output.jpg
+# Admire your portrait in cubist style
+
+./try.sh
+

Judges’ remarks:

+

This entry has reminded us of a winning entry back in the early 90s. +Can you guess which one?

+

For a given image, try graphing the execution time relative to the +number of rectangles. What is the complexity? Is it obvious from the +source code?

+

Author’s remarks:

+

Usage

+

This program divides the image into a specified number of rectangles. +This process is content aware, so the algorithm tries to match most of +the information. However, it doesn’t find the best theoretically +possible layout.

+
./prog 1000 input.jpg output.jpg
+

Building

+

You can build three versions, depending on the image format.

+

Default is JPEG version; if you have the libjpeg +development package installed in your system, then make +without arguments should do the right thing.

+

If you want to use libjpeg compiled from sources, then +use the LIBJPEG define to specify the path to includes and +the library. For example using libjpeg source +version 9c:

+
make prog LIBJPEG="-Ijpeg-9c jpeg-9c/libjpeg.a"
+

Use this command to build a PNG version (you need +libpng):

+
make prog_png LIBPNG="-lpng"
+

And the PPM version (no additional dependencies, can read raw/ASCII +PPM, writes raw PPM):

+
make prog_ppm
+

Building on macOS with +MacPorts:

+

Thanks to Cody Boone +Ferguson for this information!

+

First, make sure you have the compiler tools installed e.g. by:

+
sudo xcode-select --install
+

Make sure you install MacPorts. Then do:

+
sudo port install jpeg libpng ImageMagick
+

The program itself doesn’t need ImageMagick, install it only if you +plan to make GIFs from the results using makegif.sh.

+

After that’s installed you need to run make with these options:

+
make LDFLAGS="-I/opt/local/include -L/opt/local/lib"
+

Building on macOS with +HomeBrew

+

First, make sure you have the compiler tools installed e.g. by:

+
sudo xcode-select --install
+

Make sure you install HomeBrew.

+

Then:

+
brew install libjpeg libpng
+eval "$(brew shellenv)"
+

You are now ready to compile this entry:

+
make clobber all
+

Notes

+

Made this thing while experimenting with the idea of representing an +image with rectangles (lossy compression). It’s not very good in that +sense, but the results look funny, like a kind of cubism pixel art.

+

Do not use values above 50000, it’ll be slow.

+

To understand how this works, just try running with 1,2,3,4… number +of rectangles. At each iteration, the rectangle with the biggest +difference from the picture data is split (halves may have different +size) horizontally or vertically to get the minimum difference.

+

You can use this command to make a GIF from output images (uses +ImageMagick). For instance after running the command suggested by the +judges:

+
convert -delay 10 -dither none -loop 0 $(ls out*.jpg | sort -V) $(ls out*.jpg | sort -rV) +map out.gif
+

Also provided makegif.sh to aid with GIF creation.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2020/kurdyukov2

+

Primary files

+ +

Secondary files

+
    +
  • .gitignore +- list of files that should not be committed under git
  • +
  • .path - directory path from top directory
  • +
  • .winner.json +- description of winner in JSON
  • +
  • README.md +- markdown source for index.html
  • +
+ + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2020/kurdyukov3/index.html b/2020/kurdyukov3/index.html index 3b6919b5a..2b1b04bec 100644 --- a/2020/kurdyukov3/index.html +++ b/2020/kurdyukov3/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,231 @@ - - + + + + + + - - -2020 kurdyukov3 - - + + + +2020/kurdyukov3 + + + + + -

2020 kurdyukov3

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2020/kurdyukov3

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2020/kurdyukov3/index.html

- + + + + + +
+ + + + + + + + + +
+ + + + + + + + + +

Author:

Name: Ilya +Kurdyukov
Location: RU

+ + +

To build:

+
make
+

There is an alternate version of this program. See Alternate code below.

+

To use:

+
./prog
+

Try:

+
./try.sh
+

Alternate code:

+

The alternate version, prog.alt.c, has the +main code as a macro.

+

Alternate build:

+
make alt
+

Alternate use:

+

Use prog.alt as you would prog above.

+

Judges’ remarks:

+

It is interesting how well smeonoe can raed txet wtih lots of tyops +in it. How well can you raed porg.c, C prgoarm that is in the shpae of +an SD card (or is it a pnuch crad)?

+

BTW: this funny reading of English (which also works with several +other languages) is called typoglycemia +(the article however is incorrect in stating that if the letters were +more jumbled or if other words were formed one could not read it: we +know of some who can in fact do exactly that). Also, to be clear, there +was no such study stated in input.txt but as +you’ll likely see you should be able to do exactly what it says +nonetheless.

+

Author’s remarks:

+

Letter Mixer

+

Compile and try this:

+
cat input.txt | ./prog
+

The program can work with letters that are not represented in +English, as long as these letters are encoded in the higher part of the +single-byte character set (use iconv to convert from UTF-8 +and back).

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2020/kurdyukov3

+

Primary files

+ +

Secondary files

+
    +
  • .gitignore +- list of files that should not be committed under git
  • +
  • .path - directory path from top directory
  • +
  • .winner.json +- description of winner in JSON
  • +
  • README.md +- markdown source for index.html
  • +
+ + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2020/kurdyukov4/index.html b/2020/kurdyukov4/index.html index 5d1620025..57a5997d9 100644 --- a/2020/kurdyukov4/index.html +++ b/2020/kurdyukov4/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,292 @@ - - + + + + + + - - -2020 kurdyukov4 - - + + + +2020/kurdyukov4 + + + + + -

2020 kurdyukov4

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2020/kurdyukov4

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2020/kurdyukov4/index.html

- + + + + + +
+ + + + + + + + + +
+ + + + + + + + + +

Author:

Name: Ilya +Kurdyukov
Location: RU

+ + +

To build:

+
make
+

To use:

+
./prog text_file output_length context_length random_seed
+

Try:

+

When running this, ask yourself why it gets progressively slower when +the context length decreases:

+
./try.sh
+
+

Performance depends on the number of same hashes found. Too many +identical strings if the context length is small. – Author

+
+

Judges’ remarks:

+

We were able to write our own program performing +the same trick using the (still non-standard, for some reason) library +function memmem(), but that way it works too fast +regardless of the context length, and it’s much less fun.

+

The author wrote in reply:

+
+

Wow, amazing! Very fast, but there is a drawback to randomness. If +some string only appears after half the input, the first instance of +this string will have a 50% chance of occurrence. Example:

+
echo "00000000000000000000 01 02 02 02 02 02 02" > test.txt
+./prog test.txt 1000 2 123
+# more twos in output
+./rand test.txt 1000 2 123
+# more ones in output
+
+

But this will happen very rarely on real data. – Author

+
+
+

Try using the same random seed and varying the context size.

+

BTW: what on Middle-earth is lámatyávë? It’s Quenya, one +of the languages of the Elves in Tolkien’s Legendarium. It means sound +taste (plural is lámatyáver) and it refers to phonaesthesia - in other +words, it refers to the pleasure of sound and form of words. It’s +discussed in Morgoth’s +Ring, volume X of History +of Middle-earth (HoMe). Now can you appreciate the award title a bit +better?

+

Author’s remarks:

+

Building:

+
cc prog.c -o prog
+

Usage:

+

This program generates random text from the provided dictionary using +a Markov chain, outputting to stdout.

+
./prog input.txt 2000 10 12345
+

Parameters are:

+
    +
  1. dictionary filename Need at least the size of the book, the more +the better (1Mb); you can concatenate several books into one file. This +should be a text file (not .doc/.pdf). You can +feed it with books in .fb2 format, metadata is filtered. +Whitespace characters are also filtered. For languages other than +English, it’s better to use ANSI encoding. You can use UTF, but you need +to increase the chain length (if one ANSI character is encoded as two +UTF bytes, then multiply chain length by two).

  2. +
  3. bytes to generate (limited to 1Mb)

  4. +
  5. chain length Randomness and performance depend inversely on this +parameter and the size of the dictionary. If you feel that the bytes are +generated too slowly, then you need to increase the length of the chain. +This length means that any part of the output of this size in bytes +exists somewhere in the dictionary.

  6. +
  7. random seed

  8. +
+

Example

+

You can try this with the inputs provided with 2019/mills from the IOCCC winners.

+
$ ./prog Shakespeare.txt 2001 10 12345
+

produces:

+
r sons, wives for them, as the hope I had it. This is the way they be not too ra
+sh a trial of you only. Therefore will not out of door? Nurse: Marry, bachelor,
+Have other some, he is in Rome: but where is Warwick frowns at his. PRINCE EDWAR
+D: Where is the light: But I will watch thy waking, what work he makes Amongst y
+ou? Come, sirs, We shall write to you, fortune and The hazard of much blood. I w
+ould to heaven, respective lenity, And fire-eyed fury be my convoy in the senten
+ced; 'tis too horrible, so bloody on the banks If they were created, Would bring
+ them to our presence? FLORIZEL: And those his golden crown, What is six winters
+? they are but Lewis and Warwick bids you come too late come from the king's fri
+end, and will do't; for, look you, sir, For still thy true servitor: I will rend
+ an oak And peg thee in his knotty entrails till Thou hast hazel eyes: what eye
+but such an eye would spy out such a day to-morrow, or next day: He is within th
+e limit of the like, forsworn to love, Send her a story of more woe Than this is
+ a merry ballad, but a very pretty one. MOPSA: Thou hast amazed me, My name is E
+lbow: I do lean upon, Now thou art: Thy tears are womanish; thy wild acts denote
+ The unreasonably: come, you must: and there, I then do't to them? VOLUMNIA: Now
+ the red pestilence hangs in our aim, which is yours. What is't your honour, as
+in war, since then, You have said before: My child is dead; or 'twere not 'long
+of him; but he, like you, lads; about your ears it is Menenius? Second Officer:
+Come, come, young wanton and effeminate boy, Takes on the hungry beach Fillip th
+e stars Shall bitterly begin his wooing that we have in hand are angry And frown
+ing brow to brow, ourselves, Still your own affections are devised, As blanks, b
+enevolences, and I thank thee for it. KING HENRY VI: Master lieutenant comes. Ma
+ster lieutenant comes. Master lieutenant, pray you,-- CORIOLANUS: What's that to
+ him? CHRISTOPHER: At Pembroke, Sir James Blunt, And Rice ap Thomas with a virtu
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2020/kurdyukov4

+

Primary files

+ +

Secondary files

+
    +
  • .gitignore +- list of files that should not be committed under git
  • +
  • .path - directory path from top directory
  • +
  • .winner.json +- description of winner in JSON
  • +
  • README.md +- markdown source for index.html
  • +
+ + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2020/otterness/index.html b/2020/otterness/index.html index ed0963380..26f3e2ab6 100644 --- a/2020/otterness/index.html +++ b/2020/otterness/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,309 @@ - - + + + + + + - - -2020 otterness - - + + + +2020/otterness + + + + + -

2020 otterness

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2020/otterness

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2020/otterness/index.html

- + + + + + +
+ + + + + + + + + +
+ + + + + + + + + +

Author:

Name: Nathan +Otterness
Location: US

+ + +

To build:

+
make
+

Bugs and (Mis)features:

+

The current status of this entry is:

+
STATUS: INABIAF - please **DO NOT** fix
+

For more detailed information see 2020 otterness in bugs.md.

+

To use:

+
./prog
+

Try:

+
./prog < cvikl.mid > output.mid
+# Play output.mid with your favorite player
+
+./prog < entertainer.mid > output2.mid
+# Play output2.mid with your favorite player
+

Judges’ remarks:

+

In an entry that boasts not using literals, one would expect to see +straightforward ways to produce small integers like +!(x^x)<<!(x^x), etc. but this entry is trickier than +that. Deciphering what it does, apart from reading stdin +and writing to stdout, would take a while.

+

While doing that, you can be audibly entertained by a sample +of its output.

+

Author’s remarks:

+

MIDI “boots and cats”

+

This program seeks to automatically “improve” standard MIDI files +(.mid) by adding an extra track that provides a driving drum beat to +bring some excitement into boring video-game music rips or classical +music sequences that otherwise only see the light of day when modern +musicians import them into FL Studio to copy a few chords.

+

Prerequisites

+

If you’re not using Windows Media Player or already familiar with +MIDI files, you may need to install some additional software to be able +to listen to them. For example, on Ubuntu, I was able to play them in +VLC after installing vlc-plugin-fluidsynth and +fluid-soundfont-gm.

+

You can obtain MIDIs in many places, but I mostly tested the program +using files I found here. +However, as discussed under the Limitations +section below, not all of them work correctly. I will admit to having +used +http://www.kunstderfuge.com/-/midi.asp?file=beethoven/symphony_6_1_(c)cvikl.mid +for most of my testing (see cvikl.mid).

+

Usage

+

Compile the program using the following command (I tested this using +both clang and gcc):

+
cc -pedantic -Wall -Werror -Wextra -O3 -o prog prog.c
+

The program expects a MIDI on stdin, and writes a +modified MIDI to stdout:

+
./prog <input.mid >output.mid
+

If the program encounters an error, no output will generally be +produced, and it will exit with a specific status code. Meanings of the +various status codes are listed below, under the “Program error codes” +heading. On success, the program exits with a code of 0.

+

Limitations

+
    +
  1. The program does not support MIDI files over 4 MB (specifically, +it will not take input files larger than 2^22 - 1 bytes). +This is unlikely to be a big limitation in practice, since even lengthy +MIDIs are rarely over a couple hundred KB.

  2. +
  3. Not all MIDIs set (or correctly set) their timing +information, which will lead to the tempo of the drum beat not matching +the track. This will be especially true for “live performance” .mid +files.

  4. +
  5. There may be some types of MIDI messages that the program is +unable to correctly parse, but I have rarely seen this in practice. The +largest cause of program failures, in my experience, has been Limitation +2.

  6. +
+

Obfuscation notes

+

I had one primary goal when writing this program: include no C +literals whatsoever. The final C file includes no numerical, string, or +character literals. Instead, all literals have been replaced with a +handful of global variables, which are occasionally modified throughout +the file to prevent simple uses of find-and-replace.

+

So, in a sense, this obfuscation is simply an intentional use of +global variables’ classic problem: absolute spaghetti code. The absence +of any sort of literals has the added benefit of forcing any would-be +reader to trace the contents of many variables starting from +main(), since, without literals, very little of the code +gives any inherent visual cues as to its purpose.

+

I already took the liberty of running prog.c through +clang-format, since it still fits in the size limit and the +formatting of the code was never intended to be an obfuscation technique +here.

+

Other remarks

+

MIDI files are generally divided up into one or more “tracks” that +play concurrently. While it is easy to find the positions of each of +these tracks in the file, figuring out the amount of time each track is +supposed to play is more difficult, and requires parsing every track in +its entirety. This means that generating a drum beat that covers the +entire piece of music requires parsing every track (the entire file) in +order to determine the longest track.

+

Once the program has determined the longest track in the file, it +generates a new track, containing the simple 4-note percussion sequence, +to match the length (in beats) of the longest-running track. It appends +the new track onto the end of the file, taking care to update the file +header, as well.

+

Program error codes

+

If the program encounters an error, it will exit with a nonzero code. +The error codes can be interpreted as follows:

+
    +
  • 1: Encountered an invalid MIDI variable-length integer +in the input.
  • +
  • 2: Attempted to write an invalid MIDI variable-length +integer to output. (This would be an internal error).
  • +
  • 3: Encountered an unsupported MIDI event in the +input.
  • +
  • 4: Encountered a bad MIDI track header in the +input.
  • +
  • 5: The input MIDI file uses SMPTE time division, which +isn’t supported.
  • +
  • 6: Failed allocating a temporary buffer to hold a +single copy of our “beat” messages.
  • +
  • 7: Failed allocating a buffer to hold the new track +data.
  • +
  • 8: Failed allocating a buffer to hold the input +file.
  • +
  • 9: The input file was too large.
  • +
  • 10: The input file’s MIDI header was incorrect (but +this isn’t checked very thoroughly).
  • +
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory +for 2020/otterness

+

Primary files

+ +

Secondary files

+
    +
  • .gitignore +- list of files that should not be committed under git
  • +
  • .path - directory path from top directory
  • +
  • .winner.json +- description of winner in JSON
  • +
  • README.md +- markdown source for index.html
  • +
+ + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2020/tsoj/index.html b/2020/tsoj/index.html index b3eaa66bc..a70f32546 100644 --- a/2020/tsoj/index.html +++ b/2020/tsoj/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,281 @@ - - + + + + + + - - -2020 tsoj - - + + + +2020/tsoj + + + + + -

2020 tsoj

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2020/tsoj

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2020/tsoj/index.html

- + + + + + +
+ + + + + + + + + +
+ + + + + + + + + +

Author:

Name: tsoj
Location: DE

+ + +

To build:

+
make
+

There is an alternate version which has controls that will make much +more sense to those familiar with vi. See Alternate code below.

+

To use:

+
./prog
+

Try:

+
# Make your terminal as large as possible, possibly reduce your font size
+# then...
+./prog
+

Alternate code:

+

This version has the difference of moving forwards, left, backwards +and right, where instead of w, a, +s and d, you can use k, +h, j and l.

+

Alternate build:

+
make alt
+

Alternate use:

+
# Make your terminal as large as possible, possibly reduce your font size
+# then...
+./prog.alt
+

..and maybe curse less than you might otherwise, but still probably +curse (see below) :-)

+

Judges’ remarks:

+

This game does not use curses, but you may end up cursing.

+

The code is made more difficult to read using an innovative, right +justified, reverse indentation style.

+

Author’s remarks:

+

Controls

+
    +
  • Movement: w (forwards), a (left), +s (backwards), d (right)
  • +
  • Fire: space
  • +
  • Quit: q
  • +
  • Pause: p, then use any other key to resume
  • +
+
   /\
+  //\\
+ /    \
+/______\
+  /\/\
+

Compile and run

+

Linux

+
cc -std=c99 -O3 prog.c -o prog
+./prog
+

Windows

+

The only way I found to make it work is to use MSYS2. When using the MSYS2 shell you +can install gcc via pacman.

+
cc -std=c99 -O3 prog.c -o prog
+./prog.exe
+

Warnings

+
    +
  • -Wno-missing-prototypes
  • +
  • -Wno-shorten-64-to-32
  • +
  • -Wno-sign-conversion
  • +
  • -Wno-implicit-int-float-conversion
  • +
  • -Wno-missing-field-initializers
  • +
  • -Wno-implicit-float-conversion
  • +
  • -Wno-vla
  • +
  • -Wno-float-conversion
  • +
  • -Wno-comma
  • +
  • -Wno-shadow
  • +
  • -Wno-format
  • +
  • -Wno-empty-body
  • +
  • -Wno-misleading-indentation
  • +
  • -Wno-maybe-uninitialized
  • +
  • You may experience a mild motion +aftereffect when playing for too long.
  • +
+

High score

+

Score will be shown in the top left corner. My best was +156. If you beat that I’ll send you the image of a very +expensive chocolate.

+

Features

+
    +
  • Procedural star generation.
  • +
  • Very space-efficient for loops.
  • +
  • No use of != or ==.
  • +
  • Smooth rendering even on slow terminals.
  • +
  • Advanced ASCII art.
  • +
  • Cutting edge physics engine and collision detection.
  • +
  • Probably not many segfaults.
  • +
  • Every letter in the English alphabet has a variable or function +named after it.
  • +
  • Not a virus.
  • +
  • Runs on my machine.
  • +
+

Tips

+
    +
  • Adjust your terminal size for different experiences.
  • +
  • Run this program in a virtual console to immerse yourself in the +game.
  • +
+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2020/tsoj

+

Primary files

+ +

Secondary files

+
    +
  • .gitignore +- list of files that should not be committed under git
  • +
  • .path - directory path from top directory
  • +
  • .winner.json +- description of winner in JSON
  • +
  • README.md +- markdown source for index.html
  • +
+ + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/2020/yang/index.html b/2020/yang/index.html index a183ad7bc..a78b529e7 100644 --- a/2020/yang/index.html +++ b/2020/yang/index.html @@ -1,4 +1,6 @@ + + @@ -6,27 +8,292 @@ - - + + + + + + - - -2020 yang - - + + + +2020/yang + + + + + -

2020 yang

+ + -

XXX - fake content until readme2index is working - XXX

+
+ IOCCC image by Matt Zucker +

The International Obfuscated C Code Contest

+

2020/yang

+
-
+ + - -

Nu Html check https://ioccc-src.github.io/temp-test-ioccc/2020/yang/index.html

- + + + + + +
+ + + + + + + + + +
+ + + + + + + + + +

Author:

Name: Don Yang
Location: +US

+ + +

To build:

+
make
+

To use:

+
./prog [PIN] < input.txt > output.c
+

Try:

+
./try.sh
+

The author provided the file cppp.cc which can +preprocess the generated output to make them more acceptable to typical +compilers. To build:

+
make cppp
+

See the author’s remarks for more details.

+

Judges’ remarks:

+

You might think of this entry as code obfuscater with a code. If you +use the wrong code, you’re gonna have a bad time. What is compiling this +entry about? Having a good .. +time!

+

This winning entry also comes with a JavaScript timelapse spoiler that shows how this +entry was written.

+

Author’s remarks:

+

Synopsis

+
echo "Hello world" | ./prog 12345 > encoded.c
+
+gcc -DPIN=12345 encoded.c -o ./decoded && ./decoded
+

Details

+

Mile is a C code generator. Run without arguments for the help +message below:

+
usage: [PIN] < input.txt > output.c
+
+where [PIN] is an integer in the range of 1..65535
+

When run with an encoding PIN (first command line argument), Mile +will read bytes from stdin and generate C code on +stdout. Example:

+
echo "Hello, world!" | ./prog 56789 > encoded.c
+

This generated code will reproduce the same input bytes on +stdout when executed, if it was compiled with the same +encoding PIN.

+
gcc -DPIN=56789 encoded.c -o decoded
+

The generated code reconstructs all data at compile time by seeding a +random number generator with the given PIN to reproduce the input bytes, +and simply does one fwrite(3) call at run time to print +those bytes. Not specifying a PIN is a compile time error. Specify the +wrong PIN and output code will still compile, but will likely produce +garbage instead of the input bytes. If the original input was empty then +any PIN works, but you might get a compile time warning complaining +about empty arrays.

+

Because all data is reconstructed at compile time, expect the compile +time to be excruciatingly long if you try to encode too much data. Code +generated by encoding a haiku will probably compile in seconds, a +limerick may require tens of seconds, a sonnet will take minutes. Give +Mile an epic poem and you can probably write a faster preprocessor +before GCC is done (Clang probably already failed long before then).

+

I see that there is a lack of preprocessor abuse in recent years, +probably because programming in preprocessor is too tedious. Mile is +meant to help with that by producing C code filled with at least 98% +preprocessor lines for any input. Now you too can enjoy long compile +times with minimal effort.

+

Features

+
    +
  • Output is randomized using system clock, so if you wait a second +between runs, you should get a different generated code even for the +same encoding PIN.

  • +
  • Customized bytecode encoding of preprocessor boilerplates, mostly +for compression but should also make reverse engineering more +fun.

  • +
  • CRC32 of the source code is embedded in the source code +itself.

  • +
  • Code layout shaped to resemble “Mile” from “Didn’t I Say to Make +My Abilities Average in the Next Life?!”. Mile is known to be able to +talk to nanomachines directly, which is exactly what programming in +preprocessor feels like.

  • +
+

Compatibility

+

Mile has been verified to work in these environments (also, compiles +without warnings on all of these):

+
    +
  • gcc 9.2.0 on Cygwin
  • +
  • gcc 8.3.0 on Linux
  • +
  • gcc 7.4.0 on Cygwin
  • +
  • gcc 6.1.0 on JSLinux
  • +
  • gcc 5.4.0 on Linux
  • +
  • clang 8.0.1 on Linux
  • +
  • clang 8.0.1 on Cygwin
  • +
  • tcc 0.9.27 on Linux
  • +
  • tcc 0.9.25 on JSLinux
  • +
+

Output of Mile is a bit more taxing, and only works with a subset of +the above:

+
    +
  • gcc: works just fine when using 8.3.0 and below, but may trigger +warning for large files. gcc 9.2.0 and above may crash with large +files.
  • +
  • clang: works fine for small files, fails on large files due to preprocessor +bug.
  • +
  • tcc: works just fine on Linux. Fails silently on JSLinux.
  • +
+

For people eager to encode large files, an extra utility has been +packaged with this entry to preprocess the generated output to make them +more acceptable to typical compilers. View the cppp.cc source and then compile it with a c++ +compiler of your choice.

+ +

This file is Copyright (c) 2023 by Landon Curt Noll. All Rights +Reserved. You are free to share and adapt this file under the terms of +this license:

+
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
+

For more information, see: +https://creativecommons.org/licenses/by-sa/4.0/

+ + +

Inventory for +2020/yang

+

Primary files

+ +

Secondary files

+
    +
  • .gitignore +- list of files that should not be committed under git
  • +
  • .path - directory path from top directory
  • +
  • .winner.json +- description of winner in JSON
  • +
  • README.md +- markdown source for index.html
  • +
+ + + + + + + +
+ + + + +
+ + + + + + + + + + diff --git a/author/Anonymous_2001.json b/author/Anonymous_2001.json new file mode 100644 index 000000000..9d46b65e9 --- /dev/null +++ b/author/Anonymous_2001.json @@ -0,0 +1,20 @@ +{ + "no_comment" : "mandatory comment: because comments were removed from the original JSON spec", + "author_JSON_format_version" : "1.0 2023-06-10", + "author_handle" : "Anonymous_2001", + "full_name" : "Anonymous 2001", + "sort_word" : "anonymous", + "location_code" : "GB", + "location_name" : "Great Britain", + "email" : null, + "url" : null, + "alt_url" : null, + "deprecated_twitter_handle" : null, + "mastodon" : null, + "mastodon_url" : null, + "github" : null, + "affiliation" : null, + "winning_entry_set" : [ + { "winner_id" : "2001_anonymous" } + ] +} diff --git a/author/Jari_Arkko.json b/author/Jari_Arkko.json index 0f91c6f62..094a4459f 100644 --- a/author/Jari_Arkko.json +++ b/author/Jari_Arkko.json @@ -15,7 +15,7 @@ "github" : null, "affiliation" : null, "winning_entry_set" : [ - { "winner_id" : "1989_jar1" }, + { "winner_id" : "1989_jar.1" }, { "winner_id" : "1989_jar.2" }, { "winner_id" : "2000_jarijyrki" } ] diff --git a/bin/README.md b/bin/README.md index dd509bdd0..c76fb8177 100644 --- a/bin/README.md +++ b/bin/README.md @@ -13,6 +13,11 @@ as well as various JSON files and other content from the ## bin tools +### [all_run.sh](all_run.sh) + +Run a command on all winning entries. + + ### [gen-author.sh](gen-author.sh) Output winning author(s) Related HTML. diff --git a/bin/all_run.sh b/bin/all_run.sh new file mode 100755 index 000000000..bcd88af8e --- /dev/null +++ b/bin/all_run.sh @@ -0,0 +1,519 @@ +#!/usr/bin/env bash +# +# all_run.sh - run a command for all winners +# +# Copyright (c) 2024 by Landon Curt Noll. All Rights Reserved. +# +# Permission to use, copy, modify, and distribute this software and +# its documentation for any purpose and without fee is hereby granted, +# provided that the above copyright, this permission notice and text +# this comment, and the disclaimer below appear in all of the following: +# +# supporting documentation +# source copies +# source works derived from this source +# binaries derived from this source or from derived source +# +# LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO +# EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. +# +# chongo (Landon Curt Noll, http://www.isthe.com/chongo/index.html) /\oo/\ +# +# Share and enjoy! :-) + +# firewall - must be bash with a version 4.2 or later +# +# We must declare arrays with -ag or -Ag +# +if [[ -z ${BASH_VERSINFO[0]} || ${BASH_VERSINFO[0]} -lt 4 || ${BASH_VERSINFO[0]} -eq 4 && ${BASH_VERSINFO[1]} -lt 2 ]]; then + echo "$0: ERROR: bash version must be >= 4.2: $BASH_VERSION" 1>&2 + exit 4 +fi + +# setup bash file matching +# +# Requires bash with a version 4.2 or later +# +shopt -s nullglob # enable expanded to nothing rather than remaining unexpanded +shopt -u failglob # disable error message if no matches are found +shopt -u dotglob # disable matching files starting with . +shopt -s globskipdots # enable never matching . nor .. +shopt -u nocaseglob # disable strict case matching +shopt -u extglob # enable extended globbing patterns +shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories + +# set variables referenced in the usage message +# +export VERSION="1.1 2024-01-16" +NAME=$(basename "$0") +export NAME +export V_FLAG=0 +GIT_TOOL=$(type -P git) +export GIT_TOOL +if [[ -z "$GIT_TOOL" ]]; then + echo "$0: FATAL: git tool is not installed or not in PATH" 1>&2 + exit 10 +fi +"$GIT_TOOL" rev-parse --is-inside-work-tree >/dev/null 2>&1 +status="$?" +if [[ $status -eq 0 ]]; then + TOPDIR=$("$GIT_TOOL" rev-parse --show-toplevel) +fi +export PANDOC_WRAPPER="bin/pandoc_wrapper.sh" +export PANDOC_WRAPPER_OPTSTR="-f markdown -t html --fail-if-warnings=true" +export REPO_URL="https://github.com/ioccc-src/temp-test-ioccc" +export TOP_URL="https://ioccc-src.github.io/temp-test-ioccc" +export DOCROOT_URL_SLASH="/temp-test-ioccc/" +# +export NOOP= +export DO_NOT_PROCESS= +export EXIT_CODE="0" + +# usage +# +export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N] + [-p tool] [-P optstr] [-u repo_url] [-U top_url] [-e string ..] [-E exitcode] + tool [tool_options] + + -h print help message and exit + -v level set verbosity level (def level: 0) + -V print version string and exit + + -d topdir set topdir (def: $TOPDIR) + NOTE: The '-d topdir' is passed as leading options on tool command lines. + + -n go thru the actions, but do not update any files (def: do the action) + NOTE: -n is passed to tool + -N do not process file, just parse arguments and ignore the file (def: process the file) + NOTE: -N disables running a tool + + -p tool run 'pandoc wrapper tool' (not pandoc path) during HTML phase number 21 (def: use $PANDOC_WRAPPER) + NOTE: The '-p tool' is passed as leading options on tool command lines. + -P pandoc_opts run 'pandoc wrapper tool' with options found in 'optstr' (def: $PANDOC_WRAPPER_OPTSTR) + NOTE: The '-P pandoc_opts' is passed as leading options on tool command lines. + NOTE: The 'pandoc_opts' may not contain a single-quote, nor a double-quote. + + -u repo_url Base level URL of target git repo (def: $REPO_URL) + NOTE: The '-u repo_url' is passed as leading options on tool command lines. + -U top_url Top level URL of web site where HTML files will be viewed (def: $TOP_URL) + NOTE: The '-U top_url' is passed as leading options on tool command lines. + + tool the tool to run over all winners + tool_options tool command line options to use before YYYY/dir + NOTE: You must use -- after the tool command line option and before 'tool_options' + +Exit codes: + 0 all OK + 1 some execution of tool exited non-zero + 2 -h and help string printed or -V and version string printed + 3 command line error + 4 bash version is < 4.2 + 5 tool is not an executable + 6 topdir is not in proper form + 7 topdir/YYYY is not in proper form + 8 topdir/YYYY/dir is not in proper form + >= 10 < 200 internal error + >= 200 ((not used)) + +$NAME version: $VERSION" + +# parse command line +# +while getopts :hv:Vd:nNp:P:u:U: flag; do + case "$flag" in + h) echo "$USAGE" 1>&2 + exit 2 + ;; + v) V_FLAG="$OPTARG" + ;; + V) echo "$VERSION" + exit 2 + ;; + d) TOPDIR="$OPTARG" + ;; + n) NOOP="-n" + ;; + N) DO_NOT_PROCESS="-N" + ;; + p) PANDOC_WRAPPER="$OPTARG" + ;; + P) # parse -P optstr + case "$OPTARG" in + *"'"*) + echo "$0: ERROR: in -P optstr, the optstr may not contain a single-quote character: $OPTARG" 1>&2 + echo 1>&2 + print_usage 1>&2 + exit 3 + ;; + *'"'*) + echo "$0: ERROR: in -P optstr, the optstr may not contain a double-quote character: $OPTARG" 1>&2 + echo 1>&2 + print_usage 1>&2 + exit 3 + ;; + *) ;; + esac + PANDOC_WRAPPER_OPTSTR="$OPTARG" + ;; + u) REPO_URL="$OPTARG" + ;; + U) TOP_URL="$OPTARG" + ;; + \?) echo "$0: ERROR: invalid option: -$OPTARG" 1>&2 + echo 1>&2 + print_usage 1>&2 + exit 3 + ;; + :) echo "$0: ERROR: option -$OPTARG requires an argument" 1>&2 + echo 1>&2 + echo "$USAGE" 1>&2 + exit 3 + ;; + *) echo "$0: ERROR: unexpected value from getopts: $flag" 1>&2 + echo 1>&2 + echo "$USAGE" 1>&2 + exit 3 + ;; + esac +done +# +if [[ $V_FLAG -ge 1 ]]; then + echo "$0: debug[1]: debug level: $V_FLAG" 1>&2 +fi +# +# remove the options +# +shift $(( OPTIND - 1 )); +# +if [[ $V_FLAG -ge 5 ]]; then + echo "$0: debug[5]: file argument count: $#" 1>&2 +fi +# +# verify arg count and parse args +# +export TOOL TOOL_OPTIONS +case "$#" in +0) echo "$0: ERROR: expected 1 or more args, found: $#" 1>&2 + echo "$USAGE" 1>&2 + exit 3 + ;; +1) TOOL="$1" + ;; +*) TOOL="$1" + shift + TOOL_OPTIONS="$*" + ;; +esac + +# verify that we have a topdir directory +# +REPO_NAME=$(basename "$REPO_URL") +export REPO_NAME +if [[ -z $TOPDIR ]]; then + echo "$0: ERROR: cannot find top of git repo directory" 1>&2 + echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2 + exit 6 +fi +if [[ ! -d $TOPDIR ]]; then + echo "$0: ERROR: TOPDIR is not a directory: $TOPDIR" 1>&2 + echo "$0: Notice: if needed: $GIT_TOOL clone $REPO_URL; cd $REPO_NAME" 1>&2 + exit 6 +fi + +# verify that we have an author subdirectory +# +export AUTHOR_PATH="$TOPDIR/author" +if [[ ! -d $AUTHOR_PATH ]]; then + echo "$0: ERROR: author is not a directory under topdir: $AUTHOR_PATH" 1>&2 + exit 6 +fi +export AUTHOR_DIR="author" + +# verify that we have an inc subdirectory +# +export INC_PATH="$TOPDIR/inc" +if [[ ! -d $INC_PATH ]]; then + echo "$0: ERROR: inc is not a directory under topdir: $INC_PATH" 1>&2 + exit 6 +fi +export INC_DIR="inc" + +# verify that we have an bin subdirectory +# +export BIN_PATH="$TOPDIR/bin" +if [[ ! -d $BIN_PATH ]]; then + echo "$0: ERROR: bin is not a directory under topdir: $BIN_PATH" 1>&2 + exit 6 +fi +export BIN_DIR="bin" + +# cd to topdir +# +if [[ ! -e $TOPDIR ]]; then + echo "$0: ERROR: cannot cd to non-existent path: $TOPDIR" 1>&2 + exit 6 +fi +if [[ ! -d $TOPDIR ]]; then + echo "$0: ERROR: cannot cd to a non-directory: $TOPDIR" 1>&2 + exit 6 +fi +export CD_FAILED +if [[ $V_FLAG -ge 5 ]]; then + echo "$0: debug[5]: about to: cd $TOPDIR" 1>&2 +fi +cd "$TOPDIR" || CD_FAILED="true" +if [[ -n $CD_FAILED ]]; then + echo "$0: ERROR: cd $TOPDIR failed" 1>&2 + exit 6 +fi +if [[ $V_FLAG -ge 3 ]]; then + echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2 +fi + +# verify we have a non-empty readable .top file +# +TOP_FILE=".top" +if [[ ! -e $TOP_FILE ]]; then + echo "$0: ERROR: .top does not exist: $TOP_FILE" 1>&2 + exit 6 +fi +if [[ ! -f $TOP_FILE ]]; then + echo "$0: ERROR: .top is not a regular file: $TOP_FILE" 1>&2 + exit 6 +fi +if [[ ! -r $TOP_FILE ]]; then + echo "$0: ERROR: .top is not an readable file: $TOP_FILE" 1>&2 + exit 6 +fi +if [[ ! -s $TOP_FILE ]]; then + echo "$0: ERROR: .top is not a non-empty readable file: $TOP_FILE" 1>&2 + exit 6 +fi + +# verify tool is executable +# +if [[ ! -e $TOOL ]]; then + echo "$0: ERROR: TOOL does not exist: $TOOL" 1>&2 + exit 5 +fi +if [[ ! -f $TOOL ]]; then + echo "$0: ERROR: TOOL is not a regular file: $TOOL" 1>&2 + exit 5 +fi +if [[ ! -x $TOOL ]]; then + echo "$0: ERROR: TOOL is not an executable file: $TOOL" 1>&2 + exit 5 +fi + +# print running info if verbose +# +if [[ $V_FLAG -ge 3 ]]; then + echo "$0: debug[3]: NAME=$NAME" 1>&2 + echo "$0: debug[3]: REPO_URL=$REPO_URL" 1>&2 + echo "$0: debug[3]: REPO_NAME=$REPO_NAME" 1>&2 + echo "$0: debug[3]: TOP_URL=$TOP_URL" 1>&2 + echo "$0: debug[3]: TOP_FILE=$TOP_FILE" 1>&2 + echo "$0: debug[3]: AUTHOR_PATH=$AUTHOR_PATH" 1>&2 + echo "$0: debug[3]: AUTHOR_DIR=$AUTHOR_DIR" 1>&2 + echo "$0: debug[3]: INC_PATH=$INC_PATH" 1>&2 + echo "$0: debug[3]: INC_DIR=$INC_DIR" 1>&2 + echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2 + echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2 + echo "$0: debug[3]: DO_NOT_PROCESS=$DO_NOT_PROCESS" 1>&2 + echo "$0: debug[3]: NOOP=$NOOP" 1>&2 +fi + +# process each year +# +export YYYY +for YYYY in $(< "$TOP_FILE"); do + + # debug YYYY + # + if [[ $V_FLAG -ge 1 ]]; then + echo "$0: debug[1]: starting to process year: $YYYY" 1>&2 + fi + + # verify that YYYY is a readable directory + # + if [[ ! -e $YYYY ]]; then + echo "$0: ERROR: YYYY does not exist: $YYYY" 1>&2 + EXIT_CODE="7" # exit 7 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + if [[ ! -d $YYYY ]]; then + echo "$0: ERROR: YYYY is not a directory: $YYYY" 1>&2 + EXIT_CODE="7" # exit 7 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + if [[ ! -r $YYYY ]]; then + echo "$0: ERROR: YYYY is not an readable directory: $YYYY" 1>&2 + EXIT_CODE="7" # exit 7 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + + # verify that YYYY has a non-empty readable .year file + # + export YEAR_FILE="$YYYY/.year" + if [[ ! -e $YEAR_FILE ]]; then + echo "$0: ERROR: YYYY/.year does not exist: $YEAR_FILE" 1>&2 + EXIT_CODE="7" # exit 7 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + if [[ ! -f $YEAR_FILE ]]; then + echo "$0: ERROR: YYYY/.year is not a regular file: $YEAR_FILE" 1>&2 + EXIT_CODE="7" # exit 7 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + if [[ ! -r $YEAR_FILE ]]; then + echo "$0: ERROR: YYYY/.year is not an readable file: $YEAR_FILE" 1>&2 + EXIT_CODE="7" # exit 7 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + if [[ ! -s $YEAR_FILE ]]; then + echo "$0: ERROR: YYYY/.year is not a non-empty readable file: $YEAR_FILE" 1>&2 + EXIT_CODE="7" # exit 7 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + + # process each winner under YYYY + # + export WINNER_PATH + for WINNER_PATH in $(< "$YEAR_FILE"); do + + # debug YYYY + # + if [[ $V_FLAG -ge 3 ]]; then + echo "$0: debug[3]: starting to process year/dir: $WINNER_PATH" 1>&2 + fi + + # parse WINNER_PATH + # + if [[ ! -d $WINNER_PATH ]]; then + echo "$0: ERROR: WINNER_PATH is not a directory: $WINNER_PATH" 1>&2 + EXIT_CODE="7" # exit 7 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + if [[ ! -w $WINNER_PATH ]]; then + echo "$0: ERROR: WINNER_PATH is not a writable directory: $WINNER_PATH" 1>&2 + EXIT_CODE="7" # exit 7 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + export YEAR_DIR=${WINNER_PATH%%/*} + if [[ -z $YEAR_DIR ]]; then + echo "$0: ERROR: WINNER_PATH not in yyyy/dir form: $WINNER_PATH" 1>&2 + EXIT_CODE="7" # exit 7 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + export WINNER_DIR=${WINNER_PATH#*/} + if [[ -z $WINNER_DIR ]]; then + echo "$0: ERROR: WINNER_PATH not in $YEAR_DIR/dir form: $WINNER_PATH" 1>&2 + EXIT_CODE="7" # exit 7 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + if [[ $WINNER_DIR = */* ]]; then + echo "$0: ERROR: WINNER_PATH: $WINNER_PATH dir contains a /: $WINNER_DIR" 1>&2 + EXIT_CODE="7" # exit 7 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + + # verify that WINNER_PATH is a writable directory + # + if [[ ! -e $WINNER_PATH ]]; then + echo "$0: ERROR: WINNER_PATH does not exist: $WINNER_PATH" 1>&2 + EXIT_CODE="8" # exit 8 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + if [[ ! -d $WINNER_PATH ]]; then + echo "$0: ERROR: WINNER_PATH is not a directory: $WINNER_PATH" 1>&2 + EXIT_CODE="8" # exit 8 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + if [[ ! -w $WINNER_PATH ]]; then + echo "$0: ERROR: WINNER_PATH is not an writable directory: $WINNER_PATH" 1>&2 + EXIT_CODE="8" # exit 8 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + + # verify YYYY/dir/.path + # + export DOT_PATH="$WINNER_PATH/.path" + if [[ ! -s $DOT_PATH ]]; then + echo "$0: ERROR: not a non-empty file: $DOT_PATH" 1>&2 + EXIT_CODE="8" # exit 8 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + DOT_PATH_CONTENT=$(< "$DOT_PATH") + if [[ $WINNER_PATH != "$DOT_PATH_CONTENT" ]]; then + echo "$0: ERROR: arg: $WINNER_PATH does not match $DOT_PATH contents: $DOT_PATH_CONTENT" 1>&2 + EXIT_CODE="8" # exit 8 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + export WINNER_JSON="$WINNER_PATH/.winner.json" + if [[ ! -e $WINNER_JSON ]]; then + echo "$0: ERROR: .winner.json does not exist: $WINNER_JSON" 1>&2 + EXIT_CODE="8" # exit 8 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + if [[ ! -f $WINNER_JSON ]]; then + echo "$0: ERROR: .winner.json is not a file: $WINNER_JSON" 1>&2 + EXIT_CODE="8" # exit 8 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + if [[ ! -r $WINNER_JSON ]]; then + echo "$0: ERROR: .winner.json is not a readable file: $WINNER_JSON" 1>&2 + EXIT_CODE="8" # exit 8 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + + # run the tool + # + if [[ -z $DO_NOT_PROCESS ]]; then + + # run the tool + # + if [[ -z $NOOP ]]; then + if [[ $V_FLAG -ge 5 ]]; then + echo "$0: debug[5]: about to run: $TOOL -d \"$TOPDIR\" -p \"$PANDOC_WRAPPER\"" \ + "-P \"$PANDOC_WRAPPER_OPTSTR\" -u \"$REPO_URL\" -U \"$TOP_URL\" $TOOL_OPTIONS \"$WINNER_PATH\"" 1>&2 + fi + eval "$TOOL" -d '"'"$TOPDIR"'"' -p '"'"$PANDOC_WRAPPER"'"' -P '"'"$PANDOC_WRAPPER_OPTSTR"'"' \ + -u '"'"$REPO_URL"'"' -U '"'"$TOP_URL"'"' "$TOOL_OPTIONS" '"'"$WINNER_PATH"'"' + status="$?" + if [[ $status -ne 0 ]]; then + echo "$0: ERROR: tool: $TOOL failed, error: $status" 1>&2 + EXIT_CODE="1" # exit 1 + echo "$0: Warning: EXIT_CODE set to: $EXIT_CODE" 1>&2 + fi + + # report disabled by -n + # + elif [[ $V_FLAG -ge 5 ]]; then + echo "$0: debug[5]: because of -n, did not run: $TOOL -d \"$TOPDIR\" -p \"$PANDOC_WRAPPER\"" \ + "-P \"$PANDOC_WRAPPER_OPTSTR\" -u \"$REPO_URL\" -U \"$TOP_URL\" $TOOL_OPTIONS \"$WINNER_PATH\"" 1>&2 + fi + + # report disabled by -N + # + else + if [[ $V_FLAG -ge 5 ]]; then + echo "$0: debug[5]: arguments parsed, -N given, not running tool" 1>&2 + fi + fi + done +done + +# All Done!!! -- Jessica Noll, Age 2 +# +if [[ $V_FLAG -ge 1 ]]; then + echo "$0: debug[1]: about to exit $EXIT_CODE" 1>&2 +fi +if [[ $EXIT_CODE -ne 0 ]]; then + echo "$0: Warning: about to exit non-zero: $EXIT_CODE" 1>&2 +fi +exit "$EXIT_CODE" diff --git a/bin/gen-author.sh b/bin/gen-author.sh index f3e65494a..2050655ba 100755 --- a/bin/gen-author.sh +++ b/bin/gen-author.sh @@ -55,7 +55,7 @@ shopt -s globstar # enable ** to match all files and zero or more directories an # set variables referenced in the usage message # -export VERSION="1.3 2024-01-14" +export VERSION="1.3.1 2024-01-16" NAME=$(basename "$0") export NAME export V_FLAG=0 @@ -78,9 +78,8 @@ export DOCROOT_URL_SLASH="/temp-test-ioccc/" # set usage message # -export USAGE="usage: $0 [-h] [-v level] [-V] [-n] [-N] - [-d topdir] [-p tool] [-P optstr] - [-u repo_url] [-U top_url] [-e string ..] [-E exitcode] +export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N] + [-p tool] [-P optstr] [-u repo_url] [-U top_url] [-e string ..] [-E exitcode] yyyy/dir -h print help message and exit @@ -94,7 +93,7 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-n] [-N] -p tool run 'pandoc wrapper tool' (not pandoc path) during HTML phase number 21 (def: use $PANDOC_WRAPPER) -P pandoc_opts run 'pandoc wrapper tool' with options found in 'optstr' (def: $PANDOC_WRAPPER_OPTSTR) - NOTE: The 'optstr' may not contain a single-quote, nor a double-quote. + NOTE: The 'pandoc_opts' may not contain a single-quote, nor a double-quote. -u repo_url Base level URL of target git repo (def: $REPO_URL) -U top_url Top level URL of web site where HTML files will be viewed (def: $TOP_URL) @@ -698,7 +697,6 @@ fi else echo '**Author:**' fi - echo } | if [[ -z $NOOP ]]; then cat >> "$TMP_FILE" elif [[ $V_FLAG -ge 3 ]]; then @@ -736,14 +734,12 @@ for author_handle in $AUTHOR_HANDLE_SET; do # write this author's information # { - echo "Name: [$FULL_NAME](${DOCROOT_URL_SLASH}winners.html#$author_handle)
" + echo "

Name: [$FULL_NAME](${DOCROOT_URL_SLASH}winners.html#$author_handle)
" if [[ $LOCATION_CODE == null ]]; then echo "Location: [unknown](${DOCROOT_URL_SLASH}location.html#$LOCATION_CODE)" else - echo "Location: [$LOCATION_CODE](${DOCROOT_URL_SLASH}location.html#$LOCATION_CODE)" fi - echo } | if [[ -z $NOOP ]]; then cat >> "$TMP_FILE" elif [[ $V_FLAG -ge 3 ]]; then diff --git a/bin/gen-inventory.sh b/bin/gen-inventory.sh index af460dd63..bdc7eab75 100755 --- a/bin/gen-inventory.sh +++ b/bin/gen-inventory.sh @@ -55,7 +55,7 @@ shopt -s globstar # enable ** to match all files and zero or more directories an # set variables referenced in the usage message # -export VERSION="1.0 2024-01-14" +export VERSION="1.0.1 2024-01-16" NAME=$(basename "$0") export NAME export V_FLAG=0 @@ -77,9 +77,8 @@ export TOP_URL="https://ioccc-src.github.io/temp-test-ioccc" # set usage message # -export USAGE="usage: $0 [-h] [-v level] [-V] [-n] [-N] - [-d topdir] [-p tool] [-P optstr] - [-u repo_url] [-U top_url] [-e string ..] [-E exitcode] +export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N] + [-p tool] [-P optstr] [-u repo_url] [-U top_url] [-e string ..] [-E exitcode] yyyy/dir -h print help message and exit @@ -93,7 +92,7 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-n] [-N] -p tool run 'pandoc wrapper tool' (not pandoc path) during HTML phase number 21 (def: use $PANDOC_WRAPPER) -P pandoc_opts run 'pandoc wrapper tool' with options found in 'optstr' (def: $PANDOC_WRAPPER_OPTSTR) - NOTE: The 'optstr' may not contain a single-quote, nor a double-quote. + NOTE: The 'pandoc_opts' may not contain a single-quote, nor a double-quote. -u repo_url Base level URL of target git repo (def: $REPO_URL) -U top_url Top level URL of web site where HTML files will be viewed (def: $TOP_URL) diff --git a/bin/pandoc_wrapper.sh b/bin/pandoc_wrapper.sh index 9d9ec0f78..9fc6bfb4e 100755 --- a/bin/pandoc_wrapper.sh +++ b/bin/pandoc_wrapper.sh @@ -56,7 +56,7 @@ shopt -s globstar # enable ** to match all files and zero or more directories an # set variables referenced in the usage message # -export VERSION="1.3 2024-01-14" +export VERSION="1.3.1 2024-01-16" NAME=$(basename "$0") export NAME export V_FLAG=0 @@ -84,9 +84,8 @@ export TOP_URL="https://ioccc-src.github.io/temp-test-ioccc" # set usage message # -export USAGE="usage: $0 [-h] [-v level] [-V] [-n] [-N] - [-d topdir] [-p pandoc_tool] [-P pandoc_opts] - [-u repo_url] [-U top_url] [-e string ..] [-E exitcode] +export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N] + [-p pandoc_tool] [-P pandoc_opts] [-u repo_url] [-U top_url] [-e string ..] [-E exitcode] file.md output.html -h print help message and exit @@ -100,6 +99,7 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-n] [-N] -p pandoc_tool path to the pandoc tool (not the wrapper) (def: $PANDOC_TOOL) -P pandoc_opts options given to the pandoc tool (def: $PANDOC_ARGS) + NOTE: The 'pandoc_opts' may not contain a single-quote, nor a double-quote. -u repo_url Base level URL of target git repo (def: $REPO_URL) -U top_url Top level URL of web site where HTML files will be viewed (def: $TOP_URL) diff --git a/bin/readme2index.sh b/bin/readme2index.sh index 15e61c37c..7dea4393d 100755 --- a/bin/readme2index.sh +++ b/bin/readme2index.sh @@ -55,7 +55,7 @@ shopt -s lastpipe # run last command of a pipeline not executed in the backgroun # set variables referenced in the usage message # -export VERSION="1.0 2024-01-14" +export VERSION="1.1 2024-01-16" NAME=$(basename "$0") export NAME export V_FLAG=0 @@ -77,8 +77,8 @@ export TOP_URL="https://ioccc-src.github.io/temp-test-ioccc" # set usage message # -export USAGE="usage: $0 [-h] [-v level] [-V] [-n] [-N] - [-d topdir] [-c md2html.cfg] [-H phase=name ..] +export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N] + [-c md2html.cfg] [-H phase=name ..] [-b tool] [-B optstr] [-p tool] [-P optstr] [-a tool] [-A optstr] [-s token=value ..] [-S] [-o tool ..] [-O tool=optstr ..] [-u repo_url] [-U top_url] [-e string ..] [-E exitcode] @@ -88,12 +88,12 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-n] [-N] -v level set verbosity level (def level: $V_FLAG) -V print version string and exit - -n go thru the actions, but do not update any files (def: do the action) - -N do not process file, just parse arguments and ignore the file (def: process the file) - -d topdir set topdir (def: $TOPDIR) NOTE: -d may only be used in command_options (getopt phase 0) + -n go thru the actions, but do not update any files (def: do the action) + -N do not process file, just parse arguments and ignore the file (def: process the file) + -c md2html.cfg Use md2html.cfg as the configuration file (def: use topdir/inc/md2html.cfg) NOTE: -c may only be used in command_options (getopt phase 0) @@ -2030,16 +2030,36 @@ fi # move temporary index HTML in place # if [[ -z $NOOP ]]; then - mv -f -- "$TMP_INDEX_HTML" "$INDEX_PATH" - status="$?" - if [[ status -ne 0 ]]; then - echo "$0: ERROR: mv -f -- $TMP_INDEX_HTML $INDEX_PATH filed, error code: $status" 1>&2 - exit 138 - fi - if [[ ! -s $INDEX_PATH ]]; then - echo "$0: ERROR: not a non-empty index HTML file: $INDEX_PATH" 1>&2 - exit 139 + + # compare files + # + if cmp -s "$TMP_INDEX_HTML" "$INDEX_PATH"; then + + # case: file did not change + # + if [[ $V_FLAG -ge 5 ]]; then + echo "$0: debug[5]: file did not change: $INDEX_PATH" 1>&2 + fi + + else + + # case: index.html changed, update the file + # + if [[ $V_FLAG -ge 5 ]]; then + echo "$0: debug[5]: mv -f -- $TMP_INDEX_HTML $INDEX_PATH" 1>&2 + fi + mv -f -- "$TMP_INDEX_HTML" "$INDEX_PATH" + status="$?" + if [[ status -ne 0 ]]; then + echo "$0: ERROR: mv -f -- $TMP_INDEX_HTML $INDEX_PATH filed, error code: $status" 1>&2 + exit 138 + fi + if [[ ! -s $INDEX_PATH ]]; then + echo "$0: ERROR: not a non-empty index HTML file: $INDEX_PATH" 1>&2 + exit 139 + fi fi + elif [[ $V_FLAG -ge 3 ]]; then echo "$0: debug[3]: because of -n, disabled: mv -f -- $TMP_INDEX_HTML $INDEX_PATH" 1>&2 fi diff --git a/bin/subst.default.sh b/bin/subst.default.sh index 765bcccdd..b9748aeeb 100755 --- a/bin/subst.default.sh +++ b/bin/subst.default.sh @@ -53,7 +53,7 @@ shopt -s globstar # enable ** to match all files and zero or more directories an # set variables referenced in the usage message # -export VERSION="1.1 2024-01-14" +export VERSION="1.1.1 2024-01-16" NAME=$(basename "$0") export NAME export V_FLAG=0 @@ -73,8 +73,7 @@ export TOP_URL="https://ioccc-src.github.io/temp-test-ioccc" # set usage message # -export USAGE="usage: $0 [-h] [-v level] [-V] [-n] [-N] - [-d topdir] [-p tool] [-P optstr] +export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N] [-u repo_url] [-U top_url] [-e string ..] [-E exitcode] yyyy/dir diff --git a/bin/subst.winner-index.sh b/bin/subst.winner-index.sh index bfd499259..ed624cf7e 100755 --- a/bin/subst.winner-index.sh +++ b/bin/subst.winner-index.sh @@ -52,7 +52,7 @@ shopt -s globstar # enable ** to match all files and zero or more directories an # set variables referenced in the usage message # -export VERSION="1.1 2024-01-14" +export VERSION="1.1.1 2024-01-16" NAME=$(basename "$0") export NAME export V_FLAG=0 @@ -72,8 +72,7 @@ export TOP_URL="https://ioccc-src.github.io/temp-test-ioccc" # set usage message # -export USAGE="usage: $0 [-h] [-v level] [-V] [-n] [-N] - [-d topdir] [-p tool] [-P optstr] +export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N] [-u repo_url] [-U top_url] [-e string ..] [-E exitcode] yyyy/dir diff --git a/inc/topnav.first.html b/inc/topnav.first.html index 627e8813e..40839887d 100644 --- a/inc/topnav.first.html +++ b/inc/topnav.first.html @@ -1,7 +1,7 @@
-

first entry + first entry ↑ %%UP_TEXT%% ↑ %%RIGHT_TEXT%% → %%INVENTORY_TEXT%% diff --git a/inc/topnav.last.html b/inc/topnav.last.html index 932d4d64d..573d5502e 100644 --- a/inc/topnav.last.html +++ b/inc/topnav.last.html @@ -3,7 +3,7 @@

diff --git a/tmp/manifest.csv b/tmp/manifest.csv index 98398a597..41c7d3686 100644 --- a/tmp/manifest.csv +++ b/tmp/manifest.csv @@ -920,6 +920,8 @@ 1993,plummer,Makefile,30,true,makefile,true,winner Makefile 1993,plummer,plummer.alt.c,40,true,c,true,alternative source 1993,plummer,plummer.orig.c,50,false,c,true,original source +1993,plummer,try.alt.sh,100,true,shellscript,true,how to run alternative code +1993,plummer,try.sh,100,true,shellscript,true,how to run 1993,plummer,1993_plummer.tar.bz2,300,false,tbz2,false,download winning source 1993,plummer,README.md,4294967295,true,markdown,true,markdown source for index.html 1993,plummer,.gitignore,4294967295,true,gitignore,true,list of files that should not be committed under git @@ -989,6 +991,9 @@ 1994,horton,horton.alt.c,40,true,c,true,alternative source 1994,horton,horton.orig.c,50,false,c,true,original source 1994,horton,gtface.c,100,true,c,true,gtface source code +1994,horton,try.alt.sh,100,true,shellscript,true,how to run alternative code +1994,horton,try.sh,100,true,shellscript,true,how to run +1994,horton,login_sept92-pp28-31.pdf,125,true,pdf,false,login article on graphics for dumb terminals 1994,horton,gtface.data,150,true,text,true,data for gtfsace 1994,horton,1994_horton.tar.bz2,300,false,tbz2,false,download winning source 1994,horton,README.md,4294967295,true,markdown,true,markdown source for index.html @@ -999,6 +1004,7 @@ 1994,imc,imc.c,20,true,c,true,winning source 1994,imc,Makefile,30,true,makefile,true,winner Makefile 1994,imc,imc.orig.c,50,false,c,true,original source +1994,imc,try.sh,100,true,shellscript,true,how to run 1994,imc,1994_imc.tar.bz2,300,false,tbz2,false,download winning source 1994,imc,README.md,4294967295,true,markdown,true,markdown source for index.html 1994,imc,.gitignore,4294967295,true,gitignore,true,list of files that should not be committed under git @@ -1008,6 +1014,7 @@ 1994,ldb,ldb.c,20,true,c,true,winning source 1994,ldb,Makefile,30,true,makefile,true,winner Makefile 1994,ldb,ldb.orig.c,50,false,c,true,original source +1994,ldb,try.sh,100,true,shellscript,true,how to run 1994,ldb,1994_ldb.tar.bz2,300,false,tbz2,false,download winning source 1994,ldb,README.md,4294967295,true,markdown,true,markdown source for index.html 1994,ldb,.gitignore,4294967295,true,gitignore,true,list of files that should not be committed under git @@ -1019,6 +1026,9 @@ 1994,schnitzi,schnitzi.alt2.c,40,true,c,true,alternate alternative source 1994,schnitzi,schnitzi.alt.c,40,true,c,true,alternative source 1994,schnitzi,schnitzi.orig.c,50,true,c,true,original source +1994,schnitzi,try.alt.sh,100,true,shellscript,true,how to run alternative code +1994,schnitzi,try.sh,100,true,shellscript,true,how to run +1994,schnitzi,try.txt,100,true,text,true,input data for try.sh 1994,schnitzi,1994_schnitzi.tar.bz2,300,false,tbz2,false,download winning source 1994,schnitzi,README.md,4294967295,true,markdown,true,markdown source for index.html 1994,schnitzi,.gitignore,4294967295,true,gitignore,true,list of files that should not be committed under git @@ -1039,6 +1049,7 @@ 1994,smr,smr.c,20,true,c,true,winning source 1994,smr,Makefile,30,true,makefile,true,winner Makefile 1994,smr,smr.orig.c,50,true,c,true,original source +1994,smr,try.sh,100,true,shellscript,true,how to run 1994,smr,1994_smr.tar.bz2,300,false,tbz2,false,download winning source 1994,smr,README.md,4294967295,true,markdown,true,markdown source for index.html 1994,smr,.gitignore,4294967295,true,gitignore,true,list of files that should not be committed under git @@ -1049,6 +1060,10 @@ 1994,tvr,Makefile,30,true,makefile,true,winner Makefile 1994,tvr,tvr.alt.c,40,true,c,true,alternative source 1994,tvr,tvr.orig.c,50,true,c,true,original source +1994,tvr,try.alt.bw.sh,100,true,shellscript,true,demonstrate alt code in black and white mode +1994,tvr,try.alt.color.sh,100,true,shellscript,true,demonstrate alt code in colour mode +1994,tvr,try.bw.sh,100,true,shellscript,true,demonstrate code in black and white mode +1994,tvr,try.color.sh,100,true,shellscript,true,demonstrate alt code in colour mode 1994,tvr,tvr.bw,150,true,text,true,black and white 1994,tvr,tvr.color,150,true,text,true,RGB values 1994,tvr,1994_tvr.tar.bz2,300,false,tbz2,false,download winning source @@ -1060,6 +1075,8 @@ 1994,weisberg,weisberg.c,20,true,c,true,winning source 1994,weisberg,Makefile,30,true,makefile,true,winner Makefile 1994,weisberg,weisberg.orig.c,50,true,c,true,original source +1994,weisberg,primes.sh,100,true,shellscript,true,feed primes to the program +1994,weisberg,try.sh,100,true,shellscript,true,how to run 1994,weisberg,1994_weisberg.tar.bz2,300,false,tbz2,false,download winning source 1994,weisberg,README.md,4294967295,true,markdown,true,markdown source for index.html 1994,weisberg,.gitignore,4294967295,true,gitignore,true,list of files that should not be committed under git diff --git a/tmp/manifest.numbers b/tmp/manifest.numbers index 7b9653cfe..0141580ad 100644 Binary files a/tmp/manifest.numbers and b/tmp/manifest.numbers differ diff --git a/tmp/path_list.found.txt b/tmp/path_list.found.txt index 2d58b12cc..434ace8a8 100644 --- a/tmp/path_list.found.txt +++ b/tmp/path_list.found.txt @@ -834,6 +834,8 @@ 1993/plummer/plummer.alt.c 1993/plummer/plummer.c 1993/plummer/plummer.orig.c +1993/plummer/try.alt.sh +1993/plummer/try.sh 1993/rince/.gitignore 1993/rince/.path 1993/rince/.winner.json @@ -897,6 +899,9 @@ 1994/horton/horton.c 1994/horton/horton.orig.c 1994/horton/index.html +1994/horton/login_sept92-pp28-31.pdf +1994/horton/try.alt.sh +1994/horton/try.sh 1994/imc/.gitignore 1994/imc/.path 1994/imc/.winner.json @@ -905,6 +910,7 @@ 1994/imc/imc.c 1994/imc/imc.orig.c 1994/imc/index.html +1994/imc/try.sh 1994/ldb/.gitignore 1994/ldb/.path 1994/ldb/.winner.json @@ -913,6 +919,7 @@ 1994/ldb/index.html 1994/ldb/ldb.c 1994/ldb/ldb.orig.c +1994/ldb/try.sh 1994/schnitzi/.gitignore 1994/schnitzi/.path 1994/schnitzi/.winner.json @@ -923,6 +930,9 @@ 1994/schnitzi/schnitzi.alt2.c 1994/schnitzi/schnitzi.c 1994/schnitzi/schnitzi.orig.c +1994/schnitzi/try.alt.sh +1994/schnitzi/try.sh +1994/schnitzi/try.txt 1994/shapiro/.gitignore 1994/shapiro/.path 1994/shapiro/.winner.json @@ -940,12 +950,17 @@ 1994/smr/index.html 1994/smr/smr.c 1994/smr/smr.orig.c +1994/smr/try.sh 1994/tvr/.gitignore 1994/tvr/.path 1994/tvr/.winner.json 1994/tvr/Makefile 1994/tvr/README.md 1994/tvr/index.html +1994/tvr/try.alt.bw.sh +1994/tvr/try.alt.color.sh +1994/tvr/try.bw.sh +1994/tvr/try.color.sh 1994/tvr/tvr.alt.c 1994/tvr/tvr.bw 1994/tvr/tvr.c @@ -957,6 +972,8 @@ 1994/weisberg/Makefile 1994/weisberg/README.md 1994/weisberg/index.html +1994/weisberg/primes.sh +1994/weisberg/try.sh 1994/weisberg/weisberg.c 1994/weisberg/weisberg.orig.c 1994/westley/.gitignore diff --git a/tmp/path_list.manifest.txt b/tmp/path_list.manifest.txt index 32b687941..eacc336fe 100644 --- a/tmp/path_list.manifest.txt +++ b/tmp/path_list.manifest.txt @@ -924,6 +924,8 @@ 1993/plummer/plummer.alt.c 1993/plummer/plummer.c 1993/plummer/plummer.orig.c +1993/plummer/try.alt.sh +1993/plummer/try.sh 1993/rince/.gitignore 1993/rince/.path 1993/rince/.winner.json @@ -994,6 +996,9 @@ 1994/horton/horton.c 1994/horton/horton.orig.c 1994/horton/index.html +1994/horton/login_sept92-pp28-31.pdf +1994/horton/try.alt.sh +1994/horton/try.sh 1994/imc/.gitignore 1994/imc/.path 1994/imc/.winner.json @@ -1003,6 +1008,7 @@ 1994/imc/imc.c 1994/imc/imc.orig.c 1994/imc/index.html +1994/imc/try.sh 1994/ldb/.gitignore 1994/ldb/.path 1994/ldb/.winner.json @@ -1012,6 +1018,7 @@ 1994/ldb/index.html 1994/ldb/ldb.c 1994/ldb/ldb.orig.c +1994/ldb/try.sh 1994/schnitzi/.gitignore 1994/schnitzi/.path 1994/schnitzi/.winner.json @@ -1023,6 +1030,9 @@ 1994/schnitzi/schnitzi.alt2.c 1994/schnitzi/schnitzi.c 1994/schnitzi/schnitzi.orig.c +1994/schnitzi/try.alt.sh +1994/schnitzi/try.sh +1994/schnitzi/try.txt 1994/shapiro/.gitignore 1994/shapiro/.path 1994/shapiro/.winner.json @@ -1043,6 +1053,7 @@ 1994/smr/index.html 1994/smr/smr.c 1994/smr/smr.orig.c +1994/smr/try.sh 1994/tvr/.gitignore 1994/tvr/.path 1994/tvr/.winner.json @@ -1050,6 +1061,10 @@ 1994/tvr/Makefile 1994/tvr/README.md 1994/tvr/index.html +1994/tvr/try.alt.bw.sh +1994/tvr/try.alt.color.sh +1994/tvr/try.bw.sh +1994/tvr/try.color.sh 1994/tvr/tvr.alt.c 1994/tvr/tvr.bw 1994/tvr/tvr.c @@ -1062,6 +1077,8 @@ 1994/weisberg/Makefile 1994/weisberg/README.md 1994/weisberg/index.html +1994/weisberg/primes.sh +1994/weisberg/try.sh 1994/weisberg/weisberg.c 1994/weisberg/weisberg.orig.c 1994/westley/.gitignore diff --git a/tmp/path_list.required.txt b/tmp/path_list.required.txt index 5295c91c1..1fa56d912 100644 --- a/tmp/path_list.required.txt +++ b/tmp/path_list.required.txt @@ -664,6 +664,8 @@ 1993/plummer/plummer.alt.c 1993/plummer/plummer.c 1993/plummer/plummer.orig.c +1993/plummer/try.alt.sh +1993/plummer/try.sh 1993/rince/.gitignore 1993/rince/.winner.json 1993/rince/Makefile @@ -715,18 +717,23 @@ 1994/horton/horton.alt.c 1994/horton/horton.c 1994/horton/horton.orig.c +1994/horton/login_sept92-pp28-31.pdf +1994/horton/try.alt.sh +1994/horton/try.sh 1994/imc/.gitignore 1994/imc/.winner.json 1994/imc/Makefile 1994/imc/README.md 1994/imc/imc.c 1994/imc/imc.orig.c +1994/imc/try.sh 1994/ldb/.gitignore 1994/ldb/.winner.json 1994/ldb/Makefile 1994/ldb/README.md 1994/ldb/ldb.c 1994/ldb/ldb.orig.c +1994/ldb/try.sh 1994/schnitzi/.gitignore 1994/schnitzi/.winner.json 1994/schnitzi/Makefile @@ -735,6 +742,9 @@ 1994/schnitzi/schnitzi.alt2.c 1994/schnitzi/schnitzi.c 1994/schnitzi/schnitzi.orig.c +1994/schnitzi/try.alt.sh +1994/schnitzi/try.sh +1994/schnitzi/try.txt 1994/shapiro/.gitignore 1994/shapiro/.winner.json 1994/shapiro/Makefile @@ -748,10 +758,15 @@ 1994/smr/README.md 1994/smr/smr.c 1994/smr/smr.orig.c +1994/smr/try.sh 1994/tvr/.gitignore 1994/tvr/.winner.json 1994/tvr/Makefile 1994/tvr/README.md +1994/tvr/try.alt.bw.sh +1994/tvr/try.alt.color.sh +1994/tvr/try.bw.sh +1994/tvr/try.color.sh 1994/tvr/tvr.alt.c 1994/tvr/tvr.bw 1994/tvr/tvr.c @@ -761,6 +776,8 @@ 1994/weisberg/.winner.json 1994/weisberg/Makefile 1994/weisberg/README.md +1994/weisberg/primes.sh +1994/weisberg/try.sh 1994/weisberg/weisberg.c 1994/weisberg/weisberg.orig.c 1994/westley/.gitignore