dabidabidesh

bomb 40->100

Jun 22nd, 2020
303
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(sequence, sbnAndPower) {
  2.  
  3.   let sequenceOfNum = sequence;
  4.   let specialBombNumber = sbnAndPower[0];
  5.   let bombPower = sbnAndPower[1]
  6.  
  7.   let sum = 0;
  8.  
  9.   for (let i = 0; i < sequenceOfNum.length; i++) {
  10.     if (specialBombNumber == sequenceOfNum[i]) {
  11.       for (let j = i - bombPower; j <= i + bombPower; j++)
  12.         sequenceOfNum[j] = 0
  13.       // sequenceOfNum.splice((i - bombPower), bombPower);
  14.     }
  15.   }
  16.   /* for (let i = 0; i < sequenceOfNum.length; i++) {
  17.     if (specialBombNumber == sequenceOfNum[i]) {
  18.       sequenceOfNum.splice(i, bombPower + 1);
  19.     }
  20.   } */
  21.  
  22.   for (let el of sequenceOfNum) {
  23.     sum += el;
  24.   }
  25.   console.log(sum)
  26. }
RAW Paste Data