It looks like the Bash/Shell brush isn't included (so I added it):
$ sudo rm -rf /
Some of my horriblest JavaScript from a 5k challenge
var r=true;function st(sz){sz--;
var sc=[[0,0],[1,0],[1,2],[3,1],[4,0],[5,0],[6,0]];//edit this for a new pattern
sc=cp(sc,sz);document.getElementById('tt').innerHTML=mt(sc,sz,sz,sz,sz);rl(sc,(sz),0);}
function h(){if(r){r=false;document.getElementById('tb').disabled=true;document.getElementById('tb').value="Reload page to resart";}}
function cp(p,sz){sz=sz/2;var np=[];var lx=0;var bx=0;var ly=0;var by=0;for(i=0;i<p.length;i++){var px=p[i][0];var py=p[i][1];lx=Math.min(lx,px);bx=Math.max(bx,px);ly=Math.min(ly,py);by=Math.max(by,py);}var dx=Math.round(sz-(bx-lx+1)/2);var dy=Math.round(sz-(by-ly+1)/2);for(i=0;i<p.length;i++){np.push([p[i][0]+dx,p[i][1]+dy]);}return np;}
function rl(cs,sz,it){document.getElementById('it').innerHTML="Iteration:"+it+" Population:"+cs.length;it++;t=setTimeout("this.rc()",0);this.rc=function(){if(r){rl(uc(cs,sz),sz,it);}}}
function mt(cs,sz,x,y){var c=cc(cs,sz,x,y);var sr='<tr>';var er='</tr>';if(x==sz&&y==sz){return "<table>"+sr+c+mt(cs,sz,x-1,y);}else{if(x==sz){return sr+c+mt(cs,sz,x-1,y);}else if(x>0){return c+mt(cs,sz,x-1,y);}else{if(y > 0){return c+er+mt(cs,sz,sz,y-1);}else{return c+er+"</table>";}}}}
function cc(cs,sz,x,y){var sd='<td id="X'+x+'Y'+y+'" class="';var ed='"></td>';if(ii(x,y,cs)){return sd+'l'+ed;}else{return sd+'d'+ed;}}
function ii(x,y,cs){var r=false;if(cs.length >0){for(k=0;k<cs.length;k++){if(cs[k][0]==x&&cs[k][1]==y){r=true;}}}return r;}
function cl(ls,cs){var n=0;while(ls.length >0){var co=ls.pop();if(ii(co[0],co[1],cs)){n++;}}return n;}
function nb(x,y,sz){var ls=[];for(i=-1;i<2;i++){for(j=-1;j<2;j++){var nx=ib(x+i,sz);var ny=ib(y+j,sz);if((x!=nx)||(y!=ny)){ls.push([nx,ny]);}}}return ls;}
function ib(r,sz){if(r<0){r=sz;}if(r>sz){r=0;}return r;}
function uc(cs,sz){var nc=[];var ac=[];for(l=0;l<cs.length;l++){var ls=nb(cs[l][0],cs[l][1],sz);ls.push(cs[l]);while(ls.length >0){var co=ls.pop();if(!ii(co[0],co[1],ac)){ac.push(co);}}}while(ac.length >0){var co=ac.pop(0);var m=cl(nb(co[0],co[1],sz),cs);var c='d';if(m==2&&ii(co[0],co[1],cs)){nc.push(co);c='l';}else if(m==3){nc.push(co);c='l';}document.getElementById('X'+co[0]+'Y'+co[1]).className=c;}return nc;}
No comments:
Post a Comment