sanjeeb-talukdar / combinatoricslib

Automatically exported from code.google.com/p/combinatoricslib
0 stars 0 forks source link

Treat repeated elements of sinple permutation as identical #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

ICombinatoricsVector<Integer> corePermutation = Factory.createVector(new 
Integer[]{1, 2, 2, 3});

 Generator<Integer> generator = Factory.createPermutationGenerator(corePermutation);

 Map<List<Integer>,Character> seenVectors = new HashMap<List<Integer>, Character>();
 Character ch = 'A';
 for (ICombinatoricsVector<Integer> perm : generator) {
         List<Integer> vector = perm.getVector();
         String repeatStr = " -- "+ch;
         if(seenVectors.containsKey(vector))
             repeatStr = " -- Repeated "+seenVectors.get(vector);
         else
             seenVectors.put(vector, ch++);
         System.out.println(perm+repeatStr);
 }

What is the expected output? What do you see instead?

CombinatoricsVector=([1, 2, 2, 3], size=4) -- A
CombinatoricsVector=([1, 2, 3, 2], size=4) -- B
CombinatoricsVector=([1, 3, 2, 2], size=4) -- C
CombinatoricsVector=([3, 1, 2, 2], size=4) -- D
CombinatoricsVector=([3, 1, 2, 2], size=4) -- Repeated D
CombinatoricsVector=([1, 3, 2, 2], size=4) -- Repeated C
CombinatoricsVector=([1, 2, 3, 2], size=4) -- Repeated B
CombinatoricsVector=([1, 2, 2, 3], size=4) -- Repeated A
CombinatoricsVector=([2, 1, 2, 3], size=4) -- E
CombinatoricsVector=([2, 1, 3, 2], size=4) -- F
CombinatoricsVector=([2, 3, 1, 2], size=4) -- G
CombinatoricsVector=([3, 2, 1, 2], size=4) -- H
CombinatoricsVector=([3, 2, 2, 1], size=4) -- I
CombinatoricsVector=([2, 3, 2, 1], size=4) -- J
CombinatoricsVector=([2, 2, 3, 1], size=4) -- K
CombinatoricsVector=([2, 2, 1, 3], size=4) -- L
CombinatoricsVector=([2, 2, 1, 3], size=4) -- Repeated L
CombinatoricsVector=([2, 2, 3, 1], size=4) -- Repeated K
CombinatoricsVector=([2, 3, 2, 1], size=4) -- Repeated J
CombinatoricsVector=([3, 2, 2, 1], size=4) -- Repeated I
CombinatoricsVector=([3, 2, 1, 2], size=4) -- Repeated H
CombinatoricsVector=([2, 3, 1, 2], size=4) -- Repeated G
CombinatoricsVector=([2, 1, 3, 2], size=4) -- Repeated F
CombinatoricsVector=([2, 1, 2, 3], size=4) -- Repeated E

All repeated permutations have to be removed

Original issue reported on code.google.com by d.pau...@gmail.com on 21 Sep 2012 at 12:45

GoogleCodeExporter commented 9 years ago

Original comment by d.pau...@gmail.com on 21 Sep 2012 at 3:58

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r147.

Original comment by d.pau...@gmail.com on 21 Sep 2012 at 4:01