From aafe39aa85518e32f415c54444a1865088611e89 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Wed, 11 Dec 2024 19:40:45 +0000 Subject: [PATCH] clear up result zero value use local count variable --- day-11/internal/two/solve.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/day-11/internal/two/solve.go b/day-11/internal/two/solve.go index 28ca001..20e708d 100644 --- a/day-11/internal/two/solve.go +++ b/day-11/internal/two/solve.go @@ -25,23 +25,21 @@ func Solve(buf []byte) (int, error) { memo := make(map[int]result) for range blinks { next := make(map[int]int) - visited := make(map[int]int) for stone, count := range old { var r result - _, ok := visited[stone] + r, ok := memo[stone] if !ok { r = applyRules(stone) memo[stone] = r } - visited[stone] += count switch r.kind { case flip, multiply: - next[r.right] += visited[stone] + next[r.right] += count case split: - next[r.left] += visited[stone] - next[r.right] += visited[stone] + next[r.left] += count + next[r.right] += count } }