Sha256: f3d51227fad280ac3c603793e5e238ec5ce31c79d9b0e79c2afa90654d8aea6b

Contents?: true

Size: 1.82 KB

Versions: 53

Compression:

Stored size: 1.82 KB

Contents

import unittest

from change import find_minimum_coins

# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0


class ChangeTest(unittest.TestCase):
    def test_single_coin_change(self):
        self.assertEqual(find_minimum_coins(25, [1, 5, 10, 25, 100]), [25])

    def test_multiple_coin_change(self):
        self.assertEqual(find_minimum_coins(15, [1, 5, 10, 25, 100]), [5, 10])

    def test_change_with_Lilliputian_Coins(self):
        self.assertEqual(find_minimum_coins(23, [1, 4, 15, 20, 50]),
                         [4, 4, 15])

    def test_change_with_Lower_Elbonia_Coins(self):
        self.assertEqual(find_minimum_coins(63, [1, 5, 10, 21, 25]),
                         [21, 21, 21])

    def test_large_target_values(self):
        self.assertEqual(find_minimum_coins(999, [1, 2, 5, 10, 20, 50, 100]),
                         [2, 2, 5, 20, 20, 50, 100, 100, 100,
                          100, 100, 100, 100, 100, 100])

    def test_possible_change_without_unit_coins_available(self):
        self.assertEqual(find_minimum_coins(21, [2, 5, 10, 20, 50]),
                         [2, 2, 2, 5, 10])

    def test_another_possible_change_without_unit_coins_available(self):
        self.assertEqual(find_minimum_coins(27, [4, 5]),
                         [4, 4, 4, 5, 5, 5])

    def test_no_coins_make_0_change(self):
        self.assertEqual(find_minimum_coins(0, [1, 5, 10, 21, 25]), [])

    def test_error_testing_for_change_smaller_than_smallest_coin(self):
        self.assertEqual(find_minimum_coins(3, [5, 10]), -1)

    def test_error_if_no_combination_can_add_up_to_target(self):
        self.assertEqual(find_minimum_coins(94, [5, 10]), -1)

    def test_cannot_find_negative_change_values(self):
        self.assertEqual(find_minimum_coins(-5, [1, 2, 5]), -1)


if __name__ == "__main__":
    unittest.main()

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
trackler-2.2.1.107 tracks/python/exercises/change/change_test.py
trackler-2.2.1.106 tracks/python/exercises/change/change_test.py
trackler-2.2.1.105 tracks/python/exercises/change/change_test.py
trackler-2.2.1.104 tracks/python/exercises/change/change_test.py
trackler-2.2.1.103 tracks/python/exercises/change/change_test.py
trackler-2.2.1.102 tracks/python/exercises/change/change_test.py
trackler-2.2.1.101 tracks/python/exercises/change/change_test.py
trackler-2.2.1.100 tracks/python/exercises/change/change_test.py
trackler-2.2.1.99 tracks/python/exercises/change/change_test.py
trackler-2.2.1.98 tracks/python/exercises/change/change_test.py
trackler-2.2.1.97 tracks/python/exercises/change/change_test.py
trackler-2.2.1.96 tracks/python/exercises/change/change_test.py
trackler-2.2.1.95 tracks/python/exercises/change/change_test.py
trackler-2.2.1.94 tracks/python/exercises/change/change_test.py
trackler-2.2.1.93 tracks/python/exercises/change/change_test.py
trackler-2.2.1.92 tracks/python/exercises/change/change_test.py
trackler-2.2.1.91 tracks/python/exercises/change/change_test.py
trackler-2.2.1.90 tracks/python/exercises/change/change_test.py
trackler-2.2.1.89 tracks/python/exercises/change/change_test.py
trackler-2.2.1.88 tracks/python/exercises/change/change_test.py