Day 3 solution.
This commit is contained in:
parent
d57d3ca80b
commit
75eeea9079
3 changed files with 148 additions and 0 deletions
34
2018/day03-2.go
Normal file
34
2018/day03-2.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue