it begins
This commit is contained in:
parent
a163421f2c
commit
7b44d73c50
@ -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) {
|
||||
...;
|
||||
}
|
||||
|
@ -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';
|
||||
|
Loading…
Reference in New Issue
Block a user