public void PassingCarsSolutionTest() { PassingCars testPassingCars = new PassingCars(); int[] arrayTest = new int[] { 0, 1, 0, 1, 1 }; Assert.AreEqual(5, testPassingCars.Solution(arrayTest)); }
public void Solution_SmallArray_Correct() { //Arrange - Given var array = new int[] { 0, 1, 0, 1, 1 }; //Act - When var result = PassingCars.Solution(array); //Assert - Then var expectedResult = 5; Assert.Equal(expectedResult, result); }
public void SolutionSimpleTest() { // Arrange int[] A = new int[] { 0, 1, 0, 1, 0, 1, 0 }; // Action int actual = PassingCars.Solution(A); // Assert int expected = 6; Assert.AreEqual(expected, actual); }
public void SolutionExcedingMaxTest() { // Arrange int[] A = new int[100000]; for (int i = 0; i < 30000; i++) { A[i] = i % 2 == 0 ? 0 : 1; } for (int i = 30000; i < 100000; i++) { A[i] = 1; } // Action int actual = PassingCars.Solution(A); // Assert int expected = -1; Assert.AreEqual(expected, actual); }
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); }
public void OneDirectionTest() { Assert.AreEqual(0, PassingCars.Solution(Enumerable.Repeat(1, 5).ToArray())); }
public void OneDirectionReverseTest() { Assert.AreEqual(0, PassingCars.Solution(new int[5])); }
public void ReverseCarsTest() { Assert.AreEqual(5, PassingCars.Solution(new [] { 0, 1, 0, 1, 1 })); }
public void TwoCarsTest() { Assert.AreEqual(1, PassingCars.Solution(new [] { 0, 1 })); }
public void EmptyArrayTest() { Assert.AreEqual(0, PassingCars.Solution(new int[0])); }
public void ExampleReversTest() { Assert.AreEqual(5, PassingCars.Solution(new [] { 1, 0, 1, 0, 0 })); }
public void OneCarMiddleTest() { int[] A = new int[5]; A[2] = 1; Assert.AreEqual(2, PassingCars.Solution(A)); }
public void OneCarSouthTest() { int[] A = new int[6]; A[0] = 1; Assert.AreEqual(5, PassingCars.Solution(A)); }
public void TwoMuchTest() { int[] A = new int[1500000]; A[0] = 1; Assert.AreEqual(-1, PassingCars.Solution(A)); }
public void ExtremeTest() { int[] A = new int[1500000]; A[999999] = 1; Assert.AreEqual(500000, PassingCars.Solution(A)); }
public void ExampleTest() { Assert.AreEqual(5, PassingCars.Solution(new int[] { 0, 1, 0, 1, 1 })); }