Search code examples
rubyquine

Can anyone help me complete this quine in Ruby? - I'm so very close


s="s=@;print(s.sub('@', s))";print(s.sub('@', "\"#{s}\""))

This code is supposed to print out an exact copy of itself but instead I am getting the following:

s="s=@;print(s.sub('@', s))";print(s.sub('@', s))%

It's almost there but the problem I'm having is getting the s variable in the s.sub parameter matching in the output string.

See this for more information on quine's: http://en.wikipedia.org/wiki/Quine_%28computing%29

Thanks for any help


Solution

  • s="s=@;print(s.sub('@', 34.chr + s + 34.chr))";print(s.sub('@', 34.chr + s + 34.chr))