Again inspired by a task for Programming 101 here's another challenge.
Input:
- A positive integer
n >= 3
. (has to be odd)
Output:
n
lines of asterisks, where the first line hasn
asterisks and every new line has two asterisks less than the line before. Until hitting 1 asterisk. From there every new line has two asterisks more than the line before until getting back ton
asterisks. Spaces or something like spaces have to used to align the asterisks so that it really will look like an hourglass.
General rules:
- Trailing newlines are allowed but do not have to be used.
- indentation is a must.
- This is code-golf, so shortest answer in bytes wins.
- Since the course is taught in C++, I'm eager to see solutions in C++.
Test case (n=5):
*****
***
*
***
*****