예제 #1
0
 def test_remove_smallest(self):
     self.assertEqual(se.remove_smallest([1, 2, 3, 4, 5]), [2, 3, 4, 5],
                      "Wrong result for [1, 2, 3, 4, 5]")
     self.assertEqual(se.remove_smallest([5, 3, 2, 1, 4]), [5, 3, 2, 4],
                      "Wrong result for [5, 3, 2, 1, 4]")
     self.assertEqual(se.remove_smallest([1, 2, 3, 1, 1]), [2, 3, 1, 1],
                      "Wrong result for [1, 2, 3, 1, 1]")
     self.assertEqual(se.remove_smallest([]), [], "Wrong result for []")
예제 #2
0
 def test_tickets(self):
     self.assertEqual(se.tickets([25, 25, 50]), "YES")
     self.assertEqual(se.tickets([25, 100]), "NO")
     self.assertEqual(se.tickets([25, 25, 50, 50, 100]), "NO")
     self.assertEqual(
         se.tickets(
             [25, 25, 25, 25, 25, 25, 25, 50, 50, 50, 100, 100, 100, 100]),
         "NO")
예제 #3
0
    def test_alphabet(self):
        self.assertEqual(
            se.alphabet_position("The sunset sets at twelve o' clock."),
            "20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11"
        )
        self.assertEqual(
            se.alphabet_position("The narwhal bacons at midnight."),
            "20 8 5 14 1 18 23 8 1 12 2 1 3 15 14 19 1 20 13 9 4 14 9 7 8 20")

        number_test = ""
        for item in range(10):
            number_test += str(randint(1, 9))
        self.assertEqual(se.alphabet_position(number_test), "")
예제 #4
0
 def test_palindrome(self):
     test_function = se.is_palindrome()
     self.assertTrue(
         test_function(
             'Doc, note: I dissent. A fast never prevents a fatness. I diet on cod'
         ))
     self.assertFalse(test_function('I am not one for sure'))
     self.assertTrue(test_function('Able was I ere I saw Elba'))
     self.assertTrue(test_function('Never odd or even'))
     self.assertTrue(test_function('aabbccddeefeeddccbbaa'))
     self.assertFalse(test_function('abbccddeeffeddccbbaa'))
예제 #5
0
 def test_basic(self):
     self.assertEqual(se.is_prime(0), False, "0  is not prime")
     self.assertEqual(se.is_prime(1), False, "1  is not prime")
     self.assertEqual(se.is_prime(2), True, "2  is prime")
     self.assertEqual(se.is_prime(73), True, "73 is prime")
     self.assertEqual(se.is_prime(75), False, "75 is not prime")
     self.assertEqual(se.is_prime(-1), False, "-1 is not prime")
