Solutions for day 10.
This commit is contained in:
parent
e47b6c4a45
commit
28998c5d14
4 changed files with 67 additions and 18 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue