package thirteen

import "math"

func GetCardsGrade(cards [13]int, allGroup map[int]*Group) int {
	m := math.MinInt
	for k := range allGroup {
		sum := 0
		if k >= 1000000 {
			return k
		}
		a := k / 10000
		b := (k - a*10000) / 100
		c := k - a*10000 - b*100
		for _, m := range []int{a, b, c} {
			if m > PokersTypeZero && m <= PokersTypeOne {
				sum += PokersTypeOne - m
			}
		}
		if m <= sum {
			m = sum
		}
	}

	return m
}
