day16: part 2
This commit is contained in:
parent
ee9c2c1ca0
commit
ed4abd2d7e
@ -12,7 +12,7 @@ import (
|
||||
func Run() int {
|
||||
fmt.Println("hello from day 16")
|
||||
log.Println("starting")
|
||||
filename := "day16/example"
|
||||
filename := "day16/input"
|
||||
field := ReadField(filename)
|
||||
startPoints := StartPoints(&field)
|
||||
|
||||
@ -194,7 +194,7 @@ func (f *Field) CountEnergized() (result int) {
|
||||
func (f *Field) RecordVisits(reportedPoints <-chan MovementPoint) {
|
||||
for point := range reportedPoints {
|
||||
cell := f.cells[point.Row][point.Col]
|
||||
log.Printf("recording visit %+v to %+v at row %d col %d\n", point, cell, point.Row, point.Col)
|
||||
// log.Printf("recording visit %+v to %+v at row %d col %d\n", point, cell, point.Row, point.Col)
|
||||
cell.KnownBeams[point.Direction] = struct{}{}
|
||||
}
|
||||
}
|
||||
@ -203,7 +203,7 @@ func (f *Field) RecordVisits(reportedPoints <-chan MovementPoint) {
|
||||
// move (concurrently if required) into next points
|
||||
// ends - when out of the field, or if encountering a cycle
|
||||
func (f *Field) TraverseFrom(current MovementPoint, reportVisits chan<- MovementPoint, wg *sync.WaitGroup) {
|
||||
log.Printf("> starting traverse through %+v", current)
|
||||
// log.Printf("> starting traverse through %+v", current)
|
||||
if !f.isValid(current) {
|
||||
log.Println("invalid current ", current, " should be impossible")
|
||||
wg.Done()
|
||||
@ -212,7 +212,7 @@ func (f *Field) TraverseFrom(current MovementPoint, reportVisits chan<- Movement
|
||||
cell := f.cells[current.Row][current.Col]
|
||||
_, knownDirection := cell.KnownBeams[current.Direction]
|
||||
if knownDirection {
|
||||
log.Printf("found cycle at %+v in %+v", current, cell)
|
||||
// log.Printf("found cycle at %+v in %+v", current, cell)
|
||||
wg.Done()
|
||||
return
|
||||
}
|
||||
@ -220,7 +220,7 @@ func (f *Field) TraverseFrom(current MovementPoint, reportVisits chan<- Movement
|
||||
reportVisits <- current
|
||||
|
||||
nextPoints := NextPoints(f, current)
|
||||
log.Printf("for current %+v next are: %+v\n", current, nextPoints)
|
||||
// log.Printf("for current %+v next are: %+v\n", current, nextPoints)
|
||||
switch len(nextPoints) {
|
||||
case 0:
|
||||
wg.Done()
|
||||
|
Loading…
x
Reference in New Issue
Block a user