示例#1
0
        public IEnumerable <string> GenerateCodeSpecifiedByRequirements(CodeRequirements requirements,
                                                                        char[] codeAlphabet)
        {
            var variations      = variationsGenerator.GenerateVariations(codeAlphabet, requirements.CodewordsLength);
            var filteredResults = FilterResultsByDistance(variations, requirements.MinimalHammingDistance)
                                  .Distinct();

            return(filteredResults.Take(requirements.NumberOfCodewords));
        }
示例#2
0
        public static void Main(string[] args)
        {
            var requirements        = new CodeRequirements(4, 9, 3);
            var distanceCalculator  = new HammingDistanceCalculator();
            var variationsGenerator = new VariationsGenerator();
            var codeGeneraor        = new CodeGenerator(variationsGenerator, distanceCalculator);

            foreach (var generateCodeSpecifiedByRequirement in codeGeneraor.GenerateCodeSpecifiedByRequirements(requirements, new[] { '0', '1', '2' }))
            {
                Console.WriteLine(generateCodeSpecifiedByRequirement);
            }
        }