Waclaw
Waclaw Sierpinski was a Polish mathematician who liked playing with triangles. One day he started drawing triangles using the following procedure:
· Draw an equilateral triangle T.
· Connect the midpoints of its sides with line segments. Denote the new equilateral triangles with T1, T2, T3 and T4, as illustrated in the first figure below.
· Repeat the previous step on triangles T1, T2 and T3. New triangles are: T11, T12, T13, T14, T21, T22, T23, T24, T31, T32, T33, T34.
· Continue the procedure on all triangles ending in 1, 2 or 3. The resulting fractal is called the Sierpinski triangle.
We say that a triangle A is leaning on the triangle B if B does not contain A and if one entire side of A is a part of some side of B. For example, the triangle T23 is leaning on T24 and T4, but not on T2 or T32. Note that A leaning on B does not imply that B is leaning on A. Write a program that, given a triangle A, which is a part of the Sierpinski triangle, finds all triangles B such that A is leaning on B.
Input
T4
Output
T1
T2
T3
Input
T11
Output
T14
Input
T312
Output
T4
T314
T34
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.