[QUIZ] Quine (#207)

D

Daniel Moore

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

The three rules of Ruby Quiz:

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 Quiz 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 Talk 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 quine[1], that is: a program which
receives no input and produces a copy of its own source code as its
only output.


[1]: http://en.wikipedia.org/wiki/Quine_(computing)

Have Fun!
 
B

Bill Kelly

From: "Dana Merrick said:
Daniel said:
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
 
S

Sebastian Hungerecker

Am Samstag 30 Mai 2009 00:17:21 schrieb Dana Merrick:
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.
 
S

Sebastian Hungerecker

Am Samstag 30 Mai 2009 02:17:54 schrieb Sebastian Hungerecker:
14 if it only needs to run on unixoid-systems.

Well, 15 if it needs to work correctly ;-)
 
P

Pascal J. Bourguignon

Sebastian Hungerecker said:
Am Samstag 30 Mai 2009 02:17:54 schrieb Sebastian Hungerecker:

Well, 15 if it needs to work correctly ;-)

I've got one that is more than 40 characters, but it's _readable_!
 
B

Bill Kelly

From: "Pascal J. Bourguignon said:
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_!)) ?


;)
 
P

Pascal J. Bourguignon

Bill Kelly said:
Did you mean: ((I've got (one)) (that is more than ((40) characters)), ((but) (it's _readable_!)) ?


;)

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


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

Joel VanderWerf

Bill said:
Did you mean: ((I've got (one)) (that is more than ((40) characters)),
((but) (it's _readable_!)) ?


;)

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_!
 
M

Matthew K. Williams

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

;-)

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
 
M

Matthew K. Williams

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

;-)

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
 
J

Joshua Ballanco

Ok...with help from a friend...

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

8 bytes!

- Josh
 
S

Sebastian Hungerecker

Am Samstag 30 Mai 2009 18:50:11 schrieb Martin DeMello:
i'm impressed :) still stuck at 10 chars with extreme cheating

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

SCNR,
Sebastian
 
B

Bill Kelly

From: "Sebastian Hungerecker said:
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
 
R

Robert Dober

And how do you execute it and prove it works, mon ami? <G>
I have foreseen everything ;)

507/7 > touch prog && ruby prog > xxx && diff prog xxx
robert@roma:~/log/ruby/quiz 14:24:48
508/8 > echo $?
0





--=20
Toutes les grandes personnes ont d=92abord =E9t=E9 des enfants, mais peu
d=92entre elles s=92en souviennent.

All adults have been children first, but not many remember.

[Antoine de Saint-Exup=E9ry]
 

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,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top