public void AssertThatSolutionReturnsTheValueOfTheUnpairedElement(int[] given, int expected) { var target = new OddOccurrencesInArray(); var actual = target.solution(given); Assert.AreEqual(expected, actual); }
public void SolutionTestWith13() { OddOccurrencesInArray testOdd = new OddOccurrencesInArray(); int[] arrayTest = new int[] { 9, 3, 9, 3, 9, 7, 9, 7, 5, 4, 3, 4, 3 }; Assert.AreEqual(5, testOdd.Solution(arrayTest)); }
public void OddOccurrencesInArrayTest() { Console.WriteLine("Start"); // Random r = new Random(DateTime.Now.Millisecond); Assert.AreEqual(OddOccurrencesInArray.solution(new int[] { 9, 3, 9, 3, 9, 7, 9 }), 7); }
public void OddOccurrencesInArrayTest1() { OddOccurrencesInArray ooia = new OddOccurrencesInArray(); long[] array = { 9, 3, 9, 3, 9, 7, 9 }; long result = ooia.solution(array); Assert.Equal(7, result); }
public void TestOddOcurrences() { int[] sampleArray = new int[] { 9, 3, 9, 3, 9, 7, 9 }; var OddOccurrencesSolver = new OddOccurrencesInArray(); var solution = OddOccurrencesSolver.Solution(sampleArray); Assert.AreEqual(solution, 7); }
public void OddOccurencesInArrayTest_01() { OddOccurrencesInArray or = new OddOccurrencesInArray(); int[] array = new int[] { 3, 1, 2, 2, 3 }; var solution = or.solution(array); Assert.AreEqual(1, solution); }
public void GetUnpairedOddInteger_UnpairedNumberPresent_Find() { var solver = new OddOccurrencesInArray(); var source = new[] { 1, 5, 1, 3, 1, 7, 3, 5, 1 }; var unpairedNumber = solver.GetUnpairedOddInteger(source); unpairedNumber.Should().Be(7); }
public void SolutionTest_01() { var solution = new OddOccurrencesInArray(); int[] A = new int[] { 9, 3, 9, 3, 9, 7, 9 }; int[] expected = new int[] { 7 }; int actual = solution.Solution(A); Assert.AreEqual(expected, actual); }
public void OddOccurrencesInArrayTest() { var odd = new OddOccurrencesInArray(); int[] array = new int[] { 9, 3, 9, 3, 9, 7, 9 }; int result = odd.Solve(array); Assert.AreEqual(7, result); }
public void test_OddOccurrencesInArray() { // Arrange var input = new int[] { 9, 3, 9, 3, 9, 7, 9 }; var output = 7; //Act var result = OddOccurrencesInArray.Solution(input); //Assert Assert.AreEqual(result, output); }
public void ShouldReturnUnpairedValueWhenGivenNonEmptyA() { OddOccurrencesInArray finder = new OddOccurrencesInArray(); int[] A = new int[] { 9, 3, 9, 3, 9, 7, 9 }; int expected = 7; int actual = finder.Find(A); Assert.AreEqual(expected, actual); }
public void Solution_SmallNumbers_Correct() { //Arrange - Given var array = new int[] { 2, 3, 4, 2, 3 }; //Act - When var result = OddOccurrencesInArray.Solution(array); //Assert - Then var expectedResult = 4; Assert.Equal(expectedResult, result); }
public void OddOccurenceTest() { //Arrange int[] array = { 9, 3, 9, 3, 9, 7, 9 }; int expected = 7; int actual = 0; //Act actual = OddOccurrencesInArray.Solution2(array); //Assert Assert.Equal(expected, actual); }
public void GetUnpairedElementWithXORTest() { // Arrange int[] a = new int[] { 2, 3, 2, 3, 7, 7, 425 }; var oddOcurrencesInArray = new OddOccurrencesInArray(); // Action int result = oddOcurrencesInArray.GetUnpairedElementWithXOR(a); // Assert int expected = 425; Assert.AreEqual(expected, result); }
public void Case1() { // Arrange var arrayInput = new int[] { 9, 3, 9, 3, 9, 7, 9 }; var algorithm = new OddOccurrencesInArray(); // Act var result = algorithm.solution(arrayInput); // Assert var expected = 7; Assert.Equal(expected, result); }
public void Initialize() { _oddOccurrencesInArray = new OddOccurrencesInArray(); }
public void OddOccurrencesInArray_OneElement_Success() { int result = OddOccurrencesInArray.Solution(new int[] { 1 }); Assert.AreEqual(1, result); }
public void OddOccurrencesInArray_ThreeOccurances_Success() { int result = OddOccurrencesInArray.Solution(new int[] { 1, 2, 1, 2, 1, 2, 1 }); Assert.AreEqual(2, result); }
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 int test(int[] A) { var o = new OddOccurrencesInArray(); return(o.Solution(A)); }