A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-170.go
1packagemain
2
3import"fmt"
4
5funcmain(){
6s:=[]int{1,2,3,4}
7t:=s[1:2:2]
8fmt.Println(len(t),cap(t))
9}
Slices
Answer & explanation
Console output
1 1
Why
The full-slice expression s[1:2:2] sets len to high-low=1 and cap to max-low=1. By making cap equal len, any later append must reallocate rather than touch s’s remaining elements. This is the three-index idiom for sealing off a slice from its parent.