package main import ( "aoc2022/day13/common" "bufio" "fmt" "os" "sort" ) func main() { packets := common.ParsePackets(*bufio.NewScanner(os.Stdin), []string{"[[2]]", "[[6]]"}) sort.Slice(packets, func(i int, j int) bool { return packets[i].Compare(packets[j]) < 0 }) result := 1 for i := 0; i < len(packets); i++ { if packets[i].IsSeparator() { result *= (i+1) } } fmt.Println(result) }