diff --git a/aoc_2024/src/day6.rs b/aoc_2024/src/day6.rs index 27843a5..8233005 100644 --- a/aoc_2024/src/day6.rs +++ b/aoc_2024/src/day6.rs @@ -1,5 +1,3 @@ -use std::collections::VecDeque; - use aoc_runner_derive::{aoc, aoc_generator}; // type Input = ((usize, usize), Vec>); @@ -20,7 +18,7 @@ const NEXT_DIR: [usize; 5] = [RIGHT as usize, LEFT as usize, UP as usize, 0, DOW fn parse(input: &str) -> Input { let lines = input.split("\n"); let mut pos = (0, 0); - let mut stones = VecDeque::new(); + let mut stones = Vec::with_capacity(input.len()); let map: Vec> = lines .enumerate() @@ -30,7 +28,7 @@ fn parse(input: &str) -> Input { .map(|(x, c)| match c { '.' => EMPTY, '#' => { - stones.push_back((x, y)); + stones.push((x, y)); WALL } '^' => { @@ -45,7 +43,7 @@ fn parse(input: &str) -> Input { let mut jumps = vec![vec![[u8::MAX; 5]; map[0].len()]; map.len()]; - while let Some((x, y)) = stones.pop_front() { + for (x, y) in stones { for dir in NEXT_DIR { let mut d = 1; loop {