Egocentric Code Competition

Discussion in 'Python' started by Aurélien Géron, Jun 30, 2003.

  1. 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?
     
    Aurélien Géron, Jun 30, 2003
    #1
    1. Advertising

  2. David Eppstein, Jun 30, 2003
    #2
    1. Advertising

  3. Aurélien Géron

    Sean Ross Guest

    Sean Ross, Jun 30, 2003
    #3
  4. 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" <> a écrit dans le message de
    news:...
    > In article <bdpt0u$ci6$>,
    > "Aurélien Géron" <> 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
     
    Aurélien Géron, Jun 30, 2003
    #4
  5. 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

    "David Eppstein" <> a écrit dans le message de
    news:...
    > In article <bdpt0u$ci6$>,
    > "Aurélien Géron" <> 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
     
    Aurélien Géron, Jun 30, 2003
    #5
  6. Aurélien Géron, Jun 30, 2003
    #6
  7. Aurélien Géron

    Terry Reedy Guest

    > 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
     
    Terry Reedy, Jun 30, 2003
    #7
  8. Aurélien Géron

    Roy Smith Guest

    David Eppstein <> wrote:
    >In article <bdpt0u$ci6$>,
    > "Aurélien Géron" <> 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.
     
    Roy Smith, Jun 30, 2003
    #8
  9. 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


    "Terry Reedy" <> a écrit dans le message de
    news:...
    > > 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
    >
    >
     
    Aurélien Géron, Jun 30, 2003
    #9
  10. Argh !

    You got me.

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

    ;-)

    Congratulations !
    Aurélien

    "Roy Smith" <> a écrit dans le message de
    news:bdq32j$89t$...
    > David Eppstein <> wrote:
    > >In article <bdpt0u$ci6$>,
    > > "Aurélien Géron" <> 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.
     
    Aurélien Géron, Jun 30, 2003
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joan MacEachern

    Application Development Competition

    Joan MacEachern, Sep 30, 2003, in forum: Java
    Replies:
    0
    Views:
    663
    Joan MacEachern
    Sep 30, 2003
  2. Norman Franke
    Replies:
    0
    Views:
    370
    Norman Franke
    Jan 22, 2004
  3. Jacqui or (maybe) Pete

    Re: Anti-SARS Homepage Design Competition

    Jacqui or (maybe) Pete, Jul 22, 2003, in forum: HTML
    Replies:
    2
    Views:
    437
    Jacqui or (maybe) Pete
    Jul 22, 2003
  4. Matt Probert
    Replies:
    0
    Views:
    445
    Matt Probert
    Jul 22, 2003
  5. Kathy
    Replies:
    0
    Views:
    650
    Kathy
    Jul 22, 2003
Loading...

Share This Page