Basic structure; day 1, 2

This commit is contained in:
bluepython508
2024-12-03 10:34:33 +00:00
commit b24b64a22c
12 changed files with 2164 additions and 0 deletions

6
day-01/example-1 Normal file
View File

@@ -0,0 +1,6 @@
3 4
4 3
2 5
1 3
3 9
3 3

1000
day-01/input Normal file

File diff suppressed because it is too large Load Diff

21
day-01/main.raku Normal file
View File

@@ -0,0 +1,21 @@
use lib $*PROGRAM.parent.parent;
use Lib;
grammar Solution does AOC {
token TOP { (^^ <line> \n)+ { make ([Z] $/[0]>><line>>>.made).List; }}
token line { <num> <.ws> <num> { make $<num>>>.made }}
token num { \d+ { make val($/.Str) }}
method part1(::?CLASS:U: (@l, @r)) {
[+] (@l.sort <<->> @r.sort)>>.abs
}
method part2(::?CLASS:U: (@l, @r)) {
my $bag = @r.Bag;
[+] @l.map(-> $l { $l * $bag{$l} })
}
}
Solution.main()