Exemple #1
0
        public void TestUsage()
        {
            var collator             = new SumCollator();
            var valueCounter         = new FinalValueCounter();
            var factorFinder         = new FactorFinder();
            var abundantNumberFinder = new AbundantNumberFinder(factorFinder);
            var possibleSumsFinder   = new PossibleSumsFinder(abundantNumberFinder, collator);
            var mysteryNumFinder     = new MysteryNumberFinder(possibleSumsFinder);
            var p23Runner            = new Problem23Runner(mysteryNumFinder, valueCounter);

            Assert.That(p23Runner.Execute(0), Is.EqualTo("0"));
            Assert.That(p23Runner.Execute(1), Is.EqualTo("0"));
            Assert.That(p23Runner.Execute(2), Is.EqualTo("1"));
            Assert.That(p23Runner.Execute(25), Is.EqualTo("276"));
            Assert.That(p23Runner.Execute(36), Is.EqualTo("544"));
        }
Exemple #2
0
        private static void ExecuteProblem23(int max)
        {
            var collator             = new SumCollator();
            var factorFinder         = new FactorFinder();
            var abundantNumberFinder = new AbundantNumberFinder(factorFinder);
            var valueCounter         = new FinalValueCounter();
            var possibleSumFinder    = new PossibleSumsFinder(abundantNumberFinder, collator);
            var mysteryNumberFinder  = new MysteryNumberFinder(possibleSumFinder);
            var problem23Runner      = new Problem23Runner(mysteryNumberFinder, valueCounter);

            Console.WriteLine(problem23Runner.Execute(max));
        }