adventofcode/2015/02/wrapping.pl
Yanick Champoux 115e014fe1 day2
2017-12-03 19:57:32 -05:00

16 lines
301 B
Perl

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;