Wonder if this can be accomplished in Maple.

so I have a list of 100 items labeled {1..100} of various value {$100, $160, $220, ...... , }

the task is to distribute these items among 3 people A,B,C so they get an approximately equal share.

Adding the values and dividing by 3 gives the dollar total to aim for.

This post has C.Love procedure for evenly sized groups

http://www.mapleprimes.com/questions/200480-Product-Grouping

but what i want is a method for different sized groups. ie 25 items for A, 35 for B and 40 for C (user defined).

additionally there is a fixed constraint: A has been bequeathed items 1,4,8; B items 2 and 20; C item 50.

**restart:**

**S:= {3, 4, 5, 6, 8, 9, 28, 30, 35}:**

**SL:= [A,B,C,D,E,F,G,H,I]:**

**assign(Labels ~ (S) =~ SL); #Create remember table.**

**AllP:= [seq(P, P= Iterator:-SetPartitions(S, [[3,3]], compile= false))]:**

**lnp:= evalf(ln((`*`(S[]))^(1/3))):**

**Var:= proc(P::({list,set}(set)))**

**local r:= evalf(`+`(map(b-> abs(ln(`*`(b[]))-lnp), P)[]));**

**end proc:**

**Min:= proc(S::{list,set}, P::procedure)**

**local M:= infinity, X:= (), x, v;**

** for x in S do**

** v:= P(x);**

** if v < M then M:= v; X:= x end if**

** end do;**

** X**

**end proc:**

**ans:= Min(AllP, Var);**

[{3, 9, 35}, {4, 8, 28}, {5, 6, 30}]

**subsindets(ans, posint, Labels);**

[{I, A, F}, {B, E, G}, {C, D, H}]