Sorry for bad English and thanks for your help in advance I have to explain one kind of tricky problem I've encountered while coding. Here's the point:

I need a script that essentially do this: extract the 5 max values of 5 arrays, that are "mixed", i.e. they contain "recurrent" values. Here is an example:

array1(a, b)

array2(a, c, d, e, g)

array3(b, d, g, h)

array4(e, t, z)

array5(b, c, d, k)

**The 2 essential request are the following:**

1) the sum of those 5 arrays (array1+array2+array3...) MUST be the highest possible...

2) ...without repeat ANY value previously used(e.g. if in array1 the top value was "b", this cannot be re-taken as max value in the arrays 3 or 5).

1) the sum of those 5 arrays (array1+array2+array3...) MUST be the highest possible...

2) ...without repeat ANY value previously used

Currently I coded like this...:

- Code: Select all
`$group1 = array(a, b);`

$group = array(a, b, c, d);

$max1a = max(group1);

$max2a = max(group2) unset($max1a);

$sum1 = $max1a + $max2a;

$max2b = max(group2);

$max1b = max(group1) unset($max2b);

$sum2 = $max1b + $max2b;

if($sum1 > $sum2) {echo $sum1}

else {echo $sum2}

... but it's kinda impossible to use this code with 5 arrays, because I should compare 5! (120 ) combinations in order to find the max sum value.

I know the problem is quite difficult to explain and to solve, but I very need your help and I hope you can save me!!!

Cheers