예제 #1
0
        public void SolveTest2()
        {
            var postOrderTraversal = new List <int> {
                7, 4, 6, 5
            };

            Assert.IsFalse(Problem006.Solve(postOrderTraversal));
        }
예제 #2
0
        public void SolveTest1()
        {
            var postOrderTraversal = new List <int> {
                5, 7, 6, 9, 11, 10, 8
            };

            Assert.IsTrue(Problem006.Solve(postOrderTraversal));
        }
예제 #3
0
        public void Problem006()
        {
            var problem = new Problem006()
            {
                ConsoleOutput = false, DetailedOutput = false
            };

            Assert.AreEqual(25164150L, problem.Answer());
        }
예제 #4
0
파일: TestCSharp.cs 프로젝트: ajdust/euler
        public void IsCorrectProblem006()
        {
            var problem = new Problem006();

            Assert.Equal(Answers["6"], problem.Solve());
        }
예제 #5
0
 static void Main(string[] args)
 {
     //Check if the user entered the question number as required
     if (args.Length == 0)
     {
         Console.Out.Write("You must enter in the question number you want solved!");
     }
     else
     {
         //Make sure the question number they entered is in the correct format
         try
         {
             int num = Int32.Parse(args[0]);
         }
         catch (Exception ex)
         {
             Console.Out.Write(ex.ToString());
             Environment.Exit(0);
         }
         //Execute the code for the desired question by accessing the class containing the desired algorithm.
         int questionNum = Int32.Parse(args[0]);
         switch(questionNum)
         {
             case 1:
                 Problem001 problem001 = new Problem001();
                 problem001.run();
                 break;
             case 2:
                 Problem002 problem002 = new Problem002();
                 problem002.run();
                 break;
             case 3:
                 Problem003 problem003 = new Problem003();
                 problem003.run();
                 break;
             case 4:
                 Problem004 problem004 = new Problem004();
                 problem004.run();
                 break;
             case 5:
                 Problem005 problem005 = new Problem005();
                 problem005.run();
                 break;
             case 6:
                 Problem006 problem006 = new Problem006();
                 problem006.run();
                 break;
             case 7:
                 Problem007 problem007 = new Problem007();
                 problem007.run();
                 break;
             case 8:
                 Problem008 problem008 = new Problem008();
                 problem008.run();
                 break;
             case 9:
                 Problem009 problem009 = new Problem009();
                 problem009.run();
                 break;
             case 10:
                 Problem010 problem010 = new Problem010();
                 problem010.run();
                 break;
             case 11:
                 Problem011 problem011 = new Problem011();
                 problem011.run();
                 break;
             case 12:
                 Problem012 problem012 = new Problem012();
                 problem012.run();
                 break;
             default:
                 Console.Out.WriteLine("The question number you entered does not exist!");
                 break;
         }
     }
 }
예제 #6
0
        public void Problem006_Next_Prime_Test_1()
        {
            long act = Problem006.NextPrime(12);

            Assert.True(act.Equals(13));
        }
예제 #7
0
        public void Problem006_Next_Prime_Test_6()
        {
            long act = Problem006.NextPrime(9566326356);

            Assert.True(act.Equals(9566326409));
        }
예제 #8
0
        public void Problem006_Next_Prime_Test_5()
        {
            long act = Problem006.NextPrime(0);

            Assert.True(act.Equals(2));
        }