File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ impl Cave {
123
123
124
124
/// # Panics
125
125
#[ must_use]
126
- pub fn solve ( data : & str ) -> ( usize , usize ) {
126
+ pub fn solve ( data : & str ) -> ( usize , u64 ) {
127
127
let jets: Vec < u8 > = data. trim ( ) . bytes ( ) . collect ( ) ;
128
128
129
129
let mut cave = Cave :: new ( ) ;
@@ -162,13 +162,13 @@ pub fn solve(data: &str) -> (usize, usize) {
162
162
}
163
163
164
164
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 ( ) ;
167
167
168
168
let q = remaining_rocks / cycle_length;
169
- let r = remaining_rocks % cycle_length;
169
+ let r = usize :: try_from ( remaining_rocks % cycle_length) . unwrap ( ) ;
170
170
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 ( ) ;
172
172
}
173
173
174
174
( part1, part2)
You can’t perform that action at this time.
0 commit comments