18 lines
250 B
Perl
18 lines
250 B
Perl
|
package Day1::Part2;
|
||
|
|
||
|
use 5.36.0;
|
||
|
|
||
|
use List::Util qw/ sum pairmap /;
|
||
|
use List::MoreUtils qw/ part zip /;
|
||
|
|
||
|
sub solve($l1,$l2) {
|
||
|
my %occur;
|
||
|
|
||
|
$occur{$_}++ for @$l2;
|
||
|
|
||
|
no warnings qw/ uninitialized /;
|
||
|
sum map { $occur{$_}*$_ } @$l1;
|
||
|
}
|
||
|
|
||
|
1;
|