McNuggets problem: Difference between revisions

→‎{{header|Perl}}: Use standard arguments, change a couple helper functions.
m (→‎{{header|Perl}}: add libheader)
(→‎{{header|Perl}}: Use standard arguments, change a couple helper functions.)
Line 437:
{{trans|Perl 6}}
{{libheader|ntheory}}
<lang perl>use List::Utilntheory qw(all/forperm min)vecall vecmin/;
use ntheory qw/forperm/;
 
sub Mcnugget_number {
ourmy @counts; local *$counts = shift;
 
return 'No maximum' if allvecall { 0 == $_%2 } @$counts;
 
my $min = minvecmin @$counts;
my @meals;
my @min;
Line 457 ⟶ 456:
forperm {
$meals[
$s[$_[0]] * $counts->[0]
+ $s[$_[1]] * $counts->[1]
+ $s[$_[2]] * $counts->[2]
] = 1;
} @s;
Anonymous user