Ejemplo n.º 1
0
        internal static long PandigitalPrimeSets(List <long> digits)
        {
            if (digits.Count == 0)
            {
                return(1);
            }
            long count = 0;

            digits.Sort();
            var maxElement   = digits[digits.Count - 1];
            var restOfDigits = UtilityFunctions.Complement(new List <long> {
                maxElement
            }, digits);
            var subsets = UtilityFunctions.GenerateSubsets(restOfDigits);

            foreach (var subset in subsets)
            {
                subset.Add(maxElement);
                var complement           = UtilityFunctions.Complement(subset, digits);
                var subsetDigitSignature = UtilityFunctions.DigitSignature(subset, ProblemDigits);
                count += PrimeCandidates[subsetDigitSignature].Count * PandigitalPrimeSets(complement);
            }
            return(count);
        }