Solutions for day 10.

This commit is contained in:
Anna Rose Wiggins 2018-12-12 15:06:32 -05:00
parent e47b6c4a45
commit 28998c5d14
No known key found for this signature in database
GPG key ID: 8D9ACA841015C59A
4 changed files with 67 additions and 18 deletions

View file

@ -1,8 +1,6 @@
package main
import (
"fmt"
"internal/day10"
"internal/util"
)
@ -11,27 +9,21 @@ func main() {
data := util.ReadInput()
points := day10.ParseInput(data)
i := 0 // debug
lowest := day10.CalculateRange(points)
for {
for _, point := range points {
point.Move()
}
groups := day10.GroupPoints(points)
if groups != nil {
for _, group := range groups {
day10.DrawPoints(group)
fmt.Println()
newRange := day10.CalculateRange(points)
if newRange < lowest {
lowest = newRange
} else {
for _, point := range points {
point.Reverse()
}
day10.DrawPoints(points)
return
}
// debug
i++
if i > 100000 {
fmt.Println("oops")
return
}
// end debug
}
}