LearnPy Hub
← Arena
IntermediateRating 1400

Islands (Diagonals Count)

Count the islands of # in the grid. Cells that touch, even diagonally, belong to the same island.

Input

r and c, then r rows of # and .

Output

One integer.

Sample 1

Input
3 4
#..#
.#..
...#
Output
3

Sample 2

Input
1 1
.
Output
0
solution.py
Output appears here
Islands (Diagonals Count) · Python Arena problem · LearnPy Hub