Questions tagged [quine]

A program that generates a copy of its own source text as its complete output (generally of interest in theory only).

A program that generates a copy of its own source text as its complete output. This is generally considered of interest in theory only; but highly self-contained programs ( for example) may be viewed as quine-like. Named after the logician Willard van Orman Quine

99 questions
0
votes
1 answer

Python quine without %r and %s

I know of the shortest Python quine (shortest python quine?) but it looks like a winner of a Python obfuscation challenge. It is cryptic. Is there a Python quine that is easy to understand for a beginner: with variables, IFs, loops, but that doesnot…
Stepan
  • 1,391
  • 18
  • 40
0
votes
1 answer

How to execute AST or code object in a separate process without exceeding max recursion depth

I am trying to write a metamorphic quine. Without the "spawn" context, the subprocesses seem to inherit the stack, and so I ultimately exceed the max recursion depth. With the "spawn context," the subprocess doesn't seem to recurse. How would I go…
0
votes
0 answers

Searching Prolog Quine that doesnt use clause/2 or write/1?

The simplest Prolog Quine, that can reproduces its own clause, reads as follows: quine((quine(X) :- Y)) :- clause(quine(X), Y). ?- quine(Z). Z = (quine((quine(_22008):-_22004)):-clause(quine(_22008), _22004)). Is there another Prolog Quine…
user502187
0
votes
0 answers

Printing a function as String in Dart

Dart question about printing function as a string - I have this code on Dart- sum(a, b) { return a + b; } If i run - print(sum.toString()); I get - Closure: () => dynamic from Function 'sum':. If i run it on JavaScript…
Eden Nahum
  • 75
  • 1
  • 5
0
votes
1 answer

Quine Program Example in C

In my course slides, I have this example but without much explanation: char*f="char*f=%c%s%c;main(){printf(f,34,f,34,10);}%c";main(){printf(f,34,f,34,10);} I understand what quine programs in general mean but I do not quite understand what's…
x89
  • 2,798
  • 5
  • 46
  • 110
0
votes
7 answers

How to output the code itself?

How many ways are there to let the code output itself? For example, write the code below, public class Test { public static void main(String[] args) { // some code } } to output itself public class Test { public static void…
Ray Lu
  • 26,208
  • 12
  • 60
  • 59
0
votes
1 answer

Coding a Quine in J

Am I missing some key part in the definition of a quine, because this seems far too easy to be considered even worthwhile in J. NB. commentary for Quine code verbatim =: (3 : 0)'' smoutput 1!:1 <'filename' NB. where 'filename' would obviously be…
S_Lang
  • 87
  • 2
0
votes
0 answers

Bug in Quine Written in C Only Prints Up to The Last Line of Code Wrapped in Quotation Marks

I am trying to write a quine based off the Java code in this Wikipedia article. Here is my code so far: #include #include #include void print(int x) { char * buf = itoa(x,NULL,10); puts(buf); } int…
Tanveer Salim
  • 27
  • 1
  • 1
  • 9
0
votes
1 answer

How to embed md5 sum of sentence in the sentence?

For example, how do I solve for x such that md5(“The md5 of this sentence is [x].” = x? Is this possible with a reasonable amount of effort? Are there any other common cryptographic hashes that make this easier or harder?
personjerry
  • 1,045
  • 8
  • 28
0
votes
5 answers

Self-reproducing program

I am questioning my solution to the last exercise in Accelerated C++: Write a self-reproducing program. Such a program is one that does no input, and that, when run, writes a copy of its own source text on the standard output stream. My…
Kevin
  • 2,617
  • 29
  • 35
0
votes
2 answers

Ruby: Print source code

Recently I heard about something called Quine. But my definition of it is a bit unclear. I believe that you can print your own Ruby file's source code without using __FILE__? Is that possible? I would be very interested in your ideas. I would like…
Saturn
  • 17,888
  • 49
  • 145
  • 271
0
votes
1 answer

Is the reflection namespace a building block for writing a quine in C#?

Do I need to use reflection to write a quine program for C#? I read elsewhere - quine that opening the source file from disk is "cheating" So I guess using .net reflector and/or opening the source file using System.IO is a hack. Are there other ways…
Anonymous Type
  • 3,051
  • 2
  • 27
  • 45
0
votes
1 answer

Establishing quine type in scala

I have to parse a string with syntax lazy val expr: Parser[Term ~ Option[]] = term ~ opt(expr) You see, it uses itself to parse subexpressions. But what does this type result in? In order to reproduce the problem, I created a somewhat…
Little Alien
  • 1
  • 8
  • 22
0
votes
0 answers

Python quine stops running after 3 iterations. No error

I have made a quine. it's a mess but I think it will be readable enough. It is made to both write itself to a file and write itself in cmd. When it writes itself in cmd it writes with a short delay between each letter. All of that works. What…
Engesa
  • 9
  • 2
0
votes
3 answers

How to Reverse Quine?

i have written a C programme which prints itself n times, but i can't get how to reverse print the same n times.E.g, if the sample programme is : hello then the required output should be "olleh" for n=1. Here's my quine programme, #include…
pranay
  • 2,339
  • 9
  • 35
  • 58