my solutions to advent of code
aoc advent-of-code

bruteforce still doesnt work of course

aylac.top 67c9b20f a7c69299

verified
Changed files
+12 -6
2025
7
rust
src
+12 -6
2025/7/rust/src/main.rs
···
use std::{
char,
collections::{HashMap, HashSet},
+
mem::swap,
};
fn main() {
-
let input = include_str!("../../input_example.txt").trim();
+
let input = include_str!("../../input.txt").trim();
let mut input: Vec<&str> = input.trim().split("\n").collect();
let start = input[0].find("S").unwrap() as u32;
···
let timelines = {
let mut timelines: HashMap<String, u32> = HashMap::new();
timelines.insert("".to_string(), start);
-
for splitters in splitters_map {
-
for (timeline, pos) in timelines.clone() {
+
let mut timelines_new: HashMap<String, u32> = HashMap::new();
+
for (i, splitters) in splitters_map.iter().enumerate() {
+
println!("at: {}", i);
+
for (timeline, pos) in &timelines {
if splitters.contains(&pos) {
-
timelines.remove(&timeline);
-
timelines.insert(format!("{timeline}+"), pos + 1);
-
timelines.insert(format!("{timeline}-"), pos - 1);
+
timelines_new.insert(format!("{timeline}+"), pos + 1);
+
timelines_new.insert(format!("{timeline}-"), pos - 1);
+
} else {
+
timelines_new.insert(format!("{timeline}|"), *pos);
}
}
+
swap(&mut timelines, &mut timelines_new);
+
timelines_new.clear();
}
timelines
};