File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,8 @@ pub struct Day13;
77
88impl Solution for Day13 {
99 fn part_one ( & self , input : & str ) -> String {
10- input
11- . split_terminator ( "\n \n " )
12- . map ( |s| s. parse :: < Machine > ( ) . unwrap ( ) )
10+ self . parse ( input)
11+ . iter ( )
1312 . filter_map ( |machine| {
1413 machine
1514 . solve_2x2_system ( )
@@ -20,9 +19,8 @@ impl Solution for Day13 {
2019 }
2120
2221 fn part_two ( & self , input : & str ) -> String {
23- input
24- . split_terminator ( "\n \n " )
25- . map ( |s| s. parse :: < Machine > ( ) . unwrap ( ) )
22+ self . parse ( input)
23+ . iter ( )
2624 . filter_map ( |machine| {
2725 machine
2826 . move_prize_by_10000000000000 ( )
@@ -34,6 +32,15 @@ impl Solution for Day13 {
3432 }
3533}
3634
35+ impl Day13 {
36+ fn parse ( & self , input : & str ) -> Vec < Machine > {
37+ input
38+ . split_terminator ( "\n \n " )
39+ . map ( |s| s. parse :: < Machine > ( ) . unwrap ( ) )
40+ . collect ( )
41+ }
42+ }
43+
3744#[ derive( Debug ) ]
3845struct Machine {
3946 a : Point ,
You can’t perform that action at this time.
0 commit comments