Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bombNums(sequence, bombNum) {
- /**
- * Write a function that receives two parameters: sequence of numbers and special bomb number
- with a certain power.
- Your task is to detonate every occurrence of the special bomb number and according to
- its power his neighbors from left and right. Detonations are performed from left to
- right and all detonated numbers disappear.
- The input contains two arrays of numbers. The first contains the initial sequence and the second contains the special bomb number and its power.
- The output is the sum of the remaining elements in the sequence.*/
- for (let i = 0; i < sequence.length; i++) {
- // if (sequence[i] === bombNum[0]) {
- let firstHalf = sequence
- .splice(0, bombNum[0])
- .sort((a, b) => b - a)
- let radius = bombNum[1];
- let explosionRadius=firstHalf.splice(0,radius)
- //}
- }
- let firstHalf = sequence
- .splice(0, bombNum[0])
- .sort((a, b) => b - a)
- let radius = bombNum[1];
- let explosionRadius=firstHalf.splice(0,radius)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement