Exemplo n.º 1
0
    def test_with_one_char(self):
        num = int("0", 2)
        exp = 0
        act = bg.solution(num)
        self.assertEquals(exp, act)

        num = int("1", 2)
        act = bg.solution(num)
        self.assertEquals(exp, act)
Exemplo n.º 2
0
 def test_with_multiple_binary_gaps_where_first_is_longest(self):
     num = int("10010110", 2)
     exp = 2
     act = bg.solution(num)
     self.assertEquals(exp, act)
Exemplo n.º 3
0
 def test_with_single_binary_gap_of_one_0(self):
     num = int("101", 2)
     exp = 1
     act = bg.solution(num)
     self.assertEquals(exp, act)
Exemplo n.º 4
0
 def test_with_single_binary_gap_of_multipe_0s(self):
     num = int("10001", 2)
     exp = 3
     act = bg.solution(num)
     self.assertEquals(exp, act)
Exemplo n.º 5
0
 def test_with_0s_at_start(self):
     num = int("0011", 2)
     exp = 0
     act = bg.solution(num)
     self.assertEquals(exp, act)
Exemplo n.º 6
0
 def test_with_0s_at_end(self):
     num = int("1100", 2)
     exp = 0
     act = bg.solution(num)
     self.assertEquals(exp, act)
Exemplo n.º 7
0
 def test_solution_5(self, ):
     N = 5
     assert solution(N) == 1
Exemplo n.º 8
0
 def test_solution_561892(self):
     N = 561892
     assert solution(N) == 3
Exemplo n.º 9
0
 def test_solution_1376796946(self):
     N = 1376796946
     assert solution(N) == 5
Exemplo n.º 10
0
 def test_solution_1610612737(self):
     N = 1610612737
     assert solution(N) == 28
Exemplo n.º 11
0
 def test_solution_74901729(self):
     N = 74901729
     assert solution(N) == 4
Exemplo n.º 12
0
 def test_solution_6291457(self):
     N = 6291457
     assert solution(N) == 20
Exemplo n.º 13
0
 def test_solution_66561(self):
     N = 66561
     assert solution(N) == 9
Exemplo n.º 14
0
def test_binary_gap(N, expected):
    assert solution(N) == expected
Exemplo n.º 15
0
 def test_with_only_1s(self):
     num = int("111", 2)
     exp = 0
     act = bg.solution(num)
     self.assertEquals(exp, act)
Exemplo n.º 16
0
 def test_solution(self):
     self.assertEqual(binary_gap.solution(1), 0)
Exemplo n.º 17
0
 def test_solution_51712(self):
     N = 51712
     assert solution(N) == 2