it begins

main
Yanick Champoux 2023-12-02 11:17:13 -05:00
parent a163421f2c
commit 7b44d73c50
2 changed files with 21 additions and 0 deletions

View File

@ -4,6 +4,20 @@ package Part1;
use List::AllUtils qw/ /;
sub parse_line($line) {
my %data;
$line =~ s/Game (\d+)://;
$data{game} = $1;
my @entries = split ';', $line;
$data{entries} = [
map { +{ map { /(\d+) (\w+)/; $2 => $1 } split ",", $_ } } @entries
];
return \%data;
}
sub solution_1 ($input) {
...;
}

View File

@ -6,6 +6,13 @@ use Path::Tiny;
use Part1;
is Part1::parse_line("Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green") => +{ game => 1, entries => [
{ blue => 3, red => 4 }, { red => 1, green => 2, blue => 6},
{ green => 2 },
]};
my $input = path('input')->slurp;
is Part1::solution_1($input) => 'TODO';