Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Egocentric Code Competition

Reply
Thread Tools

Egocentric Code Competition

 
 
Aurélien Géron
Guest
Posts: n/a
 
      06-30-2003
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?


 
Reply With Quote
 
 
 
 
David Eppstein
Guest
Posts: n/a
 
      06-30-2003
In article <bdpt0u$ci6$(E-Mail Removed)>,
"Aurélien Géron" <(E-Mail Removed)> wrote:

> BTW, maybe this is a well-known problem.


Maybe...
http://www.google.com/search?q=python+quine

--
David Eppstein http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science
 
Reply With Quote
 
 
 
 
Sean Ross
Guest
Posts: n/a
 
      06-30-2003
It's called a "quine":
http://www.mines.edu/students/b/bolmstea/quines/#python


_='_=%r;print _%%_';print _%_


 
Reply With Quote
 
Aurélien Géron
Guest
Posts: n/a
 
      06-30-2003
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

"David Eppstein" <(E-Mail Removed)> a écrit dans le message de
news:(E-Mail Removed)...
> In article <bdpt0u$ci6$(E-Mail Removed)>,
> "Aurélien Géron" <(E-Mail Removed)> wrote:
>
> > BTW, maybe this is a well-known problem.

>
> Maybe...
> http://www.google.com/search?q=python+quine
>
> --
> David Eppstein http://www.ics.uci.edu/~eppstein/
> Univ. of California, Irvine, School of Information & Computer Science



 
Reply With Quote
 
Aurélien Géron
Guest
Posts: n/a
 
      06-30-2003
Hey, I just found this in "A page about quines" at
http://www.eleves.ens.fr:8080/home/m...ers/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

"David Eppstein" <(E-Mail Removed)> a écrit dans le message de
news:(E-Mail Removed)...
> In article <bdpt0u$ci6$(E-Mail Removed)>,
> "Aurélien Géron" <(E-Mail Removed)> wrote:
>
> > BTW, maybe this is a well-known problem.

>
> Maybe...
> http://www.google.com/search?q=python+quine
>
> --
> David Eppstein http://www.ics.uci.edu/~eppstein/
> Univ. of California, Irvine, School of Information & Computer Science



 
Reply With Quote
 
Aurélien Géron
Guest
Posts: n/a
 
      06-30-2003
Thanks !


"Sean Ross" <(E-Mail Removed)> a écrit dans le message de
news:A6%La.1697$(E-Mail Removed).. .
> You may find this interesting:
> http://www.nyx.net/~gthompso/quine.htm
>
>



 
Reply With Quote
 
Terry Reedy
Guest
Posts: n/a
 
      06-30-2003
> 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


 
Reply With Quote
 
Roy Smith
Guest
Posts: n/a
 
      06-30-2003
David Eppstein <(E-Mail Removed)> wrote:
>In article <bdpt0u$ci6$(E-Mail Removed)>,
> "Aurélien Géron" <(E-Mail Removed)> wrote:
>
>> BTW, maybe this is a well-known problem.

>
>Maybe...
>http://www.google.com/search?q=python+quine
>
>--
>David Eppstein http://www.ics.uci.edu/~eppstein/
>Univ. of California, Irvine, School of Information & Computer Science



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.
 
Reply With Quote
 
Aurélien Géron
Guest
Posts: n/a
 
      06-30-2003
Thanks Terry !

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

Check out:
http://groups.google.com/groups?q=se....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


"Terry Reedy" <(E-Mail Removed)> a écrit dans le message de
news:(E-Mail Removed)...
> > 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
>
>



 
Reply With Quote
 
Aurélien Géron
Guest
Posts: n/a
 
      06-30-2003
Argh !

You got me.

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



Congratulations !
Aurélien

"Roy Smith" <(E-Mail Removed)> a écrit dans le message de
news:bdq32j$89t$(E-Mail Removed)...
> David Eppstein <(E-Mail Removed)> wrote:
> >In article <bdpt0u$ci6$(E-Mail Removed)>,
> > "Aurélien Géron" <(E-Mail Removed)> wrote:
> >
> >> BTW, maybe this is a well-known problem.

> >
> >Maybe...
> >http://www.google.com/search?q=python+quine
> >
> >--
> >David Eppstein http://www.ics.uci.edu/~eppstein/
> >Univ. of California, Irvine, School of Information & Computer Science

>
>
> 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HEXUS.winners :: Dell Outlet competition Silverstrand Front Page News 0 02-08-2006 04:34 AM
Competition: Win a Kingston Datatraveler II+Migo 512MB Flash Drive @ PureOverclock Silverstrand Front Page News 0 12-15-2005 11:14 PM
CaseModGod/Crucial Ballistix Tracer Mod Competition at CaseM Silverstrand Front Page News 24 09-26-2005 08:54 AM
CaseModGod Crucial Ballistix Tracer Mod Competition Silverstrand Front Page News 6 09-03-2005 11:50 AM
HEXUS.net and Ultra Products MegaMod Competition Silverstrand Front Page News 3 07-01-2005 06:53 AM



Advertisments