The world's smallest self-replicating program
ioccc.org
ioccc.org
http://www.ncbi.nlm.nih.gov/nuccore/NC_001422.1
Enterobacteria phage phiX174 sensu lato, complete genome
5386 bp ss-DNA
In college I actually got to take part in refactoring that virus' genome into a decompressed version with no gene overlaps. And it worked! The decompressed version is still a functioning phage, and since there are no longer gene overlaps, future genetic engineers will have a much easier time modifying the phage as they see fit.
http://www.sciencedirect.com/science/article/pii/S0042682212...
[The naive] decompression added 909 nucleotides to the wild-type genome. We next addressed practical constraints arising from the length of DNA that can be physically packaged within a øX174 capsid without impacts to reproductive fitness. Previous work has shown that the length of a øX174 genome, when packaged in vitro, must be kept within a few percent of the 5386 nucleotide wild-type length in order to avoid any significant fitness decrease ( Aoyama and Hayashi, 1985). Similar results were shown in vivo ( Russell and Muller, 1984). To reduce the decompressed genome length we removed the first 916 nucleotides of gene F, encoding the coat protein ( Air et al., 1978). We chose gene F because a plasmid containing a restriction fragment encoding wild-type gene F was able to complement two conditional gene F mutations ( Avoort et al., 1983). Additionally, the gene F coding sequence is greater than the total of the combined increases needed to implement the øX174.1 genome design. The truncated gene F version of the decompressed genome was named øX174.1f. To complement øX174.1f when transformed into host cells we designed a medium copy vector expressing gene F under control of a rhamnose-inducible promoter ( Fig. S1).
I have no doubt that viruses of the computer kind also have made use of such techniques; and overlapping for obfuscation, not size-optimisation, is also a commonly seen trick in malware.
Get your genome compiler here: http://genomecompiler.com
smr: smr.c
@${RM} -rf smr
${CP} smr.c smr
${CHMOD} +x smr
Apparently, an empty file marked as executable will execute!In fact, an empty executable file has been used to implement /bin/true on some old systems. Why take the added cost of a disk seek when just the information in the inode will do?
why is this only on old systems? it seems very efficient.
A zero-length binary fed into either ld.so (a.out loader) or ld-linux.so (elf loader) will not produce a zero-length output, but a parsing error.
Can someone explain the basis of this contest and how this c file is "self-replicating"?
The makefile is not large. It's a makefile for all the entries for 1994 competition. And it's only 4 lines for smr.c
This one abuses the idea that they specify how the contest will be judged, which this "program" satisfies, as long as you don't look at the source.
$ make smr
cp smr.c smr
chmod +x smr
$ ./smr > smr.dup
$ diff smr smr.dup
$ echo $?
0
Also, it is a valid C file! $ stat -c "%s" smr.c
0
$ gcc -Wall -c smr.c
$ echo $?
0
$ stat -c "%s" smr.o
927
The judge's comments for this one explain this in a bit more detail:http://www.ioccc.org/1994/smr.hint
[1] the best kind of "valid" :)
Doesn't require make :) or cp and is pretty active - fills up all the memory space below the starting point in no time.
The short of it is that when you dropped back to the command line, early versions of DOS didn't clear the memory. That meant that the program really just went into stasis, but in practice it meant restarting; see, the program ran off the floppy then, so to save or load to another disk was tricky. Because memory would be executed from the same address, you could insert this disk with an empty executable that would get DOS to send execution to that address, which happens to be the program already in memory.
This had the huge boon of allowing you to drop to the command line, do something, and the resume working! Apparently they sold the disks for like $5 (or pounds) each, and the customers were extremely pleased. And the programmer was got a kick out of having rather impressive return per byte written :)
Thanks a mil for finding the link! I had a feeling I read the story from HN, and so it was:
I just uploaded it to https://github.com/mct/assembly-toys/tree/master/imp
Definition of replicate is: to repeat or copy (something) exactly
Empty program doesn't copy or repeat anything. Entry rejected.
EDIT: It's not reddit, downvotes doesn't go here for disagreeing. The problem is posed in natural language and it has its own rules. In natural language (at least in English) doing nothing isn't copying or replicating. You may check the dictionaries.
Next time someone will claim claim 1 million sales: million nothings for 0 dollars to nobodies.
EDIT (to other child)
Yes, empty set is subset of other sets but that's because the definition of subset. Copy or replicate in natural language (in which the problem is posed) mean something entirely different.
A great tradition.
http://www.ioccc.org/2013/cable3/hint.html
*RULE 2 ABUSE DISCLAIMER*
- cable3.c is 4043 bytes in length (half an 8086)
- iocccsize -i < cable3.c returns 1977 (the year the
4.77 MHz 8086 CPU was announced)
- Therefore, any suspicions the judges may have regarding
rule 2 non-compliance may be well-intentioned but
are groundless.
- Nonetheless, the author would like to apologise to the
judges for the one-big-block-of-code nature of this entry,
which turned out to be unavoidable. Hopefully the joys
of this entry will make up for its shortcomings. mov 0,1
is the smallest self-replicating program $ ./smr >smr.out
$ diff smr smr.out smr: smr.c
@${RM} -rf smr
${CP} smr.c smr
${CHMOD} +x smr
this is bullshit if you ask me..