My submissions for Advent of Code 2025 adventofcode.com/2025
rust aoc

add solution for day 11 part 2

cherry.computer 6523234a e30c341f

verified
+54
+4
11/part2/Cargo.toml
··· 1 + [package] 2 + name = "aoc25-11-2" 3 + version = "1.0.0" 4 + edition = "2024"
+46
11/part2/src/main.rs
··· 1 + use std::{collections::HashMap, fs::read_to_string}; 2 + 3 + fn traverse_map<'a>( 4 + device_map: &HashMap<&'a str, Vec<&'a str>>, 5 + seen_paths: &mut HashMap<&'a str, u64>, 6 + device: &'a str, 7 + target: &'a str, 8 + ) -> u64 { 9 + match seen_paths.get(device) { 10 + Some(&known_path_count) => known_path_count, 11 + None => { 12 + let path_count = match &device_map.get(device) { 13 + Some(outputs) => outputs 14 + .iter() 15 + .map(|&output| { 16 + if output == target { 17 + 1 18 + } else { 19 + traverse_map(device_map, seen_paths, output, target) 20 + } 21 + }) 22 + .sum(), 23 + None => 0, 24 + }; 25 + seen_paths.insert(device, path_count); 26 + path_count 27 + } 28 + } 29 + } 30 + 31 + fn main() { 32 + let input = read_to_string("../input.txt").expect("failed to open input file"); 33 + let device_map: HashMap<_, Vec<_>> = input 34 + .lines() 35 + .map(|line| { 36 + let (device, outputs) = line.split_once(": ").expect("failed to parse line"); 37 + (device, outputs.split_whitespace().collect()) 38 + }) 39 + .collect(); 40 + 41 + let total_paths: u64 = [("svr", "fft"), ("fft", "dac"), ("dac", "out")] 42 + .into_iter() 43 + .map(|(from, to)| traverse_map(&device_map, &mut HashMap::new(), from, to)) 44 + .product(); 45 + println!("There are {total_paths} faulty paths from 'svr' to 'out'!"); 46 + }
+4
Cargo.lock
··· 107 107 version = "1.0.0" 108 108 109 109 [[package]] 110 + name = "aoc25-11-2" 111 + version = "1.0.0" 112 + 113 + [[package]] 110 114 name = "autocfg" 111 115 version = "1.5.0" 112 116 source = "registry+https://github.com/rust-lang/crates.io-index"