Closed GoogleCodeExporter closed 9 years ago
Why don't you use all permutations for all 3-combinations generated from the
initial vector of 4 items?
Here is an example:
// Create the initial vector of 4 elements (apple, orange, cherry, raspberry)
ICombinatoricsVector<String> originalVector = Factory.createVector(
new String[] { "apple", "orange", "cherry", "raspberry" }
);
// Create the combination generator by calling the appropriate method in the Factory class
Generator<String> combinations = Factory.createSimpleCombinationGenerator(originalVector, 3);
// Print all permutations for all simple 3-combinations
for (ICombinatoricsVector<String> comb : combinations){
Generator<String> permutations = Factory.createPermutationGenerator(comb);
for(ICombinatoricsVector<String> perm : permutations){
System.out.println(perm);
}
}
You will see the following result:
CombinatoricsVector=([apple, orange, cherry], size=3)
CombinatoricsVector=([apple, cherry, orange], size=3)
CombinatoricsVector=([cherry, apple, orange], size=3)
CombinatoricsVector=([cherry, orange, apple], size=3)
CombinatoricsVector=([orange, cherry, apple], size=3)
CombinatoricsVector=([orange, apple, cherry], size=3)
CombinatoricsVector=([apple, orange, raspberry], size=3)
CombinatoricsVector=([apple, raspberry, orange], size=3)
CombinatoricsVector=([raspberry, apple, orange], size=3)
CombinatoricsVector=([raspberry, orange, apple], size=3)
CombinatoricsVector=([orange, raspberry, apple], size=3)
CombinatoricsVector=([orange, apple, raspberry], size=3)
CombinatoricsVector=([apple, cherry, raspberry], size=3)
CombinatoricsVector=([apple, raspberry, cherry], size=3)
CombinatoricsVector=([raspberry, apple, cherry], size=3)
CombinatoricsVector=([raspberry, cherry, apple], size=3)
CombinatoricsVector=([cherry, raspberry, apple], size=3)
CombinatoricsVector=([cherry, apple, raspberry], size=3)
CombinatoricsVector=([orange, cherry, raspberry], size=3)
CombinatoricsVector=([orange, raspberry, cherry], size=3)
CombinatoricsVector=([raspberry, orange, cherry], size=3)
CombinatoricsVector=([raspberry, cherry, orange], size=3)
CombinatoricsVector=([cherry, raspberry, orange], size=3)
CombinatoricsVector=([cherry, orange, raspberry], size=3)
Original comment by d.pau...@gmail.com
on 24 Apr 2015 at 9:07
True. Thanks a lot! :-)
Original comment by k...@kra.lc
on 24 Apr 2015 at 9:36
Original comment by d.pau...@gmail.com
on 24 Apr 2015 at 9:38
Original issue reported on code.google.com by
k...@kra.lc
on 24 Apr 2015 at 8:23