in reply to Constraint Satisfaction Problem

This pretty much sounds like the NP-problem "filling sacks with loot", so obviously the best answer can't be solved in poly-time.

However, an alternate solution that should get you close is to sort the list by the number of items in that list. Also calculate the Z/N ratio to know what to aim for (eg 100 people with 5 benefits managers should have Z/N = 20).

Take the letter with teh most frequent distribution, then add letters from the bottom of the list items until the sum total is just greater than Z/N (or within some range of it). Put that list aside, and repeat for all N managers. Assuming a sufficiently good distribution of last names, this really shouldn't be a problem.

If any item on the distribution is greater than Z/N by itself, (say, the S's or M's) break it up and go from there.


Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain