FireControl
Statement
Goal
You need to cut down some trees in a forest fire to stop the fire from spreading. Write code to help you determine the least amount of trees to cut to contain the fire.The size of the forest is a 6 by 6 grid.
Fire can spread sideways as well as diagonally, and continue to spread until it is stopped.
To stop the fire, it must be surrounded by two layers of non-flammable space, consisting of either cut-down trees or empty space.
If there are no trees that can be saved by blocking the fire, output:
if there is no fire, output:
Example
Input:
*#####
######
######
######
######
######
To be cut:
*12###
345###
678###
######
######
######
Output:
8
Input
6 lines of 6 characters for the 6x6 grid of the forest.
Output
The number of trees to be cut
orJUST RUN
orRELAX
or
or
Constraints
Example
Input
###### ###### ###### ###### ###### ******
Output
12
Tags
Loops, Strings, Lists, Arrays, Conditions
Difficulty
Easy
Test cases
Side-Fire Test
Input
######
######
######
######
######
******
Output
12
Side-Fire2 Validator
Input
#####*
#####*
#####*
#####*
#####*
#####*
Output
12
Who cut those? Test
Input
######
######
######
######
======
******
Output
6
Who cut those?2 Validator
Input
######
######
######
######
###===
###=**
Output
6
Should I plant some trees? Test
Input
======
======
==*===
======
======
======
Output
JUST RUN
Should I plant some trees?2 Validator
Input
======
======
=****=
======
======
======
Output
JUST RUN
Random Centre Test
Input
######
######
######
##*###
######
######
Output
24
Random Centre2 Validator
Input
######
######
###*##
######
######
######
Output
24
Trees??? Test
Input
******
oooooo
oooooo
oooooo
oooooo
oooooo
Output
JUST RUN
Trees??? 2 Validator
Input
******
oooooo
******
oooooo
******
oooooo
Output
JUST RUN
Just RUN Test
Input
******
#*****
******
******
******
*****#
Output
JUST RUN
Just RUN2 Validator
Input
***#**
******
***#**
******
******
*****#
Output
JUST RUN
who plant THIS??? Test
Input
#o##o#
#o*#o#
*o##o*
#o##o#
#o**o#
#o##o#
Output
JUST RUN
who plant THIS???2 Validator
Input
#o#*o#
#o*#o#
*o##*#
#o#*o#
#o*#o#
#o##o#
Output
JUST RUN
False alarm Test
Input
======
=###==
======
=###==
==oo==
======
Output
RELAX
False alarm2 Validator
Input
======
oooooo
======
======
======
======
Output
RELAX
Solution language
Solution
Stub generator input