From 22a8aecd4531431319816a512d913c272d3fd138 Mon Sep 17 00:00:00 2001 From: Jaakko Husso Date: Fri, 22 Dec 2023 00:56:48 +0200 Subject: [PATCH] Use u64 as the return value for day 21 both parts --- aoc-solver/src/y2023/day21.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/aoc-solver/src/y2023/day21.rs b/aoc-solver/src/y2023/day21.rs index d0471b6..76b8322 100644 --- a/aoc-solver/src/y2023/day21.rs +++ b/aoc-solver/src/y2023/day21.rs @@ -46,21 +46,21 @@ fn parse(input: &str) -> Result<(Vec>, Coords), AocError> { } impl Solution for Day21 { - type A = usize; - type B = usize; + type A = u64; + type B = u64; fn default_input(&self) -> &'static str { include_str!("../../../inputs/2023/day21.txt") } - fn part_1(&self, input: &str) -> Result { + fn part_1(&self, input: &str) -> Result { let (tiles, start) = parse(input)?; let reachable = find_reachable(&tiles, start, 64, false); - Ok(reachable.len()) + Ok(reachable.len() as u64) } - fn part_2(&self, input: &str) -> Result { + fn part_2(&self, input: &str) -> Result { let (tiles, start) = parse(input)?; // This works only on many assumptions of what the input looks like. @@ -127,7 +127,7 @@ impl Solution for Day21 { // Our input distance is odd. // After exiting the middle area (65) we need to move accross // (26501365 - 65) / 131 gardens to reach the point - let n = ((26501365 - ((size - 1) / 2)) / size) as usize; + let n = ((26501365 - ((size - 1) / 2)) / size) as u64; // On paper with some geometry and logic I've determined the count of shapes to be let a_count = (n - 1).pow(2); @@ -194,7 +194,7 @@ fn find_reachable( unique } -fn visited_area(reachable: &HashSet, garden: Coords, size: isize) -> usize { +fn visited_area(reachable: &HashSet, garden: Coords, size: isize) -> u64 { reachable .iter() .filter(|(x, y)| { @@ -203,7 +203,7 @@ fn visited_area(reachable: &HashSet, garden: Coords, size: isize) -> usi && *y >= garden.1 * size && *y < (garden.1 + 1) * size }) - .count() + .count() as u64 } #[cfg(test)]