tidy
This commit is contained in:
parent
4c98ac6a61
commit
c1984999cf
@ -4,7 +4,7 @@ package Part1;
|
||||
|
||||
use List::AllUtils qw/ max sum /;
|
||||
|
||||
sub parse_line($line) {
|
||||
sub parse_line ($line) {
|
||||
my %data;
|
||||
$line =~ /Game (\d+):/;
|
||||
$data{game} = $1;
|
||||
@ -18,7 +18,7 @@ sub solution_1 ($input) {
|
||||
sum
|
||||
map { $_->{game} }
|
||||
grep { $_->{red} <= 12 and $_->{blue} <= 14 and $_->{green} <= 13 }
|
||||
map { parse_line($_)}
|
||||
map { parse_line($_) }
|
||||
split "\n", $input;
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,8 @@ use List::AllUtils qw/ min product sum /;
|
||||
|
||||
sub solution_2 ($input) {
|
||||
sum
|
||||
map { product $_->@{qw/ red blue green /}}
|
||||
map { Part1::parse_line($_)}
|
||||
map { product $_->@{qw/ red blue green /} }
|
||||
map { Part1::parse_line($_) }
|
||||
split "\n", $input;
|
||||
}
|
||||
|
||||
|
@ -6,10 +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,
|
||||
blue => 6, red => 4, green => 2
|
||||
};
|
||||
is Part1::parse_line(
|
||||
"Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green") => +{
|
||||
game => 1,
|
||||
blue => 6,
|
||||
red => 4,
|
||||
green => 2
|
||||
};
|
||||
|
||||
is Part1::solution_1( <<'END' ) => 8;
|
||||
Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green
|
||||
|
Loading…
Reference in New Issue
Block a user