func missingRolls(rolls []int, mean int, n int) []int { m := len(rolls) sum := mean * (m + n) curSum := 0 for _, roll := range rolls { curSum += roll } subSum := sum - curSum if subSum < n || subSum > 6*n { return []int{} } ans := make([]int, n) per := subSum / n div := subSum - per*n for i := 0; i < n; i++ { ans[i] = per + min(1, div) div = max(0, div-1) } return ans }