THE CHALLENGETRIANGLES — Star patterns and pyramids.
For n = 5, print one after the other, with no blank line between them:
1) a growing right triangle of stars,
2) a shrinking right triangle,
3) a centred pyramid of stars,
4) an upside-down centred pyramid,
5) a right-aligned triangle,
6) a centred pyramid of digits whose line i starts with i (e.g. 3 4 5 4 3),
7) a centred palindrome pyramid of digits (1 ; 1 2 1 ; 1 2 3 2 1 ; ...).
Expected output:
*
**
***
****
*****
*****
****
***
**
*
*
***
*****
*******
*********
*********
*******
*****
***
*
*
**
***
****
*****
1
232
34543
4567654
567898765
1
121
12321
1234321
123454321
Artist's challenge: no pattern written by hand, at most 2 nested loops, and 40 lines at most for the whole thing.
Checks (verified automatically before your code runs):
- Print variables, not typed-in values: print(level) is accepted, print(5) is not.
- Loops may be nested at most 2 levels deep.
- Solve it in at most 40 lines of code (blank lines and comments are free).
Hint: "*" * k repeats a star k times, " " * k repeats k spaces.