single trie chain
#trie implementation in python
class trie(object):
def __init__(self, word, children=[]):
self.word = word
self.children = children
def addchild(self, child):
self.children.append(trie(child))
def singletrie(word):
word = list(word)
wt = trie(word[0])
trie_count = 0
current = wt
while trie_count < len(word):
current.addchild(word[trie_count])
current = current.children[0]
trie_count += 1
return wt