Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(sequence, bomb) {
- let index,
- removeCount = bomb[1];
- while (true) {
- index = sequence.indexOf(bomb[0]);
- if (index != -1) {
- sequence.splice(Math.max(0,index-removeCount), removeCount*2+1);
- }
- else {
- break;
- }
- }
- console.log(sequence.reduce((a, b) => a + b,0));
- }
Advertisement
Add Comment
Please, Sign In to add comment