diff --git a/src/day1.rs b/src/day1.rs index b1aaa5b..a0f909b 100644 --- a/src/day1.rs +++ b/src/day1.rs @@ -89,4 +89,4 @@ mod tests { let input = get_input(EXAMPLE); assert_eq!(part2(&input), 31); } -} \ No newline at end of file +} diff --git a/src/day4.rs b/src/day4.rs index f379b45..e8a68d1 100644 --- a/src/day4.rs +++ b/src/day4.rs @@ -53,11 +53,17 @@ impl WordSearch { for x in 0..width { for y in 0..height { // check down-right - if x <= width - needle.len() && y <= height - needle.len() && (0..needle.len()).all(|i| self.get(x + i, y + i) == needle.as_bytes()[i].into()) { + if x <= width - needle.len() + && y <= height - needle.len() + && (0..needle.len()).all(|i| self.get(x + i, y + i) == needle.as_bytes()[i].into()) + { count += 1 } // check down-left - if x >= needle.len() - 1 && y <= height - needle.len() && (0..needle.len()).all(|i| self.get(x - i, y + i) == needle.as_bytes()[i].into()) { + if x >= needle.len() - 1 + && y <= height - needle.len() + && (0..needle.len()).all(|i| self.get(x - i, y + i) == needle.as_bytes()[i].into()) + { count += 1 } } diff --git a/src/main.rs b/src/main.rs index d733dc6..e38be9e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,3 @@ use aoc_runner_derive::aoc_main; -aoc_main!{ lib = aoc2024 } \ No newline at end of file +aoc_main! { lib = aoc2024 }