Star Printing - 10
Time limit1sMemory limit256 MB
Recursively draw a Sierpinski-like N x N star pattern where N is a power of 3, replicating the base 3x3 block with blank centers at every scale.
- Level
Medium5 of 10
- Topics
- Recursion, Matrix, Implementation
- Solved
- No attempts yet
Problem
Print a recursively defined star pattern. N is a power of 3, and the pattern of size N is an N x N square.
The base pattern of size 3 has a blank center cell and one star in every other cell.
***
* *
***
When N is greater than 3, place eight patterns of size N/3 in a 3 x 3 grid and leave only the center (N/3) x (N/3) area blank.
Input
The first line contains an integer N. There is an integer k such that N = 3^k and 1 <= k < 8.
Output
Print the star pattern of size N from the first line through the N-th line.