I just completed "Laboratories" - Day 7 - Advent of Code 2025 #AdventOfCode https://adventofcode.com/2025/day/7
Like I expect most people, I found that a purely recursive strategy worked fine for the test input on part 2, but took an unrealistic amount of time on the real input. So I figured out that if you ever get to a point where another beam has reached, the result from then on is the same, and so we can cache.
https://codeberg.org/diffrentcolours/aoc2025/src/commit/817181a7ae2dab31bea890cea5c63f9de1406896/day7/src/main.rs
I had a lot of faff working out how to pass the cache object (just a HashMap) around functions while keeping it mutable. Turns out that #Rust needs you to declare something as mutable:
When you instantiate itWhen you pass it to a functionIn the function's declarationand I had missed out the second step.
Also, I figured out how to get rust-analyzer integration working in #HelixEditor which means I'm now learning how to use Helix properly.