Electrical Engineering Question:
Write a function to output a diamond shape according to the given (odd) input?

Answer:
Examples: Input is 5 Input is 7
<pre>
* *
*** ***
***** *****
*** *******
* *****
***
*
</pre>
### BEGIN PERL SNIPET ###
for ($i = 1; $i <= (($input * 2) - 1); $i += 2) {
if ($i <= $input) {
$stars = $i;
$spaces = ($input - $stars) / 2;
while ($spaces--) { print " "; }
while ($stars--) { print "*"; }
} else {
$spaces = ($i - $input) / 2;
$stars = $input - ($spaces * 2);
while ($spaces--) { print " "; }
while ($stars--) { print "*"; }
}
print "n";
}
### END PERL SNIPET ###
<pre>
* *
*** ***
***** *****
*** *******
* *****
***
*
</pre>
### BEGIN PERL SNIPET ###
for ($i = 1; $i <= (($input * 2) - 1); $i += 2) {
if ($i <= $input) {
$stars = $i;
$spaces = ($input - $stars) / 2;
while ($spaces--) { print " "; }
while ($stars--) { print "*"; }
} else {
$spaces = ($i - $input) / 2;
$stars = $input - ($spaces * 2);
while ($spaces--) { print " "; }
while ($stars--) { print "*"; }
}
print "n";
}
### END PERL SNIPET ###