[net.sources] Thompsons self duplicating program

lvc@cbscc.UUCP (Larry Cipriani) (08/18/84)

I was able to squeeze one more byte out of the self duplicator.
Line 11 containing 's); ' can be replaced by 's);\0'.

				Larry Cipriani
				cbscc!lvc

steiny@scc.UUCP (Don Steiny) (08/20/84)

***

	This probably belongs in net.unix and not net.sources, I am 
sure we will find out, but ...  This one is much shorter, Thomson must
not read Byte:

---

main(){char q='"',*s="\\main(){char q='%c',*s=%c%c%.54s%c%s%.33s%cn%c;printf(\
s+1,q,q,*s,s,*s,s+87,s+54,*s,q);}\n";printf(s+1,q,q,*s,s,*s,s+87,s+54,*s,q);}

----

Don Steiny
Personetics
109 Torrey Pine Terr.
Santa Cruz, Calif. 95060
(408) 425-0382
ihnp4!pesnta  -\
fortune!idsvax -> scc!steiny
ucbvax!twg    -/

jim@haring.UUCP (08/23/84)

> From: steiny@scc.UUCP
> 
> ***
> 
> This probably belongs in net.unix and not net.sources, I am 
> sure we will find out, but ...  This one is much shorter, Thomson must
> not read Byte:
> 
> main(){char q='"',*s="\\main(){char q='%c',*s=%c%c%.54s%c%s%.33s%cn%c;printf(\
> s+1,q,q,*s,s,*s,s+87,s+54,*s,q);}\n";printf(s+1,q,q,*s,s,*s,s+87,s+54,*s,q);}

Somebody must not be reading the EUUG Newsletter either:

	From EUUGN Vol 3. No. 4

	extracted from 'Some Self-Reproducing Programs' by Theo de Ridder
	....
	....
	selfcopy2.c

	char p[]="char p[]=%c%s%c;%cmain(){printf(p,042,p,042,012,012);}%c";
	main(){printf(p,042,p,042,012,012);}
	....
	....
So, have fun with this SOURCE code. As usual, any comments, bug-fixes,
improvements......

Jim McKie  Centrum voor Wiskunde en Informatica, Amsterdam  mcvax!jim

mike@whuxl.UUCP (BALDWIN) (08/23/84)

Larry's (cbscc!lvc) version can be made two characters shorter by
removing the spaces:

main(){char*a="main(){char*a=%c%s%c;printf(a,34,a,34);}";printf(a,34,a,34);}

which is really the same thing as a 76-character version I posted
not long ago:

char*a="char*a=%c%s%c;main(){printf(a,34,a,34);}";main(){printf(a,34,a,34);}

Now if you're using a V6 C compiler, you can remove the two equal
signs as well!  This has >got< to be the shortest one!

							Michael Baldwin
							harpo!whuxl!mike

kho@hou2a.UUCP (S.KHO) (08/25/84)

Seriously, what is the advantage or benefit of a self-duplicating
program.

			S. Kho
			hou2a!kho

sjoerd@vu44.UUCP (Sjoerd Mullender) (08/31/84)

Jim McKie (mcvax!jim) mentioned a self replicating program he extracted
from 'Some Self-Reproducing Programs' by Theo de Ridder.
I have been able to squeeze out a few more bytes.
Here it is:

char p[]="char p[]=%c%s%c;main(){printf(p,34,p,34,10);}%c";main(){printf(p,34,p,34,10);}

This program is 89 characters.
It can be made shorter if you don't insist on a newline at the end of a
program:

char p[]="char p[]=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}

This one is only 80 characters long.
---
			Sjoerd Mullender
			...!decvax!mcvax!vu44!sjoerd

sjoerd@vu44.UUCP (Sjoerd Mullender) (08/31/84)

We have been able to squeeze out 4 more bytes from the shortest
self reproducing program until now.  Here it is:

char*p="char*p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);

This one is 76 characters long.  Of course it does not end with a
newline.  If you play dirty, you can substitute 'int' for 'char*'
(if sizeof (int) == sizeof (char *)), or better still (but not with
the Ritchie C compiler), just delete 'char*'.
---
			Sjoerd Mullender
				...!decvax!mcvax!vu44!sjoerd
			    &
			Robbert van Renesse
				...!decvax!mcvax!vu44!cogito

hawk@oliven.UUCP (09/11/84)

Enough of the C versions.  How 'bout in FORTRAN IV?

-- 
   rick                                     (Rick Hawkins @ Olivetti ATC)
[hplabs|zehntel|fortune|ios|tolerant|allegra|tymix]!oliveb!oliven!hawk