Part 2 :
$packages = $input->numbers();
function solve($groups, $packages) {
$goal = $packages->sum() / $groups;
foreach (range(0, $packages->count()) as $size) {
$qes = [];
foreach ($packages->combinations($size, $size) as $comb) {
if (array_sum($comb) == $goal) {
$qes[] = array_product($comb);
}
}
if ($qes) return min($qes);
}
}
$solution_1 = solve(3, $packages);
$solution_2 = solve(4, $packages);