File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ fn parse_data(input: &str) -> DataType {
3434 let mut obstructions = FastSet :: new ( ) ;
3535
3636 let height = input. lines ( ) . count ( ) ;
37- let width = input. split_once ( " \n " ) . unwrap ( ) . 0 . len ( ) ;
37+ let width = input. lines ( ) . next ( ) . unwrap ( ) . len ( ) ;
3838
3939 for ( y, line) in input. lines ( ) . enumerate ( ) {
4040 for ( x, v) in line. bytes ( ) . enumerate ( ) {
Original file line number Diff line number Diff line change @@ -25,21 +25,22 @@ impl MapSize {
2525}
2626
2727fn parse_data ( input : & str ) -> DataType {
28- let mut data = FastMap :: new ( ) ;
28+ let mut data: FastMap < u8 , Vec < Point > > = FastMap :: new ( ) ;
2929
3030 let width = input. lines ( ) . next ( ) . unwrap ( ) . len ( ) as i32 ;
3131 let height = input. lines ( ) . count ( ) as i32 ;
3232
3333 for ( y, line) in input. lines ( ) . enumerate ( ) {
3434 for ( x, c) in line. bytes ( ) . enumerate ( ) {
3535 if c != b'.' {
36- ( * data. entry ( c) . or_insert ( vec ! [ ] ) ) . push ( Point :: new ( x as i32 , y as i32 ) ) ;
36+ let p = Point :: new ( x as i32 , y as i32 ) ;
37+ data. entry ( c) . or_default ( ) . push ( p) ;
3738 }
3839 }
3940 }
4041
4142 DataType {
42- data : data ,
43+ data,
4344 map_size : MapSize {
4445 min_x : 0 ,
4546 max_x : width - 1 ,
You can’t perform that action at this time.
0 commit comments