adventofcode/2018/02/sol1.pl

29 lines
456 B
Perl
Raw Normal View History

2018-12-02 16:17:21 +00:00
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