@@ -13,6 +13,24 @@ pub struct Day07;
1313
1414impl Solution for Day07 {
1515 fn part_one ( & self , input : & str ) -> String {
16+ let ( splits, _) = self . run ( input) ;
17+
18+ splits. to_string ( )
19+ }
20+
21+ fn part_two ( & self , _input : & str ) -> String {
22+ String :: from ( "0" )
23+ }
24+ }
25+
26+ impl Day07 {
27+ fn parse ( & self , input : & str ) -> Grid < char > {
28+ let without_redundant_lines = input. lines ( ) . step_by ( 2 ) . collect :: < Vec < _ > > ( ) . join ( "\n " ) ;
29+
30+ Grid :: from ( without_redundant_lines. as_str ( ) )
31+ }
32+
33+ fn run ( & self , input : & str ) -> ( u16 , u16 ) {
1634 let grid = self . parse ( input) ;
1735 let rows_range = grid. rows_range ( ) ;
1836 let start = grid. get_first_position ( & START ) . unwrap ( ) ;
@@ -21,7 +39,7 @@ impl Solution for Day07 {
2139
2240 let mut finished_beams: Vec < Beam > = Vec :: new ( ) ;
2341 let mut current_beams: VecDeque < Beam > = VecDeque :: from ( vec ! [ start. into( ) ] ) ;
24- let mut splits = 0 ;
42+ let mut splits = 0u16 ;
2543
2644 while let Some ( current_beam) = current_beams. pop_front ( ) {
2745 if finished_beams
@@ -53,19 +71,7 @@ impl Solution for Day07 {
5371 current_beams. push_front ( down) ;
5472 }
5573
56- splits. to_string ( )
57- }
58-
59- fn part_two ( & self , _input : & str ) -> String {
60- String :: from ( "0" )
61- }
62- }
63-
64- impl Day07 {
65- fn parse ( & self , input : & str ) -> Grid < char > {
66- let without_redundant_lines = input. lines ( ) . step_by ( 2 ) . collect :: < Vec < _ > > ( ) . join ( "\n " ) ;
67-
68- Grid :: from ( without_redundant_lines. as_str ( ) )
74+ ( splits, 0 )
6975 }
7076}
7177
0 commit comments