We have to create a shape that resembles a diamond using stars. There is an assumption involved with this problem, that the input number "n" will always be odd.
First stars increase in number and spaces decrease;
Then after a point, there is in increase in spacing and decrease in stars in a line.
So, keeping all the observations regarding the pattern in mind, we notice that the amount of spaces in first line is half the integer division of the input value "n".
Implementing the concept in programming:
The output for the above code will be as:
Which are the same values of spaces and stars respectively, for which we ran the line-by-line design analysis above.
Now we just replace these numbers in output, by placing actual spaces and stars equal to these numbers, using simple loops; as we have been doing in all the patterns leading upto now.
Final Solution Program: