Day 11
This commit is contained in:
28
day11/ex1/main.go
Normal file
28
day11/ex1/main.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"aoc2022/day11/common"
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
)
|
||||
|
||||
func main() {
|
||||
monkeys := common.Parse(*bufio.NewScanner(os.Stdin), true)
|
||||
|
||||
for i := 0; i < 20; 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])
|
||||
}
|
||||
Reference in New Issue
Block a user