Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

sapin.gno

0.53 Kb · 26 lines
 1package sapin
 2
 3import "strings"
 4
 5func Sapin(size int) string {
 6	if size < 1 {
 7		return ""
 8	}
 9	var b strings.Builder
10	for floor := 0; floor < size; floor++ {
11		for j := 0; j < floor+4; j++ {
12			spaces := size*2 - (floor-1)*2 - j + size - 2
13			bodies := j*2 + 1 + floor*4
14			b.WriteString(strings.Repeat(" ", spaces))
15			b.WriteString(strings.Repeat("*", bodies))
16			b.WriteString("\n")
17		}
18	}
19
20	for i := 0; i < size; i++ {
21		spaces := (size-1)*3 + 2
22		b.WriteString(strings.Repeat(" ", spaces))
23		b.WriteString("|||\n")
24	}
25	return b.String()
26}