logoStarPatterns
Back to Patterns

Hollow Hourglass Pattern

Pattern Result

*********
* *
* *
* *
*
* *
* *
* *
*********

Code Implementation

Explanation

The Hollow Hourglass Pattern creates a shape that resembles an hourglass where only the border is visible, except for the first and last rows which are filled with stars. The pattern consists of two halves: the upper half (an inverted hollow triangle) and the lower half (a hollow triangle). For each row except the first, middle, and last, we place stars only at specific positions to create the hollow effect. The algorithm uses nested loops to create the pattern: separate outer loops handle the upper and lower halves, while the inner loops handle the spaces and stars in each row.