Sha256: e4c99c674e110508b4cb913279a5766eafce82b1af7a1a07f0290f13595a3ec9

Contents?: true

Size: 1.52 KB

Versions: 127

Compression:

Stored size: 1.52 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


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

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

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

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

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

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

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

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

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

    def test_configurable_0_to_10(self):
        self.assertEqual(0, sum_of_multiples(10, [0]))

    def test_configurable_0_1_to_10(self):
        self.assertEqual(45, sum_of_multiples(10, [0, 1]))


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

Version data entries

127 entries across 127 versions & 1 rubygems

Version Path
trackler-2.0.6.31 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.30 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.29 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.28 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.27 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.26 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.25 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.24 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.23 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.22 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.21 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.20 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.19 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.18 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.17 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.16 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.15 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.14 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.13 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py
trackler-2.0.6.12 tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py