Exemple #1
0
 def test_2(self):
     sparse_array = SparseArray(["def", "de", "fgh"])
     result = sparse_array.compute(["de", "lmn", "fgh"])
     self.assertEqual(result["de"], 1)
     self.assertEqual(result["lmn"], 0)
     self.assertEqual(result["fgh"], 1)
Exemple #2
0
 def test_1(self):
     sparse_array = SparseArray(["aba", "baba", "aba", "xzxb"])
     result = sparse_array.compute(["aba", "xzxb", "ab"])
     self.assertEqual(result["aba"], 2)
     self.assertEqual(result["xzxb"], 1)
     self.assertEqual(result["ab"], 0)
Exemple #3
0
from sparse_array import SparseArray
import os
import sys

if __name__ == "__main__":
    words = os.environ['INPUT'].split(",")
    sparse_array = SparseArray(words)
    args = sys.argv
    if len(args) == 1:
        raise Exception("You must specify the query. Example toto,tata,titi")
    else:
        query = args[1]
        result = sparse_array.compute(query.split(','))
        print(result)