Combinatorics grouping problem
Posted
by Harry Pap
on Stack Overflow
See other posts from Stack Overflow
or by Harry Pap
Published on 2010-05-09T07:36:00Z
Indexed on
2010/05/09
7:38 UTC
Read the original article
Hit count: 466
I'm looking for an algorithm in c# that solves a combinatorics problem:
Assume i have the objects 1,2,3,4
I want to get all possible ways to group these object in multiple groups, that each time contain all objects. Order is not important. Example:
<1,2,3,4> <1,2 / 3,4> <1,3 / 2,4> <1,4 / 3,2> <1,2,3 / 4> <1,2,4 / 3> <1,3,4 / 2> <2,3,4 / 1> <1 / 2 / 3 / 4>
In the first case there is one group that contain all 4 objects. Next are cases with 2 groups that contain all objects in many different ways. The last case is 4 groups, that each one contains only one object.
© Stack Overflow or respective owner