A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-152.go
1packagemain
2
3import"fmt"
4
5funcmain(){
6s:=make([]int,2,4)
7s=append(s,1,2)
8fmt.Println(len(s),cap(s))
9}
Slices
Answer & explanation
Console output
4 4
Why
The slice begins with len 2 and cap 4, leaving room for exactly two more elements. The append fits within the existing backing array, so capacity stays at 4 and no reallocation occurs. The result is len 4, cap 4.