File tree 2 files changed +72
-69
lines changed
2 files changed +72
-69
lines changed Original file line number Diff line number Diff line change
1
+ pub fn run ( ) -> anyhow:: Result < ( ) > {
2
+ let cli = Cli :: parse ( ) ;
3
+
4
+ let input_file = cli
5
+ . input_file
6
+ . unwrap_or ( format ! ( "./input/d{}.txt" , cli. day) ) ;
7
+
8
+ let input = std:: fs:: read_to_string ( input_file) ?;
9
+
10
+ let solution = inventory:: iter :: < solution:: Solution >
11
+ . into_iter ( )
12
+ . find ( |solution| solution. day == cli. day && solution. part == cli. part )
13
+ . unwrap_or_else ( || panic ! ( "No solution found for day {} part {}" , cli. day, cli. part) ) ;
14
+
15
+ let ans = ( solution. run ) ( & input) ;
16
+ println ! ( "{}" , ans) ;
17
+
18
+ Ok ( ( ) )
19
+ }
20
+
21
+ #[ derive( Parser , Debug ) ]
22
+ #[ command( author, version, about, long_about = None ) ]
23
+ struct Cli {
24
+ /// AoC day
25
+ #[ arg( short, long) ]
26
+ day : usize ,
27
+
28
+ /// AoC part
29
+ #[ arg( short, long) ]
30
+ part : usize ,
31
+
32
+ /// Input override, otherwise defaults to ./input/d{day}.txt
33
+ #[ arg( short, long) ]
34
+ input_file : Option < String > ,
35
+ }
36
+
37
+ inventory:: collect!( solution:: Solution ) ;
38
+
39
+ mod day1;
40
+ mod day10;
41
+ mod day11;
42
+ mod day12;
43
+ mod day13;
44
+ mod day14;
45
+ mod day15;
46
+ mod day16;
47
+ mod day17;
48
+ mod day18;
49
+ mod day19;
50
+ mod day2;
51
+ mod day20;
52
+ mod day21;
53
+ mod day22;
54
+ mod day23;
55
+ mod day24;
56
+ mod day25;
57
+ mod day3;
58
+ mod day4;
59
+ mod day5;
60
+ mod day6;
61
+ mod day7;
62
+ mod day8;
63
+ mod day9;
64
+ pub mod hashmap;
65
+ mod solution;
66
+ pub mod tuplearray;
67
+ mod util;
68
+
69
+ use clap:: Parser ;
70
+
71
+ extern crate openblas_src;
Original file line number Diff line number Diff line change 1
1
fn main ( ) -> anyhow:: Result < ( ) > {
2
- let cli = Cli :: parse ( ) ;
3
-
4
- let input_file = cli
5
- . input_file
6
- . unwrap_or ( format ! ( "./input/d{}.txt" , cli. day) ) ;
7
-
8
- let input = std:: fs:: read_to_string ( input_file) ?;
9
-
10
- let solution = inventory:: iter :: < solution:: Solution >
11
- . into_iter ( )
12
- . find ( |solution| solution. day == cli. day && solution. part == cli. part )
13
- . unwrap_or_else ( || panic ! ( "No solution found for day {} part {}" , cli. day, cli. part) ) ;
14
-
15
- let ans = ( solution. run ) ( & input) ;
16
- println ! ( "{}" , ans) ;
17
-
18
- Ok ( ( ) )
2
+ aoc2023:: run ( )
19
3
}
20
-
21
- #[ derive( Parser , Debug ) ]
22
- #[ command( author, version, about, long_about = None ) ]
23
- struct Cli {
24
- /// AoC day
25
- #[ arg( short, long) ]
26
- day : usize ,
27
-
28
- /// AoC part
29
- #[ arg( short, long) ]
30
- part : usize ,
31
-
32
- /// Input override, otherwise defaults to ./input/d{day}.txt
33
- #[ arg( short, long) ]
34
- input_file : Option < String > ,
35
- }
36
-
37
- inventory:: collect!( solution:: Solution ) ;
38
-
39
- mod day1;
40
- mod day10;
41
- mod day11;
42
- mod day12;
43
- mod day13;
44
- mod day14;
45
- mod day15;
46
- mod day16;
47
- mod day17;
48
- mod day18;
49
- mod day19;
50
- mod day2;
51
- mod day20;
52
- mod day21;
53
- mod day22;
54
- mod day23;
55
- mod day24;
56
- mod day25;
57
- mod day3;
58
- mod day4;
59
- mod day5;
60
- mod day6;
61
- mod day7;
62
- mod day8;
63
- mod day9;
64
- pub mod hashmap;
65
- mod solution;
66
- pub mod tuplearray;
67
- mod util;
68
-
69
- use clap:: Parser ;
70
-
71
- extern crate openblas_src;
You can’t perform that action at this time.
0 commit comments