recursive matrix traversal
i am trying to write a function to find the number of objects in a matrix of characters, where an object is defined as an group of adjacent 'X's (not diagonal) not separated by a '0'
ex)
0XXX0XXXXXX
XX0XXX0XXX0
X0000000000
000X00000XX
0000000000X
has 3 objects: one at the top because all of them are connected, the three at the bottom right, and the single X in the middle.
I can write it iteratively, but it is complicated and i would like to have a recursive function that is easier to see.
i would imagine thaat the function would have four recursive calls in it to check left, up, right, and down. any help is appreciated. Thanks!