Skip to content

Commit

Permalink
fix d4p1
Browse files Browse the repository at this point in the history
  • Loading branch information
SOF3 committed Dec 7, 2024
1 parent 9475ba2 commit b4f6c23
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/all/d4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
})
Expand Down

0 comments on commit b4f6c23

Please sign in to comment.