Exemple #1
0
        protected IPermutationsCollection ProcessPermutations(StreamReader reader, int n)
        {
            string line;
            int    maxValue;
            int    lengthLongestAvoider         = 0;
            IPermutationsCollection collection  = new PermutationCollection();
            List <string[]>         parsedLines = new List <string[]>();

            string[] parsedLine;

            while (!reader.EndOfStream)
            {
                line                 = reader.ReadLine();
                parsedLine           = line.Split(new [] { '-' }, StringSplitOptions.RemoveEmptyEntries);
                lengthLongestAvoider = Math.Max(lengthLongestAvoider, parsedLine.Length);
                parsedLines.Add(parsedLine);
            }

            for (int i = 0; i < parsedLines.Count; i++)
            {
                parsedLine = parsedLines[i];
                maxValue   = Math.Max(n, lengthLongestAvoider);
                byte letterSize = (byte)((int)(Math.Ceiling(Math.Log(maxValue, 2))));
                collection.Add(builder.CreatePattern(parsedLine, letterSize));
            }

            return(collection);
        }
Exemple #2
0
        private IPermutationsCollection CreatePermutationsUnChecked(Permutation permutation, ExtensionMap extensionMap)
        {
            PermutationCollection permutationCollection = new PermutationCollection();

            foreach (var position in extensionMap.Ctz())
            {
                permutationCollection.Add(permutation.InsertPosition(position));
            }

            return(permutationCollection);
        }
        public MinimumLettersChecked(IPermutationsCollection permutationsAvoided)
        {
            permutationsUpfixes = new IPermutationsCollection[permutationsAvoided.LengthLongestPermutation];

            for (int i = 0; i < permutationsAvoided.LengthLongestPermutation; i++)
            {
                permutationsUpfixes[i] = new PermutationCollection();
            }

            foreach (var permutation in permutationsAvoided)
            {
                ComputeUpfixes(permutation, permutation.ComputeInversion());
            }
        }
Exemple #4
0
        private IPermutationsCollection CreatePermutationsChecked(Permutation permutation, ExtensionMap extensionMap,
                                                                  IPermutationsCollection avoidedPermutations)
        {
            PermutationCollection permutationCollection = new PermutationCollection();
            Permutation           newPermutation;

            foreach (var position in extensionMap.Ctz())
            {
                newPermutation = permutation.InsertPosition(position);
                if (!avoidedPermutations.Contains(newPermutation))
                {
                    permutationCollection.Add(newPermutation);
                }
            }

            return(permutationCollection);
        }