예제 #1
0
 def test_possible_change_without_unit_coins_available(self):
     self.assertEqual(find_fewest_coins([2, 5, 10, 20, 50], 21),
                      [2, 2, 2, 5, 10])
예제 #2
0
 def test_change_with_Lilliputian_Coins(self):
     self.assertEqual(find_fewest_coins([1, 4, 15, 20, 50], 23),
                      [4, 4, 15])
예제 #3
0
 def test_cannot_find_negative_change_values(self):
     with self.assertRaises(ValueError) as err:
         find_fewest_coins([1, 2, 5], -5)
     self.assertEqual(type(err.exception), ValueError)
     self.assertEqual(err.exception.args[0], "target can't be negative")
예제 #4
0
 def test_multiple_coin_change(self):
     self.assertEqual(find_fewest_coins([1, 5, 10, 25, 100], 15), [5, 10])
예제 #5
0
 def test_change_with_lower_elbonia_coins(self):
     self.assertEqual(find_fewest_coins([1, 5, 10, 21, 25], 63), [21, 21, 21])
예제 #6
0
 def test_error_testing_for_change_smaller_than_the_smallest_of_coins(self):
     with self.assertRaisesWithMessage(ValueError):
         find_fewest_coins([5, 10], 3)
예제 #7
0
 def test_cannot_find_negative_change_values(self):
     with self.assertRaisesWithMessage(ValueError):
         find_fewest_coins([1, 2, 5], -5)
예제 #8
0
 def test_error_testing_for_change_smaller_than_smallest_coin(self):
     with self.assertRaisesWithMessage(ValueError):
         find_fewest_coins([5, 10], 3)
예제 #9
0
 def test_error_if_no_combination_can_add_up_to_target(self):
     with self.assertRaisesWithMessage(ValueError):
         find_fewest_coins([5, 10], 94)
예제 #10
0
 def test_another_possible_change_without_unit_coins_available(self):
     self.assertEqual(find_fewest_coins([4, 5], 27),
                      [4, 4, 4, 5, 5, 5])
예제 #11
0
 def test_no_coins_make_0_change(self):
     self.assertEqual(find_fewest_coins([1, 5, 10, 21, 25], 0), [])
예제 #12
0
 def test_possible_change_without_unit_coins_available(self):
     self.assertEqual(find_fewest_coins([2, 5, 10, 20, 50], 21),
                      [2, 2, 2, 5, 10])
예제 #13
0
 def test_large_target_values(self):
     self.assertEqual(find_fewest_coins([1, 2, 5, 10, 20, 50, 100], 999),
                      [2, 2, 5, 20, 20, 50, 100, 100, 100,
                       100, 100, 100, 100, 100, 100])
예제 #14
0
 def test_change_with_Lower_Elbonia_Coins(self):
     self.assertEqual(find_fewest_coins([1, 5, 10, 21, 25], 63),
                      [21, 21, 21])
예제 #15
0
 def test_another_possible_change_without_unit_coins_available(self):
     self.assertEqual(find_fewest_coins([4, 5], 27), [4, 4, 4, 5, 5, 5])
예제 #16
0
 def test_cannot_find_negative_change_values(self):
     with self.assertRaisesWithMessage(ValueError):
         find_fewest_coins([1, 2, 5], -5)
예제 #17
0
 def test_no_coins_make_0_change(self):
     self.assertEqual(find_fewest_coins([1, 5, 10, 21, 25], 0), [])
예제 #18
0
 def test_single_coin_change(self):
     self.assertEqual(find_fewest_coins([1, 5, 10, 25, 100], 25), [25])
예제 #19
0
 def test_error_if_no_combination_can_add_up_to_target(self):
     with self.assertRaisesWithMessage(ValueError):
         find_fewest_coins([5, 10], 94)
예제 #20
0
 def test_change_for_1_cent(self):
     self.assertEqual(find_fewest_coins([1, 5, 10, 25], 1), [1])
예제 #21
0
 def test_single_coin_change(self):
     self.assertEqual(find_fewest_coins([1, 5, 10, 25, 100], 25), [25])
예제 #22
0
 def test_error_testing_for_change_smaller_than_the_smallest_of_coins(self):
     with self.assertRaises(ValueError) as err:
         find_fewest_coins([5, 10], 3)
     self.assertEqual(type(err.exception), ValueError)
     self.assertEqual(err.exception.args[0],
                      "can't make target with given coins")
예제 #23
0
 def test_change_with_lilliputian_coins(self):
     self.assertEqual(find_fewest_coins([1, 4, 15, 20, 50], 23), [4, 4, 15])
예제 #24
0
 def test_error_if_no_combination_can_add_up_to_target(self):
     with self.assertRaises(ValueError) as err:
         find_fewest_coins([5, 10], 94)
     self.assertEqual(type(err.exception), ValueError)
     self.assertEqual(err.exception.args[0],
                      "can't make target with given coins")
예제 #25
0
 def test_large_target_values(self):
     self.assertEqual(
         find_fewest_coins([1, 2, 5, 10, 20, 50, 100], 999),
         [2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100],
     )
예제 #26
0
 def test_multiple_coin_change(self):
     self.assertEqual(find_fewest_coins([1, 5, 10, 25, 100], 15), [5, 10])