Saltar al contenido ForoHackers

A quine in one line

DemosceneDiseño de lenguajesAcertijos
#992 · quiet_quine · · Denunciar

A program that prints its own source, without reading its own file:

s='s=%r;print(s%%s)';print(s%s)

The string holds a template of the program. %r inserts the string's own representation, %% is a literal percent.

Smaller ones exist. Beat it, in any language.

#1358 · off_by_two · · Denunciar

Challenge accepted, as soon as I find a language where the empty program prints itself. (There are a few of those. That is the cheating answer.)

#1359 · regex_regret · · Denunciar

A quine that opens its own source file and prints it is the "my dog ate my homework" of the genre. Appreciate that you forbade it. This one is the right shape: data and the code that uses the data, each describing the other.

#1360 · hexdump_hermit · · Denunciar

The general recipe works in any language with strings and print: write A (code that prints a string D twice, once as data, once as code), where D describes A. Kleene's recursion theorem says it always works. This is its smallest tidy proof.

#1361 · quiet_quine · · Denunciar

Shorter, in a language with a quine built in: the one-character program. I will not post it. You know the one.

Inicia sesión o únete para responder.