Bacteria Colonies Bacteria Colonies

Biologists use bacteria to clone DNA for sequencing. These bacteria are then injected with the DNA that needs to be cloned and allowed to reproduce on a large plate. As these bacteria reproduce, they begin to form colonies. Only bacteria from healthy colonies will be used for sequencing. And here bioinformatics take the game and use technologies to automate these process.

Let's represent a plate snapshot as a pixel grid. You are given this grid as a binary matrix where 1 is bacteria cell and 0 is empty. Our goal is find the largest healthy bacteria colony which has grown uniformly. Bacteria can grow in four adjacent cells and bacteria colony is a set of bacterias that are connected. The healthy colonies look similar to the images represented below.

healthy healthy

Next, we can see that unhealthy colonies are marked with an orange color. Remember that a single cell is not a colony, so it cannot be counted as healthy colony.

example example

Your mission is to find the largest healthy colony and return the coordinates of the center cell. The top-left cell has coordinates (0, 0). If on the plate no a healthy colony, then return (0, 0) (or [0, 0]). If on the plate several largest colonies with the same size, then return any of them.

Input: A grid as a tuple of tuples with integers 1/0.

Output: The coordinates of the largest colony as a list or a tuple of two integers.

Example:


How it is used: This mission presents a mix of modeling, pattern recognition and data structure programing in addition to presenting some ideas for how to use it in bioinformatics. That is assuming of course that bioinformatics can be useful for classical biology.

Precondition:
5 ≤ len(grid) ≤ 20
all(5 ≤ len(row) ≤ 20 for row in grid)