Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let matrix = input.map(row => row.toLowerCase().split(""));
- let resultMatrix = input.map(row => row.split(""));
- for (let row = 0; row < matrix.length - 2; row++) {
- for (let col = 0; col < matrix[row].length - 2; col++) {
- let el = matrix[row][col];
- if (el == matrix[row][col + 2] &&
- el == matrix[row + 1][col + 1] &&
- el == matrix[row + 2][col] &&
- el == matrix[row + 2][col + 2]) {
- resultMatrix[row][col]="";
- resultMatrix[row][col + 2]="";
- resultMatrix[row + 1][col + 1]="";
- resultMatrix[row + 2][col]="";
- resultMatrix[row + 2][col + 2]="";
- }
- }
- }
- for (let r of resultMatrix) {
- console.log(r.join(""));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement