I have 8 categories, and about a hundred items. Each item can fit into 1, 2, 3 or 4 of these categories (and we know which ones each item can fit into). The task is to have 'the most even distribution' of the items among the categories, i.e. it is best if all the categories have something in them before putting more than one into a category. Once an item has been placed in a category, it cannot be repeated in another.
Example 1, with eight items
Categories labelled, A to H. Items are represented by X's.
Code:
A | B | C | D | E | F | G | H ---------------------------- X | X | X | X | X | X | X | X .......Table (1) A | B | C | D | E | F | G | H ---------------------------- X | X | X | X | X | | X | X X | | | | | | | .......Table (2) A | B | C | D | E | F | G | H ---------------------------- X | X | X | X | X | | | X X | | X | | | | | .......Table (3)
Example 2, with ten items
Categories labelled, A to H. Items are represented by X's.
Code:
A | B | C | D | E | F | G | H ---------------------------- X | X | X | X | X | X | X | X .......Table (1) X | | X | | | | | A | B | C | D | E | F | G | H ---------------------------- X | X | X | X | X | | X | X X | | X | X | | | | .......Table (2) A | B | C | D | E | F | G | H ---------------------------- X | X | X | X | X | | | X | X | X | X | | | | | X | | | | | | .......Table (3)
Example data:
Code:
Item X could fit into category A. Item Y could fit into categories A or B. Item Z could fit into category C. Item W could fit into categories B or F.
I'm having some difficulty thinking of an algorithm for this, and I don't know what to search for in my favourite search engine (which may or may not begin with a G), so help, please!

