TopCoder problem "CantorDustEasy" used in Member Beta (Division II Level Three)



Problem Statement

    Cantor dust is a 2-dimensional fractal constructed in the following way. Initially the fractal is a black square. At each iteration, each square of the fractal is divided into a 3x3 subgrid of equal subsquares. Any black subsquares which belong to the middle row or to the middle column of a subgrid (or to both of them) are painted white.

You are given a String[] pattern which represents a rectangular pattern of black and white squares (represented by 'X' and '.' characters, respectively). Return the number of occurrences of this pattern in Cantor dust at iteration time. Overlapping occurrences are allowed.
 

Definition

    
Class:CantorDustEasy
Method:occurrencesNumber
Parameters:String[], int
Returns:int
Method signature:int occurrencesNumber(String[] pattern, int time)
(be sure your method is public)
    
 

Constraints

-time will be between 1 and 9, inclusive.
-pattern will contain between 1 and min(50, 3time) elements, inclusive.
-Each element of pattern will contain between 1 and min(50, 3time) characters, inclusive.
-All elements of pattern will contain the same number of characters.
-Each character in each element of pattern will be '.' or 'X'.
-pattern will contain at least one 'X' character.
 

Examples

0)
    
{".X",".."}
1
Returns: 1
1)
    
{"X"}
2
Returns: 16
2)
    
{"X...X"}
2
Returns: 4
3)
    
{"XX"}
9
Returns: 0
4)
    
{"X.X","...","X.."}
1
Returns: 0

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=10588

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=13935&pm=10588

Writer:

Nickolas

Testers:

Rustyoldman , timmac , StevieT , vexorian

Problem categories:

Simple Math, String Manipulation