in reply to determine numbers of boxes needed per weight


I think your Problem is a Knapsack problem . There is a cpan module for Knapsack Algorithm (Algorithm::Knapsack)

Algorithm::Knapsack
use Algorithm::Knapsack; my $knapsack = Algorithm::Knapsack->new( capacity => $capacity, weights => \@weights, ); $knapsack->compute(); foreach my $solution ($knapsack->solutions()) { foreach my $index (@{$solution}) { # do something with $weights[$index] } }


-perl_lover-

Edit: g0n - reparented to root node