Click anywhere on the board to launch your missiles. You have 8 moves to clear all 50 pieces off the board. Can you eliminate them all?
function l(){return Math.floor(Math.random()*a)}function k(b,h,k,l){++e,function m(b,h){if(b<0||b>=a||h<0||h>=a)--e||(--d,i());else{var n=t[f][0][f][h][f][b];n[g]=="o"?(n[g]="",--c,--e,i(),j(b,h)):(n[g]="b",setTimeout(function(){n[g]="",k!=0?m(b+k,h):m(b,h+l)},25))}}(b,h)}function j(a,b){k(a,b,-1,0),k(a,b,1,0),k(a,b,0,-1),k(a,b,0,1)}function i(){u.innerHTML=!d&&c?"You Lose!":c?"Moves: "+d+" — Pieces: "+c:"You Win!"}var a=50,c=50,d=8,e=0,f="children",g="className",h="parentNode";b.innerHTML='<style>body{background:#111;margin:10px;}h2{color:#EEE}table{border-collapse:collapse;border-spacing:0}td{border:1px solid #333;width:8px;height:8px}td:hover{background:#444}.b{background:#EEE}.o{background:#F80}</style><h2 id="u">Click Any Square To Play</h2><table id="t">'+Array(a+1).join("<tr>"+Array(a+1).join("<td></td>")+"</tr>")+"</table>",t.onclick=function(a){var b=a.target;d&&c&&!e&&j(b.cellIndex,b[h].rowIndex)};for(var m=0;m<c;++m)for(;;){var n=t[f][0][f][l()][f][l()];if(n[g]!="o"){n[g]="o";break}}
ZnVuY3Rpb24gbCgpe3JldHVybiBNYXRoLmZsb29yKE1hdGgucmFuZG9tKCkqYSl9ZnVuY3Rpb24gayhiLGgsayxsKXsrK2UsZnVuY3Rpb24gbShiLGgpe2lmKGI8MHx8Yj49YXx8aDwwfHxoPj1hKS0tZXx8KC0tZCxpKCkpO2Vsc2V7dmFyIG49dFtmXVswXVtmXVtoXVtmXVtiXTtuW2ddPT0ibyI/KG5bZ109IiIsLS1jLC0tZSxpKCksaihiLGgpKToobltnXT0iYiIsc2V0VGltZW91dChmdW5jdGlvbigpe25bZ109IiIsayE9MD9tKGIrayxoKTptKGIsaCtsKX0sMjUpKX19KGIsaCl9ZnVuY3Rpb24gaihhLGIpe2soYSxiLC0xLDApLGsoYSxiLDEsMCksayhhLGIsMCwtMSksayhhLGIsMCwxKX1mdW5jdGlvbiBpKCl7dS5pbm5lckhUTUw9IWQmJmM/IllvdSBMb3NlISI6Yz8iTW92ZXM6ICIrZCsiICZtZGFzaDsgUGllY2VzOiAiK2M6IllvdSBXaW4hIn12YXIgYT01MCxjPTUwLGQ9OCxlPTAsZj0iY2hpbGRyZW4iLGc9ImNsYXNzTmFtZSIsaD0icGFyZW50Tm9kZSI7Yi5pbm5lckhUTUw9JzxzdHlsZT5ib2R5e2JhY2tncm91bmQ6IzExMTttYXJnaW46MTBweDt9aDJ7Y29sb3I6I0VFRX10YWJsZXtib3JkZXItY29sbGFwc2U6Y29sbGFwc2U7Ym9yZGVyLXNwYWNpbmc6MH10ZHtib3JkZXI6MXB4IHNvbGlkICMzMzM7d2lkdGg6OHB4O2hlaWdodDo4cHh9dGQ6aG92ZXJ7YmFja2dyb3VuZDojNDQ0fS5ie2JhY2tncm91bmQ6I0VFRX0ub3tiYWNrZ3JvdW5kOiNGODB9PC9zdHlsZT48aDIgaWQ9InUiPkNsaWNrIEFueSBTcXVhcmUgVG8gUGxheTwvaDI+PHRhYmxlIGlkPSJ0Ij4nK0FycmF5KGErMSkuam9pbigiPHRyPiIrQXJyYXkoYSsxKS5qb2luKCI8dGQ+PC90ZD4iKSsiPC90cj4iKSsiPC90YWJsZT4iLHQub25jbGljaz1mdW5jdGlvbihhKXt2YXIgYj1hLnRhcmdldDtkJiZjJiYhZSYmaihiLmNlbGxJbmRleCxiW2hdLnJvd0luZGV4KX07Zm9yKHZhciBtPTA7bTxjOysrbSlmb3IoOzspe3ZhciBuPXRbZl1bMF1bZl1bbCgpXVtmXVtsKCldO2lmKG5bZ10hPSJvIil7bltnXT0ibyI7YnJlYWt9fQ==
var size = 50,
pieces = 50,
moves = 8,
bullets = 0,
children = 'children',
className = 'className',
parentNode = 'parentNode';
function updateStatus() {
u.innerHTML = (
!moves && pieces ? 'You Lose!' : (
!pieces ? 'You Win!' :
'Moves: ' + moves + ' — Pieces: ' + pieces));
}
function fireBullets(x, y) {
fireBullet(x, y, -1, 0);
fireBullet(x, y, 1, 0);
fireBullet(x, y, 0, -1);
fireBullet(x, y, 0, 1);
}
function fireBullet(x, y, dx, dy) {
++bullets;
(function moveBullet(x, y) {
if (x < 0 || x >= size || y < 0 || y >= size) {
if (!--bullets) {
--moves;
updateStatus();
}
} else {
var cell = t[children][0][children][y][children][x];
if (cell[className] == 'o') {
cell[className] = '';
--pieces;
--bullets;
updateStatus();
fireBullets(x, y);
} else {
cell[className] = 'b';
setTimeout(function() {
cell[className] = '';
if (dx != 0) {
moveBullet(x + dx, y);
} else {
moveBullet(x, y + dy);
}
}, 25);
}
}
}(x, y));
}
function random() {
return Math.floor(Math.random() * size);
}
b.innerHTML =
'<style>' +
'body{background:#111;margin:10px;}' +
'h2{color:#EEE}' +
'table{border-collapse:collapse;border-spacing:0}' +
'td{border:1px solid #333;width:8px;height:8px}' +
'td:hover{background:#444}' +
'.b{background:#EEE}' +
'.o{background:#F80}' +
'</style>' +
'<h2 id="u">Click Any Square To Play</h2>' +
'<table id="t">' +
Array(size + 1).join('<tr>' + Array(size + 1).join('<td></td>') + '</tr>') +
'</table>';
t.onclick = function(event) {
var cell = event.target;
if (moves && pieces && !bullets) {
fireBullets(cell.cellIndex, cell[parentNode].rowIndex);
}
}
for (var i = 0; i < pieces; ++i) {
for (;;) {
var cell = t[children][0][children][random()][children][random()];
if (cell[className] != 'o') {
cell[className] = 'o';
break;
}
}
}