Arxero

Untitled

Jan 30th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. function filter(input) {
  2.     let n = Number(input.pop());
  3.     let matrix = input
  4.         .map(x => Array.from(x))
  5.         .map(x => x.filter(x => x != ' '))
  6.         .map(x => x.map(Number));
  7.  
  8.     for (let row = 0; row < matrix.length; row++) {
  9.         for (let col = 0; col < matrix[row].length; col++) {
  10.             let a = matrix[row][col];
  11.             for (let i = 1; i < n; i++) {
  12.                 let b = matrix[row][i + col];
  13.                 if (a == b) {
  14.                     matrix[row][i + col] = ' ';
  15.                     if (n - i == 1) {
  16.                         matrix[row][col] = ' ';
  17.                     }
  18.                 }
  19.             }
  20.         }
  21.     }
  22.  
  23.  
  24.  
  25.     //console.log([...matrix].join('\n'));
  26. }
  27. filter([
  28.     '3 3 3 2 5 9 9 9 9 1 2',
  29.     '1 1 1 1 1 2 5 8 1 1 7',
  30.     '7 7 1 2 3 5 7 4 4 1 2',
  31.     '2'
  32. ]);
Add Comment
Please, Sign In to add comment