-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·60 lines (45 loc) · 996 Bytes
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env perl
use v5.38;
my $year;
BEGIN {
$year = shift || die 'requires year';
unshift @INC, "$year/lib";
}
use lib 'lib';
use lib 'local/lib/perl5';
use Solution::External;
use Util;
binmode STDOUT, ':encoding(UTF-8)';
my $day = shift;
my @days;
if ($day && $day =~ m{ \A (\d+) (?: \.\. (\d+))? \z }x) {
my $day_from = $1;
my $day_to = $2 || $day_from;
@days = $day_from .. $day_to;
}
die 'requires day number(s)'
if !@days;
my $language = shift;
my $total_time = 0;
foreach my $day (@days) {
my $obj;
if ($language) {
$obj = Solution::External->new(
year => $year,
day => $day,
language => $language,
);
}
else {
my $pkg = "Day${day}::Solution";
eval "use $pkg; 1" or die "error loading solution for day $day:\n$@";
$obj = $pkg->new(year => $year);
}
$obj->part_1;
$total_time += $obj->timer;
$obj->part_2;
$total_time += $obj->timer;
}
if (@days > 1) {
Util->print_time($total_time, header => 'Total', time_multiplier => @days * 2);
}