Day 7: Laboratories
Megathread guidelines
- Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
- You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL
FAQ
- What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
- Where do I participate?: https://adventofcode.com/
- Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465


Rust
Not too difficult, but my pt1 approach didnt work for pt2. Small amount of tweaking and it was back in action. This should be a really good one for visualisations, so I am definitely going to try do something. Maybe colorise the nodes based on how many paths go through it? Definitely an animation of the trickle down. Looking forward to seeing everyone elses visualisations as well!
spoiler
#[test] fn test_y2025_day7_part2() { let input = include_str!("../../input/2025/day_7.txt"); let mut rows = input .lines() .map(|l| { l.chars() .map(|c| match c { 'S' | '|' => 1isize, '^' => -1isize, _ => 0isize, }) .collect::<Vec<isize>>() }) .collect::<Vec<Vec<isize>>>(); let width = rows[0].len(); for i in 1..rows.len() { for j in 0..width { if rows[i - 1][j] >= 1 { if rows[i][j] == -1 { rows[i][j - 1] += rows[i - 1][j]; rows[i][j + 1] += rows[i - 1][j]; } else { rows[i][j] += rows[i - 1][j]; } } } } print_tree(&rows); let total: isize = rows.pop().unwrap().iter().sum(); println!("Total: {}", total); }