Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6001823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:53:22+00:00 2026-05-23T00:53:22+00:00

Quine is a self reproducing code. For example if the code in groovy looks

  • 0

Quine is a self reproducing code. For example if the code in groovy looks like:

def s = 20

When i run the above code, i should get the program statements as my outputs. So the above code should produce:

def s = 20 //as this is my input..

As I have seen in Groovy Console, i came to know groovy supports Quine :

s='s=\\\';s[0..1]+s[3]+s[0..1]+s[2]*6+s[3..-1]*2';s[0..1]+s[3]+s[0..1]+s[2]*6+s[3..-1]*2

But I don’t know how it works! Could any one say me, how the code in the above link works?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:53:23+00:00Added an answer on May 23, 2026 at 12:53 am

    The code in question is:

    s='s=\\\';s[0..1]+s[3]+s[0..1]+s[2]*6+s[3..-1]*2';s[0..1]+s[3]+s[0..1]+s[2]*6+s[3..-1]*2
    

    So, the left statement defines a string, then the right statement adds together different bits of the String:

    If we add the following to print out what it’s doing:

    println s[0..1]
    println s[3]
    println s[0..1]
    println s[2] * 6
    println s[3..-1] * 2
    

    we get the output:

    s=
    '
    s=
    \\\
    ';s[0..1]+s[3]+s[0..1]+s[2]*6+s[3..-1]*2';s[0..1]+s[3]+s[0..1]+s[2]*6+s[3..-1]*2
    

    And if you add all those strings together, you get the original program.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I came across this term - Quine (also called self-reproducing programs). Just wanted to
OK, for those who have never encountered the term, a quine is a self-replicating
I do this quite a bit in my code: self.sliderOne.frame = CGRectMake(newX, 0, self.sliderOne.frame.size.width,
i'm self-teaching c++ and i get how pointers work. but the doc i'm using
Other than self.class.send :method, args... , of course. I'd like to make a rather
It looks like I don't quite have the hang of Exception handling yet. I'm
I am unable to achieve any animation with the following code: if (self.segmentControl.selectedSegmentIndex ==
CATransition is quite unusual. Consider the following code. CATransition* trans=[CATransition animation]; trans.duration=0.5; trans.type=kCATransitionFade; [self.holdingView.layer
This is the code of my initializer: if (self = [super init]) { self.title
Well the title is quite self explanatory. I want to build two panels one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.