# How would one attempt to create an algorithm for this?

• March 30th, 2013, 12:19 AM
RedHawkLuffy
How would one attempt to create an algorithm for this?
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?
• March 30th, 2013, 10:47 AM
Starstreak
Re: How would one attempt to create an algorithm for this?
Are they neighbours if they aren't directly above? I don't see the two compounds in the 1st example.
• March 30th, 2013, 01:51 PM
RedHawkLuffy
Re: How would one attempt to create an algorithm for this?
Quote:

Originally Posted by Starstreak
Are they neighbours if they aren't directly above? I don't see the two compounds in the 1st example.

They are neighbours if they aren't directly above. They can be either above below to the right or to the left..