From 77d7355eb70d6cfa28d47efd98a6d8f72368c943 Mon Sep 17 00:00:00 2001 From: efim Date: Fri, 8 Dec 2023 10:07:11 +0000 Subject: [PATCH] day8, part2 --- day8/dayEight.go | 8 ++++++-- day8/notes.org | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/day8/dayEight.go b/day8/dayEight.go index 00195b6..72f694a 100644 --- a/day8/dayEight.go +++ b/day8/dayEight.go @@ -11,7 +11,7 @@ import ( func Run() int { fmt.Print("hello day 8") - filename := "day8/example3" + filename := "day8/input" net, path := Read(filename) fmt.Printf("got %+v and %+v\n", net, path) result := GhostTraverse(net, path) @@ -84,6 +84,7 @@ func GhostTraverse(net Network, path Path) int { } // oh, i don't need to seed the cycle, they are already not equal + cycle := 0 for !allEqual(stepCounts) { max := slices.Max(stepCounts) for i, pathInfo := range pathInfos { @@ -100,7 +101,10 @@ func GhostTraverse(net Network, path Path) int { stepCounts[i] += overJump } } - log.Printf("done one cycle iteration, results : %+v", stepCounts) + cycle += 1 + if cycle % 10000000 == 0 { + log.Printf("done %d cycle iteration, results : %+v", cycle, stepCounts) + } } return stepCounts[0] diff --git a/day8/notes.org b/day8/notes.org index 43d3082..880cb9a 100644 --- a/day8/notes.org +++ b/day8/notes.org @@ -27,3 +27,4 @@ so take the difference, if divisible by cycle - yay. just multiply, if not divis if all are same, that's solution. if one is farthest, repeat * i stopped bruteforce at 4080000000 +the answer was 14935034899483