nikolayneykov

Untitled

Feb 25th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(sequence, bomb) {
  2.   let index,
  3.       removeCount = bomb[1];
  4.      
  5.   while (true) {
  6.       index = sequence.indexOf(bomb[0]);
  7.       if (index != -1) {
  8.           sequence.splice(Math.max(0,index-removeCount), removeCount*2+1);
  9.       }
  10.       else {
  11.           break;
  12.       }
  13.   }
  14.   console.log(sequence.reduce((a, b) => a + b,0));
  15. }
Advertisement
Add Comment
Please, Sign In to add comment