I'm wondering what the best method would be for me to approach a problem where I need to find adjacent (horizontal, vertical, diagonal) X's in a grid which is provided.
I wanted to know what the recursive way, and the nonrecursive way would be. I tried a recursive method of checking each column, and then iterating rows - that gives me X's in one direction - should I write seperate recursive functions for the other directions?
Example grid:
XXX0X 0000X 00X00 XXXX0 0000X
output should be :
- (0,0),(1,0),(2,0)
- (4,0),(4,1)
- (2,2),(0,3),(1,3),(2,3)(3,3)