A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-138.go
1packagemain
2
3import"fmt"
4
5funcmain(){
6s:=[]int{1,2,3,4}
7t:=s[1:3]
8t=t[:cap(t)]
9fmt.Println(t)
10}
Slices
Answer & explanation
Console output
[2 3 4]
Why
t := s[1:3] has len 2 but cap 3, because capacity reaches the end of s. Re-slicing with t[:cap(t)] grows the length back to 3, exposing the element that was within capacity but beyond the previous length. The recovered window is s[1:4] = [2 3 4].