Skip to content

Commit 22a8aec

Browse files
committed
Use u64 as the return value for day 21 both parts
1 parent 435d41c commit 22a8aec

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

aoc-solver/src/y2023/day21.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ fn parse(input: &str) -> Result<(Vec<Vec<Tile>>, Coords), AocError> {
4646
}
4747

4848
impl Solution for Day21 {
49-
type A = usize;
50-
type B = usize;
49+
type A = u64;
50+
type B = u64;
5151

5252
fn default_input(&self) -> &'static str {
5353
include_str!("../../../inputs/2023/day21.txt")
5454
}
5555

56-
fn part_1(&self, input: &str) -> Result<usize, AocError> {
56+
fn part_1(&self, input: &str) -> Result<u64, AocError> {
5757
let (tiles, start) = parse(input)?;
5858
let reachable = find_reachable(&tiles, start, 64, false);
5959

60-
Ok(reachable.len())
60+
Ok(reachable.len() as u64)
6161
}
6262

63-
fn part_2(&self, input: &str) -> Result<usize, AocError> {
63+
fn part_2(&self, input: &str) -> Result<u64, AocError> {
6464
let (tiles, start) = parse(input)?;
6565

6666
// This works only on many assumptions of what the input looks like.
@@ -127,7 +127,7 @@ impl Solution for Day21 {
127127
// Our input distance is odd.
128128
// After exiting the middle area (65) we need to move accross
129129
// (26501365 - 65) / 131 gardens to reach the point
130-
let n = ((26501365 - ((size - 1) / 2)) / size) as usize;
130+
let n = ((26501365 - ((size - 1) / 2)) / size) as u64;
131131

132132
// On paper with some geometry and logic I've determined the count of shapes to be
133133
let a_count = (n - 1).pow(2);
@@ -194,7 +194,7 @@ fn find_reachable(
194194
unique
195195
}
196196

197-
fn visited_area(reachable: &HashSet<Coords>, garden: Coords, size: isize) -> usize {
197+
fn visited_area(reachable: &HashSet<Coords>, garden: Coords, size: isize) -> u64 {
198198
reachable
199199
.iter()
200200
.filter(|(x, y)| {
@@ -203,7 +203,7 @@ fn visited_area(reachable: &HashSet<Coords>, garden: Coords, size: isize) -> usi
203203
&& *y >= garden.1 * size
204204
&& *y < (garden.1 + 1) * size
205205
})
206-
.count()
206+
.count() as u64
207207
}
208208

209209
#[cfg(test)]

0 commit comments

Comments
 (0)