From 041a4259de818e312c98e0afbeadbac43a05ae69 Mon Sep 17 00:00:00 2001 From: hal8174 Date: Fri, 6 Dec 2024 15:56:12 +0100 Subject: [PATCH] Fix bug in day 6 --- src/bin/06.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bin/06.rs b/src/bin/06.rs index 7589294..d729be4 100644 --- a/src/bin/06.rs +++ b/src/bin/06.rs @@ -13,7 +13,7 @@ fn find_loop(mut pos: (usize, usize), mut dir: usize, map: &[Vec]) -> bool .filter(|&x| x < map[0].len()), pos.1 .checked_add_signed(DIR_MAP[dir].1) - .filter(|&y| y < map[0].len()), + .filter(|&y| y < map.len()), ) { visited.insert((pos, dir)); if map[next_pos.1][next_pos.0] { @@ -66,7 +66,7 @@ fn main() { .filter(|&x| x < map[0].len()), pos.1 .checked_add_signed(DIR_MAP[dir].1) - .filter(|&y| y < map[0].len()), + .filter(|&y| y < map.len()), ) { if map[next_pos.1][next_pos.0] { dir = (dir + 1) % 4; @@ -81,7 +81,7 @@ fn main() { let mut count = 0; for y in 0..map.len() { for x in 0..map[0].len() { - if !map[y][x] { + if !map[y][x] && (x, y) != start_pos { map[y][x] = true; if find_loop(start_pos, 0, &map) { count += 1;