Quine (#207)

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

The three rules of Ruby Q.:

  1. Please do not post any solutions or spoiler discussion for this
    quiz until 48 hours have elapsed from the time this message was
    sent.

  2. Support Ruby Q. by submitting ideas and responses
    as often as you can!
    Visit: http://rubyquiz.strd6.com/suggestions

  3. Enjoy!

Suggestion: A [QUIZ] in the subject of emails about the problem
helps everyone on Ruby T. follow the discussion. Please reply to
the original quiz message, if you can.

RSS Feed: http://rubyquiz.strd6.com/quizzes.rss

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Quine (#207)

Ahn nyeong Rubyists,

This week’s quiz is to create a quine1, that is: a program which
receives no input and produces a copy of its own source code as its
only output.

Have Fun!

Daniel M. wrote:

This week’s quiz is to create a quine[1], that is: a program which
receives no input and produces a copy of its own source code as its
only output.

I have mine down to down to one line (29 characters), though I suspect
everyone
will agree I’m cheating.

Cool side effect though, adding this line to any other Ruby source file
will
turn it into a quine :-p

-Dana

From: “Dana M.” [email protected]

Daniel M. wrote:

This week’s quiz is to create a quine[1], that is: a program which
receives no input and produces a copy of its own source code as its
only output.

I have mine down to down to one line (29 characters), though I
suspect everyone will agree I’m cheating.

I have 30 characters, w/out cheating. It does output a warning
on 1.8.6, but not 1.8.7 or 1.9.1. (And since the warning is on
stderr, it doesn’t affect the quine output really, I guess.)

Regards,

Bill

Am Samstag 30 Mai 2009 00:17:21 schrieb Dana M.:

I have mine down to down to one line (29 characters), though I suspect
everyone will agree I’m cheating.

I have 19 characters with cheating. 14 if it only needs to run on
unixoid-
systems.

Sebastian H. [email protected] writes:

Am Samstag 30 Mai 2009 02:17:54 schrieb Sebastian H.:

14 if it only needs to run on unixoid-systems.

Well, 15 if it needs to work correctly :wink:

I’ve got one that is more than 40 characters, but it’s readable!

From: “Pascal J. Bourguignon” [email protected]

I’ve got one that is more than 40 characters, but it’s readable!

Did you mean: ((I’ve got (one)) (that is more than ((40) characters)),
((but) (it’s readable!)) ?

:wink:

Bill K. [email protected] writes:

From: “Pascal J. Bourguignon” [email protected]

I’ve got one that is more than 40 characters, but it’s readable!

Did you mean: ((I’ve got (one)) (that is more than ((40) characters)), ((but) (it’s readable!)) ?

:wink:

Well I could have done something like that, yes, but I restrained myself
this time :slight_smile:

Too bad we’ve got only oneliners, a subsidiary questions would have
been to produce a reversed quine, a quine that outputs the source
lines in the reverse order. (In C it’s funny).

Bill K. wrote:

From: “Pascal J. Bourguignon” [email protected]

I’ve got one that is more than 40 characters, but it’s readable!

Did you mean: ((I’ve got (one)) (that is more than ((40) characters)),
((but) (it’s readable!)) ?

:wink:

There is only one way to respond to that mess of redundant )

(
(I’ve got
(one
(that is more than
(
(40
characters,
(
(but
(it’s readable!

Am Samstag 30 Mai 2009 02:17:54 schrieb Sebastian H.:

14 if it only needs to run on unixoid-systems.

Well, 15 if it needs to work correctly :wink:

Ok, I’m at 17 if I cheat & assume *NIX.
and 28 if I don’t cheat.

Still kinda fun, though… the one at 28 bytes is not anything I’d use
in real life, however. Definitely not maintainable.

Matt


“… if you do follow your bliss you put yourself on a kind of
track that has been there all the while, waiting for you, and the life
that you ought to be living is the one you are living. When you can
see that, you begin to meet people who are in your field of bliss, and
they open doors to you. I say, follow your bliss and don’t be afraid,
and doors will open where you didn’t know they were going to be.” –
Joseph Campbell

I’ve got one that’s 197 characters, but it:

  • is readable and formatted nicely
  • uses gems
  • uses a class
  • shows the inheritence of said class
  • has more than one instance of “end”
  • took me less than 5 minutes to write

:wink:

Now to try for brevity…

Matt

“… if you do follow your bliss you put yourself on a kind of
track that has been there all the while, waiting for you, and the life
that you ought to be living is the one you are living. When you can
see that, you begin to meet people who are in your field of bliss, and
they open doors to you. I say, follow your bliss and don’t be afraid,
and doors will open where you didn’t know they were going to be.” –
Joseph Campbell

I’m always up for some golf!

12 bytes if *NIX and cheating…HA!

-Josh

Ok…with help from a friend…

If I REALLY (and I do mean REEEEAAALLLYYY) cheat…

8 bytes!

  • Josh

i’m impressed :slight_smile: still stuck at 10 chars with extreme cheating

m.

From: “Sebastian H.” [email protected]

Ha, I just made one with 0 chars. Top that!

Hehe.

We did quines on ruby-talk back in 2002, and that is
indeed where we ended up.

(Although, personally, I tend to find nonzero length
quines more interesting) ;D

Regards,

Bill

Am Samstag 30 Mai 2009 18:50:11 schrieb Martin DeMello:

i’m impressed :slight_smile: still stuck at 10 chars with extreme cheating

Ha, I just made one with 0 chars. Top that!

SCNR,
Sebastian

0 bytes, what else?

On Sat, May 30, 2009 at 6:18 PM, Robert D. [email protected]
wrote:

0 bytes, what else?

And how do you execute it and prove it works, mon ami?


Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

On Sun, May 31, 2009 at 3:51 AM, Rick DeNatale [email protected]
wrote:

On Sat, May 30, 2009 at 6:18 PM, Robert D. [email protected] wrote:

0 bytes, what else?

And how do you execute it and prove it works, mon ami?

I’d show you but the spoiler-free period hasn’t expired yet :slight_smile:

martin

Ok, the shortest solution did not have much success, what about a long
one then :wink:

http://pastie.org/495692

Cheers
Robert