[comp.lang.c] Portable Self-Replicating C Contest

karl@haddock.ima.isc.com (Karl Heuer) (03/24/89)

In article <2976@goofy.megatest.UUCP> djones@megatest.UUCP (Dave Jones) writes:
>To me, the really interesting problem is, Write a _portable_
>program which writes its source code exactly.

Well, it happens that I was going to post this anyway...

*** Portable Self-Replicating C Contest ***

Rules:
0.  The output of the program must be its own source code.
1.  It may not be safely assumed that the source code resides in an openable
    file at runtime.
2.  The program must be written in Strictly Conforming ANSI C.
3.  The program must return a proper exit status, indicating whether or not
    its output-calls succeeded.
4.  The source must use only the ISO 646 character set, using trigraphs as
    needed.
5.  No source line may exceed 72 characters.
6.  There will be two winners: the first correct program to arrive at my site,
    and the shortest (measured in source characters, including newlines).  The
    contest ends on 23-Apr-1989.  No prizes will be awarded.

The rationale for rules 4 and 5 is that I want to distribute the result on
punch-cards.  :-)

I will be the sole judge, and my interpretation of the rules is final.  (You
might not like trigraphs, but it makes the puzzle more challenging.)  Appeals
will be allowed on the question of whether a construct is legal Strictly
Conforming ANSI C; the pANS should be the final authority here.

Be warned that rule 2 will be observed to the letter.  For example, if you
invoke the variadic function printf(), there must be a prototype in scope
(either explicitly declared in the code, or via including <stdio.h>).

Followups to comp.std.c only.

Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint
(Why 72?  The last eight columns are reserved for possible addition of a card
sequence number at some future date.)