adventofcode/2015/02/wrapping.pl

16 lines
301 B
Perl
Raw Normal View History

2017-12-04 00:57:32 +00:00
use 5.20.0;
use Algorithm::Combinatorics qw( combinations );
use List::AllUtils qw/ sum min product /;
my $total;
for(map {[ split 'x' ]} <>) {
my $x = [ combinations($_,2) ];
my @v = map { product @$_ } combinations( $_, 2 );
$total += sum min( @v ), map { 2*$_ } @v;
}
say $total;