add preset for a perl day
This commit is contained in:
parent
679dbbe180
commit
a163421f2c
1
2023/preset/day/.gitignore
vendored
Normal file
1
2023/preset/day/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
19
2023/preset/day/README.md
Normal file
19
2023/preset/day/README.md
Normal file
@ -0,0 +1,19 @@
|
||||
<p align="center">
|
||||
<br />
|
||||
<a href="https://preset.dev">
|
||||
<img width="100" src="https://raw.githubusercontent.com/preset/preset/main/.github/assets/logo.svg" alt="Logo of Preset">
|
||||
</a>
|
||||
<br />
|
||||
</p>
|
||||
|
||||
<h2 align="center">day</h2>
|
||||
<pre><div align="center">npx @preset/cli apply username//home/yanick/work/javascript/adventofcode/2023/preset/day</div></pre>
|
||||
|
||||
<br />
|
||||
|
||||
<div align="center">
|
||||
This preset was made by Yanick Champoux.
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://preset.dev">Learn more</a>
|
||||
</div>
|
6
2023/preset/day/package.json
Normal file
6
2023/preset/day/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"author": "Yanick Champoux <yanick@babyl.ca>",
|
||||
"license": "MIT",
|
||||
"preset": "preset.ts"
|
||||
}
|
14
2023/preset/day/preset.ts
Normal file
14
2023/preset/day/preset.ts
Normal file
@ -0,0 +1,14 @@
|
||||
export default definePreset({
|
||||
name: 'day',
|
||||
options: {
|
||||
perl: true,
|
||||
},
|
||||
handler: async(context) => {
|
||||
if( context.options.perl ) {
|
||||
await extractTemplates({
|
||||
from: 'perl', whenConflict: 'skip'
|
||||
})
|
||||
}
|
||||
// ...
|
||||
},
|
||||
})
|
0
2023/preset/day/templates/.gitkeep
Normal file
0
2023/preset/day/templates/.gitkeep
Normal file
11
2023/preset/day/templates/perl/Part1.pm
Normal file
11
2023/preset/day/templates/perl/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/preset/day/templates/perl/Part2.pm
Normal file
14
2023/preset/day/templates/perl/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;
|
41
2023/preset/day/templates/perl/benchmark.pl
Normal file
41
2023/preset/day/templates/perl/benchmark.pl
Normal 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/preset/day/templates/perl/part1.t
Normal file
11
2023/preset/day/templates/perl/part1.t
Normal 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/preset/day/templates/perl/part2.t
Normal file
11
2023/preset/day/templates/perl/part2.t
Normal 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';
|
18
2023/preset/day/tsconfig.json
Normal file
18
2023/preset/day/tsconfig.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "esnext",
|
||||
"baseUrl": ".",
|
||||
"target": "es2016",
|
||||
"lib": ["esnext"],
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"types": ["node", "@preset/core/globals"]
|
||||
},
|
||||
"include": [
|
||||
"./*.ts",
|
||||
"./src/**/*.ts"
|
||||
],
|
||||
"exclude": ["templates", "node_modules"]
|
||||
}
|
Loading…
Reference in New Issue
Block a user