Shortest Ruby Quine
Posted
by AaronThomson
on Stack Overflow
See other posts from Stack Overflow
or by AaronThomson
Published on 2010-03-19T03:43:14Z
Indexed on
2010/03/19
3:51 UTC
Read the original article
Hit count: 495
Just finished reading this blog post: http://www.skorks.com/2010/03/an-interview-question-that-prints-out-its-own-source-code-in-ruby/
In it, the author argues the case for using a quine as an interview question. I'm not sure I agree but thats not what this question is about.
He goes on to construct a quine in Ruby and refactor it to make it shorter. He then challenges the reader to try to make it even shorter.
I played around with it for a while and came up with the following:
s="s=;puts s[0,2]+34.chr+s+34.chr+s[2,36]";puts s[0,2]+34.chr+s+34.chr+s[2,36]
This is the first time I have ever attempted a quine and I can't figure out how to make it any shorter.
What is the shortest Ruby quine you can come up with? Please post an explanation if your implementation requires it.
© Stack Overflow or respective owner