Пример #1
0
        public void FrogRiverOneSolutionTest()
        {
            FrogRiverOne testPermCheck = new FrogRiverOne();

            int[] arrayTest = new int[] { 1, 3, 1, 4, 2, 3, 5, 4 };
            Assert.AreEqual(6, testPermCheck.Solution(5, arrayTest));
        }
Пример #2
0
        public void FindShoulReturnEarliestTimeWhichFrogCanJumpWhenGivenNonEmptyArrayAndJumpSize(int x, int[] a, int expected)
        {
            FrogRiverOne finder = new FrogRiverOne();
            int          actual = finder.Find(x, a);

            Assert.AreEqual(expected, actual);
        }
Пример #3
0
        public void test_solution_withGivenArray_returnsTheEarliestTimeWhenTheFrogCanJump(int[] given, int expected,
                                                                                          int distance)
        {
            var target = new FrogRiverOne();
            var actual = target.solution(distance, given);

            Assert.AreEqual(expected, actual);
        }
Пример #4
0
        public void FrogRiverOneSolutionTest()
        {
            var frog = new FrogRiverOne();

            int[] array  = new int[] { 1, 3, 1, 4, 2, 3, 5, 4 };
            int   result = frog.Solve(5, array);

            Assert.AreEqual(6, result);
        }
Пример #5
0
        public void TestMethod3()
        {
            int x = 3;

            int[] input    = { 1, 3, 1, 3, 2, 1 };
            int   expected = 4;
            int   result   = FrogRiverOne.Solution(x, input);

            Assert.AreEqual(expected, result);
        }
Пример #6
0
        public void FrogRiverOne_Should_Handle_Empty_Array()
        {
            FrogRiverOne subject = new FrogRiverOne();

            int[] array = { };

            int result = subject.solution(1, array);

            Assert.Equal(-1, result);
        }
Пример #7
0
        public void FrogRiverOne_Should_Validate_Complete_Array()
        {
            FrogRiverOne subject = new FrogRiverOne();

            int[] array = { 1, 3, 1, 4, 2, 3, 5, 4 };

            int result = subject.solution(5, array);

            Assert.Equal(6, result);
        }
Пример #8
0
        public void TestMethod1()
        {
            int x = 5;

            int[] input    = { 1, 3, 1, 4, 2, 3, 5, 4 };
            int   expected = 6;
            int   result   = FrogRiverOne.Solution(x, input);

            Assert.AreEqual(expected, result);
        }
Пример #9
0
        public void TestMethod2()
        {
            int x = 5;

            int[] input    = { 3 };
            int   expected = -1;
            int   result   = FrogRiverOne.Solution(x, input);

            Assert.AreEqual(expected, result);
        }
Пример #10
0
        public void FrogRiverOne_Should_Validate_Complex_Array()
        {
            FrogRiverOne subject = new FrogRiverOne();

            int[] array = { 4, 1, 2, 8, 7, 3, 2, 6, 1, 2, 9, 11, 13, 14, 16, 17, 12, 13, 14, 15, 18, 5, 10 };

            int result = subject.solution(10, array);

            Assert.Equal(22, result);
        }
Пример #11
0
        public void FrogRiverOne_Should_Invalidate_Incomplete_Array()
        {
            FrogRiverOne subject = new FrogRiverOne();

            int[] array = { 4, 1, 2 };

            int result = subject.solution(5, array);

            Assert.Equal(-1, result);
        }
Пример #12
0
        public void SolutionTest_02()
        {
            var solution = new FrogRiverOne();

            int[] A        = new int[] { 1, 3, 1, 4, 2, 3, 5, 4 };
            int   X        = 5;
            int   expected = 6;
            int   actual   = solution.Solution(X, A);

            Assert.AreEqual(expected, actual);
        }
Пример #13
0
 public void Setup()
 {
     _binaryGap          = new BinaryGap();
     _arrayRotation      = new ArrayRotation();
     _unpairedElements   = new UnpairedElements();
     _frogJump           = new FrogJump();
     _permMissingElement = new PermMissingElement();
     _tapeEquilibrium    = new TapeEquilibrium();
     _frogRiverOne       = new FrogRiverOne();
     _maxCounters        = new MaxCounters();
     _missingInteger     = new MissingInteger();
 }
Пример #14
0
        public void SolutionSimpleTest()
        {
            // Arrange
            int[] A = new int[] { 1, 3, 1, 4, 2, 3, 5, 4 };
            int   X = 5;

            // Action
            int actual = FrogRiverOne.Solution(X, A);

            // Assert
            int expected = 6;

            Assert.AreEqual(expected, actual);
        }
Пример #15
0
        public void SolutionFrogCantCrossTest()
        {
            // Arrange
            int[] A = new int[] { 1, 1, 1, 1 };
            int   X = 5;

            // Action
            int actual = FrogRiverOne.Solution(X, A);

            // Assert
            int expected = -1;

            Assert.AreEqual(expected, actual);
        }
Пример #16
0
        private static void RunFrogRiverOne()
        {
            Console.WriteLine($" --------- 4.2 FrogRiverOne --------- ");

            var result = FrogRiverOne.Solution(5, new int[] { 1, 3, 1, 4, 2, 3, 5, 4 });

            Console.WriteLine($"result = {result}");
            var result2 = FrogRiverOne.Solution(2, new int[] { 2, 2, 2 });

            Console.WriteLine($"result = {result2}");
            var result3 = FrogRiverOne.Solution(1, new int[] { 1 });

            Console.WriteLine($"result = {result3}");
        }
Пример #17
0
        public void Case1()
        {
            // Arrange
            var algorithm = new FrogRiverOne();
            int X         = 5;
            var A         = new int[] { 1, 3, 1, 4, 2, 3, 5, 4 };

            // Act
            var result = algorithm.solution(X, A);

            // Assert
            var expected = 6;

            Assert.Equal(expected, result);
        }
Пример #18
0
        public void SolutionFrogCanCrossBigNumbersTest()
        {
            // Arrange
            int X = 100000;

            int[] A = new int[X];


            for (int i = 0; i < X; i++)
            {
                A[i] = i + 1;
            }

            // Action
            int actual = FrogRiverOne.Solution(X, A);

            // Assert
            int expected = 99999;

            Assert.AreEqual(expected, actual);
        }
Пример #19
0
 public void Initialize()
 {
     _frogRiverOne = new FrogRiverOne();
 }
Пример #20
0
        public void FrogRiverOne()
        {
            var test = new FrogRiverOne();

            test.Run();
        }
 public void TestSolution2(int expected, int X, int[] A)
 {
     Assert.Equal(expected, FrogRiverOne.solution2(X, A));
 }
Пример #22
0
        static void Main(string[] args)
        {
            Console.WriteLine($"BinaryGap is {BinaryGap.Solution(9)}");
            Console.WriteLine($"BinaryGap is {BinaryGap.Solution(529)}");
            Console.WriteLine($"BinaryGap is {BinaryGap.Solution(20)}");
            Console.WriteLine($"BinaryGap is {BinaryGap.Solution(15)}");
            Console.WriteLine($"BinaryGap is {BinaryGap.Solution(32)}");
            Console.WriteLine($"BinaryGap is {BinaryGap.Solution(1041)}");
            Console.WriteLine(Environment.NewLine);

            var result = CyclicRotation.Solution(new[] { 1, 2, 3, 4 }, 2);

            Console.WriteLine($"CyclicRotation: {string.Join('-', result)}");
            Console.WriteLine(Environment.NewLine);

            Console.WriteLine($"OddOccurrencesInArray: {OddOccurrencesInArray.Solution(new[] {1, 1, 2, 2, 3, 4, 4})}");
            Console.WriteLine(Environment.NewLine);

            Console.WriteLine($"FrogJmp: {FrogJmp.Solution(10, 85, 30)}");
            Console.WriteLine(Environment.NewLine);

            Console.WriteLine($"PermMissingElem: {PermMissingElem.Solution(new[] {6, 7, 8, 1, 2, 4, 5})}");
            Console.WriteLine(Environment.NewLine);

            Console.WriteLine($"TapeEquilibrium: {TapeEquilibrium.Solution(new[] {3,1,2,4,3})}");
            Console.WriteLine(Environment.NewLine);

            Console.WriteLine($"FrogRiverOne: {FrogRiverOne.Solution(5,new[] {1,3,1,4,2,3,6,5,4})}");
            Console.WriteLine(Environment.NewLine);

            var maxCounter = MaxCounters.Solution(5, new[] { 3, 4, 4, 6, 1, 4, 4 });

            Console.WriteLine($"MaxCounters: {string.Join('-', maxCounter)}");
            Console.WriteLine(Environment.NewLine);

            Console.WriteLine($"MissingInteger: {MissingInteger.Solution(new []{1, 3, 6, 4, 1, 2})}");
            Console.WriteLine(Environment.NewLine);

            Console.WriteLine($"PermCheck: {PermCheck.Solution(new []{4,1,3,2})}");
            Console.WriteLine($"PermCheck: {PermCheck.Solution(new []{4,1,3})}");
            Console.WriteLine(Environment.NewLine);

            Console.WriteLine($"CountDiv: {CountDiv.Solution(11, 345, 17)}");
            Console.WriteLine(Environment.NewLine);

            Console.WriteLine($"PassingCars: {PassingCars.Solution(new []{0,1,0,1,1})}");
            Console.WriteLine(Environment.NewLine);

            // Console.WriteLine($"MinAvgTwoSlice: {MinAvgTwoSlice.Solution(new []{4,2,2,5,1,5,8})}");
            // Console.WriteLine(Environment.NewLine);
            //
            Console.WriteLine($"MaxProductOfThree: {MaxProductOfThree.Solution(new []{-3,1,2,-2,5,6})}");
            Console.WriteLine(Environment.NewLine);

            Console.WriteLine($"Triangle: {Triangle.Solution(new []{10,2,5,1,8,20})}");
            Console.WriteLine($"Triangle: {Triangle.Solution(new []{10,50,5,1})}");
            Console.WriteLine(Environment.NewLine);

            Console.WriteLine($"Brackets: {Brackets.Solution("{[()()]}")}");
            Console.WriteLine($"Brackets: {Brackets.Solution("([)()]")}");
            Console.WriteLine(Environment.NewLine);
        }
Пример #23
0
 public void FrogRiverOne_SomeLeaves_CannotJump_Success()
 {
     Assert.AreEqual(-1, FrogRiverOne.Solution(4, new int[] { 1, 3, 4, 3 }));
 }
Пример #24
0
 public void FrogRiverOne_RepeatPosition_CanJump_Success()
 {
     Assert.AreEqual(5, FrogRiverOne.Solution(4, new int[] { 1, 3, 3, 1, 4, 2, 2 }));
 }
Пример #25
0
 public void FrogRiverOne_OneLeaf_Success()
 {
     Assert.AreEqual(0, FrogRiverOne.Solution(1, new int[] { 1 }));
 }
Пример #26
0
 public void FrogRiverOne_RepeatPosition_CannotJump_Success()
 {
     Assert.AreEqual(-1, FrogRiverOne.Solution(6, new int[] { 1, 3, 4, 3, 1, 4 }));
 }