Triangle
Time limit1sMemory limit64 MB
Recursively subdivide a triangle into three corner triangles N-1 times and print the resulting ASCII fractal.
- Level
Easy3 of 10
- Topics
- Divide and conquer, Recursion, Simulation
- Solved
- No attempts yet
Problem
After thinking about the meaning of life for a long time, Adrijan decided to become a painter. Years spent on mathematics left their mark, so his first work is a single triangle. Mirko, the director of the gallery, refused to exhibit the picture, which surprised Adrijan a lot. He decided the problem is a lack of detail, so he will decorate the picture and try the galleries again.
Adrijan first picks a natural number and calls the triangle he drew at the start interesting.
He then repeats the following step times. In every interesting triangle he joins the midpoints of the three sides. That splits the triangle into four smaller triangles: three corner triangles and one central triangle. After the step, the interesting triangles are the three corner triangles it produced.
Write a program that draws his finished picture.
Input
The first and only line contains a natural number ().
Output
Print Adrijan's picture after the decoration.
- The only characters you may use in the output are
/,\,_, and.. - The picture has lines and every line fits in columns. A column that no triangle passes through holds a
.. - The smallest triangle takes two lines. It has two characters on each of its slanted sides and four characters on its horizontal side, so it is the same size as the picture for .
- Do not print the
.characters left at the end of a line. The last character of every line is therefore\. - Do not print blank lines.