This commit is contained in:
Yanick Champoux 2017-12-03 19:57:32 -05:00
parent 14029d26a5
commit 115e014fe1
2 changed files with 27 additions and 0 deletions

15
2015/02/wrapping.pl Normal file
View File

@ -0,0 +1,15 @@
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;

12
2015/02/wrapping_2.pl Normal file
View File

@ -0,0 +1,12 @@
use 5.20.0;
use Algorithm::Combinatorics qw( combinations );
use List::AllUtils qw/ sum min product /;
my $total;
say sum
map { 2 * ( $_->[0] + $_->[1] ), product @$_ }
map {[ sort { $a <=> $b } split 'x' ]} <>;