of size N into an K subgroups. I've been trying for hours to do this and still haven't found a solution.(adsbygoogle = window.adsbygoogle || []).push({});

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 someCode (Text):

List<T> stuff;

that has a value and hasCode (Text):

int k;

I want to populate a structureCode (Text):

0 < k <= stuff.Length

that represents all the move combinations. Can't figure out how to write this algorithm.Code (Text):

List<List<Tuple<T,T>>> partitions;

Let me know if I need to provide more clarity.

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# C/++/# Finding all the "move combinations" to partition an array

Tags:

Have something to add?

Draft saved
Draft deleted

**Physics Forums | Science Articles, Homework Help, Discussion**