···
collections::{HashMap, HashSet},
···
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 splitters_map: Vec<HashSet<u32>> = input[0..input.len()]
.map(|(i, line)| if i % 2 != 0 { "" } else { line })
···
.fold(HashSet::new(), |mut s, (i, char)| {
···
-
let mut timelines: HashMap<String, u32> = HashMap::new();
-
timelines.insert("".to_string(), start);
-
let mut timelines_new: HashMap<String, u32> = HashMap::new();
-
for (i, splitters) in splitters_map.iter().enumerate() {
-
for (timeline, pos) in &timelines {
if splitters.contains(&pos) {
-
timelines_new.insert(format!("{timeline}+"), pos + 1);
-
timelines_new.insert(format!("{timeline}-"), pos - 1);
-
timelines_new.insert(format!("{timeline}|"), *pos);
swap(&mut timelines, &mut timelines_new);
-
println!("{}", timelines.len());
···
collections::{HashMap, HashSet},
···
let input = include_str!("../../input.txt").trim();
+
let input: Vec<&str> = input.trim().split("\n").collect();
+
// let width = input[0].len() as u64;
+
let start = input[0].find("S").unwrap() as u64;
+
let splitters_map: Vec<HashSet<u64>> = input[0..input.len()]
.map(|(i, line)| if i % 2 != 0 { "" } else { line })
···
.fold(HashSet::new(), |mut s, (i, char)| {
···
+
let mut timelines: HashMap<u64, u64> = HashMap::new();
+
timelines.insert(start, 1);
+
let mut timelines_new: HashMap<u64, u64> = HashMap::new();
+
for splitters in splitters_map {
+
for (pos, amount) in &timelines {
if splitters.contains(&pos) {
+
let m1 = timelines_new.entry(pos - 1).or_insert(0);
+
let p1 = timelines_new.entry(pos + 1).or_insert(0);
+
let e = timelines_new.entry(*pos).or_insert(0);
+
// for pos in 0..width as u64 {
+
// if splitters.contains(&pos) {
+
// } else if timelines_new.contains_key(&pos) {
swap(&mut timelines, &mut timelines_new);
+
// println!("{:?}", timelines);
+
println!("{}", timelines.iter().fold(0, |acc, v| { acc + v.1 }))