Feb-11-2020, 08:35 PM
(This post was last modified: Feb-11-2020, 08:36 PM by BladedSupernova.)
Also I made the code smaller, is it really small now for what it does or not at all?? Just curious.
tree = [''] window_start = 1 window_end = 4 for count2 in range(2): window = 'ababa'[window_start - 1 : window_end] window_start = window_start + 1 window_end = window_end + 1 char_location = 1 node = 1 for count in range(4): char_in_window = window[char_location - 1] char_location = char_location + 1 char_index = tree[node - 1].find(char_in_window) + 1 if char_index == 0: tree[node - 1] = str(tree[node - 1]) + str(char_in_window) if node == len(tree): tree.append([]) tree[(node + 1 - 1)].append(len(tree) + 1) tree.append('') node = len(tree) else: node = tree[(node + 1 - 1)][char_index - 1] print(tree)