···
collections::{HashMap, HashSet},
7
-
let input = include_str!("../../input_example.txt").trim();
8
+
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 mut timelines: HashMap<String, u32> = HashMap::new();
timelines.insert("".to_string(), start);
31
-
for splitters in splitters_map {
32
-
for (timeline, pos) in timelines.clone() {
32
+
let mut timelines_new: HashMap<String, u32> = HashMap::new();
33
+
for (i, splitters) in splitters_map.iter().enumerate() {
34
+
println!("at: {}", i);
35
+
for (timeline, pos) in &timelines {
if splitters.contains(&pos) {
34
-
timelines.remove(&timeline);
35
-
timelines.insert(format!("{timeline}+"), pos + 1);
36
-
timelines.insert(format!("{timeline}-"), pos - 1);
37
+
timelines_new.insert(format!("{timeline}+"), pos + 1);
38
+
timelines_new.insert(format!("{timeline}-"), pos - 1);
40
+
timelines_new.insert(format!("{timeline}|"), *pos);
43
+
swap(&mut timelines, &mut timelines_new);
44
+
timelines_new.clear();