Canadian Computing Competition: 1999 Stage 2, Day 1, Problem 3
You may recall that in stage 1 of the CCC you were asked to calculate a region of a fractal obtained by starting with a square, dividing it into
* * * * * * * * *
* * * * * * * * *
* * * * * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * * * * *
* * * * * * * * *
* * * * * * * * *
This operation was then repeated for each of the
If we choose a different operation we get a different fractal; for example, we may clear the upper-left and lower-right corners instead of the middle. Or we may divide the square into a different number of sub-squares.
For this problem we will specify the fractal operation as an .
(period) indicates that the corresponding sub-square becomes completely empty. The character !
(exclamation mark) indicates that the corresponding sub-square becomes full and is not subject to further fractal operations. The character ?
(question mark) indicates that the corresponding sub-square remains full and is subject to further fractal operations.
The fractal above would be represented by the
???
?.?
???
Four iterations of the fractal denoted by the
.!
?.
would be:
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * *
* * * *
* * * *
* * * *
* * * *
* * * *
* * * *
* * * *
* * * *
* * * *
* * * *
* * * *
* *
* *
* *
* *
* * * *
* * * *
* * * *
* * * *
* *
* *
*
*
Your mission, should you choose to accept it (like you have any choice!) is to print out a region of an arbitrary fractal specified by an
Input Specification
The first line contains a positive integer .
, !
, ?
, defining the fractal operation to be iterated. The remainder of the input consists of queries for regions of the fractal. Each query consists of two lines: the first line gives -1
.
Output Specification
Print the region of the fractal, one line per row. Print the top row first and the bottom row last. Output a *
for a filled-in portion and a space for a blank section. To make the output appear square, leave a single horizontal space between elements. Leave a blank line in the output after each region.
Sample Input
2
.!
?.
3
2 8 1 7
-1
Sample Output
* * *
* * *
* * *
* * *
* *
* *
*
Comments