strings.Fields
helpful.) WordCount("test test")
→
map[string]int{ "test": 2 }
centeredAverage
function that computes the
average of a list of numbers, but removes the largest and smallest
values. centeredAverage([]float64{1, 2, 3, 4, 100})
→
3
canBalance([]int{1, 1, 1, 2, 1})
→ true
canBalance([]int{2, 1, 1, 2, 1})
→ false
canBalance([]int{10, 10})
→ true
countClumps([]int{1, 2, 2, 3, 4, 4})
→ 2
countClumps([]int{1, 1, 2, 1, 1})
→ 2
countClumps([]int{1, 1, 1, 1, 1})
→ 1
*
and &
new
func square(x *float64) { *x = *x * *x } func main() { x := 1.5 square(&x) }
x := 1; y := 2;
swap(&x, &y)
should
give you x==2
and y==1
).rotate(&x, &y, &z)
, with
x=1
, y=2
, y=3
, yields
x=2
, y=3
, z=1
.