예제 #6
0
 def test_tribinocci(self):
     self.assertEqual(se.tribonacci([1, 1, 1], 10),
                      [1, 1, 1, 3, 5, 9, 17, 31, 57, 105])
     self.assertEqual(se.tribonacci([0, 0, 1], 10),
                      [0, 0, 1, 1, 2, 4, 7, 13, 24, 44])
     self.assertEqual(se.tribonacci([0, 1, 1], 10),
                      [0, 1, 1, 2, 4, 7, 13, 24, 44, 81])
     self.assertEqual(se.tribonacci([1, 0, 0], 10),
                      [1, 0, 0, 1, 1, 2, 4, 7, 13, 24])
     self.assertEqual(se.tribonacci([0, 0, 0], 10),
                      [0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
     self.assertEqual(se.tribonacci([1, 2, 3], 10),
                      [1, 2, 3, 6, 11, 20, 37, 68, 125, 230])
     self.assertEqual(se.tribonacci([3, 2, 1], 10),
                      [3, 2, 1, 6, 9, 16, 31, 56, 103, 190])
     self.assertEqual(se.tribonacci([1, 1, 1], 1), [1])
     self.assertEqual(se.tribonacci([300, 200, 100], 0), [])
     self.assertEqual(se.tribonacci([0.5, 0.5, 0.5], 30), [
         0.5, 0.5, 0.5, 1.5, 2.5, 4.5, 8.5, 15.5, 28.5, 52.5, 96.5, 177.5,
         326.5, 600.5, 1104.5, 2031.5, 3736.5, 6872.5, 12640.5, 23249.5,
         42762.5, 78652.5, 144664.5, 266079.5, 489396.5, 900140.5,
         1655616.5, 3045153.5, 5600910.5, 10301680.5
     ])
예제 #7
0
 def test_remove_duplicate_words_none_exist(self):
     phrase = 'alpha'
     result = se.remove_duplicate_words(phrase)
     self.assertEqual('alpha', result)
예제 #8
0
 def test_get_roman_numeral_nine(self):
     roman_numeral = se.get_roman_numeral(9)
     self.assertEqual('IX', roman_numeral)
예제 #9
0
 def test_get_roman_numeral_ten(self):
     roman_numeral = se.get_roman_numeral(10)
     self.assertEqual('X', roman_numeral)
예제 #10
0
 def test_convert_roman_numeral_ten(self):
     roman_numeral = se.convert_roman_numeral('X')
     self.assertEqual(10, roman_numeral)
예제 #11
0
 def test_array_with_item_of_10_should_return_10(self):
     result = se.get_adjacent_elements_with_max_product([10])
     self.assertEqual(10, result)
예제 #12
0
 def test_convert_roman_numeral_four(self):
     roman_numeral = se.convert_roman_numeral('IV')
     self.assertEqual(4, roman_numeral)
예제 #13
0
 def test_convert_roman_numeral_six(self):
     roman_numeral = se.convert_roman_numeral('VI')
     self.assertEqual(6, roman_numeral)
예제 #14
0
 def test_dict_replacer_two_items_phrase(self):
     phrase = 'I think <1> lives in <2>.'
     dictionary = {'1': 'Nate', '2': 'Idaho'}
     result = se.dict_replacer(phrase, dictionary)
     self.assertEqual('I think Nate lives in Idaho.', result)
예제 #15
0
 def test_get_roman_numeral_one(self):
     roman_numeral = se.get_roman_numeral(1)
     self.assertEqual('I', roman_numeral)
예제 #16
0
 def test_are_anagramss(self):
     are_anagrams = se.are_anagrams('listen', 'silent')
     self.assertTrue(are_anagrams)
예제 #17
0
 def test_dict_replacer_one_item_phrase(self):
     phrase = '<a>'
     dictionary = {'a': 'successful'}
     result = se.dict_replacer(phrase, dictionary)
     self.assertEqual('successful', result)
예제 #18
0
 def test_array_with_0_neg5_6_should_return_0(self):
     result = se.get_adjacent_elements_with_max_product([0, -5, 6])
     self.assertEqual(0, result)
예제 #19
0
 def test_array_with_2_3_4_should_return_12(self):
     result = se.get_adjacent_elements_with_max_product([2, 3, 4])
     self.assertEqual(12, result)
예제 #20
0
 def test_array_with_4_5_should_return_20(self):
     result = se.get_adjacent_elements_with_max_product([4, 5])
     self.assertEqual(20, result)
예제 #21
0
 def test_convert_roman_numeral_one(self):
     roman_numeral = se.convert_roman_numeral('I')
     self.assertEqual(1, roman_numeral)
예제 #22
0
 def test_empty_array_should_return_none(self):
     result = se.get_adjacent_elements_with_max_product([])
     self.assertIsNone(result)
예제 #23
0
 def test_convert_roman_numeral_three(self):
     roman_numeral = se.convert_roman_numeral('III')
     self.assertEqual(3, roman_numeral)
예제 #24
0
 def test_get_roman_numeral_four(self):
     roman_numeral = se.get_roman_numeral(4)
     self.assertEqual('IV', roman_numeral)
예제 #25
0
 def test_convert_roman_numeral_five(self):
     roman_numeral = se.convert_roman_numeral('V')
     self.assertEqual(5, roman_numeral)
예제 #26
0
 def test_get_roman_numeral_five(self):
     roman_numeral = se.get_roman_numeral(5)
     self.assertEqual('V', roman_numeral)
예제 #27
0
 def test_convert_roman_numeral_nine(self):
     roman_numeral = se.convert_roman_numeral('IX')
     self.assertEqual(9, roman_numeral)
예제 #28
0
 def test_get_roman_numeral_six(self):
     roman_numeral = se.get_roman_numeral(6)
     self.assertEqual('VI', roman_numeral)
예제 #29
0
 def test_get_roman_numeral_three(self):
     roman_numeral = se.get_roman_numeral(3)
     self.assertEqual('III', roman_numeral)
예제 #30
0
 def test_dict_replacer_no_phrase(self):
     phrase = ''
     dictionary = {}
     result = se.dict_replacer(phrase, dictionary)
     self.assertEqual('', result)