DEV Community

Discussion on: Daily Challenge #274 - Aerial Firefighting

Collapse
 
bherrero profile image
Borja Herrero • Edited

JS solution with just a regular expression:

function waterbomb(plane, width) {
    const pattern = `x{1,${width}}Y*`;
    const regex = new RegExp(pattern, 'g');

    return plane.match(regex).length;
}