Advertisement
fbinnzhivko

Untitled

Jan 18th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function az(input) {
  2.     let arrOfNums = input.map(row=>row.split(' ').map(Number));
  3.     let matrix1 = arrOfNums.shift();
  4.  
  5.     let result = parseInt(1);
  6.  
  7.     if (arrOfNums[0] % 2 === 0) {
  8.         result = 0;
  9.     }
  10.  
  11.     for (let i = 0; i < input[0]; i += 1) {
  12.         if (arrOfNums[i] % 2 == 0) {
  13.             result += parseInt(arrOfNums[i]);
  14.             i += 1;
  15.         }
  16.         else {
  17.             result *= parseInt(arrOfNums[i]);
  18.         }
  19.         if (result > 1024) {
  20.             result %= 1024;
  21.         }
  22.     }
  23.     console.log(result);
  24. }
  25. az(['10', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0']);
  26. az(['9', '9', '9', '9', '9', '9', '9', '9', '9', '9']);
  27. az(['4', '2', '4', '6', '8']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement