コード例 #1
0
        public void ReturnsFalse_NoArray()
        {
            Question6 q = new Question6(
                new int[] {  },
                12);

            q.Run();
            Assert.AreEqual(q.Result, false);
        }
コード例 #2
0
        public void ReturnsFalse()
        {
            Question6 q = new Question6(
                new int[] { 6, 2, 4, 7, 8, 2 },
                16);

            q.Run();
            Assert.AreEqual(q.Result, false);
        }
コード例 #3
0
        public void ReturnsTrue()
        {
            Question6 q = new Question6(
                new int[] { 6, 2, 4, 7, 8, 2 },
                12);

            q.Run();
            Assert.AreEqual(q.Result, true);
        }
コード例 #4
0
 public static void Run()
 {
     // warms up the methods
     Question1.Answer(0.0, 0.0, 0.0);
     Question2.Answer(new int[] { 0 }, new int[] { 0 }, new int[] { 0 });
     Question3.Answer(new int[] { 0 }, new int[] { 0 });
     Question4.Answer(new int[] { 0 }, new int[] { 0 }, 0);
     Question5.Answer(new int[] { 0 });
     Question6.Answer(new string[] { "AA", "AA" });
 }
コード例 #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello PTG world!");

            Question1 questionOne = new Question1();

            int[] testOne      = new int[] { 2, 7, 11, 15 };
            int[] resultOne    = questionOne.TwoSumIterative(testOne, 9);
            int[] resultOnePT2 = questionOne.TwoSumEfficient(testOne, 9);
            Console.WriteLine("[{0}]", string.Join(", ", resultOne));
            Console.WriteLine("[{0}]", string.Join(", ", resultOnePT2));

            Question2 questionTwo = new Question2();

            int[] testTwo = new int[] { 3, 2, 2, 3, 3, 4, 5, 6, 9, 3 };
            Console.WriteLine($"Initial Lenght: {questionTwo.InitialLength(testTwo, 3)}");
            Console.WriteLine($"Final Lenght: {questionTwo.NewLength(testTwo, 3)}");

            Question3 question3 = new Question3();

            int[] test3Arr1       = new int[] { 1, 2, 3, 0, 0, 0 };
            int[] test3Arr2       = new int[] { 2, 5, 6 };
            int[] question3Result = question3.MergeSort(test3Arr1, test3Arr2);
            Console.WriteLine("Question 3");
            Console.WriteLine("[{0}]", string.Join(", ", question3Result));

            Question4 question4 = new Question4();

            Question5 question5 = new Question5();

            Console.WriteLine("Question 5:");
            string q5InTrue  = "A man,!  -  a plAn, a canal: Panama";
            string q5InFasle = "race a car";

            Console.WriteLine($"Q5 Should be TRUE:  {question5.ValidPalindrome(q5InTrue)}");
            Console.WriteLine($"Q5 Should be FALSE:  {question5.ValidPalindrome(q5InFasle)}");

            Question6 question6 = new Question6();

            Console.WriteLine("");
            Console.WriteLine("QUESTION 6");
            string simple     = "(([[{{";
            string test6True  = "(){}[]";
            string test6True2 = "}}))(({{[]";
            string test6False = "{{{{((()(){{{{}}{{[[]{{{{{";

            Console.WriteLine($"Q6 false should be: {question6.HashMapCharacterValidation(simple)}");
            Console.WriteLine($"Q6 True should be: {question6.HashMapCharacterValidation(test6True)}");
            Console.WriteLine($"True should be for starting with close: {question6.HashMapCharacterValidation(test6True2)}");
            Console.WriteLine($"False should be: {question6.HashMapCharacterValidation(test6False)}");

            Console.ReadLine();
        }
コード例 #6
0
            public void ThenTheValueIsFormattedCorrectly()
            {
                var mockDependency = new Mock <IQuestion6Dependency>();

                mockDependency.Setup(x => x.GetValueFromDatabase()).Returns("Test12");

                var question6 = new Question6(mockDependency.Object);

                string result = question6.GetFirstSixCharactersOfDatabaseValue();

                result.Should().Be("Test12");
            }
コード例 #7
0
        protected override void OnDisappearing()
        {
            base.OnDisappearing();

            Question1.RemoveBehaviors();
            Question2.RemoveBehaviors();
            Question3.RemoveBehaviors();
            Question4.RemoveBehaviors();
            Question5.RemoveBehaviors();
            Question6.RemoveBehaviors();
            Question7.RemoveBehaviors();
        }
コード例 #8
0
        TimedAnswer <int> getSixthAnwser(Test <Server> test)
        {
            var timer = new Stopwatch();

            var server = test.GetInput();

            timer.Start();

            var answer = Question6.Answer(server.numServers, server.target, server.arcs);

            timer.Stop();

            var timeTaken = ((double)timer.ElapsedTicks / Stopwatch.Frequency) * 1000000000;

            return(new TimedAnswer <int>(answer, timeTaken));
        }
コード例 #9
0
        Answer getSixthAnswer(string[] input, TestCase test)
        {
            var timer = new Stopwatch();

            timer.Start();

            var answer = Question6.Answer(input);

            timer.Stop();

            var timeTaken = ((double)timer.ElapsedTicks / Stopwatch.Frequency) * 1000000000;

            return(new Answer()
            {
                questionNumber = 6,
                testNumber = test.testNumber,
                correct = answer == test.output ? "CORRECT" : "INCORRECT",
                speed = timeTaken
            });
        }
コード例 #10
0
 public void Run()
 {
     Question6.Run();
 }