@@ -19,7 +19,7 @@ fn main() {
19
19
} ;
20
20
21
21
// Filter solutions
22
- let solutions = empty ( )
22
+ let solutions: Vec < _ > = empty ( )
23
23
. chain ( year2015 ( ) )
24
24
. chain ( year2016 ( ) )
25
25
. chain ( year2017 ( ) )
@@ -31,35 +31,31 @@ fn main() {
31
31
. chain ( year2023 ( ) )
32
32
. chain ( year2024 ( ) )
33
33
. filter ( |solution| year. is_none_or ( |y : u32 | y == solution. year ) )
34
- . filter ( |solution| day. is_none_or ( |d : u32 | d == solution. day ) ) ;
34
+ . filter ( |solution| day. is_none_or ( |d : u32 | d == solution. day ) )
35
+ . collect ( ) ;
35
36
36
- // Pretty print output and timing for each solution
37
- let mut solved = 0 ;
37
+ // Pretty print output for each solution.
38
38
let mut duration = Duration :: ZERO ;
39
39
40
- for Solution { year, day, path, wrapper } in solutions {
41
- if let Ok ( data) = read_to_string ( & path) {
40
+ for Solution { year, day, path, wrapper } in & solutions {
41
+ if let Ok ( data) = read_to_string ( path) {
42
42
let instant = Instant :: now ( ) ;
43
43
let ( part1, part2) = wrapper ( data) ;
44
- let elapsed = instant. elapsed ( ) ;
45
-
46
- solved += 2 ;
47
- duration += elapsed;
44
+ duration += instant. elapsed ( ) ;
48
45
49
46
println ! ( "{BOLD}{YELLOW}{year} Day {day:02}{RESET}" ) ;
50
47
println ! ( " Part 1: {part1}" ) ;
51
48
println ! ( " Part 2: {part2}" ) ;
52
- println ! ( " Elapsed: {} μs" , elapsed. as_micros( ) ) ;
53
49
} else {
54
50
eprintln ! ( "{BOLD}{RED}{year} Day {day:02}{RESET}" ) ;
55
51
eprintln ! ( " Missing input!" ) ;
56
52
eprintln ! ( " Place input file in {BOLD}{WHITE}{}{RESET}" , path. display( ) ) ;
57
53
}
58
54
}
59
55
60
- // Optionally print totals
56
+ // Optionally print totals.
61
57
if args ( ) . any ( |a| a == "--totals" ) {
62
- println ! ( "{BOLD}{YELLOW}⭐ {solved }{RESET}" ) ;
58
+ println ! ( "{BOLD}{YELLOW}⭐ {}{RESET}" , 2 * solutions . len ( ) ) ;
63
59
println ! ( "{BOLD}{WHITE}🕓 {} ms{RESET}" , duration. as_millis( ) ) ;
64
60
}
65
61
}
0 commit comments