aboutsummaryrefslogtreecommitdiff
path: root/challenge-145/mohammad-anwar/python/ch-1.py
blob: de600fc0a52706c4b4bef3e19ef1778a7f99fb2c (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
40
#!/usr/bin/python3

'''

Week 145:

    https://theweeklychallenge.org/blog/perl-weekly-challenge-145

Task #1: Dot Product

    You are given 2 arrays of same size, @a and @b.

    Write a script to implement Dot Product.

'''

import unittest

def dot_product(a, b):

    if len(a) == len(b):
        dp = 0
        for i in range(0, len(a)):
            dp += a[i] * b[i]

    return dp;

#
#
# Unit test class

class TestJortSort(unittest.TestCase):

    def test_example(self):
        self.assertEqual(
            dot_product([1,2,3], [4,5,6]),
            32,
            'Example')

unittest.main()