Esempio n. 1
0
        public void Test14()
        {
            var p     = new Problem14();
            var value = p.Solution1();

            Assert.Equal(837799, value);
        }
 public void Problem14_ShouldReturn_837799()
 {
     Assert.Throws <NotImplementedException>(() =>
     {
         Problem14.GetResult();
     });
 }
Esempio n. 3
0
        public void Test_FindStartingNumberWithLongestCollatzSequence_1000000AsMaxUpperBound_Returns13()
        {
            var upperBound      = 14;
            var problem14Runner = new Problem14();

            var numberOfCores = Environment.ProcessorCount;

            var results = new (int, int)[numberOfCores];
Esempio n. 4
0
        static void Main(string[] args)
        {
            IProblem problem = new Problem14();

            var startTime = DateTime.Now;
            var result = problem.Solve();
            var diff = DateTime.Now - startTime;
            Console.WriteLine(result);
            Console.WriteLine(diff);
            Console.ReadKey(true);
        }
Esempio n. 5
0
        public void FindPartOneTest()
        {
            var testInput = new []
            {
                "mask = XXXXXXXXXXXXXXXXXXXXXXXXXXXXX1XXXX0X",
                "mem[8] = 11",
                "mem[7] = 101",
                "mem[8] = 0"
            };

            Assert.AreEqual(165, Problem14.FindAnswer(testInput, true));
        }
Esempio n. 6
0
        public void FindPartTwoTest()
        {
            var testInput = new []
            {
                "mask = 000000000000000000000000000000X1001X",
                "mem[42] = 100",
                "mask = 00000000000000000000000000000000X0XX",
                "mem[26] = 1"
            };

            Assert.AreEqual(208, Problem14.FindAnswer(testInput, false));
        }
Esempio n. 7
0
        public void Test14(int a, int b, int c)
        {
            string expected = new int[] { a, b, c }.Max().ToString();

            using (var sw = new StringWriter())
            {
                using (var sr = new StringReader($"{a}\n{b}\n{c}"))
                {
                    Console.SetIn(sr);
                    Console.SetOut(sw);
                    Problem14.Main();
                }
                string result = sw.ToString().Trim();

                Assert.AreEqual(expected, result);
            }
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            //Console.WriteLine(Problem1.MultiplesOf3And5());
            //Console.WriteLine(Problem2.EvenFibonacciNumbers());
            //Console.WriteLine(Problem3.LargestPrimeFactor());
            //Console.WriteLine(Problem4.LargestPalindromeProduct());
            //Console.WriteLine(Problem5.SmallestMultiple());
            //Console.WriteLine(Problem6.SumSquareDifference());
            //Console.WriteLine(Problem7.ThousandAndOnePrime());
            //Console.WriteLine(Problem8.LargestProductInAeries());
            //Console.WriteLine(Problem9.SpecialPythagoreanTriplet());
            //Console.WriteLine(Problem10.SummationOfPrimes());
            //Console.WriteLine(Problem11.LargestProductInAGrid());
            //Console.WriteLine(Problem12.HighlyDivisibleTriangularNumber());
            //Console.WriteLine(Problem13.LargeSum());



            var watch = new System.Diagnostics.Stopwatch();

            watch.Start();

            for (int i = 0; i < 1; i++)
            {
                Console.WriteLine(Problem14.Calc(1000000));
            }


            Console.WriteLine($"Execution Time: {watch.ElapsedMilliseconds} ms");
            //Console.WriteLine(Problem15.LatticePaths());
            //Console.WriteLine(Problem16.SumOfNumber());
            //Console.WriteLine(Problem17.NumberLetterCounts());
            //Console.WriteLine(Problem18.MaximumPathSumI());
            //Console.WriteLine(Problem19.CountingSundays());
            //Console.WriteLine(Problem20.FactorialDigitSum());

            //Console.WriteLine(Problem21.AmicableNumbers());



            Console.ReadKey();
        }
Esempio n. 9
0
        public void Solution_SolutionForProblem14_ReturnsLongestCollatzChainNumber()
        {
            var result = Problem14.Solution();

            Assert.AreEqual(837799, result);
        }
Esempio n. 10
0
        public void CollatzValue_ExampleNumbers_ReturnsValue(int n, int v)
        {
            var r = Problem14.CollatzValue(n);

            Assert.AreEqual(v, r);
        }
        public void Problem14_Return_Result_837799()
        {
            long act = Problem14.LongestCollatzSequence();

            Assert.True(act.Equals(837799));
        }
 public void Problem14_ShouldReturn_837799()
 {
     Assert.Equal(Problem14.LongChainInNumber(), 837799);
 }