package main import ( "fmt" "internal/guards" "internal/util" ) func main() { data := util.ReadInput() shifts := guards.ParseInput(data) guards := guards.BuildGuards(shifts) sleepiest, sleepiestMinute := FindSleepiestData(guards) fmt.Printf("Sleepiest Guard: %d\n", sleepiest.ID) fmt.Printf("Sleepiest Minute: %d\n", sleepiestMinute) fmt.Printf("Result: %d\n", sleepiest.ID*sleepiestMinute) } func FindSleepiestData(data map[int]*guards.Guard) (*guards.Guard, int) { var sleepiest *guards.Guard for _, guard := range data { if sleepiest == nil { sleepiest = guard continue } if guard.SleepTotal > sleepiest.SleepTotal { sleepiest = guard } } sleepiestMinute := -1 sleepiestCount := 0 for minute, sleepiness := range sleepiest.Sleep { if sleepiness > sleepiestCount { sleepiestCount = sleepiness sleepiestMinute = minute } } return sleepiest, sleepiestMinute }