I have seen a lot of C/C++ based solutions to this problem where we have to write a program that upon execution prints its own source.
some solutions --
http://www.cprogramming.com/challenges/solutions/self_print.html
Quine Page solution in many languages
There are many more solutions on the net, each different from the other. I won...
There was a C program written for a contest that was formatted in ASCII art as a Japanese character. When compiled and ran it printed out another program formatted in a different Japanese character, then another, then finally it printed out the first again.
I was looking for the code to that and could not find it on the internet. I do...
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 main(String[] args)
{
// some code
}
}
(Any programming language is accepted)...
I need (preferrably the shortest) program that prints its own source code in C#.
I will post it here when I finish it, but if you already have a link your help will be greatly appreciated.
I have come with a solution, but then have found it here. Cuddos to Joey Westcott
...
I came across this term - Quine (also called self-reproducing programs). Just wanted to know more on it. How does one write a quine and are they used anywhere or they are just an exercise for fun?
I've started with Python, and I might try writing one in Python. Any suggestions?
...
Here is a special Haskell program which outputs a Python program that outputs a Ruby program that outputs the original Haskell program (from http://blog.sigfpe.com/2008/02/third-order-quine-in-three-languages.html)
To be more exactly, the output is of this Haskell program
q a b c=putStrLn $ b ++ [toEnum 10,'q','('] ++ show b ++ [','] +...
I think this might be a classic question but I am not aware of an answer. Can a program output a copy of itself, and, if so, is there a short program that does this?
I do not accept the "empty program" as an answer, and I do not accept programs that have access to there own source code. Rather, I am thinking something like this:
int ma...
I need to set myself a reminder to attend a weekly meeting. The trouble with my company's standard reminder tool is that when it runs under wine, it pops up on an off-screen virtual desktop.
I thought it would be interesting to see if I could come up with an "at" command that pops up a reminder window and then resubmits itself for the ...
I am trying to understand how this piece of self-replicating code works (found here), but the problem is I can't get it to run as-is:
class c {
static void Main(){
string s = "class c{{static void Main(){{string s={0}{10};System.Console.Write(s,(char)34,s);}}}}";
System.Console.Write(s,(char)34,s); //<<-- exception...
Blast from the past. This is one of the puzzles from my early days:
Can you write a method (a function) which when called outputs its own source - literally including all the quotes, indentations, etc?
No cheating - no reading from a file
...
It is known that C++ templates are turing complete. As such it should be possible to output a quine that is essentially rendered at compile time. Does anyone know if such a quine has been written yet or where I could find one.
...
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 ...
I just wanted to know if it is 100% possible, if my language is turing-complete, to write a program in it that prints itself out (of course not using a file reading function)
So if the language just has the really necessary things in order to make it turing complete (I would prove that by translating Brainf*ck code to it), like output, ...
Is it possible to make a Java program that prints its source code to a new file, and compiles it, and runs the compiled program?
...
I have created a turing-complete programming language (already proven) so it must be possible to write a quine for it, right?
But all quines I know store their source code in a string and then replace a special character in it using something like chr and ord.
My language only has the following
Basic arithmetics
Int and string types
...
As a purely academic exercise (read "because I have no life"), I'm trying to write a function f which accepts another function g, executes g for its side effect, and returns itself.
So I have this:
let rec f g x =
ignore(g x)
fun y -> f g y
F# complains:
fun y -> f g y;;
-------------^^^^^
C:\Users\Juliet\AppData\Lo...
is it possible to write a program which prints its own source code utilizing a "sequence-generating-function"?
what i call a sequence-generating-function is simply a function which returns a value out of a specific interval (i.e. printable ascii-charecters (32-126)). the point now is, that this generated sequence should be the programs ...
Is it possible to have a Java printf statement, whose output is the statement itself?
Some snippet to illustrate:
// attempt #1
public class Main {
public static void main(String[] args) {
System.out.printf("something");
}
}
This prints something.
So the output of attempt #1 is not quite exactly the printf statement in attempt #1....
def start(fileName):
fileReader = open(fileName)
for row in fileReader:
print row,
if __name__ == "__main__":
import sys
if len(sys.argv) <= 1:
print "usage quine /path/to/file"
sys.exit(-1)
fileName = sys.argv[0]
start(fileName)
python quine.py foo
...
OK, for those who have never encountered the term, a quine is a "self-replicating" computer program. To be more specific, one which - upon execution - produces a copy of its own source code as its only output.
The quines can, of course, be developed in many programming languages (but not all); but some languages are obviously more suite...