This problem contains an image that can be viewed in the applet.
The domino effect is a chain reaction triggered by a single tile falling down. The tile falls into another tile, which falls into the next tile, and so on (see picture below).
Consider an infinite line of cells, some of which are occupied by tiles. We want to arrange the tiles in such a way that pushing the leftmost tile will lead to all the tiles falling down. A tile will push down a neighboring tile to its right if there are between 1 and 4 free cells, inclusive, between them.
You will be given a String cells. Concatenate the elements of cells to create a single string representing a segment of the infinite line. Tiles are represented by 'X' characters and free cells are represented by '.' characters. All cells to the left and right of the given segment are free. You may only move tiles into free cells. Return the minimal number of tiles you must move to achieve the desired domino effect.