Esempio n. 1
0
        public void PermCheckSolutionTest()
        {
            PermCheck testPermCheck = new PermCheck();

            int[] arrayTest = new int[] { 4, 1, 3, 2 };
            Assert.AreEqual(1, testPermCheck.Solution(arrayTest));
        }
Esempio n. 2
0
        public void PermCheckSolutionTestNoPermutation()
        {
            PermCheck testPermCheck = new PermCheck();

            int[] arrayTest = new int[] { 4, 1, 3 };
            Assert.AreEqual(0, testPermCheck.Solution(arrayTest));
        }
Esempio n. 3
0
        public void TestMethod1()
        {
            int[] input    = { 4, 1, 3, 2 };
            int   expected = 1;
            int   result   = PermCheck.Solution(input);

            Assert.AreEqual(expected, result);
        }
Esempio n. 4
0
        private static void RunPermCheck()
        {
            Console.WriteLine($" --------- 4.1 PermCheck --------- ");

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

            Console.WriteLine($"result = {result}");
        }
        public void SolutionEmptyTest()
        {
            // Arrange
            int[] A = new int[] { };

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

            // Assert
            int expected = 0;

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

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

            // Assert
            int expected = 0;

            Assert.AreEqual(expected, actual);
        }
        public void SolutionOneHundredNumbersPermutationTest()
        {
            // Arrange
            int length = 100000;

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

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

            // Assert
            int expected = 1;

            Assert.AreEqual(expected, actual);
        }
        public void SolutionBigNumbersTest()
        {
            // Arrange
            int length = 100000;

            int[] A = new int[length];
            for (int i = 0; i < length - 10; i++)
            {
                A[i] = i + 1;
            }
            for (int i = length - 10; i < length; i++)
            {
                A[i] = 1000000000 - i;
            }

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

            // Assert
            int expected = 0;

            Assert.AreEqual(expected, actual);
        }
Esempio n. 9
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);
        }
Esempio n. 10
0
 public void PermCheck_OneElement_WithPerm_Success()
 {
     Assert.AreEqual(1, PermCheck.Solution(new int[] { 1 }));
 }
Esempio n. 11
0
 public void PermCheck_SmallArray_SumCorrect_NoPerm_Success()
 {
     Assert.AreEqual(0, PermCheck.Solution(new int[] { 1, 4, 1 }));
 }
Esempio n. 12
0
 public void PermCheck_SmallArray_GreaterN_NoPerm_Success()
 {
     Assert.AreEqual(0, PermCheck.Solution(new int[] { 1, 2, 6, 3 }));
 }
Esempio n. 13
0
 public void PermCheck_SmallArray_WithPerm_Success()
 {
     Assert.AreEqual(1, PermCheck.Solution(new int[] { 1, 2, 4, 3 }));
 }
Esempio n. 14
0
 public void PermCheck_OneElement_NoPerm_Success()
 {
     Assert.AreEqual(0, PermCheck.Solution(new int[] { 2 }));
 }