aboutsummaryrefslogtreecommitdiff
path: root/challenge-192/ealvar3z/python/ch-2.py
blob: a9f4b37bec072d92730ae70d0b9e3b10c0d082b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from statistics import mean
from unittest import main, TestCase

"""
Example 1:
    Input: @list = (1, 0, 5)
    Output: 4
Example 2:
    Input: @list = (0, 2, 0)
    Output: -1
Example 3:
    Input: (0, 3, 0)
    Output: 2
"""

cases = [
    ([1, 0, 5], 4),
    ([0, 2, 0], -1),
    ([0, 3, 0], 2),
]


class TestSolutionII(TestCase):

    def equal_distro(self, _list):
        m = int(mean(_list))
        if m == 0:
            return -1
        else:
            return m + m

    def test_equal_distribution(self):
        for input, output in cases:
            with self.subTest(input=output):
                self.assertEqual(self.equal_distro(input), output)


if __name__ == "__main__":
    main(verbosity=2)