Example #1
0
 public void Setup()
 {
     problem = new Problem3 ();
     problem.Constraints.Add (new Constraint("\"one minute rule\"", x=>x.SolveTime < TimeSpan.FromMinutes(1)));
     problem.ProblemStarted += (object sender, EventArgs e) => Console.WriteLine("Starting: " + sender.ToString ());
     problem.ProblemStopped += (object sender, EventArgs e) => Console.WriteLine ("Stopped: " + sender.ToString ());;
     problem.ConstraintEvaluationFailed += (object sender, Constraint e) => Assert.Fail (string.Format ("Constraint: {0} failed!", e.Name));
     problem.ConstraintEvaluationSuccess += (object sender, Constraint e) => Console.WriteLine (string.Format ("Constraint: {0} success!", e.Name));
 }
Example #2
0
        public void Problem3_Can_Solve()
        {
            // Arrange
            var expected = 6857;
            var target = new Problem3();

            // Act
            var result = target.Solve();
            var imperativeResult = ImperativeSolution();
            var functionalResult = FunctionalSolution();

            // Assert
            Assert.AreEqual(expected, result);
            Assert.AreEqual(expected, imperativeResult);
            Assert.AreEqual(expected, functionalResult);
        }
Example #3
0
        public static void Main(string[] args)
        {
            Console.WriteLine($"Problem1: Find the sum of all the multiples of 3 or 5 below 1000. Answer : {Problem1.Solve(3, 5, Problem1BelowValue-1)}");

            Console.WriteLine($"Problem2: By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. Answer : {Problem2.Solve(Problem2FibLimt)}");

            Console.WriteLine($"Problem3: What is the largest prime factor of the number 600851475143? Answer : {Problem3.Solve(Problem3LargestPrime)}");

            Console.WriteLine($"Problem4 :  Find the largest palindrome made from the product of two 3-digit numbers. Answer : {Problem4.Solve()}");

            Console.WriteLine($"Problem5 :  What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?. Answer : {Problem5.Solve(20)}");

            Console.WriteLine($"Problem6 :  Find the difference between the sum of the squares of the first 100 natural numbers and the square of the sum. Answer : {Problem6.Solve(100)}");

            Console.WriteLine($"Problem7 :  What is the 10 001st prime number? Answer : {Problem7.Solve1(10001)}");

            Console.WriteLine($"Problem8 :  Find the thirteen adjacent digits in the 1000-digit number that have the greatest product. What is the value of this product? Answer : {Problem8.Solve(13)}");
        }
 public void SetUp()
 {
     problem = new Problem3();
 }
Example #5
0
 public void FindPrimeFactorTest()
 {
     Problem3 target = new Problem3(); // TODO: Initialize to an appropriate value
     target.FindPrimeFactor();
 }