logoStarPatterns
Back to Patterns

Hollow Rhombus Pattern

Pattern Result

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

Code Implementation

Explanation

The Hollow Rhombus Pattern creates a rhombus shape where only the border is visible. The pattern is created by combining a hollow square with a shifting effect. Each row of the rhombus starts with a decreasing number of spaces as the row number increases, creating the slanted left edge. The hollow effect is achieved by placing stars only at the border positions (first/last row or first/last column) and spaces at all other positions. The outer loop iterates through each row, and the inner loops handle the spaces before the rhombus and the stars and spaces that form the rhombus itself.