Skip to content

Commit fef12de

Browse files
committed
32bit fix
1 parent cedef99 commit fef12de

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/year2022/day17/day17.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl Cave {
123123

124124
/// # Panics
125125
#[must_use]
126-
pub fn solve(data: &str) -> (usize, usize) {
126+
pub fn solve(data: &str) -> (usize, u64) {
127127
let jets: Vec<u8> = data.trim().bytes().collect();
128128

129129
let mut cave = Cave::new();
@@ -162,13 +162,13 @@ pub fn solve(data: &str) -> (usize, usize) {
162162
}
163163

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

168168
let q = remaining_rocks / cycle_length;
169-
let r = remaining_rocks % cycle_length;
169+
let r = usize::try_from(remaining_rocks % cycle_length).unwrap();
170170

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

174174
(part1, part2)

0 commit comments

Comments
 (0)