Untitled.png

Hi fellow coders

I have a question in regards to an algorithm problem I am trying to solve.

The input data to the algorithm is a matrix that can be described as follows:

The matrix has N dimensions, like the one in the attached picture (which has 2 dimensions for example).

There are a number of elements (denoted as c1, .. c5 in the attached sample matrix) that are mapped into the cells of the matrix.

An element can occur in one or more cells in the matrix.

The algorithm should work as follows:

Pick (and then remove) elements from the matrix and group them into buckets of E elements, so that:

1. the elements in each bucket don't have any common values on any of the dimensions
2. each element is assigned only into one bucket

For example, referring to the sample matrix attached, if we selected E to be 2, then a possible grouping could be: {c1, c2} ; {c3, c4} and {5} by itself. Check: c1 and c2 (and c3 and c4) don't have any common column or row values in the matrix.

The problem has been doing my head in for some time now and I thought it may be worth asking if some whiz here has a solution.

Thanks