From b4f6c236bd97e300ef0fa5a3e172b820750bc456 Mon Sep 17 00:00:00 2001 From: SOFe Date: Sat, 7 Dec 2024 16:43:51 +0800 Subject: [PATCH] fix d4p1 --- src/all/d4.rs | 4 ++-- src/util.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/all/d4.rs b/src/all/d4.rs index 52a457c..77cd227 100644 --- a/src/all/d4.rs +++ b/src/all/d4.rs @@ -10,10 +10,10 @@ pub fn p1_brute(input: String) -> u32 { for (index, _) in input.match_indices('X') { let loc = grid.index_to_loc(index).unwrap(); for dir in DirectDiagonal::ALL { - let mut iter = loc.direct_diagonal_iter(dir, grid).skip(1).take(3).map(|loc| grid.get(loc)); + let mut iter = + loc.direct_diagonal_iter(dir, grid).skip(1).take(3).map(|loc| grid.get(loc)); let chars: [_; 3] = array::from_fn(|_| iter.next().flatten()); if chars == [Some(b'M'), Some(b'A'), Some(b'S')] { - println!("Match: {dir:?} {loc:?}"); count += 1; } } diff --git a/src/util.rs b/src/util.rs index 16fa83a..7d7c3fa 100644 --- a/src/util.rs +++ b/src/util.rs @@ -67,7 +67,7 @@ impl GridLoc { Some(Self { x: self.x, y: match self.y.checked_add(1)? { - y if y < grid.height - 1 => y, + y if y < grid.height => y, _ => return None, }, })