starting day 7
This commit is contained in:
parent
5fedf5b0ac
commit
90b352362a
11
2023/07/Part1.pm
Normal file
11
2023/07/Part1.pm
Normal file
@ -0,0 +1,11 @@
|
||||
use 5.38.0;
|
||||
|
||||
package Part1;
|
||||
|
||||
use List::AllUtils qw/ /;
|
||||
|
||||
sub solution_1 ($input) {
|
||||
...;
|
||||
}
|
||||
|
||||
1;
|
14
2023/07/Part2.pm
Normal file
14
2023/07/Part2.pm
Normal file
@ -0,0 +1,14 @@
|
||||
use 5.38.0;
|
||||
|
||||
package Part2;
|
||||
|
||||
use Part1;
|
||||
|
||||
use List::AllUtils qw/ /;
|
||||
|
||||
|
||||
sub solution_2 ($input) {
|
||||
...;
|
||||
}
|
||||
|
||||
1;
|
43
2023/07/benchmark.pl
Normal file
43
2023/07/benchmark.pl
Normal file
@ -0,0 +1,43 @@
|
||||
use 5.38.0;
|
||||
|
||||
use Benchmark ':hireswallclock';
|
||||
use Path::Tiny;
|
||||
use JSON qw/ to_json /;
|
||||
use DateTime;
|
||||
use File::Serialize;
|
||||
|
||||
use Part1;
|
||||
use Part2;
|
||||
|
||||
my $day = path('.')->absolute->basename =~ s/^0//r;
|
||||
my $year = path('.')->absolute->parent->basename;
|
||||
my $solutions = deserialize_file('solutions.yml');
|
||||
|
||||
my @parts = (
|
||||
{ part => 1, sub => \&Part1::solution_1, expected => $solutions->{1} },
|
||||
{ part => 2, sub => \&Part2::solution_2, expected => $solutions->{2} },
|
||||
);
|
||||
|
||||
my $input = path('./input')->slurp;
|
||||
|
||||
for my $part (@parts) {
|
||||
my $res = Benchmark::countit(
|
||||
10,
|
||||
sub {
|
||||
$part->{sub}->($input) == $part->{expected} or die;
|
||||
}
|
||||
);
|
||||
|
||||
my $result = {
|
||||
day => $day,
|
||||
year => $year,
|
||||
|
||||
#variant => '',
|
||||
language => 'perl',
|
||||
part => $part->{part},
|
||||
time => $res->cpu_a / $res->iters,
|
||||
timestamp => DateTime->now->iso8601,
|
||||
};
|
||||
say to_json $result;
|
||||
}
|
||||
|
13
2023/07/part1.t
Normal file
13
2023/07/part1.t
Normal file
@ -0,0 +1,13 @@
|
||||
use 5.38.0;
|
||||
|
||||
use Test2::V0;
|
||||
|
||||
use Path::Tiny;
|
||||
|
||||
use Part1;
|
||||
|
||||
my $input = path('input')->slurp;
|
||||
|
||||
is Part1::solution_1($input) => 'TODO';
|
||||
|
||||
done_testing;
|
13
2023/07/part2.t
Normal file
13
2023/07/part2.t
Normal file
@ -0,0 +1,13 @@
|
||||
use 5.38.0;
|
||||
|
||||
use Test2::V0;
|
||||
|
||||
use Path::Tiny;
|
||||
|
||||
use Part2;
|
||||
|
||||
my $input = path('input')->slurp;
|
||||
|
||||
is Part2::solution_2($input) => 'TODO';
|
||||
|
||||
done_testing;
|
2
2023/07/solutions.yml
Normal file
2
2023/07/solutions.yml
Normal file
@ -0,0 +1,2 @@
|
||||
1: TODO
|
||||
2: TODO
|
@ -4,16 +4,18 @@ use Benchmark ':hireswallclock';
|
||||
use Path::Tiny;
|
||||
use JSON qw/ to_json /;
|
||||
use DateTime;
|
||||
use File::Serialize;
|
||||
|
||||
use Part1;
|
||||
use Part2;
|
||||
|
||||
my $day = path('.')->absolute->basename =~ s/^0//r;
|
||||
my $year = path('.')->absolute->parent->basename;
|
||||
my $solutions = deserialize_file('solutions.yml');
|
||||
|
||||
my @parts = (
|
||||
{ part => 1, sub => \&Part1::solution_1, expected => 'TODO' },
|
||||
{ part => 2, sub => \&Part2::solution_2, expected => 'TODO' },
|
||||
{ part => 1, sub => \&Part1::solution_1, expected => $solutions->{1} },
|
||||
{ part => 2, sub => \&Part2::solution_2, expected => $solutions->{2} },
|
||||
);
|
||||
|
||||
my $input = path('./input')->slurp;
|
||||
|
Loading…
Reference in New Issue
Block a user