public void MissingIntegerSolutionTestWithNegativeValues()
        {
            MissingInteger testMissingInteger = new MissingInteger();

            int[] arrayTest = new int[] { -1, -3 };
            Assert.AreEqual(1, testMissingInteger.Solution(arrayTest));
        }
        public void MissingIntegerSolutionTestWithoutOne()
        {
            MissingInteger testMissingInteger = new MissingInteger();

            int[] arrayTest = new int[] { -1000000, 1000000 };
            Assert.AreEqual(1, testMissingInteger.Solution(arrayTest));
        }
        public void MissingIntegerSolutionTestAfterArray()
        {
            MissingInteger testMissingInteger = new MissingInteger();

            int[] arrayTest = new int[] { 1, 2, 3 };
            Assert.AreEqual(4, testMissingInteger.Solution(arrayTest));
        }
        public void MissingIntegerSolutionTest()
        {
            MissingInteger testMissingInteger = new MissingInteger();

            int[] arrayTest = new int[] { 1, 3, 6, 4, 1, 2 };
            Assert.AreEqual(5, testMissingInteger.Solution(arrayTest));
        }
Beispiel #5
0
        public void TestMethod5()
        {
            int[] input = { 4, 5, 6, 2 };
            int expected = 1;
            int result = MissingInteger.Solution(input);

            Assert.AreEqual(expected, result);
        }
Beispiel #6
0
        public void test_solution_whenGivenAnArrayOfIntegers_returnsSmallesPositiveIntergerThatIsNotInArray(int[] given,
                                                                                                            int expected)
        {
            var target = new MissingInteger();
            var actual = target.solution(given);

            Assert.AreEqual(expected, actual);
        }
Beispiel #7
0
        public void TestMethod1()
        {
            int[] input = { 1, 3, 6, 4, 1, 2 };
            int expected = 5;
            int result = MissingInteger.Solution(input);

            Assert.AreEqual(expected, result);
        }
Beispiel #8
0
        public void TestMethod3()
        {
            int[] input = { 1, 2, 3 };
            int expected = 4;
            int result = MissingInteger.Solution(input);

            Assert.AreEqual(expected, result);
        }
 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();
 }
        public void SolutionSimplePositivesTest()
        {
            // Arrange
            int[] A = new int[] { 1, 2 };

            // Action
            int actual = MissingInteger.Solution(A);

            // Assert
            int expected = 3;

            Assert.AreEqual(expected, actual);
        }
        public void SolutionNegativeNumbersOnlyTest()
        {
            // Arrange
            int[] A = new int[] { -4, -5, -3 };

            // Action
            int actual = MissingInteger.Solution(A);

            // Assert
            int expected = 1;

            Assert.AreEqual(expected, actual);
        }
        public void SolutionOneElementTest()
        {
            // Arrange
            int[] A = new int[] { 5 };

            // Action
            int actual = MissingInteger.Solution(A);

            // Assert
            int expected = 1;

            Assert.AreEqual(expected, actual);
        }
        public void SolutionBigNumbersTest()
        {
            // Arrange
            int[] A = new int[] { -2147483648, 0, 1, 2, 3, 2147483647, 2147483647 };

            // Action
            int actual = MissingInteger.Solution(A);

            // Assert
            int expected = 4;

            Assert.AreEqual(expected, actual);
        }
        public void SolutionOneHundredNumbersTest()
        {
            // Arrange
            int[] A = new int[100000];
            for (int i = 0; i < 100000; i++)
            {
                A[i] = i + 1;
            }

            // Action
            int actual = MissingInteger.Solution(A);

            // Assert
            int expected = 100001;

            Assert.AreEqual(expected, actual);
        }
        public void MissingIntegerSolutionTest()
        {
            var missingInteger = new MissingInteger();

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

            Assert.AreEqual(5, result);

            array  = new int[] { 1, 2, 3 };
            result = missingInteger.Solve(array);
            Assert.AreEqual(4, result);

            array  = new int[] { -1, -3 };
            result = missingInteger.Solve(array);
            Assert.AreEqual(1, result);

            array  = new int[] { -1000000, 1000000 };
            result = missingInteger.Solve(array);
            Assert.AreEqual(1, result);
        }
Beispiel #16
0
 public void MissingInteger_NegativeValues_Success()
 {
     Assert.AreEqual(1, MissingInteger.Solution(new int[] { -1, -2 }));
 }
Beispiel #17
0
 public void MissingInteger_LastElement_Success()
 {
     Assert.AreEqual(3, MissingInteger.Solution(new int[] { 1, 2 }));
 }
Beispiel #18
0
 public MissingIntegerTest()
 {
     _mInt = new MissingInteger();
 }
Beispiel #19
0
 public void MissingInteger_IntermediateElement_Success()
 {
     Assert.AreEqual(2, MissingInteger.Solution(new int[] { 1, 3 }));
 }
Beispiel #20
0
 public void MissingInteger_FirstElement_Success()
 {
     Assert.AreEqual(1, MissingInteger.Solution(new int[] { 2, 3 }));
 }
 public int Should(int[] inputs)
 {
     return(MissingInteger.Solve(inputs));
 }
Beispiel #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);
        }
Beispiel #23
0
 public void MissingInteger_MixtValues_Success()
 {
     Assert.AreEqual(3, MissingInteger.Solution(new int[] { -1, -2, 1, 2 }));
 }
Beispiel #24
0
 private static int PlayMissingInteger()
 {
     int[] input = { 4, 5, 6, 2 };
     return(MissingInteger.Solution(input));
 }
Beispiel #25
0
 public void MissingInteger_ElementZero_Success()
 {
     Assert.AreEqual(1, MissingInteger.Solution(new int[] { 0 }));
 }
Beispiel #26
0
 public void Initialize()
 {
     _missingInteger = new MissingInteger();
 }
Beispiel #27
0
 public void MissingInteger_EmptyArray_Success()
 {
     Assert.AreEqual(1, MissingInteger.Solution(new int[] { }));
 }