This commit is contained in:
2022-12-11 14:57:54 +01:00
parent 5b8b07a37e
commit c98367aca0
3 changed files with 361 additions and 0 deletions

28
day11/ex2/main.go Normal file
View File

@@ -0,0 +1,28 @@
package main
import (
"aoc2022/day11/common"
"bufio"
"fmt"
"os"
"sort"
)
func main() {
monkeys := common.Parse(*bufio.NewScanner(os.Stdin), false)
for i := 0; i < 10000; i++ {
for j := 0; j < len(monkeys); j++ {
monkey := &monkeys[j]
monkey.NextRound()
}
}
nInspections := make([]int, len(monkeys))
for i := 0; i < len(monkeys); i++ {
nInspections[i] = monkeys[i].GetNumberOfInspections()
}
sort.Ints(nInspections)
fmt.Println(nInspections[len(nInspections)-1] * nInspections[len(nInspections)-2])
}