I would like to know if there's a known algorithm or best practice way to do the following:
I have a collection with a subcollection, for example:
R1 R2 R3 -- -- -- M M M N N L L A
What i need is an algorithm to get the following result:
R1, R2: M N L R2: A R3: M
This is -not- what i want, it has more repeating values for R than the above:
R1, R2, R3: M R1, R2: N L R2: A
I need to group in way that i get the most optimized groups of R. The least amount of groups of R the better so i get the largest sub collections.
Another example (with the most obvious result):
R1 R2 R3 -- -- -- M M A V V B L L C
Should result in:
R1, R2: M V L R3: A B C
I need to do this in LINQ/C#.
Any solutions? Tips? Links?