aoc2023/day-7/one.go
2023-12-07 23:13:05 +00:00

32 lines
633 B
Go

package main
import log "github.com/sirupsen/logrus"
const (
highcard = iota // 0
onepair = iota // 1
twopair = iota // 2
threeofakind = iota // 3
fullhouse = iota // 4
fourofakind = iota // 5
fiveofakind = iota // 6
numKinds = iota
)
// one returns the sum of products of hand values by bids
func one(lines []string) (int, error) {
parselines(lines)
strength := []rune{'A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2'}
log.Debug("strength: ", strength)
sortByKindAndStrength(strength)
sum := 0
for i, hand := range hands {
sum += (i + 1) * hand.bid
}
return sum, nil
}