LearnPy Hub
← Recursion & Lambda problems
Hard

Size of a Region

Read a grid of # and . and a starting cell (row and column from 0). Write a recursive fill that counts the # cells connected to the start (up, down, left, right). Print 0 if the start is ..

Input

r c; r rows; then 'row col'.

Output

One integer.

Sample 1

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

Sample 2

Input
3 4
##..
#..#
..##
2 3
Output
3
solution.py
Output appears here
Size of a Region · Python practice problem · LearnPy Hub