Skip to content

Commit 9f684be

Browse files
committed
Remove inaccurate timing info
1 parent 70dac10 commit 9f684be

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/main.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919
};
2020

2121
// Filter solutions
22-
let solutions = empty()
22+
let solutions: Vec<_> = empty()
2323
.chain(year2015())
2424
.chain(year2016())
2525
.chain(year2017())
@@ -31,35 +31,31 @@ fn main() {
3131
.chain(year2023())
3232
.chain(year2024())
3333
.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();
3536

36-
// Pretty print output and timing for each solution
37-
let mut solved = 0;
37+
// Pretty print output for each solution.
3838
let mut duration = Duration::ZERO;
3939

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) {
4242
let instant = Instant::now();
4343
let (part1, part2) = wrapper(data);
44-
let elapsed = instant.elapsed();
45-
46-
solved += 2;
47-
duration += elapsed;
44+
duration += instant.elapsed();
4845

4946
println!("{BOLD}{YELLOW}{year} Day {day:02}{RESET}");
5047
println!(" Part 1: {part1}");
5148
println!(" Part 2: {part2}");
52-
println!(" Elapsed: {} μs", elapsed.as_micros());
5349
} else {
5450
eprintln!("{BOLD}{RED}{year} Day {day:02}{RESET}");
5551
eprintln!(" Missing input!");
5652
eprintln!(" Place input file in {BOLD}{WHITE}{}{RESET}", path.display());
5753
}
5854
}
5955

60-
// Optionally print totals
56+
// Optionally print totals.
6157
if args().any(|a| a == "--totals") {
62-
println!("{BOLD}{YELLOW}⭐ {solved}{RESET}");
58+
println!("{BOLD}{YELLOW}⭐ {}{RESET}", 2 * solutions.len());
6359
println!("{BOLD}{WHITE}🕓 {} ms{RESET}", duration.as_millis());
6460
}
6561
}

0 commit comments

Comments
 (0)