A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-14.go
1packagemain
2
3import"fmt"
4
5funcmain(){
6s:=[]int{1,2,3,4}
7a:=s[0:2]
8b:=s[1:3]
9a[1]=9
10fmt.Println(b)
11}
Slices
Answer & explanation
Console output
[9 3]
Why
Overlapping sub-slices share the backing array, so a[1] and b[0] both refer to s[1]. Writing 9 through a is immediately visible through b, which prints [9 3]. This overlap aliasing is a frequent source of surprising mutations.