Example #1
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));
        }
Example #2
0
        public void TestUsage()
        {
            var collator             = new SumCollator();
            var factorFinder         = new FactorFinder();
            var abundantNumberFinder = new AbundantNumberFinder(factorFinder);
            var driver = new PossibleSumsFinder(abundantNumberFinder, collator);
            var runner = new MysteryNumberFinder(driver);
            var result = runner.Execute(24);

            Assert.That(runner.Execute(24), Is.EqualTo(new [] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }));
            Assert.That(runner.Execute(25), Is.EqualTo(new [] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }));
            Assert.That(runner.Execute(36), Is.EqualTo(new [] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 31, 33, 34, 35 }));
            Assert.That(runner.Execute(0), Is.EqualTo(new int[] {}));
            Assert.That(runner.Execute(1), Is.EqualTo(new [] { 0 }));
        }
Example #3
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"));
        }
Example #4
0
 public Problem23Runner(MysteryNumberFinder mysterNumberFinder, FinalValueCounter valueCounter)
 {
     mMysteryNumberFinder = mysterNumberFinder;
     mValueCounter        = valueCounter;
 }