I looking for a solution for my problem: I have to write a code which calculates a combination of unique elements, that is all different combinations of n elements chosen as group of k elemets and recalculate the new combination of the remain subset without replication. Given S, the set of all possible unique elements, I have to calculate a subset T of unique combination of elements of S, now I have to recalcuate a new subset - V - of combination of T and all the subset T and V must be unique:
For example I have this set S: {0, 1, 2, 3, 4}
I have to obtain
a {0, 1} {2, 3} { 4}
b {0, 1} {2, 4} { 3}
c {0, 1} {3, 4} { 2}
d {0, 2} {1, 3} { 4}
e {0, 2} {1, 4} { 3}
f {0, 2} {3, 4} { 1}
g {0, 3} {1, 2} { 4}
h {0, 3} {1, 4} { 2}
i {0, 3} {2, 4} { 1}
j {0, 4} {1, 2} { 3}
k {0, 4} {1, 3} { 2}
l {0, 4} {2, 3} { 1}
discarded as the same as g -> {1, 2} {0, 3} { 4}
discarded as the same as j -> {1, 2} {0, 4} { 3}
m {1, 2} {3, 4} {0}
discarded as the same as d -> {1, 3} {0, 2} { 4}
discarded as the same as k -> {1, 3} {0, 4} { 2}
n {1, 3} {2, 4}{ 0}
discarded as the same as e -> {1, 4} {0, 2} { 3}
discarded as the same as h -> {1, 4} {0, 3} { 2}
o {1, 4} {2, 3}{0}
discarded as the same as a -> {2, 3} {0, 1} { 4}
discarded as the same as l -> {2, 3} {0, 4} { 1}
discarded as the same as o -> {2, 3} {1, 4} { 0}
discarded as the same as b -> {2, 4} {0, 1} { 3}
discarded as the same as i -> {2, 4} {0, 3} { 1}
discarded as the same as n -> {2, 4} {1, 3} { 0}
discarded as the same as c -> {3, 4} {0, 1} { 2}
discarded as the same as f -> {3, 4} {0, 2} { 1}
discarded as the same as m -> {3, 4} {1, 2} { 0}
The combination {1, 2} {0, 3} { 4} as the same of (for this question) of {0, 3} {1, 2} { 4} and then must be discarded, the same for {1, 2} {0, 4} { 3} and {0, 4} {1, 2} { 3}.
Is it possible to reach the goal without using a data structure (as a list) that takes into account the combinations already obtained ?
I need something like this: Generating Combinations: 1
It is not a duplicate of previous question, because the research involves partitions that must be considered univocal, ie the elements contained in them (regardless of their order) must not have already been consensual in a previous subdivision so for example {1, 2} {0, 4} { 3} and {0, 4} {1, 2} { 3} must be considered non-unique, and therefore only a combination is valid: {0, 4} {1, 2} { 3}
n/k
unordered sets ofk
elements each, and one unordered set ofn%k
elements, all unique elements within each entire "combination", taken from a set ofn
unique elements, withk
fixed. Sounds very much like a grouping problem (a subtype of combinatorics problems) to me. Interesting.. – Linseed