public void TestFindPossibleSums() { var factorFinder = new FactorFinder(); var abundantNumberFinder = new AbundantNumberFinder(factorFinder); var collator = new SumCollator(); var possibleSumsFinder = new PossibleSumsFinder(abundantNumberFinder, collator); Assert.That(possibleSumsFinder.FindSumsForAbundantNumbers(0), Is.EqualTo(new int[] {})); Assert.That(possibleSumsFinder.FindSumsForAbundantNumbers(1), Is.EqualTo(new int[] {})); Assert.That(possibleSumsFinder.FindSumsForAbundantNumbers(25), Is.EqualTo(new[] { 24, 30, 32, 36, 36, 38, 40, 42, 44, 48 })); }
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)); }
public void TestFindSumsForAbundantNumbers() { var col = new SumCollator(); var ff = new FactorialFinder(); var af = new AbundantNumberFinder(ff); var driver = new Driver(af, col); Assert.That(driver.FindSumsForAbundantNumbers(12), Is.EqualTo(new int[] {})); Assert.That(driver.FindSumsForAbundantNumbers(24), Is.EqualTo(new[] { 30, 32, 36, 38, 42, 44 })); Assert.That(driver.FindSumsForAbundantNumbers(0), Is.EqualTo(new int[] { })); Assert.That(driver.FindSumsForAbundantNumbers(2), Is.EqualTo(new int[] { })); }
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 })); }
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")); }
public void DoSetup() { mCollator = new SumCollator(); }