On 4/16/2011 2:22 AM, R.E. Boss wrote:
> m=: /:~ 23 43 12 54 7 3 5 10 54 55 26 9 9 43 54 1 8 6 38 33
> bu=: 4
>
>     ({:,~ 2-/\]) (({~/:)+])/\. (/:(>./-<./)"1)(-bu)[\&.|.m
> 55 54 54 54
>   7  9  8  9
>   1  3  6  5
> 33 38 43 43
Nice. But:

    p =. ({:,~ 2-/\]) (({~/:)+])/\. (/:(>./-<./)"1)(-bu)[\&.|.m
    p
55 54 54 54
  7  9  8  9
  1  3  6  5
33 38 43 43
26 23 12 10
    +/p
122 127 123 121

This is a solution, but it isn't the smallest-difference solution. 
Viktor gave the minimal-difference  solution to the 20-mass 5-bucket 
problem.in his earlier email.

Victor posted:

   conf

  0  0  2  3 1 0 3  3  0  2  1 1 2  1  3 1 2 2  1  2
23 43 12 54 7 3 5 10 54 55 26 9 9 43 54 1 8 6 38 33

    +//./conf
123 123 123 124

    </./conf
?????????????????????????????????????????????????????
?23 43 3 54?12 55 9 8 6 33?54 5 10 54?7 26 9 43 1 38?
?????????????????????????????????????????????????????

Your solution may be the minimal-difference solution when all of the 
buckets have the same number of masses in each bucket, but that wasn't 
the original problem. The problem is to find the minimal mass difference 
for any partition of m, not just equal-sized partitions.

Skip

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to