Ask a Question related to Ruby, Design and Development.
-
henon #1
shortest nozero ruby quine
hi,> :quine: /kwi:n/ /n./ [from the name of the logician Willard van Orman
> Quine, via Douglas Hofstadter] A program that generates a copy of its
> own source text as its complete output. Devising the shortest
> possible quine in some given programming language is a common hackish
> amusement. (see [url]http://www.nyx.net/~gthompso/quine.htm[/url])
i have created this quine of length 32 and i believe that a
nonzero-ruby-quine cannot be shorter and more in the spirit of ruby than
that:
eval s=%q(puts"eval s=%q(#{s})")
until anyone comes up with a shorter nonzero quine i claim this to be
the shortest nonzero-ruby-quine.
it's even shorter than the shortest (i know of) in python:
l='l=%s;print l%%`l`';print l%`l`
which has 33 characters.
i have created a rubygarden wiki page for quines:
[url]http://www.rubygarden.org/ruby?RubyQuines[/url]
you can see there ruby-quines i found qoogling the web
cheers,
-- henon
henon Guest
-
[ba-rb] BA-rb ( Bay Area Ruby Users Group ) - 'Generating Code in Ruby' by Jack Herrington.
Count me in again, too. -- Jos Backus _/ _/_/_/ Sunnyvale, CA _/ _/ _/ _/ _/_/_/ _/ _/ _/ _/ jos at... -
BA-rb ( Bay Area Ruby Users Group ) - 'Generating Code in Ruby' by Jack Herrington.
BA-rb (Bay Area Ruby language Users Group) is pleased to announce that it will begin meeting again. The topic for the first meeting will be a... -
ruby-talk: 80813 (Rite/Ruby2.0 & Ruby vs OCaml)
Hope nobody finds this annoying. Somehow I missed this message when it was originally sent, but I thought my reply might be useful to sombody. ... -
RubyConf, Ruby Central, Ruby Garden temporary outage
Hi -- Just to let everyone know that there's a network outage at the host for the RubyConf registration, which also affects Ruby Garden and Ruby... -
[ANN] ruby-freedb, ruby-serialport, ruby-mp3info moved to Rubyforge
http://ruby-freedb.rubyforge.org/ http://ruby-serialport.rubyforge.org/ http://ruby-mp3info.rubyforge.org/ bye! --... -
Simon Strandgaard #2
Re: shortest nozero ruby quine
"henon" <meinrad.recheis@gmx.at> skrev i en meddelelse
news:qI7kb.68322$Lo.1167263@news.chello.at...> i have created this quine of length 32 and i believe that a
> nonzero-ruby-quine cannot be shorter and more in the spirit of ruby than
> that:
>
> eval s=%q(puts"eval s=%q(#{s})")
Nice.. compared to most other quine's this one is actually very readable.
Quine's is a very interesting science, keep up the good work ;-)
--
Simon Strandgaard
Simon Strandgaard Guest
-
Sabby and Tabby #3
Re: shortest nozero ruby quine
henon <meinrad.recheis@gmx.at> wrote:
Well, technically, your quine is 33 characters in length; the output> i have created this quine of length 32 and i believe that a
> nonzero-ruby-quine cannot be shorter and more in the spirit of ruby than
> that:
>
> eval s=%q(puts"eval s=%q(#{s})")
>
> until anyone comes up with a shorter nonzero quine i claim this to be
> the shortest nonzero-ruby-quine.
includes a "\n" at the end, so the source must also. Using a global
variable shortens it by one character:
eval$s=%q(puts"eval$s=%q(#$s)")
A Ruby version of Robin Houston's Perl quine is 31 characters:
puts <<''*2,''
puts <<''*2,''
Note that there is a blank line (or two "\n") at the end.
Sabby and Tabby Guest
-
Alan Chen #4
Re: shortest nozero ruby quine
henon <meinrad.recheis@gmx.at> wrote in message news:<qI7kb.68322$Lo.1167263@news.chello.at>...
How about:> i have created this quine of length 32 and i believe that a
> nonzero-ruby-quine cannot be shorter and more in the spirit of ruby than
> that:
>
> eval s=%q(puts"eval s=%q(#{s})")
>
> until anyone comes up with a shorter nonzero quine i claim this to be
> the shortest nonzero-ruby-quine.
puts open($0).gets
Or is it cheating to use file io?
Cheers,
- alan
Alan Chen Guest
-
gabriele renzi #5
Re: shortest nozero ruby quine
il 18 Oct 2003 11:43:15 -0700, [email]aero6dof@yahoo.com[/email] (Alan Chen) ha
scritto::
I suppose it is cheating :)>henon <meinrad.recheis@gmx.at> wrote in message news:<qI7kb.68322$Lo.1167263@news.chello.at>...
>>>> i have created this quine of length 32 and i believe that a
>> nonzero-ruby-quine cannot be shorter and more in the spirit of ruby than
>> that:
>>
>> eval s=%q(puts"eval s=%q(#{s})")
>>
>> until anyone comes up with a shorter nonzero quine i claim this to be
>> the shortest nonzero-ruby-quine.
>How about:
>
>puts open($0).gets
>
>Or is it cheating to use file io?
OTOH, if this was not cheating you could just do
print IO.read($0)
gabriele renzi Guest
-
henon #6
Re: shortest nozero ruby quine
Sabby and Tabby wrote:
[...]sorry, but i get a syntax error with yours:> A Ruby version of Robin Houston's Perl quine is 31 characters:
>
> puts <<''*2,''
> puts <<''*2,''
>
>
> Note that there is a blank line (or two "\n") at the end.
can't find string "" anywhere before EOF
henon Guest
-
henon #7
Re: shortest nozero ruby quine
Sabby and Tabby wrote:
[...]> henon <meinrad.recheis@gmx.at> wrote:wow this is very cool. you beat me by one character.> A Ruby version of Robin Houston's Perl quine is 31 characters:
>
> puts <<''*2,''
> puts <<''*2,''
>
>
> Note that there is a blank line (or two "\n") at the end.
i knew someone would come up with a shorter one!! i put it on the
RubyQuines wiki page.
cheers,
- henon
henon Guest
-
henon #8
Re: shortest nozero ruby quine
Sean Ross wrote:
[...]doesn't print (in python) add a newline? then strictly spoken this has>>>
>>Hi. This is the shortest Python quine that I'm aware of (29 characters):
>>
>>_='_=%r;print _%%_';print _%_
>>
30 chars.
-- henon
henon Guest
-
Sabby and Tabby #9
Re: shortest nozero ruby quine
henon <meinrad.recheis@gmx.at> wrote:
Wiki formatting is strange. Here's a shorter, non-italic variation:> Sabby and Tabby wrote:
>>> > A Ruby version of Robin Houston's Perl quine is 31 characters:
> >
> > puts <<''*2,''
> > puts <<''*2,''
> >
> >
> > Note that there is a blank line (or two "\n") at the end.
> wow this is very cool. you beat me by one character.
> i knew someone would come up with a shorter one!! i put it on the
> RubyQuines wiki page.
puts <<2*2,2
puts <<2*2,2
2
Sabby and Tabby Guest
-
Kero #10
Re: shortest nozero ruby quine
>> eval s=%q(puts"eval s=%q(#{s})")
Wouldn't call this cheating per se, but it doesn't run in irb and>>>
>> until anyone comes up with a shorter nonzero quine i claim this to be
>> the shortest nonzero-ruby-quine.
> How about:
>
> puts open($0).gets
>
> Or is it cheating to use file io?
doesn't run from the command line, whereas the others do...
+--- Kero ----------------------- [email]kero@chello.nl[/email] ---+
| all the meaningless and empty words I spoke |
| Promises -- The Cranberries |
+--- M38c --- [url]http://httpd.chello.nl/k.vangelder[/url] ---+
Kero Guest
-
Alan Davies #11
Re: shortest nozero ruby quine
Sabby and Tabby wrote:
Can someone explain how this works? I am completely lost!> Wiki formatting is strange. Here's a shorter, non-italic variation:
>
> puts <<2*2,2
> puts <<2*2,2
> 2
Alan Davies Guest
-
Alan Davies #12
Re: shortest nozero ruby quine
Sabby and Tabby wrote:
Can someone explain how this works? I am completely lost!> Wiki formatting is strange. Here's a shorter, non-italic variation:
>
> puts <<2*2,2
> puts <<2*2,2
> 2
Alan Davies Guest
-
Jason Williams #13
Re: shortest nozero ruby quine
In article <3F97C421.3010504@yahoo.co.ukNOSPAM>, Alan Davies wrote:
"puts <<2" - print all the text from after this statement until you> Sabby and Tabby wrote:>>> Wiki formatting is strange. Here's a shorter, non-italic variation:
>>
>> puts <<2*2,2
>> puts <<2*2,2
>> 2
> Can someone explain how this works? I am completely lost!
reach the string "2".
...."*2" - Print that string twice
....",2" - And then print the value 2
The second "puts <<2*2,2" is just text, and the final "2" is the
delimiter.
Something like that, anyway :-)
Jason Williams Guest
-
Sean Ross #14
Re: shortest nozero ruby quine
"henon" <meinrad.recheis@gmx.at> wrote in message
news:qI7kb.68322$Lo.1167263@news.chello.at...Hi. This is the shortest Python quine that I'm aware of (29 characters):> it's even shorter than the shortest (i know of) in python:
> l='l=%s;print l%%`l`';print l%`l`
> which has 33 characters.
_='_=%r;print _%%_';print _%_
Sean Ross Guest
-
Sean Ross #15
Re: shortest nozero ruby quine
"Sean Ross" <sross@connectmail.carleton.ca> wrote in message
news:Zwdkb.12975$PM2.1448514@news20.bellglobal.com ...And, if you want to cheat a little, check out this log entry> "henon" <meinrad.recheis@gmx.at> wrote in message
> news:qI7kb.68322$Lo.1167263@news.chello.at...>> > it's even shorter than the shortest (i know of) in python:
> > l='l=%s;print l%%`l`';print l%`l`
> > which has 33 characters.
> Hi. This is the shortest Python quine that I'm aware of (29 characters):
>
> _='_=%r;print _%%_';print _%_
>
[url]http://radio.weblogs.com/0104369/[/url]. If you include interactive mode on the
python interpreter, then strictly speaking, the shortest quine in Python
(and in Ruby, I suspect) will be to hit the enter key ;)
Sean Ross Guest



Reply With Quote

