amts below could also be a []float64 if required. All posted examples were with ints so that is what I used.
funcbeggars(amts[]int,beggarCountint)[]int{// defaults to slice of 0'ssums:=make([]int,beggarCount)foridx,amt:=rangeamts{beggarId:=idx%beggarCountsums[beggarId]+=amt}returnsums}
In Go!
amts below could also be a
[]float64
if required. All posted examples were with ints so that is what I used.Go Playground Example