adventofcode/2018/02/sol1.pl
Yanick Champoux 9d40efda2b part 1
2018-12-02 11:17:21 -05:00

29 lines
456 B
Perl

use 5.20.0;
use warnings;
use experimental qw/
signatures
postderef
/;
use List::UtilsBy qw/ partition_by /;
use List::AllUtils qw/ pairmap sum product /;
my @items =
map {
+{
pairmap { scalar @$b => $a }
partition_by { $_ }
@$_
}
}
map { [ split '' ] }
<>;
say product
map { scalar @$_ }
map {
my $x = $_;
[ grep { $_->{$x} } @items ]
} 2, 3