Egocentric Code Competition

A

Aurélien Géron

Hi all,

As a newly converted Python lover, I am impressed at how concise Python code
actually is. But really... how concise can it GET?

As an experiment to find out the very limits of Python, I'm generously
offering a free smiley as well as my utmost and sincere admiration to
whoever can come up with the shortest python module which can print itself
(no file reading allowed).

I tried:
print "print"
But found out I got it wrong when it just displayed:
print

Duh... (I thought). So I tried:
print "print \"print\""
But I was stunned to find that this just printed:
print "print"

Hang on, this could last forever, like the "GNU" thingy! I'm sure you can
do better than that!

BTW, maybe this is a well-known problem. Anybody heard of it before? Looks
like some problem out of "Goedel, Escher, Bach" (Hofstadter), although I
frankly never got to the end of that book (something in it got you back to
chapter one just when you thought you had reached chapter two)...

Maybe we should try to do the same with C, Java, Lisp, Smalltalk, Prolog...
and check the size difference. How fun!

I smile in your general direction,
Aurélien

ps: hope this sort of post is allowed in this newsgroup... maybe there's a
geek.lang.python newsgroup somewhere which would be more appropriate?
 
A

Aurélien Géron

Aaaaaaand we have WINNER !!!

I guess the rules of my little competition should lead me to sending my
smiley to Sean B. Palmer but I think you fully deserve it!
Picasso once said something like "Good Designers Copy, Great Designers
Steal".
I guess the same should be said about programmers!

So here it is, the prize you've all been waiting for, your very own 22 karat
smiley:

:)

Amazingly valuable, as you can see (won't be too many people answering my
quizzes next time around).

Thanks!
Aurélien
 
A

Aurélien Géron

Hey, I just found this in "A page about quines" at
http://www.eleves.ens.fr:8080/home/madore/computers/quine.html

"I also dedicate this page to Douglas R. Hofstadter, who coined the name (in
his justly famous book Gödel, Escher, Bach) and who so clearly explained
quines' importance and their relation with Gödel's incompleteness theorem."

Amazing, I really should have finished this book after all ! ;-)

Cheers,
Aurélien
 
T

Terry Reedy

As an experiment to find out the very limits of Python, I'm
generously
offering a free smiley as well as my utmost and sincere admiration to
whoever can come up with the shortest python module which can print itself
(no file reading allowed).

There was a thread on this several years ago in which I participated.
Something like Shortest Self-Reproducing Programs. Should be findable
through Google.

Terry J. Reedy
 
R

Roy Smith

David Eppstein said:


I guess it depends on how you define "shortest possible", but observe
the following:

bash-2.05b$ cp /dev/null zero.py
bash-2.05b$ python zero.py > zero2.py
bash-2.05b$ cmp zero.py zero2.py

I therefore submit that an empty file is the shortest possible Python
program which reproduces itself on output.
 
A

Aurélien Géron

Thanks Terry !

Apparently this is more like the third or fourth instance of this
discussion!!!

Check out:
http://groups.google.com/groups?q=self+replicating+group:comp.lang.python.*

If this link does not work, go to:
http://groups.google.com
and search "self replicating group:comp.lang.python.*"

I should have lived in the stone age, when people could actually be the
first ones to discover something at all.
Nothing is original anymore. Even "Nothing is original anymore" gives 150
hits on Google.
How sad. How pathetic.

Hey wait! Did anyone ever try to find english language quines? "Repeat this
sentence" is my first shot at it. Maybe one can go shorter like "Repeat
this". Or something like "Whazaaa" usually triggers repetition. While
you're at it, "Hi" seems pretty efficient. Most certainly a world record.
Apparently those quines don't appear in G. Thompson's (excellent) list of
quines: http://www.nyx.net/~gthompso/quine.htm . Maybe I should submit them!

;-)
Aurélien
 
A

Aurélien Géron

Argh !

You got me.

After deliberation, the jury decides that you deserve a smiley too.

;-)

Congratulations !
Aurélien
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top