Exemplo n.º 1
0
        private static int[] PlayMaxCounters()
        {
            int n = 5;

            int[] input = { 3, 4, 4, 6, 1, 4, 4 };
            return(MaxCounters.Solution(n, input));
        }
Exemplo n.º 2
0
        public void MaxCountersSolutionTest()
        {
            MaxCounters testMaxCounters = new MaxCounters();

            int[] arrayTest = new int[] { 3, 4, 4, 6, 1, 4, 4 };
            int[] result    = new int[] { 3, 2, 2, 4, 2 };
            Assert.IsTrue(result.SequenceEqual(testMaxCounters.Solution(5, arrayTest)));
        }
Exemplo n.º 3
0
        public void TestMethod1()
        {
            int n = 5;

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

            CollectionAssert.AreEqual(expected, result);
        }
        public void Solution_SmallNumbers_Correct()
        {
            //Arrange - Given
            var counters = 5;
            var array    = new int[] { 3, 4, 4, 6, 1, 4, 4 };

            //Act - When
            var result = MaxCounters.Solution(counters, array);

            //Assert - Then
            var expectedResult = new int[] { 3, 2, 2, 4, 2 };

            Assert.Equal(expectedResult, result);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
 public void TestMaxCounters()
 {
     int[] s = _maxCounters.Solution(5, new int[] { 3, 4, 4, 6, 1, 4, 4 });
     Assert.That(new int[] { 3, 2, 2, 4, 2 }, Is.EqualTo(s));
 }
Exemplo n.º 7
0
 public void MaxCounters_SmallArray_LastMaxCounter_Correct()
 {
     CollectionAssert.AreEqual(new int[] { 2, 2, 2 }, MaxCounters.Solution(3, new int[] { 1, 2, 2, 4 }));
 }
Exemplo n.º 8
0
 public void MaxCounters_SmallArray_JustIncrease_Correct()
 {
     CollectionAssert.AreEqual(new int[] { 3, 0, 0 }, MaxCounters.Solution(3, new int[] { 1, 1, 1 }));
 }
Exemplo n.º 9
0
 public void MaxCounters_SmallArray_JustMaxCounter_Correct()
 {
     CollectionAssert.AreEqual(new int[] { 0, 0, 0 }, MaxCounters.Solution(3, new int[] { 4, 4, 4 }));
 }
Exemplo n.º 10
0
 public void MaxCounters_SmallArray_LastIncrease_Correct()
 {
     CollectionAssert.AreEqual(new int[] { 1, 2, 1 }, MaxCounters.Solution(3, new int[] { 1, 2, 4, 2 }));
 }