Skip to content

Instantly share code, notes, and snippets.

@fwiffo
Created March 24, 2013 14:51
Show Gist options
  • Save fwiffo/5232237 to your computer and use it in GitHub Desktop.
Save fwiffo/5232237 to your computer and use it in GitHub Desktop.
A polyglot quine. Will compile, run and print its source code as C, C++, Python (2.x or 3.x) or Perl.
#include <stdio.h>
#define q(a,...) a
#define substr q
#define eval(a) main(){char c[]=a,n=10;c[419]=0;printf(c+4,n,n,n,n,34,34,n,34,39,c+4,39,34,n);}/* Copyright (C) Thomas Schumm <[email protected]>
exec("from sys import*;substr=q=lambda y:exit(stdout.write(y[4:-46]%((10,)*4+(34,34,10,34,39,y[4:-46],39,34,10))))",None);#*/
eval(substr(q("$p='#include <stdio.h>%c#define q(a,...) a%c#define substr q%c#define eval(a) main(){char c[]=a,n=10;c[419]=0;printf(c+4,n,n,n,n,34,34,n,34,39,c+4,39,34,n);}/* Copyright (C) Thomas Schumm <[email protected]>%cexec(%cfrom sys import*;substr=q=lambda y:exit(stdout.write(y[4:-46]%%((10,)*4+(34,34,10,34,39,y[4:-46],39,34,10))))%c,None);#*/%ceval(substr(q(%c$p=%c%s%c;printf($p,(10)x4,34,34,10,34,39,$p,39,34,10)%c),1,-1))%c';printf($p,(10)x4,34,34,10,34,39,$p,39,34,10)"),1,-1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment