adventofcode/2018/day03-2.go

35 lines
559 B
Go
Raw Normal View History

2018-12-03 21:53:58 +00:00
package main
import (
"fmt"
"internal/fabric"
"internal/util"
)
func main() {
data := util.ReadInput()
claims, maxX, maxY := fabric.ParseClaims(data)
fabric.PopulateGrid(claims, maxX, maxY) // ignoring return value because we only want the side effect here
id := -1
count := 0
for _, claim := range claims {
if !claim.Overlaps {
id = claim.ID
count++
}
}
if count > 1 {
fmt.Printf("%d claims detected no overlap. :(\n", count)
return
}
if count == 0 {
fmt.Println("All claims overlapped. :(")
return
}
fmt.Println(id)
}