Advent of Code solutions

fix day 10 p2 in trilogy, now that memory leaks are not so severe

+8 -3
+8 -3
2025/10/p2.tri
··· 46 46 |> it::flat_map (fn n. it::choose n buttons) 47 47 |> it::filter ((==) target << fold (^) (target ^ target) << map (button_bits (length target))) 48 48 49 + func to_tuple [] = unit 50 + func to_tuple [x, ..xs] = x : to_tuple xs 51 + 49 52 proc solver!(buttons) { 50 53 let cache = {||} 51 54 52 55 let solve = do(joltage) { 53 - if contains_key joltage cache { 54 - return cache.joltage 56 + if contains_key (to_tuple joltage) cache { 57 + return cache.(to_tuple joltage) 55 58 } 56 59 if all ((==) 0) joltage { 57 60 return 0 ··· 64 67 |> it::filter (fn remaining:_. all (fn n. n >= 0) remaining) 65 68 |> it::flat_map (fn remaining:score. with it::of <| solve!(map (fn n. n // 2) remaining) * 2 + score when 'mia cancel (do() {}) else yield) 66 69 |> it::reduce min 67 - cache.joltage = best 70 + cache.(to_tuple joltage) = best 68 71 return best 69 72 } 70 73 ··· 74 77 proc main!() { 75 78 readlines 76 79 |> it::map (parse machine) 80 + |> it::map (fn j:s. (dbg j; j:s)) 77 81 |> it::map (fn joltage:solve. solve!(joltage)) 82 + |> it::map dbg 78 83 |> it::fold (+) 0 79 84 |> dbg 80 85 }