Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
742 B
3
Indexable
Never
var matrix = [
    [0,1,0,0,0,0],
    [0,0,0,0,0,1],
    [0,1,0,0,0,0],
    [0,1,0,0,0,0],
    [0,0,0,0,1,0],
    [1,0,0,0,0,0]
]


var boomHint = [];

var countBoom = function() {
    for(var i = 0; i < 6; i++) {
        for(var j = 0; j < 6; j++) {
            if(matrix[i][j]) boomHint[i][j] = null;
            else {
                var total = 0;
                for(var a = -1; a < 1; a++) {
                    for(var b = -1; b < 1; b++) {
                        var test = matrix[i+a][j+b];
                        if(test) {
                            total++;
                        }
                    }
                }
                boomHint[i][j]=total;
            }
        }
    }
}