Aerial Firefighting
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 fireY
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
Stats:
Created | Jun 24, 2019 |
Published | Jun 24, 2019 |
Warriors Trained | 3405 |
Total Skips | 42 |
Total Code Submissions | 8621 |
Total Times Completed | 1980 |
Python Completions | 1097 |
Ruby Completions | 102 |
Java Completions | 310 |
JavaScript Completions | 500 |
C Completions | 43 |
COBOL Completions | 8 |
TypeScript Completions | 32 |
Total Stars | 55 |
% of votes with a positive feedback rating | 92% of 390 |
Total "Very Satisfied" Votes | 340 |
Total "Somewhat Satisfied" Votes | 39 |
Total "Not Satisfied" Votes | 11 |
Total Rank Assessments | 17 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |