Segunda-feira, 9 de Novembro de 2009

Codebits Quiz Challenge #5 and the #4 Winner is....


There has been great participation to our Codebits challenges this year!



To all you guys awaiting, the Codebits Challenge #5 is now online!


As a reminder, these challenges work as a qualification round for the SAPO Codebits Quiz show. Last year we had great fun, if you want to know how is it like, check the video.


The last codebits quiz had 18 valid answers. The winner is Cláudio Valente,  with an elega^H^H^H esoteric solution using Unicode to include more information per character. Cláudio  managed to get 461 strokes with the following solution:




As a runner-up we have Luis Neves with 553 strokes, no chinese character was damaged, though:


function epg(n,e,m){x=new XMLHttpRequest();'GET','/[*+TO+'+(m*60)+']&wt=json&rows=99999');x.onreadystatechange=function(){if(x.readyState==4){r=JSON.parse(x.responseText);;h=[];k=0;for(i in d){u=d[i];w=u.StartTime;b=u.ChannelName;if((b.indexOf(n)>-1)){for(j in w){g={c:b,t:u.Title,d:u.Duration/60};g.s=w[j].replace(/T|Z/g,' ').trim();if(g.s.match('^'+e))h[k++]=g}}}h.sort(function(a,b){return(a.s<b.s?-1:1)});for(i in h){y=h[i];o(y.c+' at '+y.s+': '+y.t+'('+y.d+' minutes)\n')}}};x.send()}; 


Please use the comments in this post to discuss the solutions, as always we are open to discuss any detail or question. 


publicado por joaovelhote às 20:08

editado por jac em 10/11/2009 às 13:49
link do post | comentar
9 comentários:
De Carlos Rodrigues a 9 de Novembro de 2009 às 20:51
Aww, dammit! And there I was, running around with dynamic script tags and the like to avoit XHR and be able to do cross-domain calls... And there was an in-domain proxy all along.

Well, I learned some stuff anyway. :)

De Anónimo a 9 de Novembro de 2009 às 23:17
well, you could've tested.. All the challenges so far had some 'shortcuts' :)

The most important is that all you guys have fun and learn new stuff.

De chbm a 9 de Novembro de 2009 às 20:53
Pá, o 1o lugar foi para um gajo com 1262 bytes (deve ter um keyboard chines muuuiiiiitaaaa grande para serem 461 strokes) e o segundo para um gajo que usou um proxy escondido para dar a volta ao xss e um query não documentado na API. Bonito.

Tou suficientemente longe do 1o lugar para me poder queixar à vontade mas o 3o e 4o devem tar bem lixados :P

De Anónimo a 9 de Novembro de 2009 às 23:19
Stroke != keystroke. Stroke here is more like in golf.

The question explictly mentions:

The winner is the contestant that writes the javascript program
that successfully fetches the requested data and presents in the requested format in the
shortest possible number of *characters*.

Cláudio gets the epicwin. Anyone opposes?


De phantas a 9 de Novembro de 2009 às 21:37
Cláudio... dude... wow! Eu esperava que, vindo de ti, o truque fosse de génio, não de expert nos webservices ou JS mas... wow!

De celso a 9 de Novembro de 2009 às 23:31
It's worth mentioning that Cláudio gave a talk on Codebits 2007, precisely about Unicode Poetry

Now we know what he meant :)

De Vitor Caneco a 10 de Novembro de 2009 às 00:15
Briliant solution! I'm amazed with that single use :O

De gis a 10 de Novembro de 2009 às 00:15
My 550 solution:

function b(a){z=RegExp;w=i=h=0;;p=[];for(;i
[Error: Irreparable invalid markup ('<t.length;i++){r=t[i];j=r.channelname;k=r.starttime;for(;w<k.length;++w)if(z(v).test(j)&&z(y).test(k[w]))p.push({d:k[w],n:j,t:r.title,m:r.duration})}p.sort(function(e,r)e.d>') in entry. Owner must fix manually. Raw contents below.]

My 550 solution:

function b(a){z=RegExp;w=i=h=0;;p=[];for(;i<t.length;i++){r=t[i];j=r.ChannelName;k=r.StartTime;for(;w<k.length;++w)if(z(v).test(j)&&z(y).test(k[w]))p.push({d:k[w],n:j,t:r.Title,m:r.Duration})}p.sort(function(e,r)e.d>r.d);for(;h<t.length;)o(p[h].n+' at '+p[h].d.replace('T',' ').slice(0,19)+': '+p[h].t+'('+p[h++].m/60+' minutes)\n')}function epg(n,d,m){g=document;v=n;y=d;s=g.createElement("script");s.src='[* TO '+m*60+']&rows=99999&wt=json&json.wrf=b';window.b=b;g.body.appendChild(s)}

De ncorreia a 10 de Novembro de 2009 às 00:19
Ups... My comment up there.

Comentar post