File tree 1 file changed +3
-11
lines changed
1 file changed +3
-11
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ use advent_of_code::maneatingape::iter::*;
5
5
use advent_of_code:: maneatingape:: parse:: * ;
6
6
use advent_of_code:: maneatingape:: point:: * ;
7
7
8
- #[ derive( Clone ) ]
8
+ #[ derive( Clone , Copy ) ]
9
9
enum Block {
10
10
Ok ,
11
11
Corrupted ,
@@ -35,11 +35,7 @@ fn find_shortest_path_cost(grid: &Grid<Block>) -> Option<u32> {
35
35
let end_position = Point :: new ( grid. width - 1 , grid. height - 1 ) ;
36
36
37
37
let mut queue = std:: collections:: VecDeque :: new ( ) ;
38
- let mut seen = Grid {
39
- width : grid. width ,
40
- height : grid. height ,
41
- bytes : vec ! [ false ; ( grid. width * grid. height) as usize ] ,
42
- } ;
38
+ let mut seen = grid. same_size_with ( false ) ;
43
39
44
40
queue. push_front ( ( start_position, 0 ) ) ;
45
41
seen[ start_position] = true ;
@@ -65,11 +61,7 @@ fn find_shortest_path_cost(grid: &Grid<Block>) -> Option<u32> {
65
61
}
66
62
67
63
fn generate_grid ( data : & [ Point ] , width : i32 , height : i32 , n : usize ) -> Grid < Block > {
68
- let mut grid = Grid {
69
- width,
70
- height,
71
- bytes : vec ! [ Block :: Ok ; ( width * height) as usize ] ,
72
- } ;
64
+ let mut grid = Grid :: new ( width, height, Block :: Ok ) ;
73
65
74
66
data. iter ( ) . take ( n) . for_each ( |& point| {
75
67
grid[ point] = Block :: Corrupted ;
You can’t perform that action at this time.
0 commit comments