Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Christmas poem since 1988

by Anonymous Monk
on Dec 23, 2005 at 17:21 UTC ( [id://518788] : obfuscated . print w/replies, xml ) Need Help??

This is my Merry Christmas contribution for all of you. First I wanted to post it to the poetry section. It is our beloved Christmas poem since 1988. If you have problems copy-pasting it, download it directly.

Trivia: run this program in three (3) different programming languages, and get three slightly different output!

#include <stdio.h> #define q char w=0,v[]= q("@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+,/ ++#n+" ",/#;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!/+k#;q#' +r}eK" "K#}w'r}eKK{nl]'/#;#q#n'>{>#}w'>{>{nl]'/+#n';d}rw' i;# >{nl]!/n{n#'; r +{#w'" "r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#n'wk nw' iwk{KK{nl]!/w{%'l##w#' + i; " ":{nl]'/*{q#'ld;r'}{nlwb!/*de}'c ;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd +'+e}" "+;#'rdq#w! nr'/ '> }+}{rl#'{n' '># }'+}##<!!/"),s #define dducfirstde ;static int f(int t,int _,char*a){return!0<t?t<3?f +(-79, #define lt -13,a+f(-87,1-_,f(-86,0,a+1)+a)):1,t<_?f(t+1,_,a):3,f(-94,- +27+t, #define s a)&&t==2?_<13?f(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?f(_,t,v): +t<-50 #define ici ?_==*a?putchar(31[a]):f(-65,_,a+1):f((*a=='/')+t,_,a+1):0< +t?f(2 #define length ,2,"%s"):*a=='/'||f(w,f(-61,*a,"!ek;dc i@bK'<q>-[w]*%n+ +r3#l" #define mysweetdiego ",{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}int + main #define cmp(s) (int t,char**_){struct w{int v;};if(sizeof(w)>1){v[111] +='d'; #define cos(u) (137)v[112]='n',v[113]=';',v[114]=':';}return!f(t,_?0:0 +,0);} dducfirstde lt s ici length mysweetdiego cmp(s ror study biconverge an +d s l lleg and s fd fdo do reverse foo xor s go dog chr reverse ord srand hy +perge and s eselcfirstexesee)if cos(s e e q dISWcJyccBWXJKcjBTocVUFEYcCUJWcD +ooYLW cWLoUccIEYVcTNTVLPyTcoPooQVXcLcRooVEYmTTTNTcLPREcocWoPYCcnQFKHCocEhcVM +cooQt ctUPcAWWKroCoBLcPcLcAlUToCbcWoTLVYNoREcLcToctYzoooTcoKocMcUTCKJoCDUUoc +VMURI gMLSahOXDTcococaAQAoCKBcQoocozfkIITnPikugLocvccCoBGYiTTPcXcoimVuIDfavH +lKHVX cokTPUooKgUYVoXVVxSjIAPmKUNbuocoPcBcYXUcVPkcoTcocVbPHoQTUOGxufBooTcmBF +oVKPY loFcccXcoDmcvIOMMDOGmSBQovoTTBolPycPAoVVnKUIItTwBnYroocTTVccoKCcVoKloc +rIrCf SBzgCocDJQRcccoVVzcQCUBxpioOLMsYZYucYoTTjWCoVoYHPTcBbxjoriLxGkaQcccycc +cLTTl UcNTBocoVUtuINkOxXCGOYvccJcCcUoobccLYroTcJtoooTtococzoEngovuncDNgooctc +oOLXV mVmZoTCETcYoARclVQBTVoQoLcYHVcmkjhFjOfoWTocPVmoocWoLoccJMLYWOLsMBvFiMZ +IHXNo VochoRcTooJooCoLWuskMhhgIKPTooocZZocXTTYoqcoWWaKSqmCgZoPVmWcVcQokUTWot +oNXWP uGvIqPaowkBocXcoTToLToooVVIcoqAnzzhigoTVohVVoUUQoBAcpccPooMVoGToDYQqqp +pyIjp NoVXScXUFovKoocUbLcVQTWNgbuHtioHsTocoRccoGcTXoocKTVocjgEpHDBloWcoEVVoH +oocDc goUoWTVVTcEYBPnKpaoIFVVVXAcHbcoTocoAVTNTToftfXPmiiOopuaoVXccooUjcoocUc +JUkTN cTFEXuVVmoUlWorTccoloGcTBoPooLcUlKoUcoXoYokocaAooTgPqTYLmcwJoVXocvmtJC +jpcEo TTOorccVococoMoocTErPcVocqYEcVQoYcccocoKvoooQKuYcoQoloECoWojooQoofocWR +ooJLc coojOIQcWohrdemix)

Replies are listed 'Best First'.
List of polyglot obfus (Re: Christmas poem since 1988)
by ambrus (Abbot) on Oct 09, 2012 at 20:50 UTC
        Oh, that reminds me. [answer-chaining] Add a language to a polyglot on Code Golf Stack Exchange. This is one of the polyglots with the highest number of languages, a collaborative project where every poster adds another language without ruining the existing ones.
Re: Christmas poem since 1988
by truedfx (Monk) on Dec 24, 2005 at 16:08 UTC

    Strict C compilers (tendra in default mode, gcc with -pedantic-errors) refuse to compile this, because while char v[]="..."; is valid, char v[]=("..."); is not. I haven't yet figured out what the third language is, if you don't mean C++, so I'm not sure if this breaks that, but my simple suggestion to resolve this is:

    Instead of
    #define q char w=0,v[]=
    you can use
    #define q(x) char w=0,v[]=x

    It doesn't affect the output with less strict C compilers (gcc in default mode, icc), nor does it affect the output as a Perl script.


    Update: I see now that the output is different when compiled as C++ instead of C ("only" instead of "true"), so it must be that that was what you meant.

Re: Christmas poem since 1988
by Errto (Vicar) on Dec 24, 2005 at 06:50 UTC
    Ok I give up. Besides C and Perl, what's the other language?
Re: Christmas poem since 1988
by zentara (Archbishop) on Dec 24, 2005 at 12:19 UTC
    It's also compilable as c++, at least I can compile it with g++. Of course, that is slightly cheating on "different language".

    I'm not really a human, but I play one on earth. flash japh
Re: Christmas poem since 1988
by blazar (Canon) on Dec 27, 2005 at 13:31 UTC
    Oh! impressive: not just as impressive as "the Best Ever", but I like the concept of code that is syntactically valid in more than one language. Now, a real challenge would be to write code that is valid C (and/or C++), Perl and Postscript, and does something interesting. As far as I'm concerned... quite about the only multi-language program I could write would probably be... an empty file! It would have the advantage of being a multi-language quine too!!
      I've added plain TeX, and updated the original download link target so it is now C, C++, Perl and plain TeX. I'm quite sure that it is not possible to add PostScript, because there is no way to find a common starting for C, C++, Perl, plain TeX and PostScript. However, if we remove plain TeX, it is quite easy to add TCL and Bourne Shell (hint: TCL treats a backslash at the end of the comment line as an indicator that the comment continues in the next line). The starting line should be: #define eval char *eval=

        I'm quite sure that it is not possible to add PostScript, because there is no way to find a common starting for C, C++, Perl, plain TeX and PostScript.

        I took that as a challenge :D

        %:/*:if 0;false +s&&(#*/include<stdio.h>/* { Just another \TeX\ hacker, { \bye } &g;print substr q q Just another Perl hacker, q, 1 and exit; q q %};};);echo -ne "\e[A\e[K\ Just another bash hacker, " && exit; */ int main() { printf("\ Just another C%s hacker,\n\ ", "++"+2*(1%sizeof'2')); } /* } /Times-Roman findfont 20 scalefont setfont newpath 72 72 moveto (Just another PostScript hacker,) show showpage % q # */