DEV Community

Discussion on: Daily Challenge #274 - Aerial Firefighting

Collapse
 
rafaacioly profile image
Rafael Acioly

Python solution 🐍

import re

def bombs(situation: str, fire_width: int) -> int:
  regex = "x{1,%d}" % fire_width
  matches = re.findall(re.compile(regex), situation)

  return len(matches)
Collapse
 
tbroyer profile image
Thomas Broyer

Regexp was my first thought too