Last active
April 19, 2021 12:39
-
-
Save lefuturiste/6a843e2412c9f006f8e3f1779245a368 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var input = []; | |
readline_object.on("line", (value) => { //Read input values | |
input.push(value); | |
}) | |
readline_object.on("close", ContestResponse); | |
function ContestResponse(){ | |
input = input.slice(1) | |
let cases = [] | |
let data = input.map(l => l.split('')) | |
for (var i = 0; i < data.length; i++) { | |
let line = data[i] | |
for (var j = 0; j < line.length; j++) { | |
if (line[j] !== 'X') continue | |
for (var t = i-1; t < i+2; t++) { | |
for (var k = j-1; k < j+2; k++) { | |
if (!(t < 0 || k < 0 || t >= data.length || k >= line.length || data[t][k] == 'X')) { | |
cases.push(t + ',' + k) | |
} | |
} | |
} | |
} | |
} | |
let newCases = Array.from(new Set(cases)) | |
console.log(newCases.length) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment