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 {
34
34
let mut obstructions = FastSet :: new ( ) ;
35
35
36
36
let height = input. lines ( ) . count ( ) ;
37
- let width = input. split_once ( " \n " ) . unwrap ( ) . 0 . len ( ) ;
37
+ let width = input. lines ( ) . next ( ) . unwrap ( ) . len ( ) ;
38
38
39
39
for ( y, line) in input. lines ( ) . enumerate ( ) {
40
40
for ( x, v) in line. bytes ( ) . enumerate ( ) {
Original file line number Diff line number Diff line change @@ -25,21 +25,22 @@ impl MapSize {
25
25
}
26
26
27
27
fn parse_data ( input : & str ) -> DataType {
28
- let mut data = FastMap :: new ( ) ;
28
+ let mut data: FastMap < u8 , Vec < Point > > = FastMap :: new ( ) ;
29
29
30
30
let width = input. lines ( ) . next ( ) . unwrap ( ) . len ( ) as i32 ;
31
31
let height = input. lines ( ) . count ( ) as i32 ;
32
32
33
33
for ( y, line) in input. lines ( ) . enumerate ( ) {
34
34
for ( x, c) in line. bytes ( ) . enumerate ( ) {
35
35
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) ;
37
38
}
38
39
}
39
40
}
40
41
41
42
DataType {
42
- data : data ,
43
+ data,
43
44
map_size : MapSize {
44
45
min_x : 0 ,
45
46
max_x : width - 1 ,
You can’t perform that action at this time.
0 commit comments