Example #1
0
    def test_given_valid_two_digit_greater_than_26(self):
        import random

        for _ in range(10):
            num = random.randint(27, 99)

            if num % 10 == 0:
                assert count_mapping(str(num)) == 0
                assert count_mapping_dp(str(num)) == 0
            else:
                assert count_mapping_dp(str(num)) == 1
Example #2
0
 def test_1111_should_return_5(self):
     assert count_mapping("1111") == 5
     assert count_mapping_dp("1111") == 5
Example #3
0
 def test_given_101_should_return_1(self):
     assert count_mapping("101") == 1
     assert count_mapping_dp("101") == 1
Example #4
0
 def test_given_100_should_return_0(self):
     assert count_mapping("100") == 0
     assert count_mapping_dp("100") == 0
Example #5
0
 def test_given_valid_two_digit_between_11_and_26_should_return_two(
         self, input_str):
     """All but 10 & 20"""
     assert count_mapping(input_str) == 2
     assert count_mapping_dp(input_str) == 2
Example #6
0
 def test_given_ten_twenty_returns_one(self):
     assert count_mapping("10") == 1
     assert count_mapping("20") == 1
     assert count_mapping_dp("10") == 1
     assert count_mapping_dp("20") == 1
Example #7
0
 def test_single_digit_returns_one(self, input_str):
     assert count_mapping(input_str) == 1
     assert count_mapping_dp(input_str) == 1
Example #8
0
 def test_zero_returns_zero(self):
     assert count_mapping("0") == 0
     assert count_mapping_dp("0") == 0