preps for day 2

This commit is contained in:
Yanick Champoux 2023-12-01 13:03:18 -05:00
parent f14bd1d1b8
commit 679dbbe180
5 changed files with 88 additions and 0 deletions

11
2023/02/Part1.pm Normal file
View File

@ -0,0 +1,11 @@
use 5.38.0;
package Part1;
use List::AllUtils qw/ /;
sub solution_1 ($input) {
...;
}
1;

14
2023/02/Part2.pm Normal file
View File

@ -0,0 +1,14 @@
use 5.38.0;
package Part2;
use Part1;
use List::AllUtils qw/ /;
sub solution_2 ($input) {
...;
}
1;

41
2023/02/benchmark.pl Normal file
View File

@ -0,0 +1,41 @@
use 5.38.0;
use Benchmark ':hireswallclock';
use Path::Tiny;
use JSON qw/ to_json /;
use DateTime;
use Part1;
use Part2;
my $day = path('.')->absolute->basename =~ s/^0//r;
my $year = path('.')->absolute->dir->basename;
my @parts = (
{ part => 1, sub => \&Part1::solution_1, expected => 'TODO' },
{ part => 2, sub => \&Part2::solution_2, expected => 'TODO' },
);
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;
}

11
2023/02/part1.t Normal file
View File

@ -0,0 +1,11 @@
use 5.38.0;
use Test2::V0;
use Path::Tiny;
use Part1;
my $input = path('input')->slurp;
is Part1::solution_1($input) => 'TODO';

11
2023/02/part2.t Normal file
View File

@ -0,0 +1,11 @@
use 5.38.0;
use Test2::V0;
use Path::Tiny;
use Part2;
my $input = path('input')->slurp;
is Part2::solution_2($input) => 'TODO';