A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-20.go
1packagemain
2
3import"fmt"
4
5funcmain(){
6s:=[]int{1,2,3,4,5}
7t:=s[1:3:4]
8fmt.Println(len(t),cap(t))
9}
Slices
Answer & explanation
Console output
2 3
Why
A full-slice expression s[low:high:max] yields len high-low and cap max-low. Here len is 3-1=2 and cap is 4-1=3. The max index lets you bound capacity below the backing array’s real end, which is how you protect downstream elements from append.