-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
40 lines (30 loc) · 829 Bytes
/
main.py
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
import sys
import pickle
from Trie import *
from Files import *
def solution(searchPrefix, listOfStreamers):
status = [["Found"], ["noMatches"]]
t = Trie()
t.formTrie(listOfStreamers)
comp = t.printAutoSuggestions(searchPrefix)
if len(comp) <= 0:
return(status[1])
else:
return comp
def getSearchResults( TheTrie, searchPrefix):
status = [["Found"], ["noMatches"]]
comp = TheTrie.printAutoSuggestions( searchPrefix)
if len(comp) <= 0:
return(status[1])
else:
return comp
data = {}
with open('data.json', 'r') as fp:
data = json.load(fp)
print()
TheTrie = Trie()
TheTrie.formTrie(data.keys())
result = getSearchResults( TheTrie, sys.argv[1])
# print("result", result)
for eachItem in result:
print( eachItem, data[eachItem])