@@ -12,7 +12,7 @@ use crate::util::grid::*;
12
12
use crate :: util:: point:: * ;
13
13
use std:: collections:: VecDeque ;
14
14
15
- type Input = ( u32 , usize ) ;
15
+ type Input = ( i32 , usize ) ;
16
16
17
17
/// Clockwise order starting with facing right.
18
18
const DIRECTIONS : [ Point ; 4 ] = [ RIGHT , DOWN , LEFT , UP ] ;
@@ -28,8 +28,8 @@ pub fn parse(input: &str) -> Input {
28
28
let mut todo_first = VecDeque :: new ( ) ;
29
29
let mut todo_second = VecDeque :: new ( ) ;
30
30
// State is `(position, direction)`.
31
- let mut seen = grid. same_size_with ( [ u32 :: MAX ; 4 ] ) ;
32
- let mut lowest = u32 :: MAX ;
31
+ let mut seen = grid. same_size_with ( [ i32 :: MAX ; 4 ] ) ;
32
+ let mut lowest = i32 :: MAX ;
33
33
34
34
todo_first. push_back ( ( start, 0 , 0 ) ) ;
35
35
seen[ start] [ 0 ] = 0 ;
@@ -99,16 +99,16 @@ pub fn parse(input: &str) -> Input {
99
99
// Trace our cost step by step so it will exactly match possible paths.
100
100
if next_cost == seen[ next_position] [ next_direction] {
101
101
todo. push_back ( ( next_position, next_direction, next_cost) ) ;
102
- // Set cost back to `u32 ::MAX` to prevent redundant path explorations.
103
- seen[ next_position] [ next_direction] = u32 :: MAX ;
102
+ // Set cost back to `i32 ::MAX` to prevent redundant path explorations.
103
+ seen[ next_position] [ next_direction] = i32 :: MAX ;
104
104
}
105
105
}
106
106
}
107
107
108
108
( lowest, path. bytes . iter ( ) . filter ( |& & b| b) . count ( ) )
109
109
}
110
110
111
- pub fn part1 ( input : & Input ) -> u32 {
111
+ pub fn part1 ( input : & Input ) -> i32 {
112
112
input. 0
113
113
}
114
114
0 commit comments