Back
Close
  • 67

Learning Opportunities

This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.

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

A higher resolution is required to access the IDE