| Liste Articles: [0-A] [A-C] [C-F] [F-J] [J-M] [M-P] [P-S] [S-Z] | Liste Catégories | Une page au hasard | Pages liées | ||||||
En informatique, un quine est un programme (une sorte de métaprogramme) dont la sortie et le code source sont identiques. Pour s'amuser, les hackers essaient d'écrire le plus court quine dans un langage donné.
Il faut noter que l'opération qui consiste à ouvrir le fichier source et à l'afficher est considérée comme une tricherie.
Les quines tirent leur nom du philosophe et logicien américain W. V. Quine, who made an extensive study of indirect self-reference: he coined, among others, the paradox-producing expression, "yields falsehood when appended to its own quotation."
| Sommaire |
#include<stdio.h>
char*i="\\#include<stdio.h>",n='\n',q='"',*p=
"%s%cchar*i=%c%c%s%c,n='%cn',q='%c',*p=%c%c%s%c,*m=%c%c%s%c%c;%s%c",*m=
"int main(){return!printf(p,i+1,n,q,*i,i,q,*i,q,n,q,p,q,n,q,m,q,n,m,n);}"
;int main(){return!printf(p,i+1,n,q,*i,i,q,*i,q,n,q,p,q,n,q,m,q,n,m,n);}
(Note: linebreaks added for ease of reading)
using System;
namespace quine
{
class Program
{
[STAThread]
static void Main(string[] args)
{
string s = "using System;{0}namespace quine{0}{2}{0}{1}class Program{0}
{1}{2}{0}{1}{1}[STAThread]{0}{1}{1}static void Main(string[] args){0}{1}{1}{2}{0}{1}{1}{1}
string s = {4}{6}{4};{0}{1}{1}{1}Console.Write(s, Environment.NewLine, {4}{5}t{4}, {4}{2}
{4}, {4}{3}{4}, {4}{5}{4}{4}, {4}{5}{5}{4}, s);{0}{1}{1}{3}{0}{1}{3}{0}{3}";
Console.Write(s, Environment.NewLine, "\t", "{", "}", "\"", "\\", s);
}
}
}
((lambda (x) (list x (list (quote quote) x))) (quote (lambda (x) (list x (list (quote quote) x)))))
(funcall (lambda (x) (append x (list (list 'quote x)))) '(funcall (lambda (x) (append x (list (list 'quote x))))))
(fun s -> Printf.printf "%s %S" s s) "(fun s -> Printf.printf \"%s %S\" s s)"
a='a=%s;print a%%`a`';print a%`a`
Un autre exemple :
b='\\';g='"';p='%';s="b='%s%s';g='%s';p='%s';s=%s%s%s;print s%s(b,b,g,p,g,s,g,p)";print s%(b,b,g,p,g,s,g,p)
And another one that shares the last 61 characters with the previous one (just to show that multiple assignments don't save typing :)):
b,g,p,s='\\','"','%',"b,g,p,s='%s%s','%s','%s',%s%s%s;print s%s(b,b,g,p,g,s,g,p)";print s%(b,b,g,p,g,s,g,p)
unescape(q="unescape(q=%22*%22).replace('*',q)").replace('*',q)
$_=q{$_=q{Q};s/Q/$_/;print};s/Q/$_/;print
Et un mélange shell/Perl :
perl -le '$n=q{perl -le a$n=q{$x};($_=$n)=~s/\141/\47/g;s/\$x/$n/;printa};($_=$n)=~s/\141/\47/g;s/\$x/$n/;print'
10 C=": PRINT CHR(49)+CHR(48)+CHR(32)+CHR(67)+CHR(61)+CHR(34)+C+CHR(34)+C": PRINT CHR(49)+CHR(48)+CHR(32)+CHR(67)+CHR(61)+CHR(34)+C+CHR(34)+C
const a='const a=';b='begin write(a,#39,a,#39#59#98#61#39,b,#39#59#10,b) end.'; begin write(a,#39,a,#39#59#98#61#39,b,#39#59#10,b) end.
(Note: This should be one continuous line of code, but line breaks have been added for ease of reading.)
->+>+++>>+>++>+>+++>>+>++>>>+>+>+>++>+>>>>+++>+>>++>+>+++>>++>++>>+>>+>++>++> +>>>>+++>+>>>>++>++>>>>+>>++>+>+++>>>++>>++++++>>+>>++>+>>>>+++>>+++++>>+>+++ >>>++>>++>>+>>++>+>+++>>>++>>+++++++++++++>>+>>++>+>+++>+>+++>>>++>>++++>>+>> ++>+>>>>+++>>+++++>>>>++>>>>+>+>++>>+++>+>>>>+++>+>>>>+++>+>>>>+++>>++>++>+>+ ++>+>++>++>>>>>>++>+>+++>>>>>+++>>>++>+>+++>+>+>++>>>>>>++>>>+>>>++>+>>>>+++> +>>>+>>++>+>++++++++++++++++++>>>>+>+>>>+>>++>+>+++>>>++>>++++++++>>+>>++>+>> >>+++>>++++++>>>+>++>>+++>+>+>++>+>+++>>>>>+++>>>+>+>>++>+>+++>>>++>>++++++++ >>+>>++>+>>>>+++>>++++>>+>+++>>>>>>++>+>+++>>+>++>>>>+>+>++>+>>>>+++>>+++>>>+ [[->>+<<]<+]+++++[->+++++++++<]>.[+]>>[<<+++++++[->+++++++++<]>- .------------------->-[-<.<+>>]<[+]<+>>>]<<<[-[-[-[>>+<++++++[->+++++<]]>++++ ++++++++++<]>+++<]++++++[->+++++++<]>+<<<-[->>>++<<<]>[->>.<<]<<]
Q
@echo off %1 %2 call %0 goto e %% call %0 goto e %%3 echo.%%4 echo :f goto f :e echo.%4@echo off echo.%4%31 %32 echo.%4call %30 goto e %3%3 echo.%4call %30 goto e %3%33 echo.%3%34 echo.%4echo :f echo.%4goto f echo.%4:e :f
<? $a='chr(60).chr(63).chr(10).chr(36).chr(97).chr(61).chr(39).$a.chr(39).chr(59).chr(10)."echo $a;".chr(10).chr(63).chr(62)'; echo chr(60).chr(63).chr(10).chr(36).chr(97).chr(61).chr(39).$a.chr(39).chr(59).chr(10)."echo $a;".chr(10).chr(63).chr(62); ?> <? $a='<? $a=2; echo str_replace(1+1,chr(39).$a.chr(39),$a); ?>'; echo str_replace(1+1,chr(39).$a.chr(39),$a); ?>
(Remarque : ce plus court quine écrit en PL/I compilera en utilisant la version OS PL/I V2.3.0 du compilateur, mais nécessite une marge à gauche de 1 et l'option COMPILE pour éviter un certain nombre d'erreurs ou d'avertissements)
%dcl z%z='put edit';proc options(main;q=''''put list(m;do i=1,2;z(q)skip;do j=
1to 78c=substr(m(i),j;if c=q z(c;z(c;end;z(q',';dcl(c,q)char,m(2)char(99)init(
'%dcl z%z=''put edit'';proc options(main;q=''''''''put list(m;do i=1,2;z(q)skip;do j=',
'1to 78c=substr(m(i),j;if c=q z(c;z(c;end;z(q'','';dcl(c,q)char,m(2)char(99)init(',
(dup == {dup cvx exec} pop 8 12 getinterval =)
dup cvx exec
CLEAR SET TALK OFF SET TEXTMERGE ON \CLEAR \SET TALK OFF \SET TEXTMERGE ON


