func main() { ratings := []rating.Rating{ rating.New(1500.0, 50, 0.06), rating.New(1730.0, 200, 0.06), rating.New(1600.0, 10, 0.06), rating.New(1470.0, 250, 0.06), rating.New(1550.0, 45, 0.06), rating.New(1620.0, 80, 0.06), } inds := comb.Slice(ratings, 2, func(teamInd [][]int) float64 { team0 := make([]rating.Rating, 0, 3) for _, ind := range teamInd[0] { team0 = append(team0, ratings[ind]) } team1 := make([]rating.Rating, 0, 3) for _, ind := range teamInd[1] { team1 = append(team1, ratings[ind]) } //それぞれのチームのRatingを求めて、その勝率が50%に近ければ小さくなる2次関数 return math.Pow(rating.Average(team0).WinProb(rating.Average(team1))-0.5, 2) }) fmt.Println("-- team1 --") for _, ind := range inds[0] { fmt.Println(ratings[ind]) } fmt.Println("") fmt.Println("-- team2 --") for _, ind := range inds[1] { fmt.Println(ratings[ind]) } } feature/v0.6.0 いい感じにチーム分けしてくれる機能 $ go run . -- team1 -- 1500.0 (1400.0-1600.0 v=0.06) 1600.0 (1580.0-1620.0 v=0.06) 1620.0 (1460.0-1780.0 v=0.06) -- team2 -- 1730.0 (1330.0-2130.0 v=0.06) 1470.0 (970.0-1970.0 v=0.06) 1550.0 (1460.0-1640.0 v=0.06)