package main import ( "aoc2022/day15/common" "bufio" "fmt" "os" ) func main() { sensors := common.Parse(*bufio.NewScanner(os.Stdin)) tileMap := common.NewMap() for _, sensor := range sensors { tileMap.SetSensor(sensor) } var frequency int found := false for i := 0; i <= 4000000 && !found; i++ { coverage := tileMap.GetCoverageYInXInterval(0, 4000000, i) if coverage <= 4000000 { for j := 0; j < 4000000 && !found; j++ { if tileMap.GetTile(j, i) == common.Free { frequency = j * 4000000 + i found = true } } } } fmt.Println(frequency) }