Say you have a grid with a compound. (size differs)
Let's just say our compound is HOH.
***OHH***
*H******H
****HH***
****O****
Clearly in this grid there are two HOH compounds considering the explanation below.
In this grid how would create an algorithm to find the combinations of HOH compound.
Combinations exist if they are neighbors in the grid, above, below, to the left or to the right. Atoms that are only neighbors diagonally do not count.
So these are examples of compounds.
**HH**
**O***
**H***
**O***
**H***
This is not a compound.
*HH***
***O**
How would you attempt to do this?