Sha256: c68d3ae99d3851db9a6bb2648047d779b3d71bc7a1a4323c0c509594724e1677

Contents?: true

Size: 1.84 KB

Versions: 143

Compression:

Stored size: 1.84 KB

Contents

"""
You can make the following assumptions about the inputs to the
'sum_of_multiples' function:
    * All input numbers are non-negative 'int's, i.e. natural numbers
      including zero.
    * A list of factors must be given, and its elements are unique
      and sorted in ascending order.
"""

import unittest

from sum_of_multiples import sum_of_multiples


# test cases adapted from `x-common//canonical-data.json` @ version: 1.0.0

class SumOfMultiplesTest(unittest.TestCase):
    def test_multiples_of_3_or_5_up_to_1(self):
        self.assertEqual(sum_of_multiples(1, [3, 5]), 0)

    def test_multiples_of_3_or_5_up_to_4(self):
        self.assertEqual(sum_of_multiples(4, [3, 5]), 3)

    def test_multiples_of_3_or_5_up_to_10(self):
        self.assertEqual(sum_of_multiples(10, [3, 5]), 23)

    def test_multiples_of_3_or_5_up_to_100(self):
        self.assertEqual(sum_of_multiples(100, [3, 5]), 2318)

    def test_multiples_of_3_or_5_up_to_1000(self):
        self.assertEqual(sum_of_multiples(1000, [3, 5]), 233168)

    def test_multiples_of_7_13_or_17_up_to_20(self):
        self.assertEqual(sum_of_multiples(20, [7, 13, 17]), 51)

    def test_multiples_of_4_or_6_up_to_15(self):
        self.assertEqual(sum_of_multiples(15, [4, 6]), 30)

    def test_multiples_of_5_6_or_8_up_to_150(self):
        self.assertEqual(sum_of_multiples(150, [5, 6, 8]), 4419)

    def test_multiples_of_5_or_25_up_to_51(self):
        self.assertEqual(sum_of_multiples(51, [5, 25]), 275)

    def test_multiples_of_43_or_47_up_to_10000(self):
        self.assertEqual(sum_of_multiples(10000, [43, 47]), 2203160)

    def test_multiples_of_1_up_to_100(self):
        self.assertEqual(sum_of_multiples(100, [1]), 4950)

    def test_multiples_of_an_empty_list_up_to_10000(self):
        self.assertEqual(sum_of_multiples(10000, []), 0)


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

Version data entries

143 entries across 143 versions & 1 rubygems

Version Path
trackler-2.2.1.52 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.51 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.50 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.49 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.48 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.47 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.46 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.45 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.44 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.43 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.42 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.41 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.40 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.39 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.38 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.37 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.36 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.35 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.34 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.2.1.33 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py