quine

C/C++ program that prints its own source code as its output

爱⌒轻易说出口 提交于 2019-12-17 12:05:53
问题 Wikipedia says it's called a quine and someone gave the code below: char*s="char*s=%c%s%c;main(){printf(s,34,s,34);}";main(){printf(s,34,s,34);} But, obviously you have to add #include <stdio.h> //corrected from #include <stdlib.h> so that the printf() could work. Literally, since the above program did not print #include <stdio.h> , it is not a solution (?) I am confused about the literal requirement of "print its own source code", and any purpose of this kind of problems, especially at

C/C++ program that prints its own source code as its output

瘦欲@ 提交于 2019-12-17 12:05:10
问题 Wikipedia says it's called a quine and someone gave the code below: char*s="char*s=%c%s%c;main(){printf(s,34,s,34);}";main(){printf(s,34,s,34);} But, obviously you have to add #include <stdio.h> //corrected from #include <stdlib.h> so that the printf() could work. Literally, since the above program did not print #include <stdio.h> , it is not a solution (?) I am confused about the literal requirement of "print its own source code", and any purpose of this kind of problems, especially at

Python: What does the two % signs in print '%r k%%k'%'a' do?

你。 提交于 2019-12-14 03:23:32
问题 I came across this while researching quines. I am curious to know what %% does in the following print '%r k%%k'%'a' I understand that %r takes the string representation of the argument that's passed (in this case 'a') and adds it to the string with quotes, so in this case it prints 'a' k%k. I can't figure out what k%%k does? If I remove one of the % signs, I get an error. If I have both without the %r, I get an error too. However, when I have both %r and the two % signs in between to ks (or

Ruby: Print source code

微笑、不失礼 提交于 2019-12-11 16:37:41
问题 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 to test that out. Dunno, get the source of the code below: class MyClass def initialize print "You cannot read me!!" end end So I can print that whole class? 回答1: A Quine is a program that prints out its own source code as its only functionality

On compilation of The Qlobe

戏子无情 提交于 2019-12-11 05:12:34
问题 I don't know ruby at all,but while reading some another blog I came across this beautiful piece of work The Qlobe. But I am a windows vista user and I don't have ruby installed in my system,but I am very much inquisitive to enjoy this masterpiece. So my question is it possible to enjoy this through online compilation? I do tried on Ideone but it's giving compilation error. 来源: https://stackoverflow.com/questions/4503531/on-compilation-of-the-qlobe

C# Quine Problem

牧云@^-^@ 提交于 2019-12-10 04:24:57
问题 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 on this line } } It's throwing an exception on writeline: Index (zero based) must be greater than or equal to zero and less than the size of the argument list. Can someone help -

Constructing quines (self-reproducing functions)

我与影子孤独终老i 提交于 2019-12-05 11:56:19
问题 Has anyone constructed a quine ("A program that generates a copy of its own source text as its complete output": http://www.nyx.net/~gthompso/quine.htm) in R? (The [quine] tag pulls up lots of examples in Python, Java, ... but apparently none in R.) f <- function() { body() } comes close: > f() { body() } but lacks the name of the function. How about the shortest possibility? Most obfuscated? edit : from the variety of answers below, it seems that there are a variety of ways to define self

Constructing quines (self-reproducing functions)

北城以北 提交于 2019-12-03 23:32:47
Has anyone constructed a quine ("A program that generates a copy of its own source text as its complete output": http://www.nyx.net/~gthompso/quine.htm ) in R? (The [quine] tag pulls up lots of examples in Python, Java, ... but apparently none in R.) f <- function() { body() } comes close: > f() { body() } but lacks the name of the function. How about the shortest possibility? Most obfuscated? edit : from the variety of answers below, it seems that there are a variety of ways to define self-referentiality and the environment in which it must occur: within the R environment: function ->

shortest python quine?

假装没事ソ 提交于 2019-12-03 18:32:31
问题 _='_=%r;print _%%_';print _%_ Is this the shortest possible python quine, or can it be done better? This one seems to improve on all the entries on The Quine Page. I'm not counting the trivial 'empty' program, and I'm not counting Terry Reedy's submission which is sus because of the double quotes (if that's allowed, is "hello world" a quine? or "'" for that matter?) 回答1: I'm just going to leave this here (save as exceptionQuine.py): File "exceptionQuine.py", line 1 File "exceptionQuine.py",

Zip-file that contains nothing but itself?

喜你入骨 提交于 2019-12-03 04:48:09
问题 Just out of curiosity, does there exist a valid zip-file (according to format spec) that, contains nothing but itself? Put another way, does the function implemented by unzip have a fix-point? Can I write a program to search for such a fix-point in a intelligent (not-exhaustive) way? I've thought about the opposite as well, i.e. if zip has a fix-point, but presumably a file can be compressed in different ways (different algorithms, different levels of compression and so on), thus whether or