Back
Close

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.
To stop the fire, you need to remove two layers of trees.

# Tree
= Cut-down tree
o Empty space
* Fire

If there are no trees that can be saved by blocking the fire, output: 'JUST RUN'.
if there is no fire, output: 'RELAX'.

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
or 'JUST RUN'
or 'RELAX'
Constraints
Example
Input
######
######
######
######
######
******
Output
12

Tags
LoopsStringsListsArraysif/else

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