编辑代码

package main
import "fmt"
//func getAllBallSet(n uint, useJoker bool) []uint {

//}

// 颜色枚举
type Color int
const (
    ERed Color = iota
    EYellow
    EBlue
    EGreen
    
    ColorMax // 总颜色数
)

const BallIndexMax uint = 13 // 小球最大索引
const ColorCapacity uint = 16 // 颜色容量
const BoxCapacity uint = 64 // 套装容量
const RainbowBallIndex uint = 1 // 彩虹球索引

// 球
type Ball struct {
    Index uint
}

// 球桶
type BallBucket struct {
    Balls []*Ball
}

// 套装
type BallSuit struct {
    Buckets []*BallBucket
}

// 获取小球索引
func getBallIndex(num uint) uint {
    return (num - 1) % BallIndexMax
}

// 获取小球颜色
func getBallColor(num uint) Color {
    return Color(((num - 1) % BoxCapacity) / ColorCapacity)
}

// 是否是彩虹球
func isRainbowBall(num uint) bool {
    return getBallIndex(num) == RainbowBallIndex
}

// 获取最长序列的颜色
func getPickColor(input []uint) (Color, uint) {
    var colorNum [ColorMax]uint
    for _, v := range input {
        if !isRainbowBall(v) {
            colorNum[getBallColor(v)] ++
        }
    }

    numMax := colorNum[0]
    pickColor := ERed
    for i := pickColor+1; i < ColorMax; i++ {
        if n := colorNum[i]; n > numMax {
            numMax = n
            pickColor = i
        }
    } 

    return pickColor, numMax
}

// 小球排序
func sortBalls(input []uint) []uint {
    fmt.Println(getPickColor(input))

    return nil
}

func main () {
    //fmt.Println(getAllBallSet(2))
    //fmt.Println(sortBalls([]uint{3, 2, 1, 66, 65, 67, 17, 18, 10, 11, 19, 36, 53}))
    sortBalls([]uint{3, 2, 1, 66, 65, 67, 17, 18, 10, 11, 19, 36, 53})
}