Foundations Loops through pattern printing
23. Symmetric Void
Given an integer n, return the pattern below as a list of strings, one string per row, top row first.
********
*** ***
** **
* *
* *
** **
*** ***
********
That is the pattern for n = 4. Every row is 2n characters wide: a block of stars, a gap of spaces, and a
second block as big as the first. The top row has no gap. In each row below it, both blocks lose one star and
the gap grows by two spaces, until row n has a single star at each end.
The bottom half repeats the top half in reverse order, so the pattern has 2n rows and the two middle rows
are the same.
Example 1
Input: n = 3
****** ** ** * * * * ** ** ******
Explanation: The gaps in the top half are 0, 2 and 4 spaces, and the bottom half repeats them in reverse.
Example 2
Input: n = 1
** **
Example 3
Input: n = 4
******** *** *** ** ** * * * * ** ** *** *** ********
Check your understanding
Work out the answer for this input before you write any code.
Constraints
1 ≤ n ≤ 100
Clarifying questions
What you would ask an interviewer before writing any code.