Step 3 is not quite correct, I think; you'd need to get the ceiling of the width of the string divided by the width of the bomb. ("xxxxx", 2) is 3, since two bombs will take out 4 squares of fire and leave 1 more to mop up.
E: My JS solution
var waterbombs = (fireString, bombWidth) => {
const fires = fireString.split("Y");
let bombsNeeded = 0;
for (let fire in fires) {
bombsNeeded += Math.ceil(fire.length / bombWidth);
}
return bombsNeeded;
}
Step 3 is not quite correct, I think; you'd need to get the ceiling of the width of the string divided by the width of the bomb. ("xxxxx", 2) is 3, since two bombs will take out 4 squares of fire and leave 1 more to mop up.
E: My JS solution
yes, you are right brother