Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In case you don't take the time to have your mind blown, here's the source (1014 characters):

for(B=i=y=u=b=i=5-5,x=10,I=[],l=[];l[B]="ECDFBDCEAAAAAAAAIIIIIIIIMKLNJLKM@G@TSb~?A6J57IKJT576,+-48HLSUmgukgg OJNMLK IDHGFE".charCodeAt(B)-64,B++<120;I[B-1]=B%x?B/x%x<2|B%x<2?7:B/x&4?0:l[i++]:7);function X(c,h,e,s){e^=8;for(var o,S,C,A,R,T,G,n,N=-1e8,O=20;++O<99;)if((o=I[T=O])&&(G=o^e)<7){A=G--&2?8:4;C=o-9?l[61+G]:49;do if(!(R=I[T+=l[C]])&&!!G|A<3||(R+1^e)>9&&G|A>2){if(!(R-2&7))return 78-h<<x;n=G|(e?T>29:T<91)?o:6^e;S=(R&&l[R&7|32]-h-G)+(G?0:n-o?55:(A<2)+1);if(c>h||1<c&c==h&&S>2){I[T]=n;I[O]=0;S-=X(c,h+1,e,S-N);if(!(h||c-1|B-O|T-b|S<-1e4))return W(B=0),e&&setTimeout("X(2,0,8),X(1,0,8)",50);I[O]=o;I[T]=R}if(S>N||!h&S==N&&Math.random()<.5)if(N=S,c>1)if(h?s-S<0:(B=O,b=T,0))return S}while(!R&G>2||(T=O,(G||A>2|(e?O>78:O<41)&!R)&&++C--A))}return N}function W(){i="<table>";for(u=18;u<98;i+=++u%x-9?"<th width=60 height=60 onclick='I[b="+u+"]>8?W(B=b):X(1,0,0)'style='font-size:50px'bgcolor=#"+(u-B?u.9&1||9:"d")+"0f0e0>&#"+(I[u]?9808+l[67+I[u]]:160)+";":u++&&"<tr>");document.body.innerHTML=i+"</table>"}W();

Beautified:

   for (B = i = y = u = b = i = 5 - 5, x = 10, I = [], l = []; l[B] = "ECDFBDCEAAAAAAAAIIIIIIIIMKLNJLKM@G@TSb~?A6J57IKJT576,+-48HLSUmgukgg OJNMLK IDHGFE".charCodeAt(B) - 64, B++ < 120; I[B - 1] = B % x ? B / x % x < 2 | B % x < 2 ? 7 : B / x & 4 ? 0 : l[i++] : 7);
   
   function X(c, h, e, s) {
       e ^= 8;
       for (var o, S, C, A, R, T, G, n, N = -1e8, O = 20; ++O < 99;) if ((o = I[T = O]) && (G = o ^ e) < 7) {
           A = G-- & 2 ? 8 : 4;
           C = o - 9 ? l[61 + G] : 49;
           do
           if (!(R = I[T += l[C]]) && !! G | A < 3 || (R + 1 ^ e) > 9 && G | A > 2) {
               if (!(R - 2 & 7)) return 78 - h << x;
               n = G | (e ? T > 29 : T < 91) ? o : 6 ^ e;
               S = (R && l[R & 7 | 32] - h - G) + (G ? 0 : n - o ? 55 : (A < 2) + 1);
               if (c > h || 1 < c & c == h && S > 2) {
                   I[T] = n;
                   I[O] = 0;
                   S -= X(c, h + 1, e, S - N);
                   if (!(h || c - 1 | B - O | T - b | S < -1e4)) return W(B = 0), e && setTimeout("X(2,0,8),X(1,0,8)", 50);
                   I[O] = o;
                   I[T] = R
               }
               if (S > N || !h & S == N && Math.random() < .5) if (N = S, c > 1) if (h ? s - S < 0 : (B = O, b = T, 0)) return S
           }
           while (!R & G > 2 || (T = O, (G || A > 2 | (e ? O > 78 : O < 41) & !R) && ++C--A))
       }
       return N
   }
   function W() {
       i = "<table>";
       for (u = 18; u < 98; i += ++u % x - 9 ? "<th width=60 height=60 onclick='I[b=" + u + "]>8?W(B=b):X(1,0,0)'style='font-size:50px'bgcolor=#" + (u - B ? u.9 & 1 || 9 : "d") + "0f0e0>&#" + (I[u] ? 9808 + l[67 + I[u]] : 160) + ";" : u++ && "<tr>");
       document.body.innerHTML = i + "</table>"
   }
   W();


if someone's wondering how he displays chess symbols that's how :

http://en.wikipedia.org/wiki/Chess_symbols_in_Unicode

ps : also it's better to beautifier the code to (try to) understand it :

http://jsbeautifier.org/


I'm getting empty character boxes instead of chess symbols, even if I force UTF-8 in Chrome or IE. Any ideas?


Maybe some font problem? How do you see chess symbols in Wikipedia page?

It's possible to have missing or corrupted Unicode font (once my Arial got broken and I had to get it somewhere from the web).


"once my Arial got broken".

funny sentence :D


Have you patched your uxtheme.dll and are using a custom .msstyle? I'm guessing the default font of your theme may have an impact.


for(B=i=y=u=b=i=5-5, [...]

Is there a point in saying 5-5 instead of 0, other than wasting two characters for the fun of it?


Probably because he wanted to keep 1-letter variable names, and 1024 is more interesting than 1022.


It's 1014, though.


Okay, then it was to pad the js file to 1024 bytes, because 1024 bytes is more interesting than 1014 bytes.


Also setting i twice, I'm not sure why.


It seems the author likes to use variable names to encode messages:

- "Biyubi" looks like his nickname (on his chess site [1] contact mail is "biyubi@gmail.com")

- there is also "o, S, C, A, R, T, G" which are his first name and surname initials

- and already mentioned "X(c, h, e, s)"

[1] http://nanochess.110mb.com/author.html


Good catch, although that would be easier to discount as an oversight.

[Edit: sibling post explains it.]


Extra points for the function call:

X(c, h, e, s)


would you mind re-pasting the beautified code from the locally saved source? there are characters missing in the pasted blob (notice the italics.)


If only I could understand what is going on in the code...the variable names make my head explode :(


Not a very good one :-) I just got to checkmate in 6 moves!




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: