File tree Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Expand file tree Collapse file tree 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::*;
55use advent_of_code:: maneatingape:: parse:: * ;
66use advent_of_code:: maneatingape:: point:: * ;
77
8- #[ derive( Clone ) ]
8+ #[ derive( Clone , Copy ) ]
99enum Block {
1010 Ok ,
1111 Corrupted ,
@@ -35,11 +35,7 @@ fn find_shortest_path_cost(grid: &Grid<Block>) -> Option<u32> {
3535 let end_position = Point :: new ( grid. width - 1 , grid. height - 1 ) ;
3636
3737 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 ) ;
4339
4440 queue. push_front ( ( start_position, 0 ) ) ;
4541 seen[ start_position] = true ;
@@ -65,11 +61,7 @@ fn find_shortest_path_cost(grid: &Grid<Block>) -> Option<u32> {
6561}
6662
6763fn 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 ) ;
7365
7466 data. iter ( ) . take ( n) . for_each ( |& point| {
7567 grid[ point] = Block :: Corrupted ;
You can’t perform that action at this time.
0 commit comments