Loading...
Loading...
Loading...
A map has land cells (1) and water cells (0). A patch is a group of land cells joined by shared sides. A patch is enclosed if none of its cells lies on the edge of the map. Print the number of enclosed patches.
Example 1
Input
4 4 0000 0110 0110 0001
Output
1
Example 2
Input
2 3 111 111
Output
0
Try the problem first. Open one hint at a time.
Search every patch and note whether any cell touches the edge.
Count the patches where none does.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor