i added a note:
also my code had '- 1 + 1' in it because lists have the first iem as '0' and so 
i want Next Item and '+1' achieves that but -1 works when you want the actual 
item not next item and so -1=Current, none=next

REFACTOR

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].append(len(tree) + 1)
      tree.append('')
      node = len(tree)
    else:
      node = tree[node][char_index - 1]
print(tree)

------------------------------------------
Artificial General Intelligence List: AGI
Permalink: 
https://agi.topicbox.com/groups/agi/T11f5dc3052b454b3-Me3114f4018bf1baaeee42b79
Delivery options: https://agi.topicbox.com/groups/agi/subscription

Reply via email to