// do part 1a but figure out the first repeated value use std::collections::HashMap; use aoc::read_data; fn main() { let mut visited_locations: HashMap = HashMap::from([(0, 0)]); // let binding = read_data("2018_01_data.txt"); // let lines = binding.lines(); let lines = "-6\n+3\n+8\n+5\n-6".to_string(); let mut working_value = 0i32; for line in lines.lines() { let (direction, velocity) = line.split_at(1); // println!("{line} split to ||{direction}|| and ||{velocity}||"); let direction_val : i32 = velocity.parse().unwrap(); match direction { "+" => { working_value += direction_val; } "-" => { working_value -= direction_val; } _ => { unreachable!("Invalid direction"); } } print!("{working_value}\t"); if let Some(found) = visited_locations.get(&working_value) { println!("GET SUCCESS -> {working_value} / {found}"); break; } visited_locations.insert(working_value, 0); } } // BROKEN