public void Case1() { // Arrange int param = 529; // Act var result = _binaryGap.solution(param); var expected = 4; // Assert Assert.Equal(expected, result); }
public void CountDivTest() { Console.WriteLine("Start"); int t1, t2; for (int a = 100; a < 200; a++) { for (int b = 100; b < 200; b++) { if (b < a) { continue; } for (int k = 1; k < 101; k++) { t1 = CountDiv.solution1(a, b, k); t2 = CountDiv.solution(a, b, k); Assert.AreEqual(t1, t2, 0, $"Result: {a}-{b}-{k}: [ex:{t1} ,go: {t2}]"); } } } CountDiv.solution1(1, 1, 1); // Random r = new Random(DateTime.Now.Millisecond); Assert.AreEqual(BinaryGap.solution(1041), 5); Assert.AreEqual(BinaryGap.solution(12343), 6); }
public void Test1() { Assert.AreEqual(4, BinaryGap.solution(529)); Assert.AreEqual(2, BinaryGap.solution(9)); Assert.AreEqual(1, BinaryGap.solution(20)); Assert.AreEqual(0, BinaryGap.solution(15)); }
public void WhenPassIntegerReturnsTheLongestGap(int argument, int expected) { var target = new BinaryGap(); var actual = target.solution(argument); Assert.AreEqual(expected, actual); }
public void BinaryGap_Should_Handle_Zero_Value() { BinaryGap subject = new BinaryGap(); int result = subject.solution(0); Assert.Equal(0, result); }
public void BinaryGap_Should_Process_Complex_Value() { BinaryGap subject = new BinaryGap(); int result = subject.solution(51712); Assert.Equal(2, result); }
public void BinaryGap_Should_Process_Simple_Value() { BinaryGap subject = new BinaryGap(); int result = subject.solution(6); Assert.Equal(0, result); }
public void BinaryGapTest() { Console.WriteLine("Start"); // Random r = new Random(DateTime.Now.Millisecond); Assert.AreEqual(BinaryGap.solution(1041), 5); Assert.AreEqual(BinaryGap.solution(12343), 6); }
static void Main() { Console.WriteLine(BinaryReversal("4567")); Console.WriteLine("1, 3, 4, 7, 13", "1, 2, 4, 13, 15"); Console.WriteLine(FindIntersection(new string[] { "1, 3, 4, 7, 13", "1, 2, 4, 13, 15" })); int[] array = new int[] { 10, 17, 25, 35, 52, 55, 62, 77, 90, 95 }; int index = BinarySearchDisplay(array, 77); Console.WriteLine("Index: {0}, Value: {1}", index, array[index]); string words = WordSplit(new string[] { "baseball", "a,all,b,ball,bas,base,cat,code,d,e,quit,z" }); Console.WriteLine("Words: {0}", words); int[] profit = maxProfit(new int[] { 5, 11, 3, 50, 60, 90 }); Console.WriteLine("Buy: {0}, Sell: {1}, Profit: {2}", profit[0], profit[1], profit[2]); int[] A1 = new int[] { 1, 3, 6, 4, 1, 2 }; int[] A2 = new int[] { 1, 2, 3 }; int[] A3 = new int[] { -3, 0, 1 }; int result1 = solution(A1); int result2 = solution(A2); int result3 = solution(A3); Console.WriteLine("result is: {0}, {1}, {2}", result1, result2, result3); FindElement(); int[] A5 = new int[] { 20, -1, 10, 5, 1, 9, -89, 159 }; int in1 = solution1(A5); Console.WriteLine("solution1: {0}", in1); int[] A6 = new int[] { -3, -1, 10, 3, 1, 9, -89, 159 }; int in2 = solution2(A6); Console.WriteLine("solution2: {0}", in2); Console.WriteLine("--------------------------------------------"); Console.WriteLine("--------------------------------------------"); BinaryGap binaryGap = new BinaryGap(); Console.WriteLine("binaryGap: {0}", binaryGap.solution(9)); Console.WriteLine("binaryGap: {0}", binaryGap.solution(529)); Console.WriteLine("binaryGap: {0}", binaryGap.solution(20)); Console.WriteLine("binaryGap: {0}", binaryGap.solution(15)); Console.WriteLine("binaryGap: {0}", binaryGap.solution(32)); Console.WriteLine("binaryGap: {0}", binaryGap.solution(561892)); Console.ReadKey(); }
public void BinaryGapTest_01() { var solution = bg.solution(1041); Assert.AreEqual(5, solution); }
private void TestNumber(int number, int expectedResult) { var result = _binaryGap.solution(number); Assert.AreEqual(expectedResult, result); }