logoStarPatterns
Back to Patterns

Hollow Diamond Pattern

Pattern Result

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

Code Implementation

Explanation

The Hollow Diamond Pattern creates a diamond shape where only the border is visible. The pattern consists of two halves: the upper half where the distance between the two stars in each row increases, and the lower half where it decreases. For each row, we place stars only at specific positions to create the hollow effect. The algorithm uses nested loops to create the pattern: the outer loops handle the upper and lower halves, while the inner loops handle the spaces before the first star and between the two stars in each row.