Last active
September 25, 2015 16:51
-
-
Save makenowjust/faa0ebb30af52924ce94 to your computer and use it in GitHub Desktop.
Packed Quine in JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| eval(s=` | |
| C=(s,u)=>{ | |
| p={}; | |
| for(j=2;j<=s.length/2;j++) | |
| with(s) | |
| for(k=0,q=p[r=slice(0,j)]=[];k=indexOf(r,j+k),~k;) | |
| q.push(k); | |
| r=(k=Object.keys(p))[(d=k.map(r=>(r.length-1)*(p[r].length-1)-1)).indexOf(v=Math.max.apply(1,d))]; | |
| if(v<3)return{t:s,c:''}; | |
| for(j=126;u.has(c=String.fromCharCode(j));j--); | |
| u.add(c); | |
| return{ | |
| t:s.split(r).join(c)+c+r, | |
| c, | |
| }; | |
| }; | |
| S=(s)=>{ | |
| y=''; | |
| u=s.split('').reduce((u,c)=>u.add(c),new Set); | |
| for(i=0;i<s.length/2;i++) | |
| with(C(s.slice(i),u)) | |
| s=s.slice(0,i)+t,y=c+y; | |
| return{s,y}; | |
| }; | |
| E=(s)=>s.replace(/[\\x24\\x5c\\x60]/g,'\\\\\$&'); | |
| with(S(\`eval(s=\\\`\${E(s)}\\\`)\`.replace(/^\\s+|\\n/mg,''))) | |
| console.log(\`s=\\\`\${E(s)}\\\`;for(c of\\\`\${E(y)}\\\`)with(s.split(c))s=join(pop());eval(s)\`); | |
| `) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| s=`z=\`C=_,uZ{p={YXj=2;j<=WV/2;j++U_)Xk=0,q=p[r=T0,j)]=[];k=indexOf(r,j+k),~k;)q.push(kRr=(k=Object.keys(pQ[(d=k.map(r=>(r.V-1)*(p[r].V-1)-1Q.indexOf(v=Math.max.apPy(1,dQ];if(v<3)Nt:s,c:''YXj=126;u.has(c=String.fromCharCode(j)Rj--Ru.add(cRNt:WLr).join(c)+c+r,c,YYS=_Z{y='';u=WL'').reduK(u,cZu.add(c),new SetRXi=0;i<WV/2;i++U(C_.Ti),uQs=WT0,i)+t,y=c+y;Ns,yYYE=_ZWrePaK/[\\\\x24\\\\x5c\\\\x60]/g,'\\\\\\\\\\\$&'Rwith(S(\\\`z=\\\\\\\`\\\${E_)}\\\\\\\`)\\\`.rePaK/^\\\\s+|\\\\n/mg,''Q)console.log(\\\`s=\\\\\\\`\\\${E_)}\\\\\\\`;Xc of\\\\\\\`\\\${E(y)}\\\\\\\`U_.LcQs=join(pop()Rz)\\\`R\`)zeval__(sZ)=>Y};Xfor(Ws.VlengthU)withTsliKR);Q))PplNreturn{LsPit(Kce(`;for(c of`KLNPQRTUVWXYZ_z`)with(s.split(c))s=join(pop());eval(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment