Пример #1
0
        protected override void Solve(out string answer)
        {
            var list = new List <Representation>();

            Parallelization.GetParallelRanges(1, 10_000, 4).ForAll(sequence =>
            {
                foreach (int number in sequence)
                {
                    foreach (int maxMultiplier in Enumerable.Range(2, 99))
                    {
                        var candidate = new Representation(number, maxMultiplier);
                        if (candidate.IsPandigital())
                        {
                            lock (this) list.Add(candidate);
                            break;  //If pandigit is found, multiplying by higher multipliers definitely will fail.
                        }
                    }
                }
            });
            var result = list.OrderByDescending(item => item.Pandigits);
            var max    = result.First();

            answer = $"Count = {list.Count}, Largest pandigital: {max}";
        }