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) | |
| |
1) | |
| |
2) | |
| |
3) | |
| |
4) | |
| |