7 kyu

Aerial Firefighting

1,097 of 1,980coderors

Description:

You are an aerial firefighter (someone who drops water on fires from above in order to extinguish them) and your goal is to work out the minimum amount of bombs you need to drop in order to fully extinguish the fire (the fire department has budgeting concerns and you can't just be dropping tons of bombs, they need that money for the annual christmas party).

The given string is a 2D plane of random length consisting of two characters:

  • x representing fire
  • Y representing buildings.

Water that you drop cannot go through buildings and therefore individual sections of fire must be addressed separately.

Your water bombs can only extinguish contiguous sections of fire up to a width (parameter w).

You must return the minimum number of waterbombs it would take to extinguish the fire in the string.

Note: all inputs will be valid.

Examples

"xxYxx" and w = 3      -->  2 waterbombs needed
"xxYxx" and w = 1      -->  4
"xxxxYxYx" and w = 5   -->  3
"xxxxxYxYx" and w = 2  -->  5
Strings
Algorithms
Puzzles

Stats:

CreatedJun 24, 2019
PublishedJun 24, 2019
Warriors Trained3405
Total Skips42
Total Code Submissions8621
Total Times Completed1980
Python Completions1097
Ruby Completions102
Java Completions310
JavaScript Completions500
C Completions43
COBOL Completions8
TypeScript Completions32
Total Stars55
% of votes with a positive feedback rating92% of 390
Total "Very Satisfied" Votes340
Total "Somewhat Satisfied" Votes39
Total "Not Satisfied" Votes11
Total Rank Assessments17
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • coderors Avatar
  • SagePtr Avatar
  • anter69 Avatar
  • Blind4Basics Avatar
  • hobovsky Avatar
  • hakr14 Avatar
  • trashy_incel Avatar
  • Schulzkafer Avatar
  • akar-0 Avatar
Ad