- #1
SlurrerOfSpeech
- 141
- 11
of size N into an K subgroups. I've been trying for hours to do this and still haven't found a solution.
Example: The array {A,B,C} of size N=3 and I want all the move combinations that make it into K=1 subgroups. The only such subgroup is the one with all the elements, and I can get that with the move combinations
B -> A, C -> A
C -> A, B -> A
A -> B, C -> B
C -> B, A -> B
A -> C, B -> C
B -> C, A -> C
If K=2 then the move combinations are
A -> B (now we have { {A,B}, {C} })
B -> A (now we have { {A,B}, {C} })
B -> C (now we have { {A}, {B,C} })
C -> B (now we have { {A}, {B,C} })
A -> C (now we have { {B}, {A,C} })
C -> A (now we have { {B}, {A,C} })
Hope that makes sense.
To be even more concrete, in terms of C#, what I have is a list
that I've populated with values. Given some
that has a value and has
I want to populate a structure
that represents all the move combinations. Can't figure out how to write this algorithm.
Let me know if I need to provide more clarity.
Example: The array {A,B,C} of size N=3 and I want all the move combinations that make it into K=1 subgroups. The only such subgroup is the one with all the elements, and I can get that with the move combinations
B -> A, C -> A
C -> A, B -> A
A -> B, C -> B
C -> B, A -> B
A -> C, B -> C
B -> C, A -> C
If K=2 then the move combinations are
A -> B (now we have { {A,B}, {C} })
B -> A (now we have { {A,B}, {C} })
B -> C (now we have { {A}, {B,C} })
C -> B (now we have { {A}, {B,C} })
A -> C (now we have { {B}, {A,C} })
C -> A (now we have { {B}, {A,C} })
Hope that makes sense.
To be even more concrete, in terms of C#, what I have is a list
Code:
List<T> stuff;
that I've populated with values. Given some
Code:
int k;
that has a value and has
Code:
0 < k <= stuff.Length
I want to populate a structure
Code:
List<List<Tuple<T,T>>> partitions;
that represents all the move combinations. Can't figure out how to write this algorithm.
Let me know if I need to provide more clarity.