Skip to content

Commit

Permalink
32bit fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rene-d committed Jan 27, 2025
1 parent cedef99 commit 270f684
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/year2022/day17/day17.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ pub fn solve(data: &str) -> (usize, usize) {
}

if start != 0 && end != 0 {
let remaining_rocks = 1_000_000_000_000 - start;
let cycle_length = end - start;
let remaining_rocks = 1_000_000_000_000 - u64::try_from(start).unwrap();
let cycle_length = u64::try_from(end - start).unwrap();

let q = remaining_rocks / cycle_length;
let r = remaining_rocks % cycle_length;
let r = usize::try_from(remaining_rocks % cycle_length).unwrap();

part2 = heights[start + r] + q * (heights[end] - heights[start]);
part2 = u64::try_from(heights[start + r]).unwrap() + q * u64::try_from(heights[end] - heights[start]).unwrap();
}

(part1, part2)
Expand Down

0 comments on commit 270f684

Please sign in to comment